refactor(daxpay): 优化分账功能相关代码

- 修改 AllocationGroupEdit 和 AllocationReceiverEdit组件,使用 unref 获取 appId值
- 更新 AllocationReceiver.api.ts,添加 reqTime 字段- 调整 PayOrder.api.ts 中的分账接口,使用 id 替代 orderNo
- 优化 PayOrderList 组件中的分账逻辑
- 移除 MchAppList 组件中的分账配置选项
- 更新 DevelopTradePay 组件,增加是否分账的开关
- 在 ChannelConstList 组件中添加支持分账的列
This commit is contained in:
DaxPay
2024-11-24 17:15:53 +08:00
parent 52f9baba8c
commit 95c6f55dee
10 changed files with 47 additions and 27 deletions

View File

@@ -67,7 +67,7 @@
<script setup lang="ts">
import useFormEdit from '@/hooks/bootx/useFormEdit'
import { computed, nextTick, ref } from 'vue'
import { computed, nextTick, ref, unref } from "vue";
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { get, add, update, AllocGroup, existsByNo } from './AllocationGroup.api'
import { FormEditType } from '@/enums/formTypeEnum'
@@ -114,7 +114,7 @@
initFormEditType(editType)
resetForm()
initData()
form.value.appId = appId
form.value.appId = unref(appId)
getInfo(record, editType)
}
@@ -161,6 +161,9 @@
*/
async function validateCode() {
const { groupNo, appId } = form.value
if (!addable.value) {
return Promise.resolve()
}
const res = await existsByNo(groupNo, appId)
return res.data ? Promise.reject('该分账组编号已经存在') : Promise.resolve()
}

View File

