|
@@ -140,6 +140,8 @@ public class PosOrderController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private OrderService orderService;
|
|
|
|
|
+ @Autowired
|
|
|
private PosOrderShOprateController shOprateController;
|
|
private PosOrderShOprateController shOprateController;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OrderLogHelper orderLogHelper;
|
|
private OrderLogHelper orderLogHelper;
|
|
@@ -467,8 +469,8 @@ public class PosOrderController extends BaseController {
|
|
|
|
|
|
|
|
UserBilling billing = userBillingService.getOne(wrapper);
|
|
UserBilling billing = userBillingService.getOne(wrapper);
|
|
|
if (billing == null) {
|
|
if (billing == null) {
|
|
|
- setSanghuBilling(order);
|
|
|
|
|
- setQishouBilling(order);
|
|
|
|
|
|
|
+ orderService.setSanghuBilling(order);
|
|
|
|
|
+ orderService.setQishouBilling(order);
|
|
|
}
|
|
}
|
|
|
return success(MessageUtils.message("no.modify.success"), posOrder.getId());
|
|
return success(MessageUtils.message("no.modify.success"), posOrder.getId());
|
|
|
} else {
|
|
} else {
|
|
@@ -589,153 +591,6 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- //执行商户分成
|
|
|
|
|
- public void setSanghuBilling(@NotNull PosOrder posOrder) {
|
|
|
|
|
- long count = userBillingService.count(new LambdaQueryWrapper<UserBilling>().eq(UserBilling::getUserId, posOrder.getShId()).eq(UserBilling::getType, "0").eq(UserBilling::getDdId, posOrder.getDdId()));
|
|
|
|
|
- if (count <= 0) {
|
|
|
|
|
- UserBilling billing = new UserBilling();
|
|
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否为摊位订单
|
|
|
|
|
- PosStore store = posStoreService.getById(posOrder.getMdId());
|
|
|
|
|
- boolean isStall = store != null && store.getIsStall() != null && store.getIsStall() == 1 && store.getNightMarketId() != null;
|
|
|
|
|
-
|
|
|
|
|
- InfoUser user;
|
|
|
|
|
- if (isStall) {
|
|
|
|
|
- // 摊位订单:使用夜市用户的分成比例
|
|
|
|
|
- user = infoUserService.getById(store.getNightMarketId());
|
|
|
|
|
- } else {
|
|
|
|
|
- // 普通订单:使用商家用户的分成比例
|
|
|
|
|
- user = infoUserService.getById(posOrder.getShId());
|
|
|
|
|
- }
|
|
|
|
|
- Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
|
|
- fcbili = getShCommissionRate(fcbili, user.getUserId());
|
|
|
|
|
- JSONArray list = JSONArray.parseArray(posOrder.getFood());
|
|
|
|
|
- int fenc = 0;
|
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
- JSONObject foods = list.getJSONObject(i);
|
|
|
|
|
- //20250612修改,商品金额等于价格乘以数量;未修改前金额直接为商品价格
|
|
|
|
|
- int price = foods.getInteger("price");
|
|
|
|
|
- int otherPrice = foods.getInteger("otherPrice"); //规格价格
|
|
|
|
|
- int num = foods.getInteger("number");
|
|
|
|
|
- int age = (price + otherPrice) * num; //价格=商品价格+规格价格
|
|
|
|
|
- fenc += age;
|
|
|
|
|
- }
|
|
|
|
|
- String remark = "";
|
|
|
|
|
- //商家分成总金额,减去商家优惠金额,减去商家活动金额(type=1 为平台指定商家优惠券,由平台承担)
|
|
|
|
|
- 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;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- 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 shfc = fenc - chouc;
|
|
|
|
|
- billing.setUserId(posOrder.getShId());
|
|
|
|
|
- billing.setDdId(String.valueOf(posOrder.getDdId()));
|
|
|
|
|
- billing.setType("0");
|
|
|
|
|
- billing.setAmount(Double.valueOf(df.format(shfc)));
|
|
|
|
|
- billing.setDivvy(Double.valueOf(df.format(chouc)));
|
|
|
|
|
- billing.setState("0");
|
|
|
|
|
- billing.setMdId(posOrder.getMdId());
|
|
|
|
|
- billing.setUserType("1");
|
|
|
|
|
- billing.setDivvyRate(fcbili);
|
|
|
|
|
- if (isStall) {
|
|
|
|
|
- // 摊位订单:更新摊位钱包
|
|
|
|
|
- billing.setStoreId(Long.valueOf(store.getId()));
|
|
|
|
|
- walletService.addStallBalance(Long.valueOf(store.getId()), BigDecimal.valueOf(billing.getAmount()), billing);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 普通订单:更新用户钱包
|
|
|
|
|
- walletService.addBalance(billing.getUserId(), BigDecimal.valueOf(billing.getAmount()), billing);
|
|
|
|
|
- }
|
|
|
|
|
-// int reg = userBillingService.insertUserBilling(billing);
|
|
|
|
|
-// if (reg == 1) {
|
|
|
|
|
-//
|
|
|
|
|
-// System.out.println("商户分成成功,订单号:" + posOrder.getDdId() + ",分成金额:" + shfc + ",抽成:" + chouc);
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-// System.out.println("订单:" + posOrder.getDdId() + "分成失败");
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取商家分成比例
|
|
|
|
|
- * 委托给 Service 层处理
|
|
|
|
|
- *
|
|
|
|
|
- * @param rate 默认分成比例
|
|
|
|
|
- * @param shUserId 商家用户ID
|
|
|
|
|
- * @return 分成比例
|
|
|
|
|
- */
|
|
|
|
|
- public Double getShCommissionRate(Double rate, Long shUserId) {
|
|
|
|
|
- return rate;
|
|
|
|
|
- // 委托给 Service 层处理
|
|
|
|
|
-// return commissionRatesService.getShCommissionRate(rate, shUserId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //执行骑手分成
|
|
|
|
|
- public void setQishouBilling(@NotNull PosOrder posOrder) {
|
|
|
|
|
- long count = userBillingService.count(new LambdaQueryWrapper<UserBilling>().eq(UserBilling::getUserId, posOrder.getQsId()).eq(UserBilling::getType, "0").eq(UserBilling::getDdId, posOrder.getDdId()));
|
|
|
|
|
- if (count <= 0) {
|
|
|
|
|
- UserBilling billing = new UserBilling();
|
|
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
|
|
- InfoUser user = infoUserService.getById(posOrder.getQsId());
|
|
|
|
|
- if (user == null) {
|
|
|
|
|
- System.out.println("订单无骑手");
|
|
|
|
|
- } else {
|
|
|
|
|
- Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
|
|
- Double fenc = posOrder.getFreight();
|
|
|
|
|
- Double chouc = fenc * fcbili;
|
|
|
|
|
- Double shfc = fenc - chouc;
|
|
|
|
|
- List<SysDictData> taxBl = DictUtils.getDictCache("sys_qs_freight_bl");
|
|
|
|
|
- if (taxBl != null && taxBl.get(0) != null) {
|
|
|
|
|
- Double tax = shfc * Double.parseDouble(taxBl.get(0).getDictValue());
|
|
|
|
|
- billing.setTax(BigDecimal.valueOf(tax));
|
|
|
|
|
- billing.setTaxRate(taxBl.get(0).getDictValue());
|
|
|
|
|
- shfc = shfc - tax;
|
|
|
|
|
- }
|
|
|
|
|
- billing.setUserId(posOrder.getQsId());
|
|
|
|
|
- billing.setDdId(String.valueOf(posOrder.getDdId()));
|
|
|
|
|
- billing.setType("0");
|
|
|
|
|
- billing.setAmount(Double.valueOf(df.format(shfc)));
|
|
|
|
|
- billing.setDivvy(Double.valueOf(df.format(chouc)));
|
|
|
|
|
- billing.setState("0");
|
|
|
|
|
- billing.setMdId(posOrder.getMdId());
|
|
|
|
|
- billing.setUserType("2");
|
|
|
|
|
- billing.setDivvyRate(user.getCommission());
|
|
|
|
|
- //货到付款设置代收金额
|
|
|
|
|
- if ("1".equals(posOrder.getCollectPayment())) {
|
|
|
|
|
- billing.setBehalfAmount(Double.valueOf(posOrder.getAmount()));
|
|
|
|
|
- }
|
|
|
|
|
- walletService.addBalance(billing.getUserId(), BigDecimal.valueOf(billing.getAmount()), billing);
|
|
|
|
|
-// int reg = userBillingService.insertUserBilling(billing);
|
|
|
|
|
-// if (reg == 1) {
|
|
|
|
|
-// System.out.println("骑手分成成功,订单号:" + posOrder.getDdId() + ",分成金额:" + shfc + ",抽成:" + chouc);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// System.out.println("订单:" + posOrder.getDdId() + "分成失败");
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
//后台查询详情
|
|
//后台查询详情
|
|
|
@GetMapping("/getorderhout")
|
|
@GetMapping("/getorderhout")
|