Parcourir la source

feat: setSanghuBilling 支持摊位订单抽成逻辑

摊位订单使用夜市的抽成比例,收入入摊位门店钱包

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
qmj il y a 1 jour
Parent
commit
2560baf1f9

+ 21 - 2
ruoyi-admin/src/main/java/com/ruoyi/app/order/PosOrderController.java

@@ -578,7 +578,19 @@ public class PosOrderController extends BaseController {
         if (count <= 0) {
             UserBilling billing = new UserBilling();
             DecimalFormat df = new DecimalFormat("#.00");
-            InfoUser user = infoUserService.getById(posOrder.getShId());
+
+            // 判断是否为摊位订单
+            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());
@@ -628,7 +640,14 @@ public class PosOrderController extends BaseController {
             billing.setMdId(posOrder.getMdId());
             billing.setUserType("1");
             billing.setDivvyRate(fcbili);
-            walletService.addBalance(billing.getUserId(), BigDecimal.valueOf(billing.getAmount()), billing);
+            if (isStall) {
+                // 摊位订单:更新摊位钱包
+                billing.setStoreId(store.getId());
+                walletService.addStallBalance(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) {
 //