This commit is contained in:
parent
ba6af5e2cf
commit
b5f8419e82
|
|
@ -76,4 +76,6 @@ public interface CacheKey {
|
|||
String SONG_URL = "song:";
|
||||
|
||||
String VIPCODE = "VIPCODE:";
|
||||
|
||||
String INVOICE_SD_TYPE = "invoice:sd_type:";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.dto.BindingDto;
|
||||
import cn.ysk.cashier.service.BindService;
|
||||
import cn.ysk.cashier.service.shop.TbShopInfoService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/invoice")
|
||||
public class ShopInvoiceController {
|
||||
|
||||
@Resource
|
||||
private TbShopInfoService shopInfoService;
|
||||
@Resource
|
||||
private BindService bindService;
|
||||
|
||||
@PostMapping("binding")
|
||||
@ApiOperation("绑定开票信息")
|
||||
public ResponseEntity<Object> binding(@Validated @RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(shopInfoService.binding(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("subInvoicing")
|
||||
@ApiOperation("提交开票")
|
||||
public ResponseEntity<Object> subInvoicing(@RequestBody Map<String, Object> params){
|
||||
return new ResponseEntity<>(bindService.subInvoicing(params), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("industry")
|
||||
@ApiOperation("获取项目分类")
|
||||
@AnonymousPostMapping("industry")
|
||||
public ResponseEntity<Object> industry(@RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(bindService.industry(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("digitalInvoice")
|
||||
@ApiOperation("数电发票类型")
|
||||
@AnonymousPostMapping("digitalInvoice")
|
||||
public ResponseEntity<Object> digitalInvoice(){
|
||||
return new ResponseEntity<>(bindService.digitalInvoice(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("storeSe")
|
||||
@ApiOperation("计算税额")
|
||||
@AnonymousPostMapping("storeSe")
|
||||
public ResponseEntity<Object> storeSe(@RequestBody Map<String, Object> params){
|
||||
return new ResponseEntity<>(bindService.storeSe(params), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -41,13 +41,6 @@ public class TbShopInfoController {
|
|||
private final TbShopInfoService tbShopInfoService;
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final TokenProvider tokenProvider;
|
||||
@PostMapping("binding")
|
||||
@AnonymousPostMapping("binding")
|
||||
@ApiOperation("绑定开票信息")
|
||||
public ResponseEntity<Object> binding(@RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(tbShopInfoService.binding(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
private final SecurityProperties properties;
|
||||
|
||||
@PostMapping("changChildShop")
|
||||
|
|
|
|||
|
|
@ -6,4 +6,15 @@ import lombok.Data;
|
|||
public class BindingDto {
|
||||
private Integer shopId;
|
||||
private String account;
|
||||
|
||||
// 项目分类
|
||||
private String article;
|
||||
|
||||
// 数电发票类型
|
||||
private String sdType;
|
||||
|
||||
// 税率
|
||||
private String taxAmount;
|
||||
|
||||
private Integer page = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,18 @@ public class TbMerchantAccount implements Serializable {
|
|||
@ApiModelProperty(value = "开票系统账号")
|
||||
private String bindAccount;
|
||||
|
||||
@Column(name = "`article`")
|
||||
@ApiModelProperty(value = "项目分类")
|
||||
private String article;
|
||||
|
||||
@Column(name = "`sd_type`")
|
||||
@ApiModelProperty(value = "数电发票类型")
|
||||
private String sdType;
|
||||
|
||||
@Column(name = "`tax_amount`")
|
||||
@ApiModelProperty(value = "税率")
|
||||
private String taxAmount;
|
||||
|
||||
public void copy(TbMerchantAccount source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.dto.BindingDto;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开票服务员
|
||||
*/
|
||||
public interface BindService {
|
||||
|
||||
/**
|
||||
* 绑定
|
||||
*/
|
||||
JSONObject binding(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 商家提交开票信息
|
||||
*/
|
||||
JSONObject subInvoicing(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 项目分类
|
||||
*/
|
||||
JSONObject industry(BindingDto bindingDto);
|
||||
|
||||
|
||||
/**
|
||||
* 计算税额
|
||||
*/
|
||||
JSONObject storeSe(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 数电发票类型
|
||||
*/
|
||||
JSONArray digitalInvoice();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.ysk.cashier.dto.BindingDto;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.BindService;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class BindServiceImpl implements BindService {
|
||||
|
||||
@Autowired
|
||||
private TbMerchantAccountRepository accountRepository;
|
||||
@Autowired
|
||||
private TbShopInfoRepository tbShopInfoRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
private final String url = "http://test.invoice.sxczgkj.cn/api/";
|
||||
|
||||
@Override
|
||||
public JSONObject binding(Map<String, Object> params) {
|
||||
String result = HttpUtil.post(url + "cash/binding", params, 5000);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code").equals(1)) {
|
||||
return jsonObject.getJSONObject("data");
|
||||
} else {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject subInvoicing(Map<String, Object> params) {
|
||||
String result = HttpUtil.post(url + "cash/subinvoicing", params, 5000);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code").equals(1)) {
|
||||
if (params.get("shopId") != null) {
|
||||
if (redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + params.get("shopId"))) {
|
||||
Set<Object> articles = redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + params.get("shopId"));
|
||||
if (!articles.contains(params.get("article"))) {
|
||||
articles.add(params.get("article"));
|
||||
redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + params.get("shopId"), articles);
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonObject.getJSONObject("data");
|
||||
} else {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject industry(BindingDto bindingDto) {
|
||||
if (StringUtils.isNotBlank(bindingDto.getArticle())) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", bindingDto.getArticle());
|
||||
params.put("page", bindingDto.getPage() == null ? 1 : bindingDto.getPage());
|
||||
String result = HttpUtil.post(url + "store/industrylistsj", params, 5000);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code").equals(1)) {
|
||||
return jsonObject.getJSONObject("data");
|
||||
} else {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
} else {
|
||||
Set<String> set = new HashSet<>();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (!redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())) {
|
||||
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null);
|
||||
TbMerchantAccount account = accountRepository.findByAccount(tbShopInfo.getAccount());
|
||||
set.add(account.getArticle());
|
||||
redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId(), set);
|
||||
jsonObject.put("articles", set);
|
||||
} else {
|
||||
jsonObject.put("list", redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId()));
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject storeSe(Map<String, Object> params) {
|
||||
String result = HttpUtil.post(url + "store/se", params, 5000);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code").equals(1)) {
|
||||
return jsonObject.getJSONObject("data");
|
||||
} else {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray digitalInvoice() {
|
||||
String result = HttpUtil.post(url + "store/digitalinvoice", "", 5000);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code").equals(1)) {
|
||||
return jsonObject.getJSONArray("data");
|
||||
} else {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||
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.TbShopInfoQueryCriteria;
|
||||
|
|
@ -18,6 +15,7 @@ import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
|
|||
import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.BindService;
|
||||
import cn.ysk.cashier.service.WxService;
|
||||
import cn.ysk.cashier.service.shop.TbShopInfoService;
|
||||
import cn.ysk.cashier.system.domain.Dept;
|
||||
|
|
@ -78,6 +76,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
private final RedisUtils redisUtils;
|
||||
|
||||
private final TbShopPayTypeRepository tbShopPayTypeRepository;
|
||||
private final BindService bindService;
|
||||
private final WxService wxService;
|
||||
|
||||
@Override
|
||||
|
|
@ -94,22 +93,20 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
}
|
||||
}
|
||||
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"));
|
||||
JSONObject data = bindService.binding(param);
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) {
|
||||
account.setBindAccount(bindingDto.getAccount());
|
||||
account.setArticle(bindingDto.getArticle());
|
||||
account.setTaxAmount(bindingDto.getTaxAmount());
|
||||
account.setSdType(bindingDto.getSdType());
|
||||
merchantAccountRepository.save(account);
|
||||
}
|
||||
data.put("bindAccount", account.getBindAccount());
|
||||
data.put("article", account.getArticle());
|
||||
data.put("taxAmount", account.getTaxAmount());
|
||||
data.put("sdType", account.getSdType());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue