Merge remote-tracking branch 'origin/beta-prop-all' into beta-prop-all

jianshui-ui
dongxiaoke 1 year ago
commit ddaa93bfc3
  1. 90
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceFrontController.java
  2. 39
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/BdcxsBO.java
  3. 34
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/BdczlBO.java
  4. 70
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/CezsBO.java
  5. 350
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/DdfpxxV5.java
  6. 52
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/DdfpzxxV5.java
  7. 43
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/DdkzxxV5.java
  8. 114
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/DdmxxxV5.java
  9. 54
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/DxhyInterfaceResponse.java
  10. 132
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/EsctxxV5.java
  11. 35
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/HwysBO.java
  12. 87
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/JdctxxV5.java
  13. 31
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/JzfwBO.java
  14. 53
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/LkysfwBO.java
  15. 29
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/QdFjysBO.java
  16. 69
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/QdTxxBO.java
  17. 40
      jianshui-common/src/main/java/com/jianshui/common/core/domain/entity/ele/ResponseBO.java
  18. 16
      jianshui-invoice/src/main/java/com/jianshui/invoice/domain/dto/api/elephant/DDTXX.java
  19. 3
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/ElephantInvoiceService.java
  20. 384
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/ElephantInvoiceServiceImpl.java
  21. 10
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java
  22. 80
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java

@ -1,8 +1,14 @@
package com.jianshui.api.controller.http.invoice.v1;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dxhy.order.utils.Base64Util;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.core.domain.entity.ele.DdfpzxxV5;
import com.jianshui.common.core.domain.entity.ele.DxhyInterfaceResponse;
import com.jianshui.common.core.domain.entity.ele.ResponseBO;
import com.jianshui.common.enums.ErrorCode;
import com.jianshui.common.utils.StringUtils;
import com.jianshui.invoice.service.ElephantInvoiceService;
@ -10,9 +16,14 @@ import com.jianshui.system.service.ICompanyserviceService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@ -206,4 +217,83 @@ public class InvoiceFrontController {
}
/**
* 接收大象回推发票信息接口
*/
@Validated
@PostMapping("/receiveInvoiceFromElephant")
public Object receiveInvoiceFromElephant(@RequestBody String invoiceParam){
//判断参数是否为空
if (StrUtil.isEmpty(invoiceParam)) {
return JSONObject.toJSONString(buildDxhyInterfaceResponse("9999", "推送发票信息为空", null));
}
//获取主信息
JSONObject jsonParam = JSONObject.parseObject(invoiceParam);
String content = jsonParam.getString("content");
log.info("receiveInvoiceFromElephant content:{}", content);
//判断主信息是否为空
if (StrUtil.isEmpty(content)) {
log.info("推送发票content信息为空");
return JSONObject.toJSONString(buildDxhyInterfaceResponse("9999", "推送发票信息为空", null));
}
String decodeParam = Base64Util.decodeToString(content);
List<DdfpzxxV5> ddfpzxxV5s = JSONArray.parseArray(decodeParam, DdfpzxxV5.class);
List<ResponseBO> responseBOs = new ArrayList<>();
for (DdfpzxxV5 ddfpzxxV5 : ddfpzxxV5s) {
if (ObjectUtils.isEmpty(ddfpzxxV5.getDDFPXX())){
log.info("推送发票主体信息为空");
return JSONObject.toJSONString(buildDxhyInterfaceResponse("9999", "推送发票主体信息为空", null));
}
if (ObjectUtils.isEmpty(ddfpzxxV5.getDDMXXX())){
log.info("推送发票明细信息为空");
return JSONObject.toJSONString(buildDxhyInterfaceResponse("9999", "推送发票明细信息为空", null));
}
Companyservice companyservice = iCompanyserviceService.selectCompanyserviceByTaxcode(ddfpzxxV5.getDDFPXX().getXHFSBH());
if (companyservice == null){
return JSONObject.toJSONString(buildDxhyInterfaceResponse("9999", "未查询到销方税号对应企业", null));
}
ResponseBO responseBO;
try {
elephantInvoiceService.convertAndSaveInvoice(ddfpzxxV5,companyservice);
responseBO = buildResponseBO(ddfpzxxV5, "000000", "");
}catch (Exception e){
responseBO = buildResponseBO(ddfpzxxV5, "9999", e.getMessage());
}
responseBOs.add(responseBO);
}
return JSONObject.toJSONString(buildDxhyInterfaceResponse("000000", "成功", Base64Util.encodeToString(JSONObject.toJSONString(responseBOs).getBytes(StandardCharsets.UTF_8))));
}
public static DxhyInterfaceResponse buildDxhyInterfaceResponse(String returnCode, String returnMessage,String content) {
DxhyInterfaceResponse dxhyInterfaceResponse = new DxhyInterfaceResponse();
dxhyInterfaceResponse.setContent(content);
dxhyInterfaceResponse.setEncryptCode("0");
dxhyInterfaceResponse.setEncryptCode("0");
dxhyInterfaceResponse.setReturnCode(returnCode);
dxhyInterfaceResponse.setReturnMessage(returnMessage);
return dxhyInterfaceResponse;
}
public ResponseBO buildResponseBO(DdfpzxxV5 ddfpzxxV5,String ztdm,String ztxx) {
ResponseBO responseBO = new ResponseBO();
responseBO.setDDQQLSH(ddfpzxxV5.getDDFPXX().getDDQQLSH());
responseBO.setNSRSBH(ddfpzxxV5.getDDFPXX().getXHFSBH());
responseBO.setZTXX(ztxx);
responseBO.setZTDM(ztdm);
return responseBO;
}
}

@ -0,0 +1,39 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 数电信息-不动产销售信息
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-07-04
*/
@Getter
@Setter
@ToString
public class BdcxsBO implements Serializable {
/**
* BDCWQHTBH : 不动产单元代码/网签合同备案编号
* BDCDZ : 不动产地址
* KDSBZ : 跨地()标志
* TDZZSXMBH : 土地增值税项目编号
* HDJSJG : 核定计税价格
* SJCJHSJE : 实际成交含税金额
* CQZSH : 房屋产权证书号/不动产权证号
* MJDW : 面积单位
*/
private String BDCWQHTBH;
private String BDCDZ;
private String KDSBZ;
private String TDZZSXMBH;
private String HDJSJG;
private String SJCJHSJE;
private String CQZSH;
private String MJDW;
}

@ -0,0 +1,34 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 数电信息-不动产租赁信息
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-07-04
*/
@Getter
@Setter
@ToString
public class BdczlBO implements Serializable {
/**
* BDCDZ : 不动产地址
* KDSBZ : 跨地()标志
* CQZSH : 房屋产权证书号/不动产权证号
* MJDW : 面积单位
* ZLQQZ : 租赁期起止
*/
private String BDCDZ;
private String KDSBZ;
private String CQZSH;
private String MJDW;
private String ZLQQZ;
}

