Browse Source

fix:退费

liushengqiang 2 years ago
parent
commit
fa32b4bda6

+ 52 - 32
src/views/collection-record-detail/index.tsx

@@ -33,6 +33,8 @@ export default defineComponent({
   setup() {
     const route = useRoute();
     const router = useRouter();
+    // 判断是否是退款详情
+    const isRefund = route.query.userRefundOrderId ? true : false;
     const state = reactive({
       refundAudit: '' as any, // 退回审核状态
       refundOrderId: '', // 退回订单id
@@ -45,30 +47,34 @@ export default defineComponent({
       timerCount: 0 // 执行次数
     });
     const getDetails = async () => {
+      let res = null as any;
       try {
-        if (!route.query.orderNo) return;
-        const res = await api_userPaymentOrderRefundDetail(route.query.orderNo);
-        if (res?.code !== 200) return;
-        state.orders = res.data.order || {};
-        const tempGoods = res.data.order.goodsInfos || [];
-        tempGoods.forEach((item: any) => {
-          const img = item.goodsUrl ? item.goodsUrl.split(',')[0] : '';
-          item.goodsUrl = img;
-        });
-        state.goodsInfos = tempGoods;
-        if (Array.isArray(res.data?.refund)) {
-          const refunds = res.data.refund;
-          const index = refunds.length - 1;
-          state.refundAudit = refunds[index]?.refundAudit || '';
-          state.refundOrderId = refunds[index]?.id || '';
-          if (state.refundAudit === 'ING') {
-            state.orders.status = 'REFUNDING';
-          } else if (state.refundAudit === 'PASS') {
-            state.orders.status = 'REFUNDED';
-          }
+        // 退款详情
+        if (isRefund) {
+          res = await api_userPaymentOrderRefundDetail(
+            route.query.userRefundOrderId
+          );
+        } else {
+          // 订单详情
+          res = await api_userPaymentOrderDetail(route.query.orderNo);
         }
-      } catch {
-        //
+      } catch {}
+      if (res?.code !== 200) return;
+      state.orders = res.data || {};
+      const tempGoods =
+        (isRefund ? res.data.studentRefundOrderDetails : res.data.goodsInfos) || [];
+      tempGoods.forEach((item: any) => {
+        const img = item.goodsUrl ? item.goodsUrl.split(',')[0] : '';
+        item.goodsUrl = img;
+        item.brandName = item.brandName
+          ? item.brandName
+          : goodsType[item.goodsType];
+      });
+      state.goodsInfos = tempGoods;
+      if (isRefund) {
+        state.refundAudit = res.data.refundAudit || '';
+        state.refundOrderId = res.data.userRefundOrderId || '';
+        state.orders.status = state.refundAudit;
       }
     };
 
@@ -97,8 +103,9 @@ export default defineComponent({
         TIMEOUT: iconClose,
         FAIL: iconClose,
         CLOSED: iconClose,
-        REFUNDING: iconRefunding,
-        REFUNDED: icon_success
+        ING: iconRefunding,
+        PASS: icon_success,
+        REJECT: iconClose
       };
       return template[type] || icon_success;
     };
@@ -111,11 +118,17 @@ export default defineComponent({
         TIMEOUT: '订单超时',
         FAIL: '领取失败',
         CLOSED: '已关闭',
-        REFUNDING: '退回申请中',
-        REFUNDED: '已退回'
+        ING: '退回申请中',
+        PASS: '已退回',
+        REJECT: '退回失败'
       };
       return temp[status];
     };
+    const goodsType: any = {
+      VIP: '数字化乐器学练工具',
+      INSTRUMENTS: '乐器购买',
+      TEXTBOOK: '教材'
+    };
 
     onMounted(async () => {
       await getDetails();
@@ -143,7 +156,10 @@ export default defineComponent({
     return () => (
       <div class={styles.paymentResult}>
         <div class={[styles.paymentTitle]}>
-          <MHeader background="transparent" />
+          <MHeader
+            title={isRefund ? '申请退回' : '领取详情'}
+            background="transparent"
+          />
 
           {state.orders.id && (
             <>
@@ -158,11 +174,11 @@ export default defineComponent({
                     <div class={styles.orderPrice}>
                       实付金额:¥ {moneyFormat(state.orders.paymentCashAmount)}
                     </div>
-                  ) : (
-                    ''
-                  )}
+                  ) : null}
 
-                  {['REFUNDING', 'REFUNDED'].includes(state.orders.status) && (
+                  {['ING', 'PASS', 'REJECT', 'CLOSED'].includes(
+                    state.orders.status
+                  ) && (
                     <div class={styles.orderPrice}>
                       退回金额:¥ {moneyFormat(state.orders.paymentCashAmount)}
                     </div>
@@ -177,7 +193,11 @@ export default defineComponent({
           <Cell>
             {{
               title: () => '付款时间',
-              value: () => <span>{state.orders.payTime || '--'}</span>
+              value: () => (
+                <span>
+                  {state.orders.payTime || state.orders.refundTime || '--'}
+                </span>
+              )
             }}
           </Cell>
           <Cell>

+ 2 - 1
src/views/collection-record/component/item.tsx

@@ -54,7 +54,8 @@ export default defineComponent({
               location.origin +
               location.pathname +
               '#/collection-record-detail?orderNo=' +
-              props.item?.orderNo,
+              props.item?.orderNo + 
+              '&userRefundOrderId=' + props.item?.userRefundOrderId,
             orientation: 1,
             isHideTitle: false
           }

+ 2 - 0
src/views/collection-record/component/list.tsx

@@ -85,6 +85,7 @@ export default defineComponent({
         if (res?.code === 200 && Array.isArray(res?.data?.rows)) {
           data.list = res.data.rows.map((item: any) => {
             return {
+              orderNo: item.orderNo,
               orderType: item.orderType,
               paymentCashAmount: item.paymentCashAmount,
               createTime: item.refundTime,
@@ -108,6 +109,7 @@ export default defineComponent({
         if (res?.code === 200 && Array.isArray(res?.data?.rows)) {
           data.list = res.data.rows.map((item: any) => {
             return {
+              orderNo: item.orderNo,
               refundable: item.refundable,
               status: item.status,
               orderType: item.orderType,