zhaojs
2023-09-15 39e2103e28830337c3be4dbd3dc7ad0a829ee78b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<template>
  <page-header-wrapper
    :breadcrumb="false"
  >
    <a-card :bordered="false">
      <div class="table-page-search-wrapper" style="background-color: #fff;">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="退款单号">
                <a-input v-model="queryParam.tid" placeholder="请输入有赞退款号查询"/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item>
                <a-button type="primary" @click="onSearch">查询</a-button>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
 
      <a-table
        rowKey="id"
        ref="table"
        size="default"
        :pagination="pagination"
        :columns="columns"
        :data-source="data"
        :scroll="{ x: 2200 }"
        :loading="loading"
      >
        <template slot="tradedetail" slot-scope="text, record">
          <a @click="getRefundDetail(record)">{{ record.refundId }}</a>
        </template>
        <template slot="alitradestatus" slot-scope="text, record">
          {{ getAliStatus(record) }}
        </template>
        <template slot="refundstatus" slot-scope="text, record">
          {{ getRefundStatus(record) }}
        </template>
        <template slot="action" slot-scope="text, record">
          <a @click="applyForAli(record)">1688申请退款</a>
        </template>
      </a-table>
    </a-card>
 
    <!--  <RefuseRemardForm
      ref="refuseModal"
      :visible="refusevisible"
      :model="refuseRecord"
 
      @cancel="refuseCancel"
      @ok="refuse"
    /> -->
 
    <ReturnGoodsSet
      ref="returnsetModal"
      :visible="returngoodssetvisible"
      :model="returnGoodsSet"
      @cancel="returngoodsCancel"
      @ok="returngoods"
    />
 
  </page-header-wrapper>