@ -0,0 +1,70 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* 差额征税
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-09-25
*/
@Getter
@Setter
public class CezsBO implements Serializable {
/**
* 序号
*/
private String XH;
/**
* 凭证类型
*/
private String PZLX;
/**
* 发票代码
*/
private String FPDM;
/**
* 发票号码
*/
private String FPHM;
/**
* 纸质发票号码
*/
private String ZZFPHM;
/**
* 凭证号码
*/
private String PZHM;
/**
* 开具日期
*/
private String KJRQ;
/**
* 合计金额
*/
private String HJJE;
/**
* 扣除额
*/
private String KCE;
/**
* 备注
*/
private String BZ;
/**
* 录入方式
*/
private String LRFS;
/**
* 本次扣除金额
*/
private String BCKCJE;
/**
* 凭证合计金
*/
private String PZHJJE;
}

@ -0,0 +1,350 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 订单发票全数据协议beanV3
*
* @author ZSC-DXHY
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class DdfpxxV5 {
/**
* 订单请求唯一流水号
*/
private String DDQQLSH;
/**
* 开票类型
*/
private String KPLX;
/**
* 编码表版本号
*/
private String BMBBBH;
/**
* 销售方纳税人识别号
*/
private String XHFSBH;
/**
* 销售方名称
*/
private String XHFMC;
/**
* 销售方地址
*/
private String XHFDZ;
/**
* 销售方电话
*/
private String XHFDH;
/**
* 销售方银行账号名称
*/
private String XHFYH;
/**
* 销售方银行账号
*/
private String XHFZH;
/**
* 购买方编码
*/
private String GMFBM;
/**
* 购买方纳税人识别号
*/
private String GMFSBH;
/**
* 购买方名称
*/
private String GMFMC;
/**
* 购买方地址
*/
private String GMFDZ;
/**
* 购买方固定电话
*/
private String GMFDH;
/**
* 购买方银行账号名称
*/
private String GMFYH;
/**
* 购买方银行账号
*/
private String GMFZH;
/**
* 购买方企业类型
*/
private String GMFLX;
/**
* 购买方手机
*/
private String GMFSJH;
/***
* 购买方邮箱
*/
private String GMFDZYX;
/**
* 开票人
*/
private String KPR;
/**
* 收款人
*/
private String SKR;
/**
* 复核人
*/
private String FHR;
/**
* 原发票代码
*/
private String YFPDM;
/**
* 原发票号码红字发票必填
*/
private String YFPHM;
/**
* 原发票类型
*/
private String YFPLX;
/**
* 原发票开票日期
*/
private String YFPKPRQ;
/**
* 冲红原因 (1-销货退回 2-开票有误 3-服务中止 4-销售折让)
*/
private String CHYY;
/**
* 清单标志
*/
private String QDBZ;
/**
* 价税合计
*/
private String JSHJ;
/**
* 合计金额(不含税)
*/
private String HJJE;
/**
* 合计税额
*/
private String HJSE;
/**
* 备注 冲红时必填
* 增值税发票红字发票非专票开具时备注要求:
* 开具负数发票必须在备注中注明对应正数发票代码:XXXXXXXXX号码:YYYYYYYY字样其中X为发票代码Y为发票号码如未注明系统自动追加
* 增值税发票红字发票专票开具时备注要求:
* 开具负数发票必须在备注中注明开具红字增值税专用发票信息表编号ZZZZZZZZZZZZZZZZ字样其中Z为开具红字增值税专用发票所需要的长度为16位信息表编号如未注明系统报错
*/
private String BZ;
/**
* 特殊冲红标志
* 冲红时必填0正常冲红(电子发票)1特殊冲红(冲红纸质等)
*/
private String TSCHBZ;
/**
* 红字信息表编号
*/
private String HZXXBBH;
/**
* 订单号
*/
private String DDH;
/**
* 订单时间
*/
private String DDSJ;
/**
* 业务类型区分企业业务线),可以企业自定义
*/
private String YWLX;
/**
* 企业开票方式(0:自动开票;1:手动开票;2:静态码开票;3:动态码开票),默认为0
*/
private String KPFS;
/**
* 提取码
*/
private String TQM;
/**
* 订单状态
*/
private String DDZT;
/**
* 订单状态对应的信息
*/
private String DDZTXX;
/**
* 订单状态对应的信息
*/
private String FPLXDM;
/**
* 订单类型(目前只有数据导入时使用,8为历史数据导入,9为发票修复数据)
*/
private String DDLY;
/**
* 订单类型0:原始订单,1:拆分后订单,2:合并后订单,3:系统冲红订单,4:自动开票订单,5:作废重开订单
*/
private String DDLX;
/**
* 冲红标志(0:未冲红;1:全部冲红;2:部分冲红)
*/
private String CHBZ;
/**
* 作废标志 (0:正常;1:已作废)
*/
private String ZFBZ;
/**
* 是否拆分订单(0:不拆分;1:拆分)
*/
private String SFCF;
/**
* 动态码URL
*/
private String DTM;
/**
* 税率开具理由
*/
private String SLKJLY;
/**
* 电局登录用户名
*/
private String YHM;
/**
* 备用字段
*/
private String BYZD1;
private String BYZD2;
private String BYZD3;
private String BYZD4;
private String BYZD5;
/**
* 开票机号
*/
private String KPJH;
/**
* 开票点
*/
private String KPZD;
/**
* 机器编号
*/
private String JQBH;
/**
* 分机号
*/
private String FJH;
/**
* 发票代码
*/
private String FPDM;
/**
* 发票号码
*/
private String FPHM;
/**
* 数电发票号码
*/
private String SDFPHM;
/**
* 开票日期
*/
private String KPRQ;
/**
* 校验码
*/
private String JYM;
/**
* 防伪码
*/
private String FWM;
/**
* 二维码
*/
private String EWM;
/**
* pdf流
*/
private String PDFZJL;
/**
* 字节流类型针对pdfzjl进行处理,OFD和PDF
*/
private String ZJLLX;
/**
* ofd转pdf流文件
*/
private String OFDTOPDFZJ;
/**
* 数据权限ID
*/
private String ENTID;
}

@ -0,0 +1,52 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
/**
* 订单发票全数据返回协议beanV3
*
* @author zsc
* @date 2018年9月19日 15:14:50
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class DdfpzxxV5 implements Serializable {
/**
* 订单发票信息
*/
private DdfpxxV5 DDFPXX;
/**
* 二手车信息
*/
private EsctxxV5 ESCTXX;
/**
* 机动车信息
*/
private JdctxxV5 JDCTXX;
/**
* 数电信息
*/
private QdTxxBO QDTXX;
/**
* 发票明细信息
*/
private List<DdmxxxV5> DDMXXX;
/**
* 订单扩展信息
*/
private List<DdkzxxV5> DDKZXX;
}

@ -0,0 +1,43 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 订单拆分合并关系协议beanV5
*
* @author ZSC-DXHY
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class DdkzxxV5 implements Serializable {
/**
* 订单请求流水号
*/
private String DDQQLSH;
/**
* 订单号
*/
private String DDH;
/**
* 订单类型0:原始订单,1:拆分后订单,2:合并后订单,3:系统冲红订单,4:自动开票订单,5:作废重开订单
*/
private String DDLX;
/**
* 备用字段
*/
private String BYZD1;
private String BYZD2;
private String BYZD3;
}

