|
@@ -1,19 +1,17 @@
|
|
|
package com.ruoyi.app.order;
|
|
package com.ruoyi.app.order;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ruoyi.app.service.WalletService;
|
|
import com.ruoyi.app.service.WalletService;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
import com.ruoyi.common.utils.DictUtils;
|
|
import com.ruoyi.common.utils.DictUtils;
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.system.domain.*;
|
|
import com.ruoyi.system.domain.*;
|
|
|
import com.ruoyi.system.mapper.PosOrderPromotionMapper;
|
|
import com.ruoyi.system.mapper.PosOrderPromotionMapper;
|
|
|
import com.ruoyi.system.service.IInfoUserService;
|
|
import com.ruoyi.system.service.IInfoUserService;
|
|
|
import com.ruoyi.system.service.IPosStoreService;
|
|
import com.ruoyi.system.service.IPosStoreService;
|
|
|
import com.ruoyi.system.service.IUserBillingService;
|
|
import com.ruoyi.system.service.IUserBillingService;
|
|
|
-import com.ruoyi.system.service.IVipUserQuanyiService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -37,8 +35,6 @@ public class OrderService {
|
|
|
private WalletService walletService;
|
|
private WalletService walletService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IVipUserQuanyiService userQuanyiService;
|
|
private IVipUserQuanyiService userQuanyiService;
|
|
|
- @Autowired
|
|
|
|
|
- private PosOrderPromotionMapper posOrderPromotionMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 执行商户分成
|
|
* 执行商户分成
|
|
@@ -63,27 +59,39 @@ public class OrderService {
|
|
|
user = infoUserService.getById(posOrder.getShId());
|
|
user = infoUserService.getById(posOrder.getShId());
|
|
|
}
|
|
}
|
|
|
Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
- // 分成基数 = 商品总金额(元) - 优惠促销减免(元)
|
|
|
|
|
- // 优惠促销统一从 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)));
|
|
|
|
|
|
|
+ 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;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- billing.setIllustrate(remark.toString());
|
|
|
|
|
|
|
+ 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);
|
|
|
Double chouc = fenc * fcbili;
|
|
Double chouc = fenc * fcbili;
|
|
|
Double shfc = fenc - chouc;
|
|
Double shfc = fenc - chouc;
|
|
|
billing.setUserId(posOrder.getShId());
|
|
billing.setUserId(posOrder.getShId());
|
|
@@ -103,6 +111,7 @@ public class OrderService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 执行骑手分成
|
|
* 执行骑手分成
|
|
|
*/
|
|
*/
|