</template>
 
  <script>
  import { ref } from 'vue'
 
  import { GetRefundList, JudgeAliTrade, AliApplyFor, GetRefundDetailUrl, GetRefundDetail } from '@/api/refundapi'
  import RefuseRemardForm from './modules/RefuseRemardForm'
  import ReturnGoodsSet from './modules/ReturnGoodsSet'
  const columns = [
  {
    title: '有赞退款单',
    dataIndex: 'refundId',
    fixed: 'left',
    scopedSlots: { customRender: 'tradedetail' }
  },
  {
    title: '退款类型',
    width: '100px',
    dataIndex: 'refundType',
    ellipsis: true,
    customRender: (text) => text == 'REFUND_ONLY' ? '仅退款' : '退货退款'
  },
  {
    title: '1688订单',
    dataIndex: 'aliTid',
    customRender: (text) => text == null ? '未创建1688订单' : text
  },
  {
    title: '有赞子订单',
    dataIndex: 'yzOid'
  },
  {
    title: '有赞主订单',
    dataIndex: 'yzTid'
  },
  {
    title: '退款金额',
    dataIndex: 'refundedFee'
  },
  {
    title: '有赞退款状态',
    dataIndex: 'yzRefundStaus',
    ellipsis: true,
    scopedSlots: { customRender: 'refundstatus' }
  },
  {
    title: '退款原因',
    dataIndex: 'refundReasonDesc'
  },
  {
    title: '1688订单状态',
    dataIndex: 'aliTradeStatus',
    ellipsis: true,
    scopedSlots: { customRender: 'alitradestatus' }
  },
 
  {
    title: '备注',
    dataIndex: 'memo'
  },
  {
    title: '操作',
    dataIndex: 'action',
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
  export default {
    name: 'Waiteapplyfor',
    components: {
      RefuseRemardForm,
      ReturnGoodsSet
  },
    data () {
      return {
        queryParam: {},
        columns,
        refuseRecord: {},
        loading: false,
        returnGoodsSet: {},
        refusevisible: false,
        returngoodssetvisible: false,
        data: [],
        pagination: {
          current: 1,
          pageSize: 10,
          total: 0,
          pageSizeOptions: ['10', '20'],
          onChange: this.onPageChange,
         onShowSizeChange: this.onPageChange
        }
      }
    },
    setup () {
 
    },
    created () {
      this.onSearch()
    },
    methods: {
 
      onPageChange (current, size) {
              this.pagination.current = current
              this.pagination.pageSize = size
              this.onSearch()
        },
      onSearch () {
        this.loading = true
        var parameter = {
          PageNo: this.pagination.current,
          PageSize: this.pagination.pageSize,
          YzRefundStatus: 'REFUND_WAIT_SELLER_AGREE',
          RelationType: 0
        }
        GetRefundList(parameter).then(res => {
         this.data = res.result.data
          this.pagination.total = res.result.totalCount
        }).finally(() => {
            this.loading = false
         })
      },
      // 1688申请退款
      applyForAli (record) {
        this.loading = true
        // 判断1688订单状态
        const judgePar = {
          RefundId: record.refundId
        }
        JudgeAliTrade(judgePar).then(res => {
          if (res.result.isAliTrade && res.result.isAliTradePay)//
          { // 已经创建订单且已付款
            const getParam = {
              RefundId: record.refundId
            }
            GetRefundDetail(getParam).then(res => {
                this.returnGoodsSet = res.result
                  this.returngoodssetvisible = true
            })
          } else {
                const parameter = {
                    refundId: record.refundId
                }
                AliApplyFor(parameter).then(res => {
                    this.$message.success(`操作成功!`)
                    this.pagination.current = 1
                    this.onSearch()
                }).finally(() => {
                    this.loading = false
                })
          }
        })
      },
      // 获取1688订单状态
      getAliStatus (record) {
        switch (record.aliTradeStatus) {
          case 'waitbuyerpay':
            return '等待买家付款'
          case 'waitsellersend':
            return '等待卖家发货'
          case 'waitbuyerreceive':
            return '等待买家收货'
            case 'confirm_goods':
            return '已收货'
            case 'success':
            return '交易成功'
            case 'cancel':
            return '交易取消'
            case 'terminated':
            return '交易终止'
        default:
            return '未知状态'
        }
      },
      // 获取退款状态
      getRefundStatus (record) {
        switch (record.yzRefundStaus) {
          case 'REFUND_WAIT_SELLER_AGREE':
            return '买家已经申请退款,等待卖家同意'
          case 'REFUND_SELLER_REFUSE_BUYER':
            return '卖家拒绝退款'
          case 'REFUND_WAIT_BUYER_RETURN_GOODS':
            return '卖家已经同意退货,等待买家退货'
            case 'REFUND_WAIT_SELLER_CONFIRM_GOODS':
            return '买家已经退货,等待卖家确认收货'
            case 'REFUND_SELLER_REFUSE_RETURN_GOODS':
            return '卖家未收到货,拒绝退款'
            case 'REFUND_CLOSED':
            return '退款关闭'
            case 'REFUND_SUCCESS':
            return '退款成功'
        }
      },
      // 跳转退款详情
      getRefundDetail (record) {
        const parameter = {
          RefundId: record.refundId,
          TradeId: record.yzTid
        }
        GetRefundDetailUrl(parameter).then(res => {
          window.open(res.result, '_blank')
        })
      },
      // 1688退货退款
      returngoodsCancel () {
        this.returnGoodsSet = {}
        this.returngoodssetvisible = false
        this.loading = false
      },
      returngoods () {
        const form = this.$refs.returnsetModal.form
          const data = this.$refs.returnsetModal.model
          form.validateFields((errors, values) => {
            if (!errors) {
              const applyPar = {
              refundId: this.returnGoodsSet.refundId,
              disputeRequest: values.disputeRequest,
              applyPayment: values.applyPayment,
              applyCarriage: values.applyCarriage,
              applyReasonId: values.applyReasonIds,
              description: values.description,
              goodsStatus: values.goodsStatus
            }
            AliApplyFor(applyPar).then(res => {
              if (res.result) {
                this.$message.success(`操作成功!`)
                this.pagination.current = 1
                this.onSearch()
              }
            }).finally(() => {
              this.loading = false
            })
            }
          }
          )
      }
    }
  }
  </script>