@ -0,0 +1,114 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 订单发票全数据明细协议bean
*
* @author ZSC-DXHY
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class DdmxxxV5 implements Serializable {
/**
* 项目序号
*/
private String XH;
/**
* 发票行性质
*/
private String FPHXZ;
/**
* 商品编码
*/
private String SPBM;
/**
* 自行编码
*/
private String ZXBM;
/**
* 优惠政策标识
*/
private String YHZCBS;
/**
* 零税率标识
* 非零税率0:出口零税,1免税2不征税 3:普通零税率
* 若填写了3(普通零税率), :YHZCBS填0,ZZSTSGL填空
*/
private String LSLBS;
/**
* 增值税特殊管理
*/
private String ZZSTSGL;
/**
* 项目名称
*/
private String XMMC;
/**
* 规格型号
*/
private String GGXH;
/**
* 单位
*/
private String DW;
/**
* 项目数量
*/
private String SPSL;
/**
* 项目单价
*/
private String DJ;
/**
* 项目金额
*/
private String JE;
/**
* 含税标志
*/
private String HSBZ;
/**
* 税率
*/
private String SL;
/**
* 税额
*/
private String SE;
/**
* 扣除额
*/
private String KCE;
/**
* 备用字段
*/
private String BYZD1;
private String BYZD2;
private String BYZD3;
}

@ -0,0 +1,54 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* 标准版本SDK方式接口响应参数
*
* @author ZSC-DXHY
* @date 创建时间: 2021-12-13 11:07
*/
@Getter
@Setter
public class DxhyInterfaceResponse implements Serializable {
/**
* 接口响应code
*/
private String returnCode;
/**
* 接口响应信息
*/
private String returnMessage;
/**
* 数据交换流水号
*/
private String dataExchangeId;
/**
* 加密标识
*/
private String encryptCode;
/**
* 压缩标识
*/
private String zipCode;
/**
* 响应内容
*/
private String content;
public DxhyInterfaceResponse() {
}
public DxhyInterfaceResponse(String returnCode, String returnMessage) {
this.returnCode = returnCode;
this.returnMessage = returnMessage;
}
}

@ -0,0 +1,132 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 二手车信息
*
* @author ZSC-DXHY
* @date 创建时间: 2020-12-07 17:01
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class EsctxxV5 implements Serializable {
/**
* 开票方类型
*/
private String KPFLX;
/**
* 车牌照号
*/
private String CPZH;
/**
* 登记证号
*/
private String DJZH;
/**
* 车辆类型
*/
private String CLLX;
/**
* 车架号/车辆识别代码
*/
private String CLSBDM;
/**
* 厂牌型号
*/
private String CPXH;
/**
* 转入地车辆管理所名称
*/
private String ZRDCLGLSMC;
/**
* 经营拍卖单位名称
*/
private String JYPMDW_MC;
/**
* 经营拍卖单位地址
*/
private String JYPMDW_DZ;
/**
* 经营拍卖单位税号
*/
private String JYPMDW_SH;
/**
* 经营拍卖单位银行账号
*/
private String JYPMDW_YHZH;
/**
* 经营拍卖单位电话
*/
private String JYPMDW_DH;
/**
* 二手车市场名称
*/
private String SC_MC;
/**
* 二手车市场税号
*/
private String SC_SH;
/**
* 二手车市场地址
*/
private String SC_DZ;
/**
* 二手车市场银行账号
*/
private String SC_YHZH;
/**
* 二手车市场电话
*/
private String SC_DH;
/**
* 二手车销方代码
*/
private String ESC_XHFDM;
/**
* 二手车销方名称
*/
private String ESC_XHFMC;
/**
* 二手车销方地址
*/
private String ESC_XHFDZ;
/**
* 二手车销方电话
*/
private String ESC_XHFDH;
/**
* 车购税完税凭证号码
*/
private String SC_CGSWSPZHM;
}

@ -0,0 +1,35 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 数电信息-货物运输
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-07-03
*/
@Getter
@Setter
@ToString
public class HwysBO implements Serializable {
/**
* XMXH : 明细序号
* QYD : 起运地
* DDD : 到达地
* YSGJZL : 运输工具种类
* YSGJPH : 运输工具牌号
* YSHWMC : 运输货物名称
*/
private String XMXH;
private String QYD;
private String DDD;
private String YSGJZL;
private String YSGJPH;
private String YSHWMC;
}

@ -0,0 +1,87 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 机动车信息
*
* @author ZSC-DXHY
* @date 创建时间: 2020-12-07 17:01
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class JdctxxV5 implements Serializable {
/**
* 车辆类型
*/
private String CLLX;
/**
* 厂牌型号
*/
private String CPXH;
/**
* 产地
*/
private String CLCD;
/**
* 合格证号
*/
private String HGZH;
/**
* 进口证明书号
*/
private String JKZMSH;
/**
* 商检单号
*/
private String SJDH;
/**
* 发动机号码
*/
private String FDJHM;
/**
* 车辆识别单号
*/
private String CLSBDH;
/**
* 完税凭证号码
*/
private String WSPZHM;
/**
* 吨位
*/
private String DW;
/**
* 限乘人数
*/
private String XCRS;
/**
* 厂家信息
*/
private String CJXX;
/**
* 身份证号码/组织机构代码
*/
private String ZZJGDM;
}

@ -0,0 +1,31 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 数电信息-建筑服务信息
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-07-24
*/
@Getter
@Setter
@ToString
public class JzfwBO implements Serializable {
/**
* TDZZSXMBH : 土地增值税项目编号
* JZFWFSD : 建筑服务发生地
* JZFWMC : 建筑服务名称
* KDSBZ : 跨地()标志
*/
private String TDZZSXMBH;
private String JZFWFSD;
private String JZFWMC;
private String KDSBZ;
}

@ -0,0 +1,53 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* 数电信息-旅客运输服务信息
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2023-08-16
*/
@Getter
@Setter
public class LkysfwBO implements Serializable {
/**
* 出行人序号
*/
private String CXRXH;
/**
* 出行人
*/
private String CXR;
/**
* 出行日期
*/
private String CXRQ;
/**
* 出行人证件类型
*/
private String CXRZJLX;
/**
* 出行人证件号码
*/
private String CXRZJHM;
/**
* 旅客运输出发地
*/
private String LKYSCFD;
/**
* 旅客运输到达地
*/
private String LKYSDDD;
/**
* 交通工具类型
*/
private String JTGJLX;
/**
* 座位等级
*/
private String ZWDJ;
}

@ -0,0 +1,29 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 数电信息-附加要素
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2022-10-12
*/
@Getter
@Setter
@ToString
public class QdFjysBO implements Serializable {
/**
* FJYSMC : 附加要素名称
* FJYSLX : 附加要素类型
* FJYSZ : 附加要素值
*/
private String FJYSMC;
private String FJYSLX;
private String FJYSZ;
}

