feat(customers): add Digipay installment admin section

Wire routes, settings groups, page access, and customer UI for installment management.
This commit is contained in:
2026-10-21 03:38:59 -04:00
parent e5b3d0c931
commit 88271dba2a
7 changed files with 129 additions and 1 deletions
@@ -15,6 +15,12 @@ export type SettingGroupDef = {
/** گروه‌های صفحه تنظیمات عادی (فقط can_edit=1) */
export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
{
id: 'digipay_installment',
title: 'خرید اقساطی دیجی‌پی',
icon: 'vuesax-linear:calendar',
match: (k) => k === 'enable_digipay_installment' || k.startsWith('digipay_')
},
{
id: 'general',
title: 'عمومی و برند',
@@ -0,0 +1,84 @@
<template>
<BasicShowContext title="خرید اقساطی" :help="digipayInstallmentPageIntro">
<div class="flex flex-col gap-2 p-2.5">
<div class="text-sm font-bold">ثبت اعتبار بعد از دیجی‌پی</div>
<p class="text-xs opacity-70">
کاربر اول با لینک تنظیمات به دیجی‌پی می‌رود. بعد از احراز، مانده اعتبارش را اینجا بنویسید تا در اپ بتواند مس بخرد.
</p>
<a-form layout="vertical" class="sm:grid sm:grid-cols-2 sm:gap-2" @finish="save">
<a-form-item label="موبایل مشتری" name="mobile" :rules="[{ required: true, message: 'موبایل را وارد کنید' }]">
<a-input v-model:value="form.mobile" placeholder="09..." />
</a-form-item>
<a-form-item label="مانده ۴ قسط (تومان)" name="plan4">
<a-input-number v-model:value="form.plan4_toman" class="w-full" :min="0" />
</a-form-item>
<a-form-item label="مانده ۱۲ قسط (تومان)" name="plan12">
<a-input-number v-model:value="form.plan12_toman" class="w-full" :min="0" />
</a-form-item>
<a-form-item label=" " class="flex items-end">
<a-button type="primary" html-type="submit" :loading="saving">ثبت اعتبار</a-button>
</a-form-item>
</a-form>
<div class="mt-2 text-sm font-bold">خریدهای اخیر</div>
<a-table
size="small"
row-key="id"
:loading="loading"
:data-source="rows"
:pagination="false"
:columns="columns"
/>
</div>
</BasicShowContext>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import useAxios from '@core/utils/useAxios'
import { digipayInstallmentPageIntro } from '@/utils/adminHelpCopy'
const form = reactive({ mobile: '', plan4_toman: 0, plan12_toman: 0 })
const saving = ref(false)
const loading = ref(false)
const rows = ref<Record<string, unknown>[]>([])
const columns = [
{ title: 'مشتری', dataIndex: 'name' },
{ title: 'موبایل', dataIndex: 'mobile' },
{ title: 'طرح', dataIndex: 'plan' },
{ title: 'مبلغ مس (تومان)', dataIndex: 'amount_toman' },
{ title: 'کارمزد (تومان)', dataIndex: 'fee_toman' },
{ title: 'مقدار', dataIndex: 'grams' }
]
async function load() {
loading.value = true
try {
const res = await useAxios.post('/admin/digipay_installment/orders')
rows.value = res?.data?.data || res?.data || []
} finally {
loading.value = false
}
}
async function save() {
saving.value = true
try {
await useAxios.post('/admin/digipay_installment/credit', {
mobile: form.mobile,
plan4_toman: form.plan4_toman || 0,
plan12_toman: form.plan12_toman || 0
})
message.success('اعتبار ثبت شد')
await load()
} catch (e: any) {
message.error(e?.response?.data?.message || 'ثبت اعتبار انجام نشد')
} finally {
saving.value = false
}
}
onMounted(load)
</script>
+2 -1
View File
@@ -21,7 +21,7 @@ import { computed } from 'vue'
import BasicMenu from '@/components/BasicMenu/index.vue'
import { useRouterStore } from '@core/stores/router'
import { get } from 'lodash'
import { customerSpecialPricingEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
import { customerSpecialPricingEnabledSetting, digipayInstallmentEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
initWalletSettingsFromApi()
@@ -36,6 +36,7 @@ const menu = computed(() => {
.filter((child) => {
if (child.name === 'customerMain_specialPrice') return customerSpecialPricingEnabledSetting.value
if (child.name === 'customerMain_goldCredit') return goldCreditEnabledSetting.value
if (child.name === 'customerMain_digipayInstallment') return digipayInstallmentEnabledSetting.value
return true
})
.sort((a, b) => (a.meta?.order ?? 99) - (b.meta?.order ?? 99))