绑定 开票信息

This commit is contained in:
wangw 2024-11-20 16:04:30 +08:00
parent 118404ecbe
commit 105671347a
5 changed files with 64 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.config.security.service.OnlineUserService; import cn.ysk.cashier.config.security.service.OnlineUserService;
import cn.ysk.cashier.dto.BindingDto;
import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto;
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.pojo.shop.TbShopInfo;
@ -36,7 +37,12 @@ public class TbShopInfoController {
private final TbShopInfoService tbShopInfoService; private final TbShopInfoService tbShopInfoService;
private final OnlineUserService onlineUserService; private final OnlineUserService onlineUserService;
private final TokenProvider tokenProvider; private final TokenProvider tokenProvider;
@PostMapping("binding")
@AnonymousPostMapping("binding")
@ApiOperation("绑定开票信息")
public ResponseEntity<Object> binding(@RequestBody BindingDto bindingDto){
return new ResponseEntity<>(tbShopInfoService.binding(bindingDto), HttpStatus.OK);
}
// @Log("导出数据") // @Log("导出数据")
// @ApiOperation("导出数据") // @ApiOperation("导出数据")
// @GetMapping(value = "/download") // @GetMapping(value = "/download")

View File

@ -0,0 +1,9 @@
package cn.ysk.cashier.dto;
import lombok.Data;
@Data
public class BindingDto {
private Integer shopId;
private String account;
}

View File

@ -131,6 +131,10 @@ public class TbMerchantAccount implements Serializable {
@ApiModelProperty(value = "操作密码") @ApiModelProperty(value = "操作密码")
private String pwd; private String pwd;
@Column(name = "`bind_account`")
@ApiModelProperty(value = "开票系统账号")
private String bindAccount;
public void copy(TbMerchantAccount source){ public void copy(TbMerchantAccount source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -3,8 +3,10 @@ package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig; import cn.hutool.extra.qrcode.QrConfig;
import cn.hutool.http.HttpUtil;
import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.config.security.service.UserCacheManager; import cn.ysk.cashier.config.security.service.UserCacheManager;
import cn.ysk.cashier.dto.BindingDto;
import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto;
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
@ -28,6 +30,7 @@ import cn.ysk.cashier.system.repository.UserRepository;
import cn.ysk.cashier.system.service.ParamsService; import cn.ysk.cashier.system.service.ParamsService;
import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.system.service.UserService;
import cn.ysk.cashier.utils.*; import cn.ysk.cashier.utils.*;
import com.alibaba.fastjson.JSONObject;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -86,6 +89,38 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
private final TbShopPayTypeRepository tbShopPayTypeRepository; private final TbShopPayTypeRepository tbShopPayTypeRepository;
private final WxService wxService; private final WxService wxService;
@Override
public JSONObject binding(BindingDto bindingDto) {
// TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null);
// TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount());
// if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) {
// if (tbShopInfo != null) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) {
// bindingDto.setAccount(account.getBindAccount());
// } else {
// return null;
// }
// }
// }
Map<String, Object> param = new HashMap<>();
//超掌柜生活-用户端
param.put("account", bindingDto.getAccount());
String result = HttpUtil.post("http://test.invoice.sxczgkj.cn/api/cash/binding", param, 5000);
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.getInteger("code").equals(1)) {
JSONObject data = jsonObject.getJSONObject("data");
// if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) {
// String bindAccount = data.getJSONObject("store").getString("account");
// account.setBindAccount(bindAccount);
// merchantAccountRepository.save(account);
// }
return data;
} else {
throw new BadRequestException(jsonObject.getString("msg"));
}
}
@Override @Override
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){ public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){
Sort sort = Sort.by(Sort.Direction.DESC, "id"); Sort sort = Sort.by(Sort.Direction.DESC, "id");

View File

@ -15,9 +15,11 @@
*/ */
package cn.ysk.cashier.service.shop; package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.BindingDto;
import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto;
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@ -32,6 +34,13 @@ import javax.servlet.http.HttpServletResponse;
**/ **/
public interface TbShopInfoService { public interface TbShopInfoService {
/**
* 绑定开票信息
* @param bindingDto
* @return
*/
JSONObject binding(BindingDto bindingDto);
/** /**
* 查询数据分页 * 查询数据分页
* @param criteria 条件 * @param criteria 条件