@ -0,0 +1,69 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
/**
* 数电发票信息
*
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
* @createDate: Created in 2022-10-12
*/
@Getter
@Setter
@ToString
public class QdTxxBO implements Serializable {
/**
* ZZID : 组织ID
* TDYS : 特定要素
* QYDM : 区域代码
* CEZSLXDM : 差额征税类型代码
* SGFPLXDM : 收购发票类型代码
* CKYWSYZCDM : 出口业务适用政策代码
* ZZSJZJTDM : 增值税即征即退代码
* ZPPZDM : 纸票票种代码
* GMFJBR : 经办人
* JBRSFZJHM : 经办人身份证件号码
* GMFJBRLXDH : 经办人联系电话
* JSFS : 结算方式
* SKYHMC : 收款银行名称
* SKYHZH : 收款银行账号
* YSXWFSD : 应税行为发生地
* FJYSLIST : [{"FJYSMC":"附加要素名称","FJYSLX":"附加要素类型","FJYSZ":"附加要素值"}]
* CEZSLIST: [{"XH": "序号","PZLX": "凭证类型","FPDM": "发票代码","FPHM": "发票号码","ZZFPHM": "纸质发票号码","PZHM": "凭证号码","KJRQ": "开具日期","HJJE": "合计金额",KCE": "扣除额","BZ": "备注","LRFS": "录入方式","BCKCJE": "本次扣除金额","PZHJJE": "凭证合计金额"}]
* HWYSLIST : [{"XMXH":"明细序号","QYD":"起运地","DDD":"到达地","YSGJZL":"运输工具种类","YSGJPH":"运输工具牌号","YSHWMC":"运输货物名称"}]
* BDCZLXX:{BDCDZ : 不动产地址,KDSBZ : 跨地()标志,CQZSH : 房屋产权证书号/不动产权证号, MJDW : 面积单位,ZLQQZ : 租赁期起止}
* BDCXSXX:{BDCWQHTBH : 不动产单元代码/网签合同备案编号,BDCDZ : 不动产地址,KDSBZ : 跨地()标志,TDZZSXMBH : 土地增值税项目编号,HDJSJG : 核定计税价格,SJCJHSJE : 实际成交含税金额,CQZSH : 房屋产权证书号/不动产权证号,MJDW : 面积单位}
* JZFWXX:{ TDZZSXMBH : 土地增值税项目编号,JZFWFSD : 建筑服务发生地,JZFWMC : 建筑服务名称,KDSBZ : 跨地()标志}
* LKYSFWLIST:[{"CXRXH": "出行人序号 ","CXRQ": "出行日期","CXRZJLX": "出行人证件类型","CXRZJHM": "出行人证件号码","LKYSCFD": "旅客运输出发地","LKYSDDD": "旅客运输到达地","JTGJLX": "旅客运输交通工具类型","ZWDJ": "座位等级"}]
*/
private String ZZID;
private String TDYS;
private String QYDM;
private String CEZSLXDM;
private String SGFPLXDM;
private String CKYWSYZCDM;
private String ZZSJZJTDM;
private String ZPPZDM;
private String GMFJBR;
private String JBRSFZJHM;
private String GMFJBRLXDH;
private String JSFS;
private String SKYHMC;
private String SKYHZH;
private String YSXWFSD;
private List<QdFjysBO> FJYSLIST;
private List<CezsBO> CEZSLIST;
private List<HwysBO> HWYSLIST;
private BdczlBO BDCZLXX;
private BdcxsBO BDCXSXX;
private JzfwBO JZFWXX;
private List<LkysfwBO> LKYSFWLIST;
}

@ -0,0 +1,40 @@
package com.jianshui.common.core.domain.entity.ele;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* 协议接口统一返回协议bean
*
* @author ZSC-DXHY
* @date 创建时间: 2018/9/19 9:52
*/
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Setter
@Getter
@ToString
public class ResponseBO implements Serializable {
/**
* 通用code
*/
private String ZTDM;
/**
* 通用错误信息
*/
private String ZTXX;
/**
* 订单请求流水号
*/
private String DDQQLSH;
/**
* 纳税人识别号
*/
private String NSRSBH;
}

