Merge remote-tracking branch 'origin/master'

20230922-ljl-fixBug
qiushengjie 1 year ago
commit d18625a751

@ -27,6 +27,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.regex.MatchResult; import java.util.regex.MatchResult;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -916,71 +917,77 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
HashMap<Long, Integer> purchaseNumMap = buildPurchaseOrderItemsPurchaseNum(skuIdAndOpOrderChildMap, needRebuildSkuIds, realPurchaseNumMap); HashMap<Long, Integer> purchaseNumMap = buildPurchaseOrderItemsPurchaseNum(skuIdAndOpOrderChildMap, needRebuildSkuIds, realPurchaseNumMap);
HashMap<Long, Double> purchasePriceMap = buildPurchaseOrderItemsPurchasePrice(skuIdAndOpOrderChildMap, needRebuildSkuIds, (double) 0, purchaseNumMap); HashMap<Long, Double> purchasePriceMap = buildPurchaseOrderItemsPurchasePrice(skuIdAndOpOrderChildMap, needRebuildSkuIds, (double) 0, purchaseNumMap);
PurchaseOrder purchaseOrder = buildPurchaseOrderByDto(purchaseOrderDto, oldPurchaseOrder, opOrder); TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
log.info("savePurchaseOrderInfoSavePurchaseOrder" + purchaseOrder); try {
if (purchaseOrder.getPurchaseOrderId() != null && purchaseOrder.getPurchaseOrderId() > 0) { PurchaseOrder purchaseOrder = buildPurchaseOrderByDto(purchaseOrderDto, oldPurchaseOrder, opOrder);
purchaseOrderService.updateByPrimaryKeySelective(purchaseOrder); log.info("savePurchaseOrderInfoSavePurchaseOrder" + purchaseOrder);
} else { if (purchaseOrder.getPurchaseOrderId() != null && purchaseOrder.getPurchaseOrderId() > 0) {
purchaseOrderService.insertSelective(purchaseOrder); purchaseOrderService.updateByPrimaryKeySelective(purchaseOrder);
} } else {
purchaseOrderService.insertSelective(purchaseOrder);
if (!purchaseOrderDto.getPurchaseOrderFlow().isEmpty()) { }
purchaseOrderTagService.save(purchaseOrder, PurchaseOrderTagConst.FLOW, purchaseOrderDto.getPurchaseOrderFlow());
}
if (Objects.equals(purchaseOrderDto.getNotFirst1688OrderType(), "normal") || Objects.equals(purchaseOrderDto.getNotFirst1688OrderType(), "force")) {
purchaseOrderTagService.save(purchaseOrder, PurchaseOrderTagConst.NOT_FIRST1688_ORDER_TYPE, purchaseOrderDto.getNotFirst1688OrderType());
}
if (purchaseOrderDto.getIsDsEncryptOrder() >= 1) { if (!purchaseOrderDto.getPurchaseOrderFlow().isEmpty()) {
PurchaseOrderDsEncrypt log = buildPurchaseOrderDsEncrypt(purchaseOrderDto, opOrder); purchaseOrderTagService.save(purchaseOrder, PurchaseOrderTagConst.FLOW, purchaseOrderDto.getPurchaseOrderFlow());
purchaseOrderDsEncryptService.insertSelective(log); }
} if (Objects.equals(purchaseOrderDto.getNotFirst1688OrderType(), "normal") || Objects.equals(purchaseOrderDto.getNotFirst1688OrderType(), "force")) {
purchaseOrderTagService.save(purchaseOrder, PurchaseOrderTagConst.NOT_FIRST1688_ORDER_TYPE, purchaseOrderDto.getNotFirst1688OrderType());
}
Map<Long, PurchaseOrderItemDTO> skuIdAndItemMap = purchaseOrderDto.getSkuIdAndItemMap(); if (purchaseOrderDto.getIsDsEncryptOrder() >= 1) {
System.out.println("needRebuildSkuIds" + needRebuildSkuIds); PurchaseOrderDsEncrypt log = buildPurchaseOrderDsEncrypt(purchaseOrderDto, opOrder);
for (Long skuId: needRebuildSkuIds) { purchaseOrderDsEncryptService.insertSelective(log);
OpOrderChild opOrderChild = skuIdAndOpOrderChildMap.get(skuId);
PurchaseOrderItem oldPurchaseOrderitem = oldPurchaseOrderItemMap.get(skuId);
PurchaseOrderItemDTO newPurchaseOrderItem = skuIdAndItemMap.get(skuId);
String purchaseUrl = newPurchaseOrderItem.getPurchaseUrl();
Integer purchaseNum = purchaseNumMap.get(skuId);
Double purchasePrice = purchasePriceMap.get(skuId);
if (oldPurchaseOrderitem != null) {
purchaseUrl = StringUtils.isBlank(oldPurchaseOrderitem.getPurchaseUrl()) ? oldPurchaseOrderitem.getPurchaseUrl() : purchaseUrl;
purchaseNum = purchaseNum != null ? purchaseNum : oldPurchaseOrderitem.getPurchaseNum();
purchasePrice = purchasePrice != null ? purchasePrice : oldPurchaseOrderitem.getPurchasePrice().doubleValue();
} }
PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem(); Map<Long, PurchaseOrderItemDTO> skuIdAndItemMap = purchaseOrderDto.getSkuIdAndItemMap();
purchaseOrderItem.setPurchaseOrderId(purchaseOrder.getPurchaseOrderId().intValue()); System.out.println("needRebuildSkuIds" + needRebuildSkuIds);
purchaseOrderItem.setOrderId(purchaseOrder.getOrderId()); for (Long skuId: needRebuildSkuIds) {
purchaseOrderItem.setShopId(purchaseOrder.getShopId()); OpOrderChild opOrderChild = skuIdAndOpOrderChildMap.get(skuId);
purchaseOrderItem.setWareId(opOrderChild.getProductId()); PurchaseOrderItem oldPurchaseOrderitem = oldPurchaseOrderItemMap.get(skuId);
purchaseOrderItem.setSkuId(skuId); PurchaseOrderItemDTO newPurchaseOrderItem = skuIdAndItemMap.get(skuId);
purchaseOrderItem.setStatus(StatusConst.normal); String purchaseUrl = newPurchaseOrderItem.getPurchaseUrl();
purchaseOrderItem.setPurchaseUrl(purchaseUrl); Integer purchaseNum = purchaseNumMap.get(skuId);
purchaseOrderItem.setPurchaseNum(purchaseNum); Double purchasePrice = purchasePriceMap.get(skuId);
purchaseOrderItem.setPurchasePrice(BigDecimal.valueOf(purchasePrice)); if (oldPurchaseOrderitem != null) {
purchaseOrderItem.setRealPurchaseUrl(newPurchaseOrderItem.getRealPurchaseUrl()); purchaseUrl = StringUtils.isBlank(oldPurchaseOrderitem.getPurchaseUrl()) ? oldPurchaseOrderitem.getPurchaseUrl() : purchaseUrl;
purchaseOrderItem.setGmtModified(new Date()); purchaseNum = purchaseNum != null ? purchaseNum : oldPurchaseOrderitem.getPurchaseNum();
purchaseOrderItem.setPurchasePlatform(purchaseOrderDto.getPurchasePlatform()); purchasePrice = purchasePrice != null ? purchasePrice : oldPurchaseOrderitem.getPurchasePrice().doubleValue();
if (oldPurchaseOrderitem != null) { }
purchaseOrderItemService.updateByPrimaryKeySelective(purchaseOrderItem);
} else { PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem();
purchaseOrderItemService.insertSelective(purchaseOrderItem); purchaseOrderItem.setPurchaseOrderId(purchaseOrder.getPurchaseOrderId().intValue());
purchaseOrderItem.setOrderId(purchaseOrder.getOrderId());
purchaseOrderItem.setShopId(purchaseOrder.getShopId());
purchaseOrderItem.setWareId(opOrderChild.getProductId());
purchaseOrderItem.setSkuId(skuId);
purchaseOrderItem.setStatus(StatusConst.normal);
purchaseOrderItem.setPurchaseUrl(purchaseUrl);
purchaseOrderItem.setPurchaseNum(purchaseNum);
purchaseOrderItem.setPurchasePrice(BigDecimal.valueOf(purchasePrice));
purchaseOrderItem.setRealPurchaseUrl(newPurchaseOrderItem.getRealPurchaseUrl());
purchaseOrderItem.setGmtModified(new Date());
purchaseOrderItem.setPurchasePlatform(purchaseOrderDto.getPurchasePlatform());
if (oldPurchaseOrderitem != null) {
purchaseOrderItemService.updateByPrimaryKeySelective(purchaseOrderItem);
} else {
purchaseOrderItemService.insertSelective(purchaseOrderItem);
}
} }
} if (!needCancelPurchaseOrderIds.isEmpty()) {
if (!needCancelPurchaseOrderIds.isEmpty()) { purchaseOrderService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderIds);
purchaseOrderService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderIds); purchaseOrderItemService.updateStatusByPurchaseIds(StatusConst.cancel, needCancelPurchaseOrderIds);
purchaseOrderItemService.updateStatusByPurchaseIds(StatusConst.cancel, needCancelPurchaseOrderIds);
}
if (!needCancelPurchaseOrderItemIds.isEmpty()) {
purchaseOrderItemService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderItemIds);
}
if (!purchaseOrderCancelLogs.isEmpty()) {
for (PurchaseOrderCancelLog log: purchaseOrderCancelLogs) {
purchaseOrderCancelLogService.insertSelective(log);
} }
if (!needCancelPurchaseOrderItemIds.isEmpty()) {
purchaseOrderItemService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderItemIds);
}
if (!purchaseOrderCancelLogs.isEmpty()) {
for (PurchaseOrderCancelLog log: purchaseOrderCancelLogs) {
purchaseOrderCancelLogService.insertSelective(log);
}
}
dataSourceTransactionManager.commit(transactionStatus);
} catch (Throwable e) {
dataSourceTransactionManager.rollback(transactionStatus);
} }
updateOpOrderFilterPurchaseStatus(opOrder.getOrderId(), null); updateOpOrderFilterPurchaseStatus(opOrder.getOrderId(), null);
opOrderDsService.updateOpOrderDsFilterStatus(opOrder.getOrderId(), purchaseOrderDto.getPurchasePlatform()); opOrderDsService.updateOpOrderDsFilterStatus(opOrder.getOrderId(), purchaseOrderDto.getPurchasePlatform());
@ -1007,11 +1014,17 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
Date purchaseOrderSendTime = null; Date purchaseOrderSendTime = null;
Date purchaseOrderStartTime = null; Date purchaseOrderStartTime = null;
if (StringUtils.isNotBlank(purchaseOrderDto.getPurchaseOrderStartTime())) { System.out.println("purchaseOrderDto: " + purchaseOrderDto);
purchaseOrderStartTime = DateUtils.parseDate(purchaseOrderDto.getPurchaseOrderStartTime(), new String[]{"yyyy-MM-dd HH:mm:ss"}); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
} try {
if (StringUtils.isNotBlank(purchaseOrderDto.getPurchaseOrderSendTime())) { if (StringUtils.isNotBlank(purchaseOrderDto.getPurchaseOrderStartTime())) {
purchaseOrderSendTime = DateUtils.parseDate(purchaseOrderDto.getPurchaseOrderSendTime(), new String[]{"yyyy-MM-dd HH:mm:ss"}); purchaseOrderStartTime = dateFormat.parse(purchaseOrderDto.getPurchaseOrderStartTime());
}
if (StringUtils.isNotBlank(purchaseOrderDto.getPurchaseOrderSendTime())) {
purchaseOrderSendTime = dateFormat.parse(purchaseOrderDto.getPurchaseOrderSendTime());
}
} catch (java.text.ParseException e) {
throw new RuntimeException("时间格式错误");
} }
String purchaseStatus = purchaseOrderDto.getPurchaseOrderStatus(); String purchaseStatus = purchaseOrderDto.getPurchaseOrderStatus();

Loading…
Cancel
Save