Эх сурвалжийг харах

Merge branch 'mp-server-test' into 'master'

Mp server test

See merge request quanshu/mp-server!1007
jiang hao 2 жил өмнө
parent
commit
5870cfbcf1

+ 8 - 5
mp-service/src/main/java/com/qs/mp/user/service/impl/UserTicketOrderServiceImpl.java

@@ -608,11 +608,14 @@ public class UserTicketOrderServiceImpl extends
             // 线下购票,优先给当前票的经销商渠道分润
             // 线下购票,优先给当前票的经销商渠道分润
             TicketBox ticketBox = ticketBoxService.getById(channelCommParam.getBoxId());
             TicketBox ticketBox = ticketBoxService.getById(channelCommParam.getBoxId());
 
 
+            // 推广员的分佣
+            int promoterCommAmt = 0;
             // 如果有推广员则先给推广员分佣
             // 如果有推广员则先给推广员分佣
             if (channelCommParam.getPromoterId() != null && channelCommParam.getPromoterId() > 0) {
             if (channelCommParam.getPromoterId() != null && channelCommParam.getPromoterId() > 0) {
                 Channel promoter = channelService.getById(channelCommParam.getPromoterId());
                 Channel promoter = channelService.getById(channelCommParam.getPromoterId());
                 if (promoter != null) {
                 if (promoter != null) {
-                    ChannelCommission siteCommission = saveSiteCommAmt(channelCommParam, ticketBox, promoter);
+                    ChannelCommission siteCommission = saveSiteCommAmt(channelCommParam, ticketBox, promoter, promoterCommAmt);
+                    promoterCommAmt = siteCommission.getCommAmt();
                     // 推广员账户余额增加
                     // 推广员账户余额增加
                     changeMoney(promoter, siteCommission);
                     changeMoney(promoter, siteCommission);
                 }
                 }
@@ -621,11 +624,11 @@ public class UserTicketOrderServiceImpl extends
             // 给门店分佣
             // 给门店分佣
             Channel channel = channelService.getById(channelCommParam.getChannelId());
             Channel channel = channelService.getById(channelCommParam.getChannelId());
 
 
-            ChannelCommission siteCommission = saveSiteCommAmt(channelCommParam, ticketBox, channel);
+            ChannelCommission siteCommission = saveSiteCommAmt(channelCommParam, ticketBox, channel, promoterCommAmt);
             // 经销商账户余额增加
             // 经销商账户余额增加
             changeMoney(channel, siteCommission);
             changeMoney(channel, siteCommission);
 
 
-            int sumCommAmt = siteCommission.getCommAmt();
+            int sumCommAmt = siteCommission.getCommAmt() + promoterCommAmt;
             // 渠道分润
             // 渠道分润
             while (channel.getParentId() > 0) {
             while (channel.getParentId() > 0) {
                 channel = channelService.getById(channel.getParentId());
                 channel = channelService.getById(channel.getParentId());
@@ -670,7 +673,7 @@ public class UserTicketOrderServiceImpl extends
     }
     }
 
 
     private ChannelCommission saveSiteCommAmt(ChannelCommParam channelCommParam, TicketBox ticketBox,
     private ChannelCommission saveSiteCommAmt(ChannelCommParam channelCommParam, TicketBox ticketBox,
-        Channel channel) {
+        Channel channel, int sumCommAmt) {
         ChannelCommission siteCommission = new ChannelCommission();
         ChannelCommission siteCommission = new ChannelCommission();
         siteCommission.setChannelId(channel.getChannelId());
         siteCommission.setChannelId(channel.getChannelId());
         siteCommission.setOrderId(channelCommParam.getOrderId());
         siteCommission.setOrderId(channelCommParam.getOrderId());
@@ -682,7 +685,7 @@ public class UserTicketOrderServiceImpl extends
             .intValue());
             .intValue());
         siteCommission.setCommRate(channel.getCommRate());
         siteCommission.setCommRate(channel.getCommRate());
         siteCommission.setCommAmt(new BigDecimal(siteCommission.getSaleCommAmt()).multiply(
         siteCommission.setCommAmt(new BigDecimal(siteCommission.getSaleCommAmt()).multiply(
-            siteCommission.getCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN).intValue());
+            siteCommission.getCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN).intValue() - sumCommAmt);
         channelCommissionService.save(siteCommission);
         channelCommissionService.save(siteCommission);
         return siteCommission;
         return siteCommission;
     }
     }