|
@@ -261,9 +261,8 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
order.setStoreId(storeId);
|
|
order.setStoreId(storeId);
|
|
|
}
|
|
}
|
|
|
order.setTotalNum(totalNum);
|
|
order.setTotalNum(totalNum);
|
|
|
- order.setTotalPrice(totalPrice);
|
|
|
|
|
|
|
+ order.setTotalPrice(param.getTotalPrice()!=null?param.getTotalPrice():totalPrice);
|
|
|
order.setPayPrice(param.getPayMoney() != null ? param.getPayMoney() : totalPrice);
|
|
order.setPayPrice(param.getPayMoney() != null ? param.getPayMoney() : totalPrice);
|
|
|
-
|
|
|
|
|
if (fsExternalOrderMapper.insertFsExternalOrder(order) > 0) {
|
|
if (fsExternalOrderMapper.insertFsExternalOrder(order) > 0) {
|
|
|
for (FsExternalOrderItem item : items) {
|
|
for (FsExternalOrderItem item : items) {
|
|
|
item.setOrderId(order.getOrderId());
|
|
item.setOrderId(order.getOrderId());
|
|
@@ -308,6 +307,7 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<ShopOrderDTO> shopOrderList = new ArrayList<>();
|
|
List<ShopOrderDTO> shopOrderList = new ArrayList<>();
|
|
|
|
|
+ List<ShopOrderDTO> codOrderList = new ArrayList<>();
|
|
|
Map<String, Long> orderCodeToIdMap = new HashMap<>();
|
|
Map<String, Long> orderCodeToIdMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (Long orderId : orderIds) {
|
|
for (Long orderId : orderIds) {
|
|
@@ -333,6 +333,12 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
ShopOrderDTO shopOrderDTO = buildShopOrderDTO(order);
|
|
ShopOrderDTO shopOrderDTO = buildShopOrderDTO(order);
|
|
|
if (shopOrderDTO != null) {
|
|
if (shopOrderDTO != null) {
|
|
|
shopOrderList.add(shopOrderDTO);
|
|
shopOrderList.add(shopOrderDTO);
|
|
|
|
|
+ if (isCodOrder(order)) {
|
|
|
|
|
+ ShopOrderDTO codOrderDTO = buildCodShopOrderDTO(order, shopOrderDTO);
|
|
|
|
|
+ if (codOrderDTO != null) {
|
|
|
|
|
+ codOrderList.add(codOrderDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
orderCodeToIdMap.put(order.getOrderCode(), orderId);
|
|
orderCodeToIdMap.put(order.getOrderCode(), orderId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -381,6 +387,43 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
|
|
|
|
|
Thread.sleep(600);
|
|
Thread.sleep(600);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < codOrderList.size(); i += batchSize) {
|
|
|
|
|
+ int endIndex = Math.min(i + batchSize, codOrderList.size());
|
|
|
|
|
+ List<ShopOrderDTO> batch = new ArrayList<>(codOrderList.subList(i, endIndex));
|
|
|
|
|
+ ErpOrderResponseDTO response = jstErpHttpService.batchUpload(batch);
|
|
|
|
|
+ log.info("外部订单货到付款推送聚水潭,批次: {}-{}, 结果: {}", i, endIndex, response);
|
|
|
|
|
+ Thread.sleep(600);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean isCodOrder(FsExternalOrder order) {
|
|
|
|
|
+ return order != null && (Integer.valueOf(2).equals(order.getPayType()) || Integer.valueOf(3).equals(order.getPayType()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ShopOrderDTO buildCodShopOrderDTO(FsExternalOrder order, ShopOrderDTO shopOrderDTO) {
|
|
|
|
|
+ if (order == null || shopOrderDTO == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ ShopOrderDTO codOrderDTO = JSON.parseObject(JSON.toJSONString(shopOrderDTO), ShopOrderDTO.class);
|
|
|
|
|
+ BigDecimal totalPrice = order.getTotalPrice() == null ? BigDecimal.ZERO : order.getTotalPrice();
|
|
|
|
|
+ BigDecimal payPrice = order.getPayPrice() == null ? BigDecimal.ZERO : order.getPayPrice();
|
|
|
|
|
+ BigDecimal codAmount = totalPrice.subtract(payPrice);
|
|
|
|
|
+ if (codAmount.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ codAmount = BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+ codOrderDTO.setIsCod(true);
|
|
|
|
|
+ codOrderDTO.setPayAmount(totalPrice.doubleValue());
|
|
|
|
|
+
|
|
|
|
|
+ PaymentDTO paymentDTO = new PaymentDTO();
|
|
|
|
|
+ paymentDTO.setAmount(codAmount.doubleValue());
|
|
|
|
|
+ paymentDTO.setOuterPayId(String.format("%s%d", order.getOrderCode(), 1));
|
|
|
|
|
+ paymentDTO.setPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
+ paymentDTO.setPayment("货到付款");
|
|
|
|
|
+ paymentDTO.setBuyerAccount(order.getUserName());
|
|
|
|
|
+ paymentDTO.setSellerAccount("平台销售");
|
|
|
|
|
+ codOrderDTO.setPay(paymentDTO);
|
|
|
|
|
+ return codOrderDTO;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private ShopOrderDTO buildShopOrderDTO(FsExternalOrder order) {
|
|
private ShopOrderDTO buildShopOrderDTO(FsExternalOrder order) {
|
|
@@ -398,12 +441,11 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
ShopOrderDTO shopOrderDTO = new ShopOrderDTO();
|
|
ShopOrderDTO shopOrderDTO = new ShopOrderDTO();
|
|
|
shopOrderDTO.setShopId(Long.valueOf(fsStore.getShopCode()));
|
|
shopOrderDTO.setShopId(Long.valueOf(fsStore.getShopCode()));
|
|
|
shopOrderDTO.setSoId(order.getOrderCode());
|
|
shopOrderDTO.setSoId(order.getOrderCode());
|
|
|
-
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
shopOrderDTO.setOrderDate(sdf.format(new Date()));
|
|
shopOrderDTO.setOrderDate(sdf.format(new Date()));
|
|
|
shopOrderDTO.setShopStatus("WAIT_SELLER_SEND_GOODS");
|
|
shopOrderDTO.setShopStatus("WAIT_SELLER_SEND_GOODS");
|
|
|
shopOrderDTO.setShopBuyerId(order.getUserName());
|
|
shopOrderDTO.setShopBuyerId(order.getUserName());
|
|
|
- shopOrderDTO.setPayAmount(order.getPayPrice().doubleValue());
|
|
|
|
|
|
|
+ shopOrderDTO.setPayAmount(order.getTotalPrice().doubleValue());
|
|
|
shopOrderDTO.setFreight(order.getFreightPrice() != null ? order.getFreightPrice().doubleValue() : 0.0);
|
|
shopOrderDTO.setFreight(order.getFreightPrice() != null ? order.getFreightPrice().doubleValue() : 0.0);
|
|
|
|
|
|
|
|
StringBuilder remarkBuilder = new StringBuilder();
|
|
StringBuilder remarkBuilder = new StringBuilder();
|
|
@@ -487,7 +529,7 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
itemDTO.setName(orderItem.getProductName());
|
|
itemDTO.setName(orderItem.getProductName());
|
|
|
itemDTO.setShopIId(orderItem.getProductCode() != null ? orderItem.getProductCode().trim() : "");
|
|
itemDTO.setShopIId(orderItem.getProductCode() != null ? orderItem.getProductCode().trim() : "");
|
|
|
itemDTO.setPropertiesValue(orderItem.getProductSpec());
|
|
itemDTO.setPropertiesValue(orderItem.getProductSpec());
|
|
|
- itemDTO.setAmount(orderItem.getTotalPrice());
|
|
|
|
|
|
|
+ itemDTO.setAmount(orderItem.getTotalPrice().multiply(new BigDecimal(orderItem.getNum())));
|
|
|
itemDTO.setPrice(orderItem.getPrice());
|
|
itemDTO.setPrice(orderItem.getPrice());
|
|
|
itemDTO.setQty(orderItem.getNum().intValue());
|
|
itemDTO.setQty(orderItem.getNum().intValue());
|
|
|
itemDTO.setOuterOiId(String.format("%s%d", order.getOrderCode(), orderItem.getItemId()));
|
|
itemDTO.setOuterOiId(String.format("%s%d", order.getOrderCode(), orderItem.getItemId()));
|