@@ -184,7 +184,7 @@
* 新建
*/
function add() {
allocationGroupEdit.value.init(null, FormEditType.Add, appId)
allocationGroupEdit.value.init(null, FormEditType.Add, appId.value)
}
/**

View File

@@ -100,4 +100,6 @@ export interface AllocReceiver extends MchEntity {
relationType?: string
// 关系名称
relationName?: string
// 请求时间
reqTime?: string
}

View File

@@ -107,7 +107,7 @@
<script setup lang="ts">
import useFormEdit from '@/hooks/bootx/useFormEdit'
import { useMessage } from '@/hooks/web/useMessage'
import { computed, nextTick, ref } from 'vue'
import { computed, nextTick, ref, unref } from "vue";
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import {
add,
@@ -124,6 +124,7 @@
import { LabeledValue } from 'ant-design-vue/lib/select'
import { Icon } from '@/components/Icon'
import OpenIdQrCode from './OpenIdQrCode.vue'
import XEUtils from 'xe-utils'
const {
initFormEditType,
@@ -177,7 +178,7 @@
function init(record, editType: FormEditType, appId) {
initFormEditType(editType)
resetForm()
form.value.appId = appId
form.value.appId = unref(appId)
initData()
getInfo(record, editType)
}
@@ -226,6 +227,7 @@
formRef.value?.validate().then(async () => {
confirmLoading.value = true
try {
form.value.reqTime = XEUtils.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss')
if (formEditType.value === FormEditType.Add) {
await add(form.value)
} else if (formEditType.value === FormEditType.Edit) {

View File

@@ -41,7 +41,7 @@
<a-link @click="show(row)">{{ row.receiverNo }}</a-link>
</template>
</vxe-column>
<vxe-column field="channel" title="所属通道" :min-width="120" align="center">
<vxe-column field="channel" title="所属通道" :min-width="150" align="center">
<template #default="{ row }">
<a-tag>{{ dictConvert('channel', row.channel) }}</a-tag>
</template>
@@ -75,7 +75,7 @@
@page-change="handleTableChange"
/>
</div>
<allocation-receiver-edit ref="allocationReceiverEdit" @ok="queryPage" />
<AllocationReceiverEdit ref="allocationReceiverEdit" @ok="queryPage" />
</basic-drawer>
</template>
@@ -127,21 +127,21 @@
type: LIST,
name: '分账通道',
placeholder: '请选择分账通道',
selectList: payChannelList,
selectList: payChannelList.value,
},
{
field: 'allocReceiverType',
type: LIST,
name: '接收方类型',
placeholder: '请选择接收方类型',
selectList: receiverTypeList,
selectList: receiverTypeList.value,
},
{
field: 'relationType',
type: LIST,
name: '分账关系',
placeholder: '请选择分账关系',
selectList: relationTypeList,
selectList: relationTypeList.value,
},
] as QueryField[]
})

View File

@@ -27,6 +27,12 @@
<a-tag v-else color="red">停用</a-tag>
</template>
</vxe-column>
<vxe-column field="enable" title="支持分账">
<template #default="{ row }">
<a-tag v-if="row.enable" color="green">支持</a-tag>
<a-tag v-else color="red">不支持</a-tag>
</template>
</vxe-column>
<vxe-column field="remark" title="备注" />
</vxe-table>
</div>

View File

@@ -55,6 +55,13 @@
placeholder="请选择支付方式"
/>
</a-form-item>
<a-form-item label="是否分账" name="allocation">
<a-switch
checked-children=""
un-checked-children=""
v-model:checked="form.allocation"
/>
</a-form-item>
<a-form-item label="支付描述" name="description">
<a-input v-model:value="form.description" placeholder="请输入支付描述" />
</a-form-item>
@@ -150,6 +157,7 @@
title: [{ required: true, message: '支付标题不可为空' }],
amount: [{ required: true, message: '支付金额不可为空' }],
method: [{ required: true, message: '支付方式不可为空' }],
allocation: [{ required: true, message: '分账不可为空' }],
clientIp: [{ required: true, message: '终端IP不可为空' }],
nonceStr: [{ required: true, message: '随机数不可为空' }],
reqTime: [{ required: true, message: '请求时间不可为空' }],

View File

@@ -67,9 +67,9 @@
<a-menu-item>
<a-link @click="showCashierCode(row)">码牌配置</a-link>
</a-menu-item>
<a-menu-item>
<a-link @click="showAllocConfig(row)">分账配置</a-link>
</a-menu-item>
<!-- <a-menu-item>-->
<!-- <a-link @click="showAllocConfig(row)">分账配置</a-link>-->
<!-- </a-menu-item>-->
<a-menu-item>
<a-link @click="showAllocReceiver(row)">分账接收方</a-link>
</a-menu-item>

View File

@@ -70,10 +70,10 @@ export function cancel(id) {
/**
* 触发分账
*/
export function allocByOrderNo(orderNo) {
export function allocation(id) {
return defHttp.post<Result<void>>({
url: '/order/pay/allocation',
params: { orderNo },
params: { id },
})
}

View File

@@ -99,7 +99,7 @@
PayStatusEnum.SUCCESS === row.status
"
>
<a-link @click="allocation(row)">分账</a-link>
<a-link @click="allocationOrder(row)">分账</a-link>
</a-menu-item>
<a-menu-item
v-if="
@@ -135,9 +135,9 @@
</template>
<script lang="ts" setup>
import { computed, onMounted, ref, watch } from 'vue'
import { computed, onMounted, ref } from 'vue'
import {
allocByOrderNo,
allocation,
close,
getTotalAmount,
page,
@@ -340,29 +340,28 @@
},
})
}
/**
* 退款
*/
function refund(record) {
refundModel.value.init(record.id)
}
/**
* 触发分账
*/
function allocation(record) {
function allocationOrder(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否触发该订单的分账操作',
onOk: () => {
allocByOrderNo(record.orderNo).then(() => {
allocation(record.id).then(() => {
createMessage.success('分账请求已发送')
queryPage()
})
},
})
}
/**
* 退款
*/
function refund(record) {
refundModel.value.init(record.id)
}
</script>
<style lang="less" scoped></style>