|
|
|
@ -6,7 +6,6 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
|
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; |
|
|
|
@ -31,7 +30,6 @@ import com.jianshui.invoice.mapper.InvoiceBackMapper; |
|
|
|
|
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.queue.dto.RedisQueueMessage; |
|
|
|
|
import com.jianshui.queue.utils.RedisQueueUtil; |
|
|
|
@ -42,8 +40,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
@ -197,17 +193,132 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService { |
|
|
|
|
|
|
|
|
|
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); |
|
|
|
|
|
|
|
|
|
log.info("convertAndSaveInvoice ddfpzxxV5{}", JSONObject.toJSONString(ddfpzxxV5)); |
|
|
|
|
if ("1".equals(ddfpxx.getKPLX())){ |
|
|
|
|
log.info("开始红票推送"); |
|
|
|
|
Invoice invoice = new Invoice(); |
|
|
|
|
// invoice.setBillInfoId(parseLong); // bill_info表的bill_id */
|
|
|
|
|
invoice.setCompanyId(companyservice.getCompanyid()); // "销方ID"
|
|
|
|
|
invoice.setSystemOrderno(ddfpxx.getHZXXBBH()); // "系统订单号"
|
|
|
|
|
invoice.setOutTradeOrderno(ddfpxx.getHZXXBBH()); // "客户订单号"
|
|
|
|
|
invoice.setFpqqlsh(ddfpxx.getDDQQLSH()); // "流水号"
|
|
|
|
|
invoice.setInvoiceType(ElephantUtils.transElephantType(ddfpxx.getFPLXDM(), 2)); // "发票种类"
|
|
|
|
|
invoice.setState(2);//开票状态成功才会推送
|
|
|
|
|
invoice.setcInvoiceid("not used"); // 发票c_invoiceid */
|
|
|
|
|
invoice.setFpdm(ddfpxx.getFPDM()); // "发票代码"
|
|
|
|
|
invoice.setFphm(ddfpxx.getFPHM()); // "发票号码"
|
|
|
|
|
invoice.setHzxxbbh(ddfpxx.getHZXXBBH()); |
|
|
|
|
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(ddfpxx.getGMFDZYX()); // "购方邮箱"
|
|
|
|
|
invoice.setBuyerPhone(ddfpxx.getGMFSJH()); // "购方联系电话,可空"
|
|
|
|
|
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()); |
|
|
|
|
//处理明细
|
|
|
|
|
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())); // 计算不含税金额
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Invoice invoiceQuery = invoiceMapper.selectByFpdmFphm(companyservice.getCompanyid(),ddfpxx.getYFPHM(),""); |
|
|
|
|
if(invoiceQuery == null ){ |
|
|
|
|
log.error("原蓝字发票信息不存在,发票号码为{}",ddfpxx.getYFPHM()); |
|
|
|
|
return AjaxResult.error("发票信息不存在"); |
|
|
|
|
invoiceDetailList.add(tempDetail); |
|
|
|
|
} |
|
|
|
|
invoice.setInvoiceDetailList(invoiceDetailList); |
|
|
|
|
log.info("invoice{}", JSONObject.toJSONString(invoice)); |
|
|
|
|
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class); |
|
|
|
|
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(Long.valueOf(companyservice.getIdentity()), "aisino_callback_url"); |
|
|
|
|
String callBackUrl = secretIdProp.getValue(); |
|
|
|
|
log.info("【控制台】发票回调接口,发送数据开始,callBackUrl={},param={}", callBackUrl, JSONUtil.toJsonStr(invoice)); |
|
|
|
|
String result = HttpUtil.post(callBackUrl, JSONUtil.toJsonStr(invoice)); |
|
|
|
|
log.info("【控制台】发票回调接口,发送数据结束,接口返回信息={}", result); |
|
|
|
|
|
|
|
|
|
JSONObject resultObject = JSONObject.parseObject(result); |
|
|
|
|
if (StringUtils.isNotBlank(resultObject.getString("status")) && "0000".equals(resultObject.getString("status"))){ |
|
|
|
|
return AjaxResult.success(); |
|
|
|
|
}else { |
|
|
|
|
return AjaxResult.error(resultObject.getString("msg")); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
log.info("开始蓝票推送"); |
|
|
|
|
//查询billInfo
|
|
|
|
|
QueryWrapper<BillInfo> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("company_id", companyservice.getCompanyid()); |
|
|
|
|
queryWrapper.eq("fpqqlsh", invoiceQuery.getFpqqlsh()); |
|
|
|
|
queryWrapper.eq("fpqqlsh", ddfpxx.getDDQQLSH()); |
|
|
|
|
queryWrapper.orderByDesc("id"); |
|
|
|
|
queryWrapper.last(" limit 1"); |
|
|
|
|
BillInfo originBillInfo = billInfoMapper.selectOne(queryWrapper); |
|
|
|
@ -404,10 +515,144 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService { |
|
|
|
|
log.error("推送订单信息失败id:{}", originBillInfo.getId(), e); |
|
|
|
|
log.error("推送订单信息失败:{}", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<InvoiceDetail> buildDetail(DdfpzxxV5 ddfpzxxV5,Invoice invoice){ |
|
|
|
|
List<InvoiceDetail> invoiceDetailList = new ArrayList<>(); |
|
|
|
|
List<DdmxxxV5> ddmxxxList = ddfpzxxV5.getDDMXXX(); |
|
|
|
|
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return invoiceDetailList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Invoice buildInvoice(DdfpzxxV5 ddfpzxxV5, Companyservice companyservice,BillInfo originBillInfo) { |
|
|
|
|
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); |
|
|
|
|
Invoice invoice; |
|
|
|
|
if ("0".equals(ddfpxx.getKPLX())){ |
|
|
|
|
invoice = invoiceMapper.selectBySystemOrderNo(companyservice.getCompanyid(), originBillInfo.getSystemOrderno()); |
|
|
|
|
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.setBuyerEmail(originBillInfo.getBuyerEmail()); // "购方邮箱"
|
|
|
|
|
invoice.setBuyerPhone(originBillInfo.getBuyerPhone()); // "购方联系电话,可空"
|
|
|
|
|
}else { |
|
|
|
|
invoice = new Invoice(); |
|
|
|
|
invoice.setCompanyId(companyservice.getCompanyid()); // "销方ID"
|
|
|
|
|
invoice.setSystemOrderno(ddfpxx.getHZXXBBH()); // "系统订单号"
|
|
|
|
|
invoice.setOutTradeOrderno(ddfpxx.getHZXXBBH()); // "客户订单号"
|
|
|
|
|
invoice.setFpqqlsh(ddfpxx.getDDQQLSH()); // "流水号"
|
|
|
|
|
invoice.setInvoiceType(ElephantUtils.transElephantType(ddfpxx.getFPLXDM(), 2)); // "发票种类"
|
|
|
|
|
invoice.setHzxxbbh(ddfpxx.getHZXXBBH()); |
|
|
|
|
invoice.setBuyerEmail(ddfpxx.getGMFDZYX()); // "购方邮箱"
|
|
|
|
|
invoice.setBuyerPhone(ddfpxx.getGMFSJH()); // "购方联系电话,可空"
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (invoice == null) { |
|
|
|
|
invoice = new Invoice(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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.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); |
|
|
|
|
|
|
|
|
|
return invoice; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void saveFileUseLocal(Invoice invoice, DdfpxxV5 ddfpxx) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -465,7 +710,6 @@ public class ElephantInvoiceServiceImpl implements ElephantInvoiceService { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void saveFileUseDb(Invoice invoice,String fileId,String fileName,Companyservice companyservice,DdfpxxV5 ddfpxx) { |
|
|
|
|
InvoiceFile invoiceFile = new InvoiceFile(); |
|
|
|
|
invoiceFile.setFphm(ddfpxx.getFPHM()); |
|
|
|
|