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

feat: 结算记录新增微信提现手续费(0.6%),结算金额扣减该费用

- 结算金额 = 可结算总额(扣平台费后) - 提现手续费(0.6% 向下取整)
- 站点可提现余额同步按扣除手续费后的净额增加
- 前端结算列表新增提现手续费列,站点列改为ID在上名称在下
- 新增 v19 迁移脚本(t_settlement_record.withdrawal_fee)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 өдөр өмнө
parent
commit
3f969cd3d1

+ 4 - 3
admin-web-new/src/views/admin/finance/settlement.vue

@@ -38,6 +38,7 @@ const state = reactive({
       { label: "跨店支出(元)", prop: "totalCrossExpend", width: 140 },
       { label: "平台费基数(元)", prop: "platformFeeBase", width: 150 },
       { label: "平台费(元)", prop: "platformFee", width: 130 },
+      { label: "提现手续费(元)", prop: "withdrawalFee", width: 150 },
       { label: "结算金额(元)", prop: "settlementAmount", width: 150 },
       { label: "期末余额(元)", prop: "closingPendingBalance", width: 150 },
       { label: "状态", prop: "status", width: 100 },
@@ -164,9 +165,9 @@ const formatMoney = (value: number) => {
           <template #default="{ row }">
             <template v-if="col.prop === 'stationId'">
               <div class="station-name-cell">
-                <span class="station-name">{{ row.stationName }}</span>
-                <span class="station-divider"></span>
                 <span class="station-id">{{ row.stationId }}</span>
+                <span class="station-divider"></span>
+                <span class="station-name">{{ row.stationName }}</span>
               </div>
             </template>
             <template v-else-if="col.prop === 'status'">
@@ -174,7 +175,7 @@ const formatMoney = (value: number) => {
                 {{ formatDict('Settlement.status', row.status) }}
               </el-tag>
             </template>
-            <template v-else-if="['openingPendingBalance', 'totalRecharge', 'totalRefund', 'totalCrossIncome', 'totalCrossExpend', 'platformFeeBase', 'platformFee', 'settlementAmount', 'closingPendingBalance'].includes(col.prop)">
+            <template v-else-if="['openingPendingBalance', 'totalRecharge', 'totalRefund', 'totalCrossIncome', 'totalCrossExpend', 'platformFeeBase', 'platformFee', 'withdrawalFee', 'settlementAmount', 'closingPendingBalance'].includes(col.prop)">
               {{ formatMoney(row[col.prop]) }}
             </template>
             <template v-else>

+ 4 - 3
admin-web/src/views/admin/finance/settlement.vue

@@ -116,9 +116,9 @@
           <template #default="{row}">
             <template v-if="field.prop==='stationId'">
               <div class="station-name-cell">
-                <span class="station-name">{{ row.stationName }}</span>
-                <span class="station-divider"></span>
                 <span class="station-id">{{ row.stationId }}</span>
+                <span class="station-divider"></span>
+                <span class="station-name">{{ row.stationName }}</span>
               </div>
             </template>
             <template v-else-if="field.prop==='status'">
@@ -126,7 +126,7 @@
                 {{ getStatusLabel(row.status) }}
               </el-tag>
             </template>
-            <template v-else-if="['openingPendingBalance','totalRecharge','totalRefund','totalCrossIncome','totalCrossExpend','platformFeeBase','platformFee','settlementAmount','closingPendingBalance'].includes(field.prop)">
+            <template v-else-if="['openingPendingBalance','totalRecharge','totalRefund','totalCrossIncome','totalCrossExpend','platformFeeBase','platformFee','withdrawalFee','settlementAmount','closingPendingBalance'].includes(field.prop)">
               {{ u.fmt.fmtMoney(row[field.prop]) }}
             </template>
             <template v-else-if="['createTime','updateTime'].includes(field.prop)">
@@ -181,6 +181,7 @@ const state = reactive({
     {label: '跨店支出(元)', width: 140, prop: 'totalCrossExpend', resizable: true},
     {label: '平台费基数(元)', width: 150, prop: 'platformFeeBase', resizable: true},
     {label: '平台费(元)', width: 130, prop: 'platformFee', resizable: true},
+    {label: '提现手续费(元)', width: 150, prop: 'withdrawalFee', resizable: true},
     {label: '结算金额(元)', width: 150, prop: 'settlementAmount', resizable: true},
     {label: '期末余额(元)', width: 150, prop: 'closingPendingBalance', resizable: true},
     {label: '状态', width: 100, prop: 'status', resizable: true},

+ 5 - 0
car-wash-entity/src/main/java/com/kym/entity/SettlementRecord.java

@@ -73,6 +73,11 @@ public class SettlementRecord extends BaseEntity {
      */
     private Integer platformFee;
 
+    /**
+     * 提现手续费(分),微信提现费率 0.6%
+     */
+    private Integer withdrawalFee;
+
     /**
      * 实际结算金额(分)
      */

+ 1 - 0
car-wash-entity/src/main/java/com/kym/entity/vo/SettlementRecordVo.java

@@ -25,6 +25,7 @@ public class SettlementRecordVo {
     private Integer closingPendingBalance;
     private Integer platformFeeBase;
     private Integer platformFee;
+    private Integer withdrawalFee;
     private Integer settlementAmount;
     private Integer status;
     private String remark;

+ 9 - 0
car-wash-entity/src/main/resources/sql/v19_add_settlement_withdrawal_fee.sql

@@ -0,0 +1,9 @@
+-- ====================================================
+-- V19 — t_settlement_record 新增提现手续费列
+-- 微信提现手续费,费率固定 0.6%(千分之六)
+-- 结算金额 = 可结算总额(扣除平台费后) - 提现手续费
+-- ====================================================
+
+ALTER TABLE `t_settlement_record`
+    ADD COLUMN `withdrawal_fee` INT NOT NULL DEFAULT 0 COMMENT '提现手续费(分),微信提现费率0.6%'
+    AFTER `platform_fee`;

+ 12 - 5
car-wash-service/src/main/java/com/kym/service/impl/SettlementServiceImpl.java

@@ -44,6 +44,7 @@ import java.util.stream.Collectors;
 public class SettlementServiceImpl extends MyBaseServiceImpl<SettlementRecordMapper, SettlementRecord> implements SettlementService {
 
     private static final BigDecimal PLATFORM_FEE_RATE = new BigDecimal("0.1");
+    private static final BigDecimal WITHDRAWAL_FEE_RATE = new BigDecimal("0.006");
     private static final DateTimeFormatter PERIOD_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM");
 
     private final SplitRecordService splitRecordService;
@@ -129,14 +130,19 @@ public class SettlementServiceImpl extends MyBaseServiceImpl<SettlementRecordMap
                 .setPlatformFee(platformFee);
 
         if (available > 0) {
+            // 微信提现手续费 = 可结算金额 × 0.6%,向下取整
+            int withdrawalFee = new BigDecimal(available).multiply(WITHDRAWAL_FEE_RATE).setScale(0, RoundingMode.DOWN).intValue();
+            int finalSettlement = available - withdrawalFee;
+
             // 正常结算
-            record.setSettlementAmount(available)
+            record.setWithdrawalFee(withdrawalFee)
+                    .setSettlementAmount(finalSettlement)
                     .setClosingPendingBalance(0)
                     .setStatus(SettlementRecord.STATUS_待结算);
 
-            // 增加站点可提现金额
+            // 增加站点可提现金额(扣除提现手续费后的净额)
             stationAccountService.lambdaUpdate()
-                    .setSql("available_balance = available_balance + {0}", available)
+                    .setSql("available_balance = available_balance + {0}", finalSettlement)
                     .eq(StationAccount::getStationId, stationId)
                     .update();
 
@@ -148,10 +154,11 @@ public class SettlementServiceImpl extends MyBaseServiceImpl<SettlementRecordMap
                 platformAccountService.addRevenue(platformFee);
             }
 
-            log.info("站点 {} 结算成功,金额:{} 分,平台费:{} 分", stationId, available, platformFee);
+            log.info("站点 {} 结算成功,金额:{} 分,平台费:{} 分,提现手续费:{} 分", stationId, finalSettlement, platformFee, withdrawalFee);
         } else {
             // 异常结算
-            record.setSettlementAmount(0)
+            record.setWithdrawalFee(0)
+                    .setSettlementAmount(0)
                     .setClosingPendingBalance(available)
                     .setStatus(SettlementRecord.STATUS_异常结算)
                     .setRemark("结算金额为负,结转至下期");