|
|
@@ -157,6 +157,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
@Autowired
|
|
|
private FsExternalOrderMapper fsExternalOrderMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LifeSaluteOrderMapper lifeSaluteOrderMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FsPatientMapper fsPatientMapper;
|
|
|
|
|
|
@@ -2482,6 +2485,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
}
|
|
|
updateStoreOrderDelivery(dto);
|
|
|
updateExternalOrderDelivery(dto);
|
|
|
+ updateLifeSaluteOrderDelivery(dto);
|
|
|
if (!dto.isSuccess()) {
|
|
|
logger.info("物流状态异常:{}", dto);
|
|
|
}
|
|
|
@@ -2574,6 +2578,28 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void updateLifeSaluteOrderDelivery(ExpressInfoDTO dto) {
|
|
|
+ List<LifeSaluteOrder> orders = lifeSaluteOrderMapper.selectLifeSaluteOrderByWaybillNo(dto.getLogisticCode());
|
|
|
+ if (orders == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (LifeSaluteOrder order : orders) {
|
|
|
+ logger.info("生命礼赞订单物流回调订单信息:{}", JSONUtil.toJsonStr(order));
|
|
|
+ if (order == null || (order.getDeliveryStatus() != null && order.getDeliveryStatus() == 3)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (dto.getState() == null || dto.getStateEx() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ LifeSaluteOrder update = new LifeSaluteOrder();
|
|
|
+ update.setId(order.getId());
|
|
|
+ update.setDeliveryStatus(Integer.parseInt(dto.getState()));
|
|
|
+ update.setDeliveryType(dto.getStateEx());
|
|
|
+ update.setDeliveryUpdateTime(DateUtils.getNowDate());
|
|
|
+ lifeSaluteOrderMapper.updateLifeSaluteOrder(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isNormalSigned(ExpressInfoDTO dto) {
|
|
|
return "3".equals(dto.getState())
|
|
|
&& ("301".equals(dto.getStateEx())
|
|
|
@@ -4849,39 +4875,50 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int applyFinanceAudit(List<Long> orderIds, Integer auditType,
|
|
|
+ public int applyFinanceAudit(List<Long> orderIds, Integer auditType,
|
|
|
BigDecimal newTotalPrice, BigDecimal newPayPrice,
|
|
|
String priceChangeReason, String voucherImages, String voucherRemark,
|
|
|
Long applyUserId, String applyUserName, Integer orderType) {
|
|
|
int count = 0;
|
|
|
+ Integer realOrderType = orderType != null ? orderType : 1;
|
|
|
for (Long orderId : orderIds) {
|
|
|
- FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(orderId);
|
|
|
- if (order == null) {
|
|
|
- throw new CustomException("订单不存在:" + orderId);
|
|
|
- }
|
|
|
-
|
|
|
- FsStoreOrderFinanceAudit existAudit = fsStoreOrderFinanceAuditMapper.selectByOrderId(orderId);
|
|
|
+ FsStoreOrderFinanceAudit existAudit = fsStoreOrderFinanceAuditMapper.selectByOrderIdAndOrderType(orderId, realOrderType);
|
|
|
if (existAudit != null && existAudit.getAuditStatus() == 0) {
|
|
|
- throw new CustomException("订单已存在待审核记录:" + order.getOrderCode());
|
|
|
+ throw new CustomException("订单已存在待审核记录:" + existAudit.getOrderCode());
|
|
|
}
|
|
|
|
|
|
FsStoreOrderFinanceAudit audit = new FsStoreOrderFinanceAudit();
|
|
|
audit.setOrderId(orderId);
|
|
|
- audit.setOrderCode(order.getOrderCode());
|
|
|
audit.setAuditType(auditType);
|
|
|
- audit.setOriginalTotalPrice(order.getTotalPrice());
|
|
|
- audit.setOriginalPayPrice(order.getPayPrice());
|
|
|
audit.setNewTotalPrice(newTotalPrice);
|
|
|
audit.setNewPayPrice(newPayPrice);
|
|
|
audit.setPriceChangeReason(priceChangeReason);
|
|
|
audit.setVoucherImages(voucherImages);
|
|
|
audit.setVoucherRemark(voucherRemark);
|
|
|
- audit.setOrderType(orderType != null ? orderType : 1);
|
|
|
+ audit.setOrderType(realOrderType);
|
|
|
audit.setAuditStatus(0);
|
|
|
audit.setApplyUserId(applyUserId);
|
|
|
audit.setApplyUserName(applyUserName);
|
|
|
audit.setApplyTime(new Date());
|
|
|
|
|
|
+ if (isExternalFinanceAuditOrder(realOrderType)) {
|
|
|
+ FsExternalOrder order = fsExternalOrderMapper.selectFsExternalOrderByOrderId(orderId);
|
|
|
+ if (order == null) {
|
|
|
+ throw new CustomException("外部订单不存在:" + orderId);
|
|
|
+ }
|
|
|
+ audit.setOrderCode(order.getOrderCode());
|
|
|
+ audit.setOriginalTotalPrice(order.getTotalPrice());
|
|
|
+ audit.setOriginalPayPrice(order.getPayPrice());
|
|
|
+ } else {
|
|
|
+ FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(orderId);
|
|
|
+ if (order == null) {
|
|
|
+ throw new CustomException("订单不存在:" + orderId);
|
|
|
+ }
|
|
|
+ audit.setOrderCode(order.getOrderCode());
|
|
|
+ audit.setOriginalTotalPrice(order.getTotalPrice());
|
|
|
+ audit.setOriginalPayPrice(order.getPayPrice());
|
|
|
+ }
|
|
|
+
|
|
|
count += fsStoreOrderFinanceAuditMapper.insertFsStoreOrderFinanceAudit(audit);
|
|
|
}
|
|
|
return count;
|
|
|
@@ -4909,23 +4946,45 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
int result = fsStoreOrderFinanceAuditMapper.updateFsStoreOrderFinanceAudit(audit);
|
|
|
|
|
|
if (auditStatus == 1) {
|
|
|
- FsStoreOrder order = new FsStoreOrder();
|
|
|
- order.setOrderId(audit.getOrderId());
|
|
|
-
|
|
|
- if (audit.getAuditType() == 1) {
|
|
|
- order.setTotalPrice(audit.getNewTotalPrice());
|
|
|
- order.setPayPrice(audit.getNewPayPrice());
|
|
|
- order.setPayMoney(audit.getNewPayPrice());
|
|
|
- } else if (audit.getAuditType() == 2) {
|
|
|
- order.setStatus(4);
|
|
|
+ if (isExternalFinanceAuditOrder(audit.getOrderType())) {
|
|
|
+ updateExternalOrderByFinanceAudit(audit);
|
|
|
+ } else {
|
|
|
+ updateStoreOrderByFinanceAudit(audit);
|
|
|
}
|
|
|
-
|
|
|
- fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void updateStoreOrderByFinanceAudit(FsStoreOrderFinanceAudit audit) {
|
|
|
+ FsStoreOrder order = new FsStoreOrder();
|
|
|
+ order.setOrderId(audit.getOrderId());
|
|
|
+ if (audit.getAuditType() == 1) {
|
|
|
+ order.setTotalPrice(audit.getNewTotalPrice());
|
|
|
+ order.setPayPrice(audit.getNewPayPrice());
|
|
|
+ order.setPayMoney(audit.getNewPayPrice());
|
|
|
+ } else if (audit.getAuditType() == 2) {
|
|
|
+ order.setStatus(4);
|
|
|
+ }
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateExternalOrderByFinanceAudit(FsStoreOrderFinanceAudit audit) {
|
|
|
+ FsExternalOrder order = new FsExternalOrder();
|
|
|
+ order.setOrderId(audit.getOrderId());
|
|
|
+ if (audit.getAuditType() == 1) {
|
|
|
+ order.setTotalPrice(audit.getNewTotalPrice());
|
|
|
+ order.setPayPrice(audit.getNewPayPrice());
|
|
|
+ } else if (audit.getAuditType() == 2) {
|
|
|
+ order.setStatus(4);
|
|
|
+ }
|
|
|
+ fsExternalOrderMapper.updateFsExternalOrder(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isExternalFinanceAuditOrder(Integer orderType) {
|
|
|
+ return orderType != null && orderType == 0;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void createJSTOmsOrder(List<Long> orderIds) throws Exception {
|
|
|
// 1. 检查 ERP 是否开启
|