@ -169,8 +169,24 @@ public class DDTXX {
private String KPRZJHM; // 开票人证件号码
private String KPRZJLX; // 开票人证件类型
private String YHM; // 电局登录用户名
private String SFZSGFYHZH;
private String SFZSXFYHZH;
public String getSFZSGFYHZH() {
return SFZSGFYHZH;
}
public void setSFZSGFYHZH(String SFZSGFYHZH) {
this.SFZSGFYHZH = SFZSGFYHZH;
}
public String getSFZSXFYHZH() {
return SFZSXFYHZH;
}
public void setSFZSXFYHZH(String SFZSXFYHZH) {
this.SFZSXFYHZH = SFZSXFYHZH;
}
public void setDDQQLSH(String DDQQLSH) {
this.DDQQLSH = DDQQLSH;

@ -3,6 +3,7 @@ package com.jianshui.invoice.service;
import com.alibaba.fastjson.JSONObject;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.core.domain.entity.ele.DdfpzxxV5;
public interface ElephantInvoiceService {
@ -17,4 +18,6 @@ public interface ElephantInvoiceService {
//获取状态
AjaxResult getRpaAuthStatus(JSONObject paramJson, Companyservice companyservice);
AjaxResult convertAndSaveInvoice(DdfpzxxV5 ddfpzxxV5,Companyservice companyservice);
}

@ -1,55 +1,92 @@
package com.jianshui.invoice.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dxhy.order.protocol.invoke.DxhyInterfaceResponse;
import com.jianshui.common.config.JianshuiConfig;
import com.jianshui.common.constant.Constants;
import com.jianshui.common.constant.PersonList;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.core.domain.entity.ele.DdfpxxV5;
import com.jianshui.common.core.domain.entity.ele.DdfpzxxV5;
import com.jianshui.common.core.domain.entity.ele.DdmxxxV5;
import com.jianshui.common.utils.DateUtils;
import com.jianshui.common.utils.JsonKeyCase;
import com.jianshui.common.utils.StringUtils;
import com.jianshui.common.utils.file.FileUtils;
import com.jianshui.common.utils.spring.SpringUtils;
import com.jianshui.common.utils.uuid.IdUtils;
import com.jianshui.invoice.constant.elephant.ElephantConstantsV6;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.invoice.domain.BillInfo;
import com.jianshui.invoice.domain.Invoice;
import com.jianshui.invoice.domain.InvoiceDetail;
import com.jianshui.invoice.domain.InvoiceFile;
import com.jianshui.invoice.mapper.BillInfoMapper;
import com.jianshui.invoice.mapper.InvoiceFileMapper;
import com.jianshui.invoice.mapper.InvoiceMapper;
import com.jianshui.invoice.service.ElephantInvoiceService;
import com.jianshui.invoice.service.IBillInfoService;
import com.jianshui.invoice.utils.elephant.ElephantUtils;
import com.jianshui.system.domain.CompanyserviceProp;
import com.jianshui.system.service.ICompanyservicePropService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.util.*;
@Slf4j
@Service
public class ElephantInvoiceServiceImpl implements ElephantInvoiceService {
@Autowired
private BillInfoMapper billInfoMapper;
@Autowired
private InvoiceMapper invoiceMapper;
@Autowired
private IBillInfoService billInfoService;
@Autowired
private InvoiceFileMapper invoiceFileMapper;
//调用大象获取电子税局账号
@Override
public AjaxResult queryRpaTaxAccount(String sellertax, Companyservice companyservice) {
Map<String,String> param = new HashMap<>();
param.put("NSRSBH",sellertax);
Map<String, String> param = new HashMap<>();
param.put("NSRSBH", sellertax);
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
log.info("front queryRpaTaxAccount param{}",JSONObject.toJSONString(param));
log.info("front queryRpaTaxAccount param{}", JSONObject.toJSONString(param));
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.QUERY_RPA_TAX_ACCOUNT_LOCALHOST, ElephantConstantsV6.QUERY_RPA_TAX_ACCOUNT_METHOD, JSONUtil.parse(param), companyservice);
log.info("front queryRpaTaxAccount response{}",JSONObject.toJSONString(dxhyInterfaceResponse));
log.info("front queryRpaTaxAccount response{}", JSONObject.toJSONString(dxhyInterfaceResponse));
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("获取电子税局账号失败{}",e);
log.error("获取电子税局账号失败{}", e);
return AjaxResult.error("009999", "系统异常!");
}
if (!"000000".equals(dxhyInterfaceResponse.getCode())){
if (!"000000".equals(dxhyInterfaceResponse.getCode())) {
return AjaxResult.error(dxhyInterfaceResponse.getMessage());
}
JSONObject responJson = JSONObject.parseObject(dxhyInterfaceResponse.getData());
responJson = JsonKeyCase.JsonKeyCase(responJson,1);
if (!"000000".equals(responJson.getString("ztdm"))){
responJson = JsonKeyCase.JsonKeyCase(responJson, 1);
if (!"000000".equals(responJson.getString("ztdm"))) {
return AjaxResult.error(responJson.getString("ztxx"));
}
return AjaxResult.success(responJson.getJSONArray("data"));
@ -59,36 +96,36 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService {
@Override
public AjaxResult rpaLogin(JSONObject paramJson, Companyservice companyservice) {
paramJson.put("NSRSBH",companyservice.getSellertax());
paramJson.put("NSRSBH", companyservice.getSellertax());
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
paramJson = JsonKeyCase.JsonKeyCase(paramJson);
log.info("front rpaLogin param{}",paramJson);
log.info("front rpaLogin param{}", paramJson);
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.RPA_LOGIN_LOCALHOST, ElephantConstantsV6.RPA_LOGIN_METHOD, JSONUtil.parse(paramJson), companyservice);
log.info("front rpaLogin response{}",JSONObject.toJSONString(dxhyInterfaceResponse));
log.info("front rpaLogin response{}", JSONObject.toJSONString(dxhyInterfaceResponse));
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("电子税局登陆失败{}",e);
return AjaxResult.error("009999", "系统异常!");
log.error("电子税局登陆失败{}", e);
return AjaxResult.error("009999", "系统异常!");
}
if (!"000000".equals(dxhyInterfaceResponse.getCode())){
if (!"000000".equals(dxhyInterfaceResponse.getCode())) {
return AjaxResult.error(dxhyInterfaceResponse.getMessage());
}
//获取返回数据
JSONObject responJson = JSONObject.parseObject(dxhyInterfaceResponse.getData());
//key转成小写
responJson = JsonKeyCase.JsonKeyCase(responJson,1);
responJson = JsonKeyCase.JsonKeyCase(responJson, 1);
if (!"000000".equals(responJson.getString("ztdm"))){
if (!"000000".equals(responJson.getString("ztdm"))) {
return AjaxResult.error(responJson.getString("ztxx"));
}
//判断后续方法是否为3
JSONObject dataJson = responJson.getJSONObject("data");
if ("2".equals(dataJson.getString("hxff"))){
if ("2".equals(dataJson.getString("hxff"))) {
JSONObject sj = dataJson.getJSONObject("sj");
List<String> personList = sj.getJSONArray("personList").toJavaList(String.class);
Map<String,String> personTypes = new HashMap<>();
personList.forEach(e->personTypes.put(e, PersonList.getName(e)));
dataJson.put("personList",personTypes);
Map<String, String> personTypes = new HashMap<>();
personList.forEach(e -> personTypes.put(e, PersonList.getName(e)));
dataJson.put("personList", personTypes);
}
return AjaxResult.success(dataJson);
@ -98,24 +135,24 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService {
@Override
public AjaxResult getRpaQrCode(JSONObject paramJson, Companyservice companyservice) {
paramJson.put("NSRSBH",companyservice.getSellertax());
paramJson.put("NSRSBH", companyservice.getSellertax());
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
paramJson = JsonKeyCase.JsonKeyCase(paramJson);
log.info("front getRpaQrCode param{}",JSONObject.toJSONString(paramJson));
log.info("front getRpaQrCode param{}", JSONObject.toJSONString(paramJson));
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.GET_RPA_QY_CODE_LOCALHOST, ElephantConstantsV6.GET_RPA_QY_CODE_METHOD, JSONUtil.parse(paramJson), companyservice);
log.info("front getRpaQrCode response{}",JSONObject.toJSONString(dxhyInterfaceResponse));
log.info("front getRpaQrCode response{}", JSONObject.toJSONString(dxhyInterfaceResponse));
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("电子税局登陆失败{}",e);
return AjaxResult.error("009999", "系统异常!");
log.error("电子税局登陆失败{}", e);
return AjaxResult.error("009999", "系统异常!");
}
if (!"000000".equals(dxhyInterfaceResponse.getCode())){
if (!"000000".equals(dxhyInterfaceResponse.getCode())) {
return AjaxResult.error(dxhyInterfaceResponse.getMessage());
}
JSONObject responJson = JSONObject.parseObject(dxhyInterfaceResponse.getData());
responJson = JsonKeyCase.JsonKeyCase(responJson,1);
responJson = JsonKeyCase.JsonKeyCase(responJson, 1);
if (!"000000".equals(responJson.getString("ztdm"))){
if (!"000000".equals(responJson.getString("ztdm"))) {
return AjaxResult.error(responJson.getString("ztxx"));
}
return AjaxResult.success(responJson.getJSONObject("data"));
@ -124,26 +161,289 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService {
//数电实名认证状态
@Override
public AjaxResult getRpaAuthStatus(JSONObject paramJson, Companyservice companyservice) {
paramJson.put("NSRSBH",companyservice.getSellertax());
paramJson.put("NSRSBH", companyservice.getSellertax());
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
paramJson = JsonKeyCase.JsonKeyCase(paramJson);
log.info("front getRpaAuthStatus param{}",paramJson);
log.info("front getRpaAuthStatus param{}", paramJson);
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.GET_RPA_AUTH_STATUS_LOCALHOST, ElephantConstantsV6.GET_RPA_AUTH_STATUS_METHOD, JSONUtil.parse(paramJson), companyservice);
log.info("front getRpaAuthStatus response{}",JSONObject.toJSONString(dxhyInterfaceResponse));
log.info("front getRpaAuthStatus response{}", JSONObject.toJSONString(dxhyInterfaceResponse));
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("电子税局登陆失败{}",e);
return AjaxResult.error("009999", "系统异常!");
log.error("电子税局登陆失败{}", e);
return AjaxResult.error("009999", "系统异常!");
}
if (!"000000".equals(dxhyInterfaceResponse.getCode())){
if (!"000000".equals(dxhyInterfaceResponse.getCode())) {
return AjaxResult.error(dxhyInterfaceResponse.getMessage());
}
JSONObject responJson = JSONObject.parseObject(dxhyInterfaceResponse.getData());
responJson = JsonKeyCase.JsonKeyCase(responJson,1);
responJson = JsonKeyCase.JsonKeyCase(responJson, 1);
if (!"000000".equals(responJson.getString("ztdm"))){
if (!"000000".equals(responJson.getString("ztdm"))) {
return AjaxResult.error(responJson.getString("ztxx"));
}
return AjaxResult.success(responJson.getJSONObject("data"));
}
@Override
public AjaxResult convertAndSaveInvoice(DdfpzxxV5 ddfpzxxV5, Companyservice companyservice) {
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX();
//查询billInfo
QueryWrapper<BillInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("company_id", companyservice.getCompanyid());
queryWrapper.eq("fpqqlsh", ddfpxx.getDDQQLSH());
queryWrapper.orderByDesc("id");
queryWrapper.last(" limit 1");
BillInfo originBillInfo = billInfoMapper.selectOne(queryWrapper);
if (originBillInfo == null) {
log.error("originBillInfo信息不存在");
return AjaxResult.error("发票信息不存在");
}
Invoice invoice = invoiceMapper.selectBySystemOrderNo(companyservice.getCompanyid(), originBillInfo.getSystemOrderno());
if (invoice == null) {
invoice = new Invoice();
}
invoice.setBillInfoId(originBillInfo.getId()); // bill_info表的bill_id */
invoice.setCompanyId(companyservice.getCompanyid()); // "销方ID"
invoice.setSystemOrderno(originBillInfo.getSystemOrderno()); // "系统订单号"
invoice.setOutTradeOrderno(originBillInfo.getOutTradeOrderno()); // "客户订单号"
invoice.setFpqqlsh(originBillInfo.getFpqqlsh()); // "流水号"
invoice.setInvoiceType(originBillInfo.getInvoiceType()); // "发票种类"
invoice.setState(2);//开票状态成功才会推送
invoice.setcInvoiceid("not used"); // 发票c_invoiceid */
invoice.setFpdm(ddfpxx.getFPDM()); // "发票代码"
invoice.setFphm(ddfpxx.getFPHM()); // "发票号码"
//TODO
try {
String kprq = ddfpxx.getKPRQ();
if (StringUtils.isNotEmpty(kprq)) {
invoice.setKprq(DateUtils.parseDate(kprq, "yyyy-MM-dd HH:mm:ss")); // "开票日期", width = 30, dateFormat = "yyyy-MM-dd"
}
} catch (ParseException e) {
log.error("{}日期处理错误",ddfpxx.getDDQQLSH());
throw new RuntimeException(e.getMessage());
}
invoice.setBuyerName(ddfpxx.getGMFMC()); // "购方名称"
invoice.setBuyerTaxnum(ddfpxx.getGMFSBH()); // "购方税号"
invoice.setBuyerAddress(ddfpxx.getGMFDZ()); // "购方地址"
invoice.setBuyerTelephone(ddfpxx.getGMFDH()); // "购方电话"
invoice.setBuyerAccount(ddfpxx.getGMFYH() + ddfpxx.getGMFZH()); // "购方开户行及账户"
invoice.setBuyerEmail(originBillInfo.getBuyerEmail()); // "购方邮箱"
invoice.setBuyerPhone(originBillInfo.getBuyerPhone()); // "购方联系电话,可空"
invoice.setSellerName(ddfpxx.getXHFMC()); // "销方名称"
invoice.setSellerTaxnum(ddfpxx.getXHFSBH()); // "销方税号"
invoice.setSellerAddress(ddfpxx.getXHFDZ()); // "销方地址"
invoice.setSellerTelephone(ddfpxx.getXHFDH()); // "销方电话"
invoice.setSellerAccount(ddfpxx.getXHFYH() + ddfpxx.getXHFZH()); // "销方开户行及账户"
invoice.setMessage(ddfpxx.getBZ()); // "备注"
invoice.setClerk(ddfpxx.getKPR()); // "开票人"
invoice.setPayee(ddfpxx.getSKR()); // "收款人"
invoice.setChecker(ddfpxx.getFHR()); // "复核人"
invoice.setTaxfreeamt(new BigDecimal(ddfpxx.getHJJE())); // "不含税金额"
invoice.setTax(new BigDecimal(ddfpxx.getHJSE())); // "税额"
invoice.setTaxamt(new BigDecimal(ddfpxx.getJSHJ())); // "含税金额"
invoice.setOriginFpdm(ddfpxx.getYFPDM()); // "原发票代码"
invoice.setOriginFphm(ddfpxx.getYFPHM()); // "原发票号码"
invoice.setJym(ddfpxx.getJYM()); // "校验码"
invoice.setQrCode(ddfpxx.getDTM()); // "二维码" 动态码是二维码吗?
invoice.setMachineCode(ddfpxx.getJQBH()); // "税控设备号"
invoice.setInvoiceMsg(ddfpxx.getDDZTXX()); // "开票信息,成功或者失败的信息"
invoice.setInvoiceResultMsg(ddfpxx.getDDZTXX()); // "结果信息"
String oilFlag = "0";
String qdbz = "0";
if (StringUtils.equals(ddfpxx.getQDBZ(), "4")) {
oilFlag = "1";
}
if (StringUtils.equals(ddfpxx.getQDBZ(), "1")) {
qdbz = "1";
}
invoice.setProductOilFlag(oilFlag); // "成品油标志"
invoice.setQdbz(qdbz); // "清单标志"
// invoice.setcOfdUrl(); // "ofdUrl"
invoice.setFjh(ddfpxx.getKPJH()); // "分机号"
invoice.setTerminalNumber(ddfpxx.getKPZD()); // "终端号"
invoice.setJqbh(ddfpxx.getKPZD());
saveFileUseDb(invoice,IdUtils.randomUUID(),invoice.getFphm(),companyservice, ddfpxx);
//判断id是否为空,为空则插入,不为空则更新
if (invoice.getId() != null) {
invoiceMapper.updateInvoice(invoice);
} else {
invoiceMapper.insertInvoice(invoice);
}
//发票明细先删除再插入
invoiceMapper.deleteInvoiceDetailByInvoiceId(invoice.getId());
List<InvoiceDetail> invoiceDetailList = new ArrayList<>();
List<DdmxxxV5> ddmxxxList = ddfpzxxV5.getDDMXXX();
for (int i = 0; i < ddmxxxList.size(); i++) {
DdmxxxV5 ddmxxx = ddmxxxList.get(i);
InvoiceDetail tempDetail = new InvoiceDetail();
// tempDetail.setId(); // id
tempDetail.setInvoiceId(invoice.getId()); // 发票主键
tempDetail.setIndex(Long.parseLong(StringUtils.isEmpty(ddmxxx.getXH()) ? "" : ddmxxx.getXH())); // 顺序
tempDetail.setGoodName(StringUtils.isEmpty(ddmxxx.getXMMC()) ? "" : ddmxxx.getXMMC()); // 商品名称
//TODO
if (StringUtils.isNotBlank(ddmxxx.getSPSL())){
tempDetail.setNum(new BigDecimal(ddmxxx.getSPSL())); // 商品数量
}
tempDetail.setPrice(new BigDecimal(StringUtils.isEmpty(ddmxxx.getDJ()) ? "0" : ddmxxx.getDJ())); // 商品单价
tempDetail.setHsbz(Integer.parseInt(StringUtils.isEmpty(ddmxxx.getHSBZ()) ? "0" : ddmxxx.getHSBZ())); // 含税标志
tempDetail.setTaxrate(new BigDecimal(StringUtils.isEmpty(ddmxxx.getSL()) ? "0" : ddmxxx.getSL())); // 税率
tempDetail.setSpec(StringUtils.isEmpty(ddmxxx.getGGXH()) ? "" : ddmxxx.getGGXH()); // 规格型号
tempDetail.setUnit(StringUtils.isEmpty(ddmxxx.getDW()) ? "" : ddmxxx.getDW()); // 单位
tempDetail.setSpbm(StringUtils.isEmpty(ddmxxx.getSPBM()) ? "" : ddmxxx.getSPBM()); // 税收分类编码
tempDetail.setBmbbh(ddfpxx.getBMBBBH()); // 商品编码版本号
tempDetail.setZsbm(StringUtils.isEmpty(ddmxxx.getZXBM()) ? "" : ddmxxx.getZXBM()); // 自行编码
tempDetail.setFphxz(Integer.parseInt(StringUtils.isEmpty(ddmxxx.getFPHXZ()) ? "0" : ddmxxx.getFPHXZ())); // 发票行性质
tempDetail.setYhzcbs(Integer.parseInt(StringUtils.isEmpty(ddmxxx.getYHZCBS()) ? "0" : ddmxxx.getYHZCBS())); // 优惠政策标识
tempDetail.setZzstsgl(StringUtils.isEmpty(ddmxxx.getZZSTSGL()) ? "" : ddmxxx.getZZSTSGL()); // 增值税特殊管理
tempDetail.setLslbs(StringUtils.isEmpty(ddmxxx.getLSLBS()) ? "" : ddmxxx.getLSLBS()); // 零税率标识
if (ddmxxx.getKCE() != null && !"".equals(ddmxxx.getKCE())) {
tempDetail.setKce(new BigDecimal(ddmxxx.getKCE())); // 扣除额
}
tempDetail.setTax(new BigDecimal(ddmxxx.getSE())); // 税额
if (tempDetail.getHsbz() == 0) {
tempDetail.setTaxfreeamt(new BigDecimal(ddmxxx.getJE())); // 不含税金额
// 计算含税金额
tempDetail.setTaxamt(tempDetail.getTaxfreeamt().add(tempDetail.getTax()));
} else {
tempDetail.setTaxamt(new BigDecimal(ddmxxx.getJE())); // 含税金额
tempDetail.setTaxfreeamt(tempDetail.getTaxamt().subtract(tempDetail.getTax())); // 计算不含税金额
}
invoiceDetailList.add(tempDetail);
}
invoiceMapper.batchInvoiceDetail(invoiceDetailList);
//更新原来的billInfo
originBillInfo.setState(invoice.getState());
if (StringUtils.equals(originBillInfo.getKptype(), "2")) {
originBillInfo.setOriginFpdm(invoice.getOriginFpdm());
originBillInfo.setOriginFphm(invoice.getOriginFphm());
// 如果是红票,开票状态为成功,还需要对原来的蓝票进行状态修改
if (invoice.getState() == 2) {
Invoice originInvoice = invoiceMapper.selectByFpdmFphm(companyservice.getCompanyid(), invoice.getOriginFpdm(), invoice.getOriginFphm());
if (originInvoice != null) {
originBillInfo.setOriginSystemOrderno(originInvoice.getSystemOrderno());
QueryWrapper<BillInfo> myQueryWrapper = new QueryWrapper<>();
myQueryWrapper.eq("company_id", companyservice.getCompanyid());
myQueryWrapper.eq("system_orderno", originInvoice.getSystemOrderno());
BillInfo originBlueBillInfo = billInfoMapper.selectOne(myQueryWrapper);
if (originBlueBillInfo != null) {
originBlueBillInfo.setState(99);
billInfoMapper.updateBillInfo(originBlueBillInfo);
}
originInvoice.setState(99);
invoiceMapper.updateInvoice(originInvoice);
}
}
}
billInfoMapper.updateBillInfo(originBillInfo);
try {
log.info("推送订单信息,id:{}", originBillInfo.getId());
billInfoService.pushBillInfo(originBillInfo.getId());
} catch (Exception e) {
log.error("推送订单信息失败id:{}", originBillInfo.getId(), e);
log.error("推送订单信息失败:{}", e);
}
return AjaxResult.success();
}
private void saveFileUseLocal(Invoice invoice, DdfpxxV5 ddfpxx) {
try {
byte[] pdfBytes = Base64.decode(ddfpxx.getPDFZJL());
String key = IdUtils.fastSimpleUUID();
String fileName = key + "."+ddfpxx.getZJLLX().toLowerCase();
String fileDir = JianshuiConfig.getDownloadPath() + "/storage/";
// 判断fileDir是否存在,不存在则创建
File fileDirInst = new File(fileDir);
if (!fileDirInst.exists()) {
fileDirInst.mkdirs();
}
String realPath = fileDir + fileName;
FileUtils.byteToFile(pdfBytes, realPath);
// IStorageService service = storageFactory.getStorageInstance(Constants.LOCAL);
//
//
//
// AjaxResult upload = service.upload(pdfBytes, "");
//文件名称
// fileName = fileName+ Constants.POINT + (StringUtils.equals(ddfpxx.getZJLLX(), Constants.PDF_UPCASE) ? Constants.PDF : Constants.OFD);
//文件写入路径
// String targetFilePath = environment.getProperty(Constants.INVOICE_FILE_SAVE_PATH) + fileName;
// 创建一个输出流对象,用于将数据写入到本地文件,如果文件存在则会覆盖
FileOutputStream fileOutputStream = new FileOutputStream(realPath, false);
// 直接将字节数组写入到输出流(即本地文件)
fileOutputStream.write(pdfBytes);
// 完成写入后关闭流
fileOutputStream.close();
//拼接url
// StorageUrlDTO uploadResultDTO = (StorageUrlDTO) upload.get(Constants.DATA);
// String fileUrl = configService.selectConfigByKey(Constants.FILE_URL);
// uploadResultDTO.setStoragePath(targetFilePath);
// uploadResultDTO.setContentType(ddfpxx.getZJLLX().toLowerCase());
// Base64.encode(JSONObject.toJSONString(uploadResultDTO));
// String pdfUrl = fileUrl + Constants.ESCAPE + Base64.encode(JSONObject.toJSONString(uploadResultDTO));
invoice.setInvoicePdfUrl(realPath);
invoice.setInvoiceFileStorage("local");
if (StringUtils.equals(ddfpxx.getZJLLX(), Constants.OFD_UPCASE)) {
invoice.setcOfdUrl(realPath);
}
}catch (Exception e){
log.error("文件保存异常",e);
}
}
private void saveFileUseDb(Invoice invoice,String fileId,String fileName,Companyservice companyservice,DdfpxxV5 ddfpxx) {
InvoiceFile invoiceFile = new InvoiceFile();
invoiceFile.setFphm(ddfpxx.getFPHM());
List<InvoiceFile> invoiceFileList = invoiceFileMapper.selectInvoiceFileList(invoiceFile);
if(invoiceFileList != null && invoiceFileList.size() > 0){
invoiceFile = invoiceFileList.get(0);
invoiceFile.setFileContent(ddfpxx.getPDFZJL());
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
fileId = invoiceFile.getFileId();
fileName = invoiceFile.getFileName();
invoiceFileMapper.updateInvoiceFile(invoiceFile);
}else{
invoiceFile.setId(fileId);
invoiceFile.setFileContent(ddfpxx.getPDFZJL());
invoiceFile.setFileId(fileId);
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
invoiceFileMapper.insertInvoiceFile(invoiceFile);
}
// 2023/11/16 kk:上传OSS转下载地址关闭,改为直接返回大象的文件流
invoice.setInvoicePdfUrl(SpringUtils.getBean(Environment.class).getProperty("elephant_invoice_file") + fileId);
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class);
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "elephant_invoice_file_dc");
if (secretIdProp != null) {
invoice.setInvoicePdfUrl(secretIdProp.getValue() + fileId);
}
}
}

@ -194,8 +194,8 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(billInfo.getBuyerBank()) && StringUtils.isEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerBank());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
@ -228,15 +228,15 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
if (billInfo.getTaxamt() != null && billInfo.getTaxamt().compareTo(new BigDecimal("12"))>0){
throw new RuntimeException("发票金额不能大于10元");
}
if (billInfo.getTaxfreeamt() == null && billInfo.getTaxamt() == null){
if (billInfo.getTaxfreeamt() == null && billInfo.getTaxamt() == null && billDetailList != null){
BigDecimal taxAmount = new BigDecimal("0");
if ("1".equals(billInfo.getHsbz())){
billDetailList.forEach(e->taxAmount.add(e.getTaxfreeamt()));
billDetailList.forEach(e->taxAmount.add(e.getTaxfreeamt()==null?new BigDecimal("0"):e.getTaxfreeamt()));
if (taxAmount.compareTo(new BigDecimal("10"))>0){
throw new RuntimeException("发票金额不能大于10元");
}
}else {
billDetailList.forEach(e->taxAmount.add(e.getTaxamt()));
billDetailList.forEach(e->taxAmount.add(e.getTaxamt()==null?new BigDecimal("0"):e.getTaxamt()));
if (taxAmount.compareTo(new BigDecimal("12"))>0){
throw new RuntimeException("发票金额不能大于10元");
}

@ -170,42 +170,42 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
// 订单头信息
DDTXX ddtxx = new DDTXX(billInfo);
CompanyserviceProp companyserviceProp = companyservicePropMapper.selectPropByKey(companyservice.getCompanyid(), "account_show");
if (companyserviceProp != null && "1".equals(companyserviceProp.getValue())){
StringBuilder bz = new StringBuilder();
if (StringUtils.isNotBlank(ddtxx.getBZ())){
bz.append(ddtxx.getBZ()).append("\n");
}
String buyerBank = billInfo.getBuyerBank();
String buyerAccount = billInfo.getBuyerAccount();
String sellerAccount = billInfo.getSellerAccount();
String sellerBank = billInfo.getSellerBank();
bz.append("购方开户银行账号:");
if (StringUtils.isNotBlank(buyerBank)) {
bz.append("\t").append(buyerBank);
}
if (StringUtils.isNotBlank(buyerAccount)) {
bz.append("\t").append(buyerAccount);
}
bz.append("\n");
bz.append("销方开户银行账号:");
if (StringUtils.isNotBlank(sellerBank)) {
bz.append("\t").append(sellerBank);
}
if (StringUtils.isNotBlank(sellerAccount)) {
bz.append("\t").append(sellerAccount);
}
log.info("备注信息:\n{}",bz.toString());
ddtxx.setBZ(bz.toString());
}
// CompanyserviceProp companyserviceProp = companyservicePropMapper.selectPropByKey(companyservice.getCompanyid(), "account_show");
//
// if (companyserviceProp != null && "1".equals(companyserviceProp.getValue())){
// StringBuilder bz = new StringBuilder();
// if (StringUtils.isNotBlank(ddtxx.getBZ())){
// bz.append(ddtxx.getBZ()).append("\n");
// }
// String buyerBank = billInfo.getBuyerBank();
// String buyerAccount = billInfo.getBuyerAccount();
// String sellerAccount = billInfo.getSellerAccount();
// String sellerBank = billInfo.getSellerBank();
//
//
// bz.append("购方开户银行账号:");
//
// if (StringUtils.isNotBlank(buyerBank)) {
// bz.append("\t").append(buyerBank);
// }
// if (StringUtils.isNotBlank(buyerAccount)) {
// bz.append("\t").append(buyerAccount);
// }
//
// bz.append("\n");
//
// bz.append("销方开户银行账号:");
//
// if (StringUtils.isNotBlank(sellerBank)) {
// bz.append("\t").append(sellerBank);
// }
// if (StringUtils.isNotBlank(sellerAccount)) {
// bz.append("\t").append(sellerAccount);
// }
//
// log.info("备注信息:\n{}",bz.toString());
// ddtxx.setBZ(bz.toString());
// }
// 订单票面信息
@ -218,6 +218,14 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
String fplxdm = ElephantUtils.transElephantType(invioceType, 1);
ddpcxx.setFPLXDM(fplxdm);
if ("001".equals(fplxdm)||"002".equals(fplxdm)){
CompanyserviceProp companyserviceProp = companyservicePropMapper.selectPropByKey(companyservice.getCompanyid(), "account_show");
if (companyserviceProp != null && "1".equals(companyserviceProp.getValue())) {
ddtxx.setSFZSGFYHZH("Y");
ddtxx.setSFZSXFYHZH("Y");
}
}
//kk 2023/9/15 V6数电新增
// 标准开具
Qdtxx qdtxx = BeanUtil.copyProperties(billInfo, Qdtxx.class);

Loading…
Cancel
Save