支持提号完成后财务调整
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
cancelAdminPickup,
|
||||
confirmAdminPickupOfflineSettlement,
|
||||
completeAdminPickup,
|
||||
createAdminPickupFinancialAdjustment,
|
||||
createAdminPickup,
|
||||
fetchAdminPickups,
|
||||
fetchAdminPickupShopOptions,
|
||||
@@ -36,9 +37,11 @@ const filters = reactive({
|
||||
const createDialogVisible = ref(false)
|
||||
const completeDialogVisible = ref(false)
|
||||
const profitDialogVisible = ref(false)
|
||||
const financialAdjustmentDialogVisible = ref(false)
|
||||
const activePickupId = ref(0)
|
||||
const activePickup = ref<AdminPickup | null>(null)
|
||||
const profitSaving = ref(false)
|
||||
const financialAdjustmentSaving = ref(false)
|
||||
|
||||
const createForm = reactive({
|
||||
listing_id: null as number | null,
|
||||
@@ -49,6 +52,7 @@ const createForm = reactive({
|
||||
})
|
||||
const completeForm = reactive({ settle_amount: 0, profit_amount: 0, complete_remark: '' })
|
||||
const profitForm = reactive({ profit_amount: 0, reason: '' })
|
||||
const financialAdjustmentForm = reactive({ profit_amount: 0, settle_amount: 0, reason: '' })
|
||||
|
||||
const listingOptions = ref<AvailableListing[]>([])
|
||||
const listingLoading = ref(false)
|
||||
@@ -196,7 +200,7 @@ function openCompleteDialog(row: AdminPickup) {
|
||||
async function handleConfirmOfflineSettlement(row: AdminPickup) {
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
`确认已向卖家线下支付 ${formatCentWithSymbol(row.settle_amount_cent)}?`,
|
||||
`确认已向卖家线下支付 ${formatCentWithSymbol(effectiveSettleCent(row))}?`,
|
||||
'确认线下结算',
|
||||
{
|
||||
confirmButtonText: '确认已打款',
|
||||
@@ -228,6 +232,45 @@ function openProfitDialog(row: AdminPickup) {
|
||||
profitDialogVisible.value = true
|
||||
}
|
||||
|
||||
function openFinancialAdjustmentDialog(row: AdminPickup) {
|
||||
activePickupId.value = row.id
|
||||
activePickup.value = row
|
||||
financialAdjustmentForm.profit_amount = centToYuan(effectiveProfitCent(row))
|
||||
financialAdjustmentForm.settle_amount = centToYuan(effectiveSettleCent(row))
|
||||
financialAdjustmentForm.reason = ''
|
||||
financialAdjustmentDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleFinancialAdjustment() {
|
||||
if (!financialAdjustmentForm.reason.trim()) {
|
||||
ElMessage.warning('请输入调整原因')
|
||||
return
|
||||
}
|
||||
if (financialAdjustmentForm.profit_amount < 0 || financialAdjustmentForm.settle_amount < 0) {
|
||||
ElMessage.warning('金额不能小于 0')
|
||||
return
|
||||
}
|
||||
financialAdjustmentSaving.value = true
|
||||
try {
|
||||
await createAdminPickupFinancialAdjustment(activePickupId.value, {
|
||||
profit_amount_cent: yuanToCent(financialAdjustmentForm.profit_amount),
|
||||
settle_amount_cent: yuanToCent(financialAdjustmentForm.settle_amount),
|
||||
reason: financialAdjustmentForm.reason.trim(),
|
||||
})
|
||||
ElMessage.success(
|
||||
activePickup.value?.settlement_mode === 'platform_managed'
|
||||
? '财务调整已创建,请确认线下补款或追回'
|
||||
: '财务调整已创建'
|
||||
)
|
||||
financialAdjustmentDialogVisible.value = false
|
||||
loadList()
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(errorMessage(e) || '调整失败')
|
||||
} finally {
|
||||
financialAdjustmentSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleComplete() {
|
||||
if (completeForm.settle_amount <= 0) {
|
||||
ElMessage.warning('请输入结算金额')
|
||||
@@ -329,6 +372,18 @@ function normalizeCent(value: number | undefined | null) {
|
||||
return Math.max(Math.round(cent), 0)
|
||||
}
|
||||
|
||||
function effectiveProfitCent(row: AdminPickup) {
|
||||
return Number.isFinite(row.effective_profit_amount_cent)
|
||||
? row.effective_profit_amount_cent
|
||||
: row.profit_amount_cent
|
||||
}
|
||||
|
||||
function effectiveSettleCent(row: AdminPickup) {
|
||||
return Number.isFinite(row.effective_settle_amount_cent)
|
||||
? row.effective_settle_amount_cent
|
||||
: row.settle_amount_cent
|
||||
}
|
||||
|
||||
function listingOwnerTotalCent(item: AvailableListing) {
|
||||
return normalizeCent(item.owner_total_price_cent || item.owner_price_cent)
|
||||
}
|
||||
@@ -454,13 +509,13 @@ function listingOptionLabel(item: AvailableListing) {
|
||||
<el-table-column label="结算金额" width="130">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.status === 'completed'">{{
|
||||
formatCentWithSymbol(row.settle_amount_cent)
|
||||
formatCentWithSymbol(effectiveSettleCent(row))
|
||||
}}</span>
|
||||
<span v-else class="text-muted">待结算</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="线下利润" width="120">
|
||||
<template #default="{ row }">{{ formatCentWithSymbol(row.profit_amount_cent) }}</template>
|
||||
<template #default="{ row }">{{ formatCentWithSymbol(effectiveProfitCent(row)) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
@@ -512,6 +567,15 @@ function listingOptionLabel(item: AvailableListing) {
|
||||
>
|
||||
确认线下结算
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'completed'"
|
||||
size="small"
|
||||
plain
|
||||
:icon="EditPen"
|
||||
@click="openFinancialAdjustmentDialog(row)"
|
||||
>
|
||||
财务调整
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'picking_up'"
|
||||
type="danger"
|
||||
@@ -747,6 +811,58 @@ function listingOptionLabel(item: AvailableListing) {
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="financialAdjustmentDialogVisible" title="完成后财务调整" width="500px">
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="目标利润(元)">
|
||||
<el-input-number
|
||||
v-model="financialAdjustmentForm.profit_amount"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="目标打款金额(元)">
|
||||
<el-input-number
|
||||
v-model="financialAdjustmentForm.settle_amount"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-hint">
|
||||
{{
|
||||
activePickup?.settlement_mode === 'platform_managed'
|
||||
? '代管账号会生成待线下补款或待追回记录'
|
||||
: '增加金额会立即补入号主钱包,减少金额会生成待追回记录'
|
||||
}}
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="调整原因" required>
|
||||
<el-input
|
||||
v-model="financialAdjustmentForm.reason"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="255"
|
||||
show-word-limit
|
||||
placeholder="请输入调整原因"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="financialAdjustmentDialogVisible = false">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="financialAdjustmentSaving"
|
||||
@click="handleFinancialAdjustment"
|
||||
>
|
||||
确认调整
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user