|
|
@ -3,6 +3,7 @@ package com.dxhy.order.consumer.modules.bespoke.service.impl; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
import com.dxhy.base.common.constant.OrderManagementConstant; |
|
|
|
import com.dxhy.base.common.constant.OrderManagementConstant; |
|
|
|
|
|
|
|
import com.dxhy.base.common.model.OrderInfo; |
|
|
|
import com.dxhy.base.common.model.R; |
|
|
|
import com.dxhy.base.common.model.R; |
|
|
|
import com.dxhy.base.common.utils.DecimalCalculateUtil; |
|
|
|
import com.dxhy.base.common.utils.DecimalCalculateUtil; |
|
|
|
import com.dxhy.base.service.module.buyer.model.BuyerEntity; |
|
|
|
import com.dxhy.base.service.module.buyer.model.BuyerEntity; |
|
|
@ -34,19 +35,21 @@ import com.dxhy.order.consumer.modules.bespoke.service.OrderService; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v4.order.*; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v4.order.*; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v6.order.QdTxxBO; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v6.order.QdTxxBO; |
|
|
|
import com.dxhy.order.consumer.openapi.service.AllocateInvoiceInterfaceServiceV3; |
|
|
|
import com.dxhy.order.consumer.openapi.service.AllocateInvoiceInterfaceServiceV3; |
|
|
|
|
|
|
|
import com.dxhy.order.invoice.module.invoice.dao.OrderInfoMapper; |
|
|
|
|
|
|
|
import com.dxhy.order.invoice.module.invoice.service.impl.OrderInvoiceInfoServiceImpl; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
@Service("yyOrderService") |
|
|
|
@Service("yyOrderService") |
|
|
@ -82,6 +85,12 @@ public class YyOrderServiceImpl implements OrderService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private TInvoiceInvmapMapper tInvoiceInvmapMapper; |
|
|
|
private TInvoiceInvmapMapper tInvoiceInvmapMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private OrderInfoMapper orderInfoMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private OrderInvoiceInfoServiceImpl orderInvoiceInfoService; |
|
|
|
|
|
|
|
|
|
|
|
//订单读入
|
|
|
|
//订单读入
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R orderRead(ReqParam reqParam) { |
|
|
|
public R orderRead(ReqParam reqParam) { |
|
|
@ -192,11 +201,34 @@ public class YyOrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
|
|
|
|
List<NewTable> newTableList = new ArrayList<>(); |
|
|
|
List<NewTable> newTableList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for (OrderOriginExtendInfo orderOriginExtendInfo : orderOriginExtendInfos) { |
|
|
|
ddh = orderInvoiceInfo.getDdh(); |
|
|
|
|
|
|
|
if (ConfigureConstant.STRING_1.equals(orderInvoiceInfo.getKplx())) { |
|
|
|
|
|
|
|
//查询订单信息获取原蓝字发票号码
|
|
|
|
|
|
|
|
List<String> shList = Arrays.asList(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
|
|
|
|
OrderInfo orderInfo = orderInfoMapper.selectOrderInfoByDdqqlsh(orderInvoiceInfo.getFpqqlsh(), shList); |
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(orderInfo)) { |
|
|
|
|
|
|
|
log.error("未查询到相关订单信息"); |
|
|
|
|
|
|
|
return R.error("未查询到相关订单信息"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
OrderInvoiceInfo orderInvoiceInfoLz = orderInvoiceInfoService.selectOrderInvoiceInfoByFpdmAndFphm("", "", orderInfo.getYfpHm(), shList); |
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(orderInvoiceInfoLz)) { |
|
|
|
|
|
|
|
log.error("未查询到相关蓝字发票信息"); |
|
|
|
|
|
|
|
return R.error("未查询到相关蓝字发票信息"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrderInfo orderInfoLz = orderInfoMapper.selectOrderInfoByDdqqlsh(orderInvoiceInfoLz.getFpqqlsh(), shList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ddh = orderInfoLz.getDdh(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
|
|
|
|
ddh =yyOrderMapper.findBackDdh(ddh); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewTable newTable = new NewTable(); |
|
|
|
NewTable newTable = new NewTable(); |
|
|
|
newTable.setCDLCode(orderOriginExtendInfo.getOriginDdh()); |
|
|
|
newTable.setCDLCode(ddh); |
|
|
|
newTable.setInvoiceCode(orderInvoiceInfo.getSdfphm()); |
|
|
|
newTable.setInvoiceNo(orderInvoiceInfo.getSdfphm()); |
|
|
|
newTable.setInvoiceTime(orderInvoiceInfo.getKprq()); |
|
|
|
newTable.setInvoiceTime(orderInvoiceInfo.getKprq()); |
|
|
|
newTable.setInvoiceAmount(orderInvoiceInfo.getKphjje()); |
|
|
|
newTable.setInvoiceAmount(orderInvoiceInfo.getKphjje()); |
|
|
|
newTable.setInvoicePhoto(fileModel.getFilePath()); |
|
|
|
newTable.setInvoicePhoto(fileModel.getFilePath()); |
|
|
@ -207,11 +239,12 @@ public class YyOrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
|
|
|
|
//更新会写表
|
|
|
|
//更新会写表
|
|
|
|
String reBackFild = fildConfig.getReBackFild(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
String reBackFild = fildConfig.getReBackFild(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
yyOrderMapper.updateBackMsg(reBackFild,orderOriginExtendInfo.getOriginDdh(),orderInvoiceInfo.getSdfphm()); |
|
|
|
DynamicContextHolder.push(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
} |
|
|
|
yyOrderMapper.updateBackMsg(reBackFild, ddh, orderInvoiceInfo.getSdfphm()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.debug("待回传数据:{}", JSON.toJSONString(newTableList)); |
|
|
|
log.debug("待回传数据:{}", JSON.toJSONString(newTableList)); |
|
|
|
int count = accressReback(newTableList,orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
int count = accressReback(newTableList, orderInvoiceInfo.getXhfNsrsbh(), orderInvoiceInfo.getSdfphm()); |
|
|
|
|
|
|
|
|
|
|
|
if (count >= newTableList.size()) { |
|
|
|
if (count >= newTableList.size()) { |
|
|
|
return R.ok("成功回传" + count + "条数据"); |
|
|
|
return R.ok("成功回传" + count + "条数据"); |
|
|
@ -220,21 +253,22 @@ public class YyOrderServiceImpl implements OrderService { |
|
|
|
return R.error("回传失败"); |
|
|
|
return R.error("回传失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int accressReback(List<NewTable> newTableList,String nsrsbh) { |
|
|
|
public int accressReback(List<NewTable> newTableList, String nsrsbh, String fphm) { |
|
|
|
|
|
|
|
|
|
|
|
int count = ConfigureConstant.INT_0; |
|
|
|
int count = ConfigureConstant.INT_0; |
|
|
|
|
|
|
|
DynamicContextHolder.push(ConfigureConstant.MAIN); |
|
|
|
|
|
|
|
tInvoiceInvmapMapper.deleteBackMsg(fphm); |
|
|
|
for (NewTable newTable : newTableList) { |
|
|
|
for (NewTable newTable : newTableList) { |
|
|
|
DynamicContextHolder.push(nsrsbh); |
|
|
|
DynamicContextHolder.push(nsrsbh); |
|
|
|
List<InvoiceBpmmap> ddbhList = yyOrderMapper.getDdbh(newTable.getCDLCode()); |
|
|
|
List<InvoiceBpmmap> ddbhList = yyOrderMapper.getDdbh(newTable.getCDLCode()); |
|
|
|
log.debug("查询到中间表信息:{}", JSON.toJSONString(ddbhList)); |
|
|
|
log.debug("查询到中间表信息:{}", JSON.toJSONString(ddbhList)); |
|
|
|
if (CollectionUtils.isNotEmpty(ddbhList)) { |
|
|
|
if (CollectionUtils.isNotEmpty(ddbhList)) { |
|
|
|
DynamicContextHolder.push(ConfigureConstant.MAIN); |
|
|
|
|
|
|
|
tInvoiceInvmapMapper.deleteBackMsg(newTable.getCDLCode()); |
|
|
|
|
|
|
|
for (InvoiceBpmmap invoiceBpmmap : ddbhList) { |
|
|
|
for (InvoiceBpmmap invoiceBpmmap : ddbhList) { |
|
|
|
NewTable newTableFull = new NewTable(); |
|
|
|
NewTable newTableFull = new NewTable(); |
|
|
|
BeanUtil.copyProperties(newTable, newTableFull); |
|
|
|
BeanUtil.copyProperties(newTable, newTableFull); |
|
|
|
newTableFull.setBpmNo(invoiceBpmmap.getBpmno()); |
|
|
|
newTableFull.setBpmNo(invoiceBpmmap.getBpmno()); |
|
|
|
newTableFull.setBpmlsNo(invoiceBpmmap.getBpmlsno()); |
|
|
|
newTableFull.setBpmlsNo(invoiceBpmmap.getBpmlsno()); |
|
|
|
|
|
|
|
DynamicContextHolder.push(ConfigureConstant.MAIN); |
|
|
|
count += tInvoiceInvmapMapper.insertBackMsg(newTableFull); |
|
|
|
count += tInvoiceInvmapMapper.insertBackMsg(newTableFull); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -273,7 +307,7 @@ public class YyOrderServiceImpl implements OrderService { |
|
|
|
yyOrderInfo.setStatus(ConfigureConstant.STRING_0); |
|
|
|
yyOrderInfo.setStatus(ConfigureConstant.STRING_0); |
|
|
|
yyOrderInfo.setEntId(reqParam.getEntId()); |
|
|
|
yyOrderInfo.setEntId(reqParam.getEntId()); |
|
|
|
yyOrderInfo.setDetailCount(String.valueOf(yyOrderItemInfoList.size())); |
|
|
|
yyOrderInfo.setDetailCount(String.valueOf(yyOrderItemInfoList.size())); |
|
|
|
yyOrderInfo.setHsje(hsje.add(se).setScale(ConfigureConstant.INT_2,RoundingMode.HALF_UP).toPlainString()); |
|
|
|
yyOrderInfo.setHsje(hsje.setScale(ConfigureConstant.INT_2, RoundingMode.HALF_UP).toPlainString()); |
|
|
|
yyOrderInfo.setSe(se.setScale(ConfigureConstant.INT_2, RoundingMode.HALF_UP).toPlainString()); |
|
|
|
yyOrderInfo.setSe(se.setScale(ConfigureConstant.INT_2, RoundingMode.HALF_UP).toPlainString()); |
|
|
|
if (yyOrderInfo.getCvouchtype().equals(ConfigureConstant.STRING_26)) { |
|
|
|
if (yyOrderInfo.getCvouchtype().equals(ConfigureConstant.STRING_26)) { |
|
|
|
yyOrderInfo.setCvouchtype(ConfigureConstant.STRING_001); |
|
|
|
yyOrderInfo.setCvouchtype(ConfigureConstant.STRING_001); |
|
|
|