Merge branch 'beta' into kk

beta-prop-all^2
dongxiaoke 2 years ago
commit 6fd9d36888
  1. 4
      jianshui-admin/src/main/java/com/jianshui/web/controller/platform/InvoiceDeliveryController.java
  2. 34
      jianshui-admin/src/main/java/com/jianshui/web/controller/platform/TaxSwitchingController.java
  3. 37
      jianshui-platform/src/main/java/com/jianshui/platform/dto/TaxSwitchingDTO.java
  4. 17
      jianshui-platform/src/main/java/com/jianshui/platform/mapper/CompanyServiceMapper.java
  5. 20
      jianshui-platform/src/main/java/com/jianshui/platform/service/TaxSwitchingService.java
  6. 102
      jianshui-platform/src/main/java/com/jianshui/platform/service/impl/InvoiceDeliveryServiceImpl.java
  7. 53
      jianshui-platform/src/main/java/com/jianshui/platform/service/impl/TaxSwitchingServiceImpl.java
  8. 60
      jianshui-platform/src/main/java/com/jianshui/platform/utils/InvoiceAllYhdjUtils.java
  9. 37
      jianshui-platform/src/main/java/com/jianshui/platform/vo/TaxSwitchingVO.java
  10. 16
      jianshui-platform/src/main/resources/com/jianshui/platform/mapper/CompanyServiceMapper.xml

