Forráskód Böngészése

feat(hdApp): 支持充值记录退款操作

- 在充值记录页按财务权限展示退款入口,并标记已退款流水

- 细化线上/线下支付渠道筛选,统计页默认查看今日并跳转复用筛选条件
shizhongqi 3 hete
szülő
commit
9d673d697c

+ 118 - 16
hdApp/src/admin/custom/rechargeChange.vue

@@ -45,7 +45,6 @@
                         <view class="table-cell cell-staff">操作人</view>
                         <view class="table-cell cell-status">客户姓名</view>
                         <view class="table-cell cell-amount">金额</view>
-                        <view class="table-cell cell-give">赠送</view>
                     </view>
                     <view v-for="(item, index) in list.data" :key="index" class="table-body">
                         <view class="table-row table-row-data">
@@ -53,11 +52,19 @@
                             <view class="table-cell cell-scene">
                                 <view>{{ getChannelLine(item, 0) }}</view>
                                 <view v-if="getChannelLine(item, 1)">{{ getChannelLine(item, 1) }}</view>
+                                <view v-if="isRefunded(item)" class="refund-tag">已退款</view>
                             </view>
                             <view class="table-cell cell-staff">{{ item.staffName }}</view>
                             <view class="table-cell cell-status">{{ item.customName }}</view>
-                            <view class="table-cell cell-amount">{{ item.amount }}</view>
-                            <view class="table-cell cell-give">{{ item.giveAmount>0 ? parseFloat(item.giveAmount) : '-' }}</view>
+                            <view class="table-cell cell-amount">
+                                <view class="amount-line">{{ item.amount }}{{ getGiveAmountText(item) }}</view>
+                                <view
+                                    v-if="canRefund(item)"
+                                    class="refund-btn"
+                                    :class="{ disabled: refundingId == item.id }"
+                                    @click.stop="confirmRefund(item)"
+                                >退款</view>
+                            </view>
                         </view>
                         <view class="table-row table-row-extra" v-if="!$util.isEmpty(item.remark)">
                             <view class="table-cell cell-extra">
@@ -113,8 +120,9 @@
     </template>
     <script>
     import AppWrapperEmpty from "@/components/app-wrapper-empty";
-    import { rechargeList } from '@/api/recharge'
+    import { rechargeList, refundRecharge } from '@/api/recharge'
     import { getList } from "@/api/member";
+    import { getStaffInfo } from '@/api/shop-admin'
     import list from '@/mixins/list'
     import AppSearchModule from "@/components/module/app-search";
     import DateSelect from "@/components/module/dateSelect";
@@ -152,7 +160,8 @@
                 channelKey: 'all',
                 channelOptions: [
                     { label: '全部', value: 'all' },
-                    { label: '系统', value: 'system' },
+                    { label: '线上微信', value: 'online_0' },
+                    { label: '线上支付宝', value: 'online_1' },
                     { label: '线下微信', value: 'pay_0' },
                     { label: '线下支付宝', value: 'pay_1' },
                     { label: '现金', value: 'pay_4' },
@@ -163,7 +172,9 @@
                     { label: '全部金额', value: '' },
                     { label: '充值金额', value: '1' },
                     { label: '减少金额', value: '0' }
-                ]
+                ],
+                hasFinance: 0,
+                refundingId: 0
             };
         },
         onLoad(option) {
@@ -175,6 +186,13 @@
         },
         methods: {
             iconSrc,
+            loadFinancePermission() {
+                getStaffInfo().then(res => {
+                    if (res.code == 1 && res.data && res.data.staff) {
+                        this.hasFinance = res.data.staff.finance ? 1 : 0;
+                    }
+                });
+            },
             decodeQueryText(text) {
                 try {
                     return decodeURIComponent(text || '');
@@ -241,6 +259,7 @@
             },
             async init(){
                 this.hydrateQueryFilters();
+                this.loadFinancePermission();
                 const res = await rechargeList({
                     page: this.list.page,
                     customId: this.customId,
@@ -256,7 +275,8 @@
                 }
                 let currentList = res.data.list
                 currentList.forEach(function(item,index,array){
-                    array[index].amount = parseFloat(item.settleAmount) > 0 ? '-'+parseFloat(item.amount) : '+'+parseFloat(item.amount)
+                    const prefix = Number(item.isRefund) === 1 ? '-' : '+';
+                    array[index].amount = prefix + parseFloat(item.amount)
                 });
                 res.data.list = currentList
                 this.completes(res)
@@ -266,10 +286,60 @@
             },
             getChannelLine(item, line) {
                 if (item.onlinePay == 2) {
-                    return line === 0 ? '系统' : '';
+                    return line === 0 ? '线上' : this.getPayWayName(item.payWay);
                 }
                 return line === 0 ? '线下' : this.getPayWayName(item.payWay);
             },
+            isRefunded(item) {
+                return Number(item && item.isRefund) === 1;
+            },
+            canRefund(item) {
+                return this.hasFinance == 1
+                    && item
+                    && Number(item.payStatus) === 1
+                    && !this.isRefunded(item)
+                    && Number(item.amount) > 0;
+            },
+            // 格式化金额列的赠送补充文案,只有存在正向赠送金额时才跟随主金额展示。
+            getGiveAmountText(item) {
+                const giveAmount = Number(item && item.giveAmount);
+                if (!giveAmount || giveAmount <= 0) {
+                    return '';
+                }
+                return '(赠送' + parseFloat(item.giveAmount) + ')';
+            },
+            confirmRefund(item) {
+                const amount = Math.abs(parseFloat(item.amount)) || 0;
+                let content = '确认对该笔充值退款 ¥' + amount + ' ?';
+                if (Number(item.onlinePay) === 2) {
+                    content = '此单为线上付款,提交后钱会原路退回给客户,确认退款 ¥' + amount + ' ?';
+                }
+                uni.showModal({
+                    title: '确认退款',
+                    content,
+                    success: (res) => {
+                        if (res.confirm) {
+                            this.submitRefund(item);
+                        }
+                    }
+                });
+            },
+            submitRefund(item) {
+                if (this.refundingId) {
+                    return;
+                }
+                this.refundingId = item.id;
+                refundRecharge({ id: item.id }).then(res => {
+                    if (res.code == 1) {
+                        this.$msg('退款成功');
+                        this.resetList();
+                        this.init();
+                    }
+                    this.refundingId = 0;
+                }).catch(() => {
+                    this.refundingId = 0;
+                });
+            },
             openFilterPanel() {
                 this.showFilterPanel = true;
             },
@@ -577,17 +647,49 @@
             }
             &.cell-amount {
                 text-align: right;
-                min-width: 100upx;
-                flex: 1;
-            }
-            &.cell-give {
-                text-align: right;
-                min-width: 80upx;
-                padding-right: 32upx;
-                flex: 1;
+                min-width: 152upx;
+                padding-right: 18upx;
+                flex: 1.45;
             }
         }
     }
