Commit bdb93459 authored by daniel's avatar daniel

Merge branch 'feature/refund-unbound-gps' into master

parents 65b9de14 034ae045
...@@ -147,6 +147,9 @@ ...@@ -147,6 +147,9 @@
<n-button type="error" @click="refundAll"> <n-button type="error" @click="refundAll">
一键退款 一键退款
</n-button> </n-button>
<n-button type="warning" @click="refundUnbound">
一键退款未绑定
</n-button>
<n-button type="success" @click="exportOrder"> <n-button type="success" @click="exportOrder">
一键导出 一键导出
</n-button> </n-button>
...@@ -283,6 +286,39 @@ ...@@ -283,6 +286,39 @@
</div> </div>
</template> </template>
</n-modal> </n-modal>
<n-modal :mask-closable="false" style="width: 700px"
title="一键退款未绑定" preset="card" draggable
v-model:show="showUnboundRefundModal">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px">
<n-alert type="warning" :bordered="false" style="flex: 1">
该操作会将所有已支付但未绑定设备的选手进行全额退款
</n-alert>
<n-button size="small" style="margin-left: 12px" @click="exportUnboundList">
导出名单
</n-button>
</div>
<n-data-table
v-model:checked-row-keys="unboundCheckedKeys"
:columns="unboundColumns"
:data="unboundList"
:loading="unboundLoading"
:row-key="row => row.applyId"
:max-height="400"
/>
<template #footer>
<div class="flex gap-x-2 flex-row items-center">
<n-button class="flex-1" @click="showUnboundRefundModal = false">
取消
</n-button>
<n-button class="flex-1" type="error"
:loading="unboundLoading"
:disabled="!unboundCheckedKeys.length"
@click="submitUnboundRefund">
确认退款 ({{unboundCheckedKeys.length}}人)
</n-button>
</div>
</template>
</n-modal>
</n-space> </n-space>
</script> </script>
<script> <script>
...@@ -331,8 +367,8 @@ ...@@ -331,8 +367,8 @@
const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText } = naive const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText } = naive
// 添加全局 loading 指令 // 添加全局 loading 指令
const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=' + 'gk/invoice' + '&cmptId=' + getCId() const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=' + 'gk/invoice' + '&cmptId=' + getCId()
const BASE_ECC_URL = "https://ecc.geexek.com" // const BASE_ECC_URL = "https://ecc.geexek.com"
// const BASE_ECC_URL = "http://localhost:8081" const BASE_ECC_URL = "http://localhost:8082"
// 随机分配名单 // 随机分配名单
const RANDOM_ASSIGN_URL = BASE_ECC_URL + '/api-pick/v1/pick-up-batch?cmptId=' + getCId() const RANDOM_ASSIGN_URL = BASE_ECC_URL + '/api-pick/v1/pick-up-batch?cmptId=' + getCId()
...@@ -350,6 +386,8 @@ ...@@ -350,6 +386,8 @@
const ORDER_BATCH_REFUND_URL = BASE_ECC_URL + "/api-refund/v1/batch-refund" const ORDER_BATCH_REFUND_URL = BASE_ECC_URL + "/api-refund/v1/batch-refund"
// 一键退款 // 一键退款
const ORDER_REFUND_ALL_URL = BASE_ECC_URL + "/api-refund/v1/refund-all" const ORDER_REFUND_ALL_URL = BASE_ECC_URL + "/api-refund/v1/refund-all"
const QUERY_UNBOUND_PAID_URL = BASE_ECC_URL + "/api-refund/v1/query-unbound-paid-list"
// 编辑订单 // 编辑订单
const EDIT_ORDER_URL = BASE_ECC_URL + "/api-order/v1/edit" const EDIT_ORDER_URL = BASE_ECC_URL + "/api-order/v1/edit"
// 导出名单 // 导出名单
...@@ -660,6 +698,20 @@ ...@@ -660,6 +698,20 @@
const showEditModal = ref(false) const showEditModal = ref(false)
// 退款订单的modal // 退款订单的modal
const showRefundModal = ref(false) const showRefundModal = ref(false)
// 退款未绑定相关
const showUnboundRefundModal = ref(false)
const unboundList = ref([])
const unboundCheckedKeys = ref([])
const unboundLoading = ref(false)
const unboundColumns = [
{ type: 'selection' },
{ title: '序号', key: 'index', width: 70, render: (row, index) => index + 1 },
{ title: '参赛号', key: 'markNo', width: 100 },
{ title: '姓名', key: 'name', width: 100 },
{ title: '手机号', key: 'phone', width: 130 },
{ title: '支付金额', key: 'amount', width: 100 },
{ title: '支付时间', key: 'payEndTime', width: 170 },
]
// 订单列表 // 订单列表
const orders = ref([]) const orders = ref([])
// 反馈表单 // 反馈表单
...@@ -1141,6 +1193,79 @@ ...@@ -1141,6 +1193,79 @@
message.error(result.message) message.error(result.message)
} }
} }
// 一键退款未绑定 — 拉取名单
const refundUnbound = async () => {
unboundLoading.value = true
const [err, result] = await to(
fetch(QUERY_UNBOUND_PAID_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ cmptId: getCId() })
}).then(res => res.json())
)
unboundLoading.value = false
if (err || result.code !== 200) {
message.error(err?.message || result?.message || '获取名单失败')
return
}
if (!result.data || !result.data.length) {
message.info('暂无已支付但未绑定的选手')
return
}
unboundList.value = result.data
unboundCheckedKeys.value = result.data.map(v => v.applyId)
showUnboundRefundModal.value = true
}
// 一键退款未绑定 — 确认退款
const submitUnboundRefund = async () => {
if (!unboundCheckedKeys.value.length) return
const ok = confirm('确定对已选的 ' + unboundCheckedKeys.value.length + ' 位选手发起退款吗?')
if (!ok) return
unboundLoading.value = true
const [err, result] = await to(
fetch(ORDER_BATCH_REFUND_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
applyIds: unboundCheckedKeys.value,
operatorCode: getUId(),
cmptId: getCId()
})
}).then(res => res.json())
)
unboundLoading.value = false
showUnboundRefundModal.value = false
if (err) {
message.error(err.message || '退款失败')
return
}
if (result.code === 200) {
result.data.length && confirm(result.data.map(v => v.markNo + ':' + v.result).join('\n'))
fetchOrders()
} else {
message.error(result.message)
}
}
// 导出未绑定名单
const exportUnboundList = () => {
const rows = unboundList.value
if (!rows.length) return
const header = ['序号', '参赛号', '姓名', '手机号', '支付金额', '支付时间']
const csvRows = [header.join(',')]
rows.forEach((row, i) => {
csvRows.push([i + 1, row.markNo, row.name, row.phone, row.amount, row.payEndTime || ''].join(','))
})
const bom = ''
const blob = new Blob([bom + csvRows.join('\n')], { type: 'text/csv;charset=utf-8;' })
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = getCId() + '_已支付未绑定名单.csv'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
}
// 清空选中 // 清空选中
const clearCheck = () => { const clearCheck = () => {
checkedRowKeys.value = [] checkedRowKeys.value = []
...@@ -1191,6 +1316,15 @@ ...@@ -1191,6 +1316,15 @@
batchRefund, batchRefund,
refundAll, refundAll,
exportOrder, exportOrder,
// 退款未绑定相关
showUnboundRefundModal,
unboundList,
unboundCheckedKeys,
unboundLoading,
unboundColumns,
refundUnbound,
submitUnboundRefund,
exportUnboundList,
// 编辑相关 // 编辑相关
editOrderValue, editOrderValue,
editOrderRules, editOrderRules,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment