Browse Source

Merge branch 'refs/heads/dev-对账管理' into dev-test

codingliang 1 year atrás
parent
commit
2d512ebc09

+ 16 - 11
src/main/java/com/sqx/modules/reconciliation/service/impl/PlatformBillServiceImpl.java

@@ -349,6 +349,9 @@ public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, Pla
         // 计算平台账单数据
         PlatformBill platformBills = calcPlatformBill(date, shopPlatformBills, riderPlatformBills, prePlatformBillDataS);
 
+        // 清除骑手账单中临时存储的商户余额数据
+        riderPlatformBills.forEach(e -> e.setShopBalance(null));
+
         // 合并商户、骑手账单数据
         Collection<PlatformBill> allPlatformBills = CollUtil.union(shopPlatformBills, riderPlatformBills, Arrays.asList(platformBills));
 
@@ -373,17 +376,8 @@ public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, Pla
         // 平台对账
         platformBill.setType("0");
 
-        Optional<PlatformBill> prePlatformBillOptional = prePlatformBills.stream().filter(e -> "0".equals(e.getType())).findFirst();
-
-        // 初始金额
-        if (prePlatformBillOptional.isPresent()) {
-            platformBill.setStartMoney(prePlatformBillOptional.get().getEndMoney());
-        } else {
-            platformBill.setStartMoney(BigDecimal.ZERO);
-        }
-
-        // 订单总收入
-        platformBill.setRevenue(sum(shopPlatformBills, PlatformBill::getRevenue));
+        // 平台总收入等于所有支付金额
+        platformBill.setRevenue(sum(shopPlatformBills, PlatformBill::getPayMoney));
         // 订单总笔数
         platformBill.setRevenueCount(sumInt(shopPlatformBills, PlatformBill::getRevenueCount));
         // 商家总提现金额
@@ -405,6 +399,14 @@ public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, Pla
         // 平台抽成手续费
         platformBill.setPlatformRates(sum(shopPlatformBills, PlatformBill::getPlatformRates));
 
+        // 初始金额等于前一天的期末金额,如果前一天没有平台账单,则初始金额等于所有商家账户余额和所有骑手账户余额
+        Optional<PlatformBill> prePlatformBillOptional = prePlatformBills.stream().filter(e -> "0".equals(e.getType())).findFirst();
+        if (prePlatformBillOptional.isPresent()) {
+            platformBill.setStartMoney(prePlatformBillOptional.get().getEndMoney());
+        } else {
+            platformBill.setStartMoney(sum(shopPlatformBills, PlatformBill::getShopBalance));
+        }
+
         // 期末金额 = 期初金额 + 当天收入 - 商家当天提现手续费 - 商家当天提现金额(已转账和待转账) - 骑手当天提现手续费 - 骑手当天提现金额(已转账+待转账+已拒绝)
         BigDecimal endMoney = platformBill.getStartMoney()
                 .add(platformBill.getRevenue())
@@ -497,6 +499,9 @@ public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, Pla
 
             platformBill.setTotalIncome(platformBill.getRevenue());
 
+            // 临时存储骑手余额
+            platformBill.setShopBalance(riderInfo.getBalance());
+
 
             PlatformBill preBill = platformBillMap.get(riderInfo.getUserId() + "-2");
 

+ 6 - 6
src/main/resources/mapper/reconciliation/PlatformBillMapper.xml

@@ -24,7 +24,7 @@
                 and tu.user_name like concat('%',#{params.riderName},'%')
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
 
     <select id="shopBill" resultType="com.sqx.modules.reconciliation.model.ShopBillVo">
@@ -46,7 +46,7 @@
                 and gs.shop_name like concat('%',#{params.shopName},'%')
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
     <select id="platformBill" resultType="com.sqx.modules.reconciliation.model.PlatformBill">
         select pb.*
@@ -60,7 +60,7 @@
                 and pb.day_id <![CDATA[ <= ]]> #{params.endDate}
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
 
     <select id="excelRiderBillList" resultType="com.sqx.modules.reconciliation.model.RiderBillVo">
@@ -85,7 +85,7 @@
                 and tu.user_name like concat('%',#{params.riderName},'%')
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
 
     <select id="excelShopBillList" resultType="com.sqx.modules.reconciliation.model.ShopBillVo">
@@ -107,7 +107,7 @@
                 and gs.shop_name like concat('%',#{params.shopName},'%')
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
 
     <select id="excelPlatformBillList" resultType="com.sqx.modules.reconciliation.model.PlatformBill">
@@ -122,7 +122,7 @@
                 and pb.day_id <![CDATA[ <= ]]> #{params.endDate}
             </if>
         </where>
-        order by pb.dayId desc
+        order by pb.day_id desc
     </select>
 
     <update id="updatePlatFormStartMoney">