+    .refund-tag {
+        display: inline-flex;
+        align-items: center;
+        justify-content: center;
+        min-width: 64upx;
+        height: 30upx;
+        margin-top: 6upx;
+        padding: 0 8upx;
+        border-radius: 6upx;
+        background: #fff1f0;
+        color: #e5484d;
+        font-size: 20upx;
+        line-height: 30upx;
+        box-sizing: border-box;
+    }
+    .amount-line {
+        line-height: 34upx;
+        word-break: break-all;
+    }
+    .refund-btn {
+        display: inline-flex;
+        align-items: center;
+        justify-content: center;
+        min-width: 70upx;
+        height: 44upx;
+        margin-top: 8upx;
+        padding: 0 12upx;
+        border-radius: 8upx;
+        background: #e5484d;
+        color: #fff;
+        font-size: 24upx;
+        line-height: 44upx;
+        box-sizing: border-box;
+        &.disabled {
+            opacity: 0.55;
+        }
+    }
     .filter-overlay {
         position: fixed;
         top: 0;

+ 11 - 5
hdApp/src/admin/stat/rechargeStat.vue

@@ -99,7 +99,7 @@ export default {
   data() {
     return {
       params: {
-        searchTime: "",
+        searchTime: "today",
         startTime: "",
         endTime: ""
       },
@@ -231,13 +231,19 @@ export default {
         return rawKey;
       }
       const name = item.name || item.channelName || "";
-      if (name.indexOf("系统") > -1 || name.indexOf("线上") > -1) {
-        return "system";
+      if (name.indexOf("线上微信") > -1) {
+        return "online_0";
       }
-      if (name.indexOf("微信") > -1) {
+      if (name.indexOf("线上支付宝") > -1) {
+        return "online_1";
+      }
+      if (name.indexOf("系统") > -1) {
+        return "online_0";
+      }
+      if (name.indexOf("线下微信") > -1 || name.indexOf("微信") > -1) {
         return "pay_0";
       }
-      if (name.indexOf("支付宝") > -1) {
+      if (name.indexOf("线下支付宝") > -1 || name.indexOf("支付宝") > -1) {
         return "pay_1";
       }
       if (name.indexOf("现金") > -1) {

+ 5 - 0
hdApp/src/api/recharge/index.js

@@ -25,6 +25,11 @@ export const rechargeStat = data => {
 	return https.get('/recharge/stat', data)
 }
 
+//充值记录退款
+export const refundRecharge = data => {
+	return https.post('/recharge/refund', data)
+}
+
 // 活动页
 export const rechargeRenew = data => {
 	return https.get('/recharge/renew', data)