|
|
@@ -190,14 +190,16 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
return R.error("商品列表不能为空");
|
|
|
}
|
|
|
|
|
|
- // 构建产品ID列表和数量映射
|
|
|
+ // 构建产品ID列表、数量映射和价格映射
|
|
|
List<Long> productIds = new ArrayList<>();
|
|
|
Map<Long, Long> productNumMap = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> productPriceMap = new HashMap<>();
|
|
|
for (ExternalOrderProductDTO productDTO : param.getProducts()) {
|
|
|
if (productDTO.getProductId() != null) {
|
|
|
productIds.add(productDTO.getProductId());
|
|
|
Long num = productDTO.getNum() != null && productDTO.getNum() > 0 ? productDTO.getNum() : 1L;
|
|
|
productNumMap.put(productDTO.getProductId(), num);
|
|
|
+ productPriceMap.put(productDTO.getProductId(), productDTO.getPrice());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -237,7 +239,10 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
Long storeId = 0L;
|
|
|
for (FsStoreProduct product : storeProductList) {
|
|
|
Long num = productNumMap.getOrDefault(product.getProductId(), 1L);
|
|
|
- BigDecimal price = product.getPrice() != null ? product.getPrice() : BigDecimal.ZERO;
|
|
|
+ BigDecimal price = productPriceMap.get(product.getProductId());
|
|
|
+ if (price == null) {
|
|
|
+ price = product.getPrice() != null ? product.getPrice() : BigDecimal.ZERO;
|
|
|
+ }
|
|
|
BigDecimal itemTotalPrice = price.multiply(BigDecimal.valueOf(num));
|
|
|
|
|
|
totalNum += num;
|
|
|
@@ -258,7 +263,13 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
|
|
|
storeId = product.getStoreId();
|
|
|
}
|
|
|
if(storeId !=null){
|
|
|
- order.setStoreId(storeId);
|
|
|
+ FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(storeId);
|
|
|
+ String orderCode = null;
|
|
|
+ if(fsStore !=null){
|
|
|
+ orderCode=fsStore.getShopCode();
|
|
|
+ }
|
|
|
+ assert orderCode != null;
|
|
|
+ order.setStoreId(Long.valueOf(orderCode));
|
|
|
}
|
|
|
order.setTotalNum(totalNum);
|
|
|
order.setTotalPrice(param.getTotalPrice()!=null?param.getTotalPrice():totalPrice);
|