|
|
@@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
import com.ruoyi.common.utils.DictUtils;
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
+import com.ruoyi.system.mapper.PosOrderPromotionMapper;
|
|
|
import com.ruoyi.system.service.IInfoUserService;
|
|
|
import com.ruoyi.system.service.IPosStoreService;
|
|
|
import com.ruoyi.system.service.IUserBillingService;
|
|
|
@@ -36,6 +37,8 @@ public class OrderService {
|
|
|
private WalletService walletService;
|
|
|
@Autowired
|
|
|
private IVipUserQuanyiService userQuanyiService;
|
|
|
+ @Autowired
|
|
|
+ private PosOrderPromotionMapper posOrderPromotionMapper;
|
|
|
|
|
|
/**
|
|
|
* 执行商户分成
|
|
|
@@ -60,39 +63,27 @@ public class OrderService {
|
|
|
user = infoUserService.getById(posOrder.getShId());
|
|
|
}
|
|
|
Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
- JSONArray list = JSONArray.parseArray(posOrder.getFood());
|
|
|
- int fenc = 0;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- JSONObject foods = list.getJSONObject(i);
|
|
|
- int price = foods.getInteger("price");
|
|
|
- int otherPrice = foods.getInteger("otherPrice");
|
|
|
- int num = foods.getInteger("number");
|
|
|
- int age = (price + otherPrice) * num;
|
|
|
- fenc += age;
|
|
|
- }
|
|
|
- String remark = "";
|
|
|
- if (posOrder.getMdYhId() != null && posOrder.getMdDiscountAmount() != null) {
|
|
|
- VipUserQuanyi userQuanyi = userQuanyiService.getById(posOrder.getMdYhId());
|
|
|
- if (userQuanyi != null && "1".equals(userQuanyi.getType())) {
|
|
|
- fenc = fenc - posOrder.getMdDiscountAmount();
|
|
|
- String yhmcMessage = MessageUtils.message("no.posorder.md.yh.mc.messag");
|
|
|
- yhmcMessage = StrUtil.format(yhmcMessage, posOrder.getMdYhName());
|
|
|
- remark += yhmcMessage;
|
|
|
- String yhAmount = MessageUtils.message("no.posorder.md.yh.jiner.messag");
|
|
|
- yhAmount = StrUtil.format(yhAmount, posOrder.getMdDiscountAmount());
|
|
|
- remark += yhAmount;
|
|
|
+ // 分成基数 = 商品总金额(元) - 优惠促销减免(元)
|
|
|
+ // 优惠促销统一从 pos_order_promotion 明细表取(算价快照,单位元),
|
|
|
+ // 不再用 pos_order 摘要字段(单位为分,且 mdYhId 已指向 promotion_user_coupon)
|
|
|
+ Double fenc = posOrder.getFoodAmount() != null ? posOrder.getFoodAmount().doubleValue() : 0.00;
|
|
|
+ StringBuilder remark = new StringBuilder();
|
|
|
+ List<PosOrderPromotion> promotions = posOrderPromotionMapper.selectByOrderId(posOrder.getId());
|
|
|
+ if (promotions != null) {
|
|
|
+ for (PosOrderPromotion promo : promotions) {
|
|
|
+ BigDecimal reduce = promo.getReduceAmount();
|
|
|
+ if (reduce == null || reduce.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ fenc -= reduce.doubleValue();
|
|
|
+ boolean isCoupon = promo.getPromoType() != null && promo.getPromoType() == 2;
|
|
|
+ String nameLabel = MessageUtils.message(isCoupon ? "no.posorder.md.yh.mc.messag" : "no.posorder.md.cx.mc.messag");
|
|
|
+ String amountLabel = MessageUtils.message(isCoupon ? "no.posorder.md.yh.jiner.messag" : "no.posorder.md.cx.jiner.messag");
|
|
|
+ remark.append(StrUtil.format(nameLabel, promo.getPromoName()))
|
|
|
+ .append(StrUtil.format(amountLabel, df.format(reduce)));
|
|
|
}
|
|
|
}
|
|
|
- if (posOrder.getMdSalesName() != null && posOrder.getMdSalesReduction() != null) {
|
|
|
- fenc = fenc - posOrder.getMdSalesReduction();
|
|
|
- String cxNameMessage = MessageUtils.message("no.posorder.md.cx.mc.messag");
|
|
|
- cxNameMessage = StrUtil.format(cxNameMessage, posOrder.getMdSalesName());
|
|
|
- remark += cxNameMessage;
|
|
|
- String cxAmount = MessageUtils.message("no.posorder.md.cx.jiner.messag");
|
|
|
- cxAmount = StrUtil.format(cxAmount, posOrder.getMdSalesReduction());
|
|
|
- remark += cxAmount;
|
|
|
- }
|
|
|
- billing.setIllustrate(remark);
|
|
|
+ billing.setIllustrate(remark.toString());
|
|
|
Double chouc = fenc * fcbili;
|
|
|
Double shfc = fenc - chouc;
|
|
|
billing.setUserId(posOrder.getShId());
|
|
|
@@ -112,7 +103,6 @@ public class OrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 执行骑手分成
|
|
|
*/
|