|
@@ -8,6 +8,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.yiqi.common.constant.CacheConstants;
|
|
import com.yiqi.common.exception.ServiceException;
|
|
import com.yiqi.common.exception.ServiceException;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.yiqi.app.domain.AppUser;
|
|
import com.yiqi.app.domain.AppUser;
|
|
@@ -36,10 +37,7 @@ import com.yiqi.recharge.service.IRechargePasswordCardService;
|
|
import com.yiqi.system.domain.SysOrg;
|
|
import com.yiqi.system.domain.SysOrg;
|
|
import com.yiqi.system.domain.SysSettlementRate;
|
|
import com.yiqi.system.domain.SysSettlementRate;
|
|
import com.yiqi.system.domain.SysStore;
|
|
import com.yiqi.system.domain.SysStore;
|
|
-import com.yiqi.system.service.ISysConfigService;
|
|
|
|
-import com.yiqi.system.service.ISysOrgService;
|
|
|
|
-import com.yiqi.system.service.ISysSettlementRateService;
|
|
|
|
-import com.yiqi.system.service.ISysStoreService;
|
|
|
|
|
|
+import com.yiqi.system.service.*;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -91,7 +89,7 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
|
|
@Autowired
|
|
@Autowired
|
|
private ISysConfigService sysConfigService;
|
|
private ISysConfigService sysConfigService;
|
|
@Autowired
|
|
@Autowired
|
|
- private IOrderClothCouponRelationService orderClothCouponRelationService;
|
|
|
|
|
|
+ private ISysConfigRecordService sysConfigRecordService;
|
|
@Autowired
|
|
@Autowired
|
|
private IOrderClothItemCouponRelationService orderClothItemCouponRelationService;
|
|
private IOrderClothItemCouponRelationService orderClothItemCouponRelationService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -696,38 +694,35 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
|
|
for (OrderClothItem orderClothItem : orderClothItems) {
|
|
for (OrderClothItem orderClothItem : orderClothItems) {
|
|
totalPrice = CurrencyUtil.add(totalPrice, orderClothItem.getTotalPrice());
|
|
totalPrice = CurrencyUtil.add(totalPrice, orderClothItem.getTotalPrice());
|
|
}
|
|
}
|
|
-
|
|
|
|
- int freeDeliveryNum = 0;//免费的配送次数
|
|
|
|
- if (totalPrice.doubleValue() >= 100) {
|
|
|
|
- freeDeliveryNum++;
|
|
|
|
- }
|
|
|
|
- if (totalPrice.doubleValue() >= 200) {
|
|
|
|
- freeDeliveryNum++;
|
|
|
|
|
|
+ String deliveryAmountStr = sysConfigRecordService.getCacheConfigRecordByKey(CacheConstants.WASH_DELIVERY_AMOUNT_KEY);
|
|
|
|
+ BigDecimal deliveryAmount = StringUtils.isEmpty(deliveryAmountStr) ? BigDecimal.ZERO : new BigDecimal(deliveryAmountStr);
|
|
|
|
+ BigDecimal freeAmount = BigDecimal.ZERO;
|
|
|
|
+ //配送费减免规则 价格1-价格2:减免费用; 多个阶梯之间用英文分号隔开
|
|
|
|
+ String deliveryFreezeStr = sysConfigRecordService.getCacheConfigRecordByKey(CacheConstants.WASH_DELIVERY_FREE_KEY);
|
|
|
|
+ if (StringUtils.isNotEmpty(deliveryFreezeStr)) {
|
|
|
|
+ String[] deliveryFreezes = deliveryFreezeStr.split(";");
|
|
|
|
+ for (String deliveryFreeze : deliveryFreezes) {
|
|
|
|
+ String[] deliveryFreezeArr = deliveryFreeze.split(":");
|
|
|
|
+ String[] amountArr = deliveryFreezeArr[0].split("-");
|
|
|
|
+ if (totalPrice.doubleValue() >= Double.parseDouble(amountArr[0]) && totalPrice.doubleValue() <= Double.parseDouble(amountArr[1])) {
|
|
|
|
+ freeAmount = new BigDecimal(deliveryFreezeArr[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
orderCloth.setOrderClothPrice(totalPrice);
|
|
orderCloth.setOrderClothPrice(totalPrice);
|
|
-
|
|
|
|
BigDecimal totalDeliveryAmount = BigDecimal.ZERO;
|
|
BigDecimal totalDeliveryAmount = BigDecimal.ZERO;
|
|
// 上门收衣-计算收衣配送费
|
|
// 上门收衣-计算收衣配送费
|
|
if (orderCloth.getTakeClothWay().equals(TakeOrSendClothWay.DELIVERY.getCode())) {
|
|
if (orderCloth.getTakeClothWay().equals(TakeOrSendClothWay.DELIVERY.getCode())) {
|
|
- if (freeDeliveryNum > 0) {
|
|
|
|
- freeDeliveryNum--;
|
|
|
|
- } else {
|
|
|
|
- totalDeliveryAmount.add(new BigDecimal(sysConfigService.selectConfigByKey(SysConfigKey.OrderClothDeliveryPrice.getCode())));
|
|
|
|
- totalPrice.add(new BigDecimal(sysConfigService.selectConfigByKey(SysConfigKey.OrderClothDeliveryPrice.getCode())));
|
|
|
|
- }
|
|
|
|
|
|
+ totalDeliveryAmount = deliveryAmount;
|
|
}
|
|
}
|
|
// 上门取衣(配送上门)-计算取衣配送费
|
|
// 上门取衣(配送上门)-计算取衣配送费
|
|
if (orderCloth.getSendClothWay() != null && orderCloth.getSendClothWay().equals(TakeOrSendClothWay.DELIVERY.getCode())) {
|
|
if (orderCloth.getSendClothWay() != null && orderCloth.getSendClothWay().equals(TakeOrSendClothWay.DELIVERY.getCode())) {
|
|
- if (freeDeliveryNum > 0) {
|
|
|
|
- freeDeliveryNum--;
|
|
|
|
- } else {
|
|
|
|
- totalDeliveryAmount.add(new BigDecimal(sysConfigService.selectConfigByKey(SysConfigKey.OrderClothDeliveryPrice.getCode())));
|
|
|
|
- totalPrice.add(new BigDecimal(sysConfigService.selectConfigByKey(SysConfigKey.OrderClothDeliveryPrice.getCode())));
|
|
|
|
- }
|
|
|
|
|
|
+ totalDeliveryAmount = CurrencyUtil.add(totalDeliveryAmount, deliveryAmount);
|
|
}
|
|
}
|
|
orderCloth.setDeliveryAmount(totalDeliveryAmount);
|
|
orderCloth.setDeliveryAmount(totalDeliveryAmount);
|
|
- orderCloth.setOrderAmount(totalPrice);
|
|
|
|
- orderCloth.setPayAmount(orderCloth.getOrderAmount());
|
|
|
|
|
|
+ orderCloth.setOrderAmount(CurrencyUtil.add(totalPrice, totalDeliveryAmount));
|
|
|
|
+ orderCloth.setDeliveryDeductAmount(freeAmount.compareTo(totalDeliveryAmount) > 0 ? totalDeliveryAmount : freeAmount);
|
|
|
|
+ orderCloth.setPayAmount(CurrencyUtil.sub(orderCloth.getOrderAmount(), orderCloth.getDeliveryDeductAmount()));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|