|
|
@@ -1680,6 +1680,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Transactional
|
|
|
public R createPackageOrder(long uid, FsStorePackageOrderCreateParam param) {
|
|
|
//计算金额
|
|
|
+ FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
|
|
|
String packageId = redisCache.getCacheObject("orderKey:" + param.getOrderKey());
|
|
|
if (packageId != null) {
|
|
|
FsStoreProductPackageScrm storeProductPackage = productPackageService.selectFsStoreProductPackageById(param.getPackageId());
|
|
|
@@ -1717,6 +1718,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
String joinCartIds = null;
|
|
|
if(carts == null || carts.isEmpty()){
|
|
|
carts = new ArrayList<>();
|
|
|
+ List<FsStoreCartQueryVO> cartQueryVOS = new LinkedList<>();
|
|
|
for (StorePackageProductDTO goods : goodsList) {
|
|
|
FsStoreProductAttrValueScrm attrValue = attrValueService.selectFsStoreProductAttrValueById(goods.getId());
|
|
|
if (attrValue != null && attrValue.getProductId() != null) {
|
|
|
@@ -1734,12 +1736,26 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
vo.setGroupBarCode(attrValue.getGroupBarCode());
|
|
|
vo.setPrice(product.getPrice());
|
|
|
vo.setProductType(product.getProductType());
|
|
|
+ vo.setTempId(product.getTempId().longValue());
|
|
|
carts.add(vo);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
cartService.checkProductStock(attrValue.getProductId(), attrValue.getId());
|
|
|
}
|
|
|
+ //校验运费
|
|
|
+ if ("北京卓美".equals(companyName)) {
|
|
|
+ try {
|
|
|
+ BigDecimal payPostage =getPayPostage(carts,address);
|
|
|
+ storeOrder.setPayPostage(payPostage);
|
|
|
+ } catch (ServiceException e) {
|
|
|
+ // 捕获运费模板检查异常,直接返回错误
|
|
|
+ if ("偏远地区暂不可购买".equals(e.getMessage())) {
|
|
|
+ return R.error("偏远地区暂不可购买");
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
// 如果cartIds不为空,则表示是套餐制单购买,非套餐制单是没有购物车信息的。
|
|
|
List<Long> cartIds = carts.stream().map(FsStoreCartQueryVO::getId).collect(Collectors.toList());
|
|
|
@@ -1751,7 +1767,6 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
Boolean isIntegral = false;
|
|
|
//组合数据
|
|
|
CompanyUser user = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
|
- FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
|
|
|
storeOrder.setCartId(joinCartIds);
|
|
|
//修改默认仓库
|
|
|
|
|
|
@@ -1784,6 +1799,14 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //如果运费存在加入运费金额
|
|
|
+ if("北京卓美".equals(companyName)){
|
|
|
+ if(storeOrder.getPayPostage().compareTo(BigDecimal.ZERO) == 1){
|
|
|
+ totalMoney = totalMoney.add(storeOrder.getPayPostage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
storeOrder.setCompanyUserId(param.getCompanyUserId());
|
|
|
storeOrder.setUserId(uid);
|
|
|
storeOrder.setOrderCode(orderSn);
|
|
|
@@ -6105,4 +6128,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
public FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto) {
|
|
|
return fsStoreOrderMapper.selectFsStoreOrderAmountScrmStats(queryDto);
|
|
|
}
|
|
|
+
|
|
|
+ private BigDecimal getPayPostage(List<FsStoreCartQueryVO> carts, FsUserAddressScrm
|
|
|
+ userAddress){
|
|
|
+ FsStoreOrderPriceDTO priceGroup = this.getOrderPriceGroup(carts, userAddress);
|
|
|
+ BigDecimal payPostage = priceGroup.getStorePostage();
|
|
|
+ BigDecimal badCode = BigDecimal.valueOf(-1);
|
|
|
+ // 检查运费计算结果,如果是 -1 表示偏远地区不可购买
|
|
|
+ if (payPostage.compareTo(badCode) == 0) {
|
|
|
+ throw new ServiceException("偏远地区暂不可购买");
|
|
|
+ }
|
|
|
+ return payPostage;
|
|
|
+ }
|
|
|
}
|