@ -21,14 +21,14 @@ import java.util.List;
**/
@Api(tags={"发票交付"},value = "发票交付")
@RestController
@RequestMapping("/platForm")
@RequestMapping("/platForm/invoiceDelivery")
public class InvoiceDeliveryController {
@Autowired
private InvoiceDeliveryService invoiceDeliveryService;
@ApiOperation("发票交付")
@PostMapping("/invoiceDelivery")
@PostMapping("/delivery")
public Object invoiceDelivery(@RequestBody List<InvoiceDeliveryJsonDataDTO> dtos){
HXResponse response = invoiceDeliveryService.invoiceDelivery(dtos);
return response;

@ -0,0 +1,34 @@
package com.jianshui.web.controller.platform;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.platform.dto.TaxSwitchingDTO;
import com.jianshui.platform.service.TaxSwitchingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* @Author: kane
* @Description: 含税不含税切换控制类
* @CreateTime: 2023-06-07 12:01
* @Version: 1.0
**/
@Api(tags = "含税不含税切换",value = "含税不含税切换")
@RestController
@RequestMapping("/platForm/taxSwitching")
public class TaxSwitchingController {
@Autowired
private TaxSwitchingService taxSwitchingService;
@ApiOperation("含税不含税切换")
@PostMapping("/switching")
public AjaxResult taxSwitching(@RequestBody TaxSwitchingDTO dto){
return taxSwitchingService.taxswitching(dto);
}
}

@ -0,0 +1,37 @@
package com.jianshui.platform.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @Author: kane
* @Description: 含税不含税转换传输类
* @CreateTime: 2023-06-07 13:46
* @Version: 1.0
**/
@ApiModel("含税不含税转换")
@Data
public class TaxSwitchingDTO {
@ApiModelProperty("货物或应税劳务、服务名称")
private String taxName;
@ApiModelProperty("规格型号")
private String specification;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("数量")
private BigDecimal number;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("金额")
private BigDecimal money;
@ApiModelProperty("税率")
private BigDecimal taxRate;
@ApiModelProperty("税额")
private BigDecimal taxMoney;
@ApiModelProperty("状态0-含税,1-不含税")
private String status;
}

@ -1,17 +0,0 @@
package com.jianshui.platform.mapper;
import com.jianshui.common.core.domain.entity.Companyservice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @Author: xingze
* @Description: 企业信息持久层
* @CreateTime: 2023-06-06 12:05
* @Version: 1.0
**/
@Mapper
public interface CompanyServiceMapper {
Companyservice findByCompanyId(@Param("companyId") Long companyId);
}

@ -0,0 +1,20 @@
package com.jianshui.platform.service;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.platform.dto.TaxSwitchingDTO;
/**
* @Author: kane
* @Description: 含税不含税切换业务层
* @CreateTime: 2023-06-07 13:40
* @Version: 1.0
**/
public interface TaxSwitchingService {
/**
* 功能描述: 含税不含税切换计算
* @param dto
* @return : com.jianshui.common.core.domain.AjaxResult
*/
AjaxResult taxswitching(TaxSwitchingDTO dto);
}

@ -11,6 +11,7 @@ import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.core.domain.entity.SysUser;
import com.jianshui.common.core.redis.RedisCache;
import com.jianshui.common.utils.BeanToMapUtils;
import com.jianshui.common.utils.InvoiceUtils;
import com.jianshui.common.utils.SecurityUtils;
import com.jianshui.common.utils.ValidateUtils;
import com.jianshui.common.utils.jcsk.ApiHttp;
@ -19,11 +20,12 @@ import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.platform.domain.InvoiceDelivery;
import com.jianshui.platform.dto.InvoiceDeliveryDTO;
import com.jianshui.platform.dto.InvoiceDeliveryJsonDataDTO;
import com.jianshui.platform.mapper.CompanyServiceMapper;
import com.jianshui.platform.mapper.InvoiceDeliveryMapper;
import com.jianshui.platform.service.InvoiceDeliveryService;
import com.jianshui.platform.utils.InvoiceAllYhdjUtils;
import com.jianshui.system.domain.InvoiceAllApiLog;
import com.jianshui.system.domain.InvoiceAllYhdj;
import com.jianshui.system.mapper.CompanyserviceMapper;
import com.jianshui.system.mapper.InvoiceAllApiLogMapper;
import com.jianshui.system.mapper.InvoiceAllYhdjMapper;
import com.jianshui.system.mapper.SysUserMapper;
@ -31,9 +33,11 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* @Author: xingze
@ -47,9 +51,8 @@ public class InvoiceDeliveryServiceImpl implements InvoiceDeliveryService {
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private CompanyServiceMapper companyServiceMapper;
@Autowired
private InvoiceAllYhdjMapper yhdjMapper;
private CompanyserviceMapper companyServiceMapper;
@Autowired
private InvoiceDeliveryMapper invoiceDeliveryMapper;
@ -63,18 +66,15 @@ public class InvoiceDeliveryServiceImpl implements InvoiceDeliveryService {
*/
@Override
public HXResponse invoiceDelivery(List<InvoiceDeliveryJsonDataDTO> dtos) {
//判空
if (dtos.isEmpty()){
return new HXResponse("传入信息为空,请检查信息!");
}
//获取用户id
Long userId = SecurityUtils.getUserId();
//根据用户id获取用户信息
SysUser sysUser = sysUserMapper.selectUserById(userId);
//根据企业id获取企业信息
Companyservice companyservice = companyServiceMapper.findByCompanyId(sysUser.getCompanyId());
Companyservice companyservice = companyServiceMapper.selectCompanyserviceByCompanyid(sysUser.getCompanyId());
//获取登记用户信息
InvoiceAllYhdj userInfo = getUserInfo(companyservice);
InvoiceAllYhdjUtils invoiceAllYhdjUtils = new InvoiceAllYhdjUtils();
InvoiceAllYhdj userInfo = invoiceAllYhdjUtils.getUserInfo(companyservice);
if (BeanUtil.isEmpty(userInfo)) {
return new HXResponse("未查询到登记信息!");
}
@ -86,10 +86,10 @@ public class InvoiceDeliveryServiceImpl implements InvoiceDeliveryService {
invoiceDeliveryDTO.setNsrsbh(userInfo.getNsrsbh());
//校验
ValidateUtils.validate(invoiceDeliveryDTO);
ValidateUtils.validate(dtos);
InvoiceDelivery invoiceDelivery = new InvoiceDelivery();
for (InvoiceDeliveryJsonDataDTO dto : dtos) {
invoiceDeliveryDTO.setJsonData(dto);
ValidateUtils.validate(invoiceDeliveryDTO);
//发送请求获取结果
JSONObject result = null;
try {
@ -99,40 +99,35 @@ public class InvoiceDeliveryServiceImpl implements InvoiceDeliveryService {
String code = result.get("code") != null ? result.get("code").toString() : "";
String msg = result.get("msg") != null ? result.get("msg").toString() : "";
String data = result.get("data") != null ? result.get("data").toString() : "";
//封装调用日志
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog();
allApiLog.setUrl(WebServiceConstant.INVOIVEDELIVERY);
allApiLog.setSendMsg(invoiceDeliveryDTO.toString());
allApiLog.setResultMsg(JSONUtil.toJsonStr(result));
allApiLog.setCompany(companyservice.getSellertax());
allApiLog.setIdentityId(companyservice.getIdentity());
allApiLog.setCreateTime(new Date());
allApiLog.setRequestId(UUID.randomUUID().toString());
//封装实体类
BeanUtils.copyProperties(invoiceDeliveryDTO, invoiceDelivery);
invoiceDelivery.setJflx(dto.getJflx());
invoiceDelivery.setFphm(dto.getFphm());
invoiceDelivery.setGmflxdh(dto.getGmflxdh());
invoiceDelivery.setGmfyx(dto.getGmfyx());
invoiceDelivery.setType("1");
invoiceDelivery.setClerk(sysUser.getUserId());
invoiceDelivery.setCreateTime(new Date());
if ("0000".equals(code) && StrUtil.isNotEmpty(data)) {
//存入调用日志表
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog();
allApiLog.setUrl(WebServiceConstant.INVOIVEDELIVERY);
allApiLog.setSendMsg(invoiceDeliveryDTO.toString());
allApiLog.setResultMsg(JSONUtil.toJsonStr(result));
allApiLog.setCompany(companyservice.getSellertax());
allApiLog.setIdentityId(companyservice.getIdentity());
allApiLog.setCreateTime(new Date());
allApiLogMapper.insertInvoiceAllApiLog(allApiLog);
//封装实体类
BeanUtils.copyProperties(invoiceDeliveryDTO, invoiceDelivery);
invoiceDelivery.setJflx(dto.getJflx());
invoiceDelivery.setFphm(dto.getFphm());
invoiceDelivery.setGmflxdh(dto.getGmflxdh());
invoiceDelivery.setGmfyx(dto.getGmfyx());
invoiceDelivery.setStatus("0");
invoiceDelivery.setType("1");
invoiceDelivery.setClerk(sysUser.getUserId());
invoiceDelivery.setCreateTime(new Date());
//将数据存入业务表
invoiceDelivery.setStatus("0");
invoiceDeliveryMapper.insertInvoiceDelivery(invoiceDelivery);
} else {
//封装实体类
BeanUtils.copyProperties(invoiceDeliveryDTO, invoiceDelivery);
invoiceDelivery.setJflx(dto.getJflx());
invoiceDelivery.setFphm(dto.getFphm());
invoiceDelivery.setGmflxdh(dto.getGmflxdh());
invoiceDelivery.setGmfyx(dto.getGmfyx());
invoiceDelivery.setStatus("1");
invoiceDelivery.setType("1");
invoiceDelivery.setClerk(sysUser.getUserId());
invoiceDelivery.setCreateTime(new Date());
//存入日志调用表
allApiLogMapper.insertInvoiceAllApiLog(allApiLog);
//将数据存入业务表
invoiceDelivery.setStatus("1");
invoiceDeliveryMapper.insertInvoiceDelivery(invoiceDelivery);
return new HXResponse(msg);
}
@ -145,35 +140,4 @@ public class InvoiceDeliveryServiceImpl implements InvoiceDeliveryService {
return new HXResponse("0000", "处理成功");
}
/**
* 获取登记用户信息
*/
public InvoiceAllYhdj getUserInfo(Companyservice companyservice) {
String identity = companyservice.getIdentity();
String sellertax = companyservice.getSellertax();
String key = WebServiceConstant.TOKEN_KEY + sellertax + "_"+ identity;
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
cn.hutool.json.JSONObject yhdjObj = redisCache.getCacheObject(key);
if(JSONUtil.isNull(yhdjObj)){
// 查询用户登记参数
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>();
yhdjQueryWrapper.eq("nsrsbh", sellertax);
yhdjQueryWrapper.eq("identity", identity);
InvoiceAllYhdj invoiceAllYhdj = yhdjMapper.selectOne(yhdjQueryWrapper);
cn.hutool.json.JSONObject obj = JSONUtil.parseObj(invoiceAllYhdj);
Long exprieTime = System.currentTimeMillis(); // 过期时间
obj.put("exprieTime", exprieTime);
redisCache.setCacheObject(key, obj);
yhdjObj = obj;
}
return BeanUtil.copyProperties(yhdjObj,InvoiceAllYhdj.class);
}
}

@ -0,0 +1,53 @@
package com.jianshui.platform.service.impl;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.utils.bean.BeanUtils;
import com.jianshui.platform.dto.TaxSwitchingDTO;
import com.jianshui.platform.service.TaxSwitchingService;
import com.jianshui.platform.vo.TaxSwitchingVO;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* @Author: kane
* @Description: 含税不含税业务层
* @CreateTime: 2023-06-07 13:40
* @Version: 1.0
**/
@Service
public class TaxSwitchingServiceImpl implements TaxSwitchingService {
/**
* 功能描述: 含税不含税切换计算
* @param dto
* @return : com.jianshui.common.core.domain.AjaxResult
*/
@Override
public AjaxResult taxswitching(TaxSwitchingDTO dto) {
//判空
if (dto == null){
return AjaxResult.error("未传入发票相关信息,请检查!");
}
//实体类转换
TaxSwitchingVO taxSwitchingVO = new TaxSwitchingVO();
BeanUtils.copyProperties(dto,taxSwitchingVO);
//判断是否为含税
if ("0".equals(dto.getStatus())){
//含税改为非含税返回
taxSwitchingVO.setStatus("1");
//单个商品税额
BigDecimal taxMoney = dto.getTaxMoney().divide(dto.getNumber());
taxSwitchingVO.setUnitPrice(dto.getUnitPrice().subtract(taxMoney));
taxSwitchingVO.setMoney(dto.getMoney().subtract(dto.getTaxMoney()));
return AjaxResult.success(taxSwitchingVO);
}else {
//非含税改为含税返回
taxSwitchingVO.setStatus("0");
//单个商品税额
BigDecimal taxMoney = dto.getTaxMoney().divide(dto.getNumber());
taxSwitchingVO.setUnitPrice(dto.getUnitPrice().add(taxMoney));
taxSwitchingVO.setMoney(dto.getMoney().add(dto.getTaxMoney()));
return AjaxResult.success(taxSwitchingVO);
}
}
}

@ -0,0 +1,60 @@
package com.jianshui.platform.utils;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jianshui.common.constant.WebServiceConstant;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.core.redis.RedisCache;
import com.jianshui.common.utils.spring.SpringUtils;
import com.jianshui.system.domain.InvoiceAllYhdj;
import com.jianshui.system.mapper.InvoiceAllYhdjMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Author: kane
* @Description: 获取用户登记信息工具类
* @CreateTime: 2023-06-07 09:08
* @Version: 1.0
**/
@Component
public class InvoiceAllYhdjUtils {
@Autowired
private InvoiceAllYhdjMapper invoiceAllYhdjMapper;
public InvoiceAllYhdjUtils() {
}
/**
* 获取登记用户信息
*/
public InvoiceAllYhdj getUserInfo(Companyservice companyservice) {
String identity = companyservice.getIdentity();
String sellertax = companyservice.getSellertax();
String key = WebServiceConstant.TOKEN_KEY + sellertax + "_"+ identity;
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
cn.hutool.json.JSONObject yhdjObj = redisCache.getCacheObject(key);
if(JSONUtil.isNull(yhdjObj)){
// 查询用户登记参数
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>();
yhdjQueryWrapper.eq("nsrsbh", sellertax);
yhdjQueryWrapper.eq("identity", identity);
InvoiceAllYhdj invoiceAllYhdj = invoiceAllYhdjMapper.selectOne(yhdjQueryWrapper);
cn.hutool.json.JSONObject obj = JSONUtil.parseObj(invoiceAllYhdj);
Long exprieTime = System.currentTimeMillis(); // 过期时间
obj.put("exprieTime", exprieTime);
redisCache.setCacheObject(key, obj);
yhdjObj = obj;
}
return BeanUtil.copyProperties(yhdjObj,InvoiceAllYhdj.class);
}
}

@ -0,0 +1,37 @@
package com.jianshui.platform.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @Author: kane
* @Description: 含税不含税转换
* @CreateTime: 2023-06-07 13:46
* @Version: 1.0
**/
@ApiModel("含税不含税转换")
@Data
public class TaxSwitchingVO {
@ApiModelProperty("货物或应税劳务、服务名称")
private String taxName;
@ApiModelProperty("规格型号")
private String specification;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("数量")
private BigDecimal number;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("金额")
private BigDecimal money;
@ApiModelProperty("税率")
private BigDecimal taxRate;
@ApiModelProperty("税额")
private BigDecimal taxMoney;
@ApiModelProperty("状态")
private String status;
}

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jianshui.platform.mapper.CompanyServiceMapper">
<resultMap id="companyServiceResultMap" type="Companyservice">
<id column="companyid" property="companyid"/>
<result column="reback_type" property="rebackType"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
</resultMap>
<select id="findByCompanyId" resultMap="companyServiceResultMap">
select * from companyservice where companyid = #{companyId}
</select>
</mapper>