This commit is contained in:
@@ -17,13 +17,15 @@ import type {
|
||||
MyCommissionSummary,
|
||||
SubmitWithdrawalParams,
|
||||
ShopCommissionRecordPageResult,
|
||||
ShopCommissionSummaryQueryParams,
|
||||
ShopCommissionSummaryPageResult,
|
||||
MyCommissionStatsQueryParams,
|
||||
MyCommissionStatsResponse,
|
||||
MyDailyCommissionStatsQueryParams,
|
||||
ShopFundSummaryQueryParams,
|
||||
ShopFundSummaryPageResult,
|
||||
ShopCommissionStatsQueryParams,
|
||||
CommissionStatsResponse,
|
||||
DailyCommissionStatsQueryParams,
|
||||
DailyCommissionStatsItem,
|
||||
ResolveCommissionParams
|
||||
ResolveCommissionParams,
|
||||
MainWalletTransactionQueryParams,
|
||||
MainWalletTransactionPageResult
|
||||
} from '@/types/api/commission'
|
||||
|
||||
export class CommissionService extends BaseService {
|
||||
@@ -91,9 +93,10 @@ export class CommissionService extends BaseService {
|
||||
)
|
||||
}
|
||||
|
||||
// ==================== 我的佣金 ====================
|
||||
// ==================== 我的佣金(已废弃,仅保留用于向后兼容) ====================
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopCommissionRecords 代替
|
||||
* 获取我的佣金明细
|
||||
* GET /api/admin/my/commission-records
|
||||
*/
|
||||
@@ -107,6 +110,7 @@ export class CommissionService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopFundSummary 代替
|
||||
* 获取我的佣金概览
|
||||
* GET /api/admin/my/commission-summary
|
||||
*/
|
||||
@@ -115,6 +119,7 @@ export class CommissionService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopWithdrawalRequests 代替
|
||||
* 获取我的提现记录
|
||||
* GET /api/admin/my/withdrawal-requests
|
||||
*/
|
||||
@@ -128,6 +133,7 @@ export class CommissionService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 submitShopWithdrawalRequest 代替
|
||||
* 发起提现申请
|
||||
* POST /api/admin/my/withdrawal-requests
|
||||
*/
|
||||
@@ -136,24 +142,26 @@ export class CommissionService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopCommissionStats 代替
|
||||
* 获取我的佣金统计
|
||||
* GET /api/admin/my/commission-stats
|
||||
*/
|
||||
static getMyCommissionStats(
|
||||
params?: MyCommissionStatsQueryParams
|
||||
): Promise<BaseResponse<MyCommissionStatsResponse>> {
|
||||
return this.get<BaseResponse<MyCommissionStatsResponse>>(
|
||||
params?: ShopCommissionStatsQueryParams
|
||||
): Promise<BaseResponse<CommissionStatsResponse>> {
|
||||
return this.get<BaseResponse<CommissionStatsResponse>>(
|
||||
'/api/admin/my/commission-stats',
|
||||
params
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopDailyCommissionStats 代替
|
||||
* 获取我的每日佣金统计
|
||||
* GET /api/admin/my/commission-daily-stats
|
||||
*/
|
||||
static getMyDailyCommissionStats(
|
||||
params?: MyDailyCommissionStatsQueryParams
|
||||
params?: DailyCommissionStatsQueryParams
|
||||
): Promise<BaseResponse<DailyCommissionStatsItem[]>> {
|
||||
return this.get<BaseResponse<DailyCommissionStatsItem[]>>(
|
||||
'/api/admin/my/commission-daily-stats',
|
||||
@@ -192,14 +200,78 @@ export class CommissionService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商资金汇总列表(含预充值余额 + 佣金)
|
||||
* GET /api/admin/shops/fund-summary
|
||||
*/
|
||||
static getShopFundSummary(
|
||||
params?: ShopFundSummaryQueryParams
|
||||
): Promise<BaseResponse<ShopFundSummaryPageResult>> {
|
||||
return this.get<BaseResponse<ShopFundSummaryPageResult>>(
|
||||
'/api/admin/shops/fund-summary',
|
||||
params
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 getShopFundSummary 代替
|
||||
* 获取代理商佣金汇总列表
|
||||
* GET /api/admin/shops/commission-summary
|
||||
*/
|
||||
static getShopCommissionSummary(
|
||||
params?: ShopCommissionSummaryQueryParams
|
||||
): Promise<BaseResponse<ShopCommissionSummaryPageResult>> {
|
||||
return this.get<BaseResponse<ShopCommissionSummaryPageResult>>(
|
||||
'/api/admin/shops/commission-summary',
|
||||
params?: ShopFundSummaryQueryParams
|
||||
): Promise<BaseResponse<ShopFundSummaryPageResult>> {
|
||||
return this.getShopFundSummary(params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商佣金统计
|
||||
* GET /api/admin/shops/{shop_id}/commission-stats
|
||||
*/
|
||||
static getShopCommissionStats(
|
||||
shopId: number,
|
||||
params?: ShopCommissionStatsQueryParams
|
||||
): Promise<BaseResponse<CommissionStatsResponse>> {
|
||||
return this.get<BaseResponse<CommissionStatsResponse>>(
|
||||
`/api/admin/shops/${shopId}/commission-stats`,
|
||||
params
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商每日佣金统计
|
||||
* GET /api/admin/shops/{shop_id}/commission-daily-stats
|
||||
*/
|
||||
static getShopDailyCommissionStats(
|
||||
shopId: number,
|
||||
params?: DailyCommissionStatsQueryParams
|
||||
): Promise<BaseResponse<DailyCommissionStatsItem[]>> {
|
||||
return this.get<BaseResponse<DailyCommissionStatsItem[]>>(
|
||||
`/api/admin/shops/${shopId}/commission-daily-stats`,
|
||||
params
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起代理商提现申请
|
||||
* POST /api/admin/shops/{shop_id}/withdrawal-requests
|
||||
*/
|
||||
static submitShopWithdrawalRequest(
|
||||
shopId: number,
|
||||
params: SubmitWithdrawalParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/shops/${shopId}/withdrawal-requests`, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预充值钱包流水
|
||||
* GET /api/admin/shops/{shop_id}/main-wallet/transactions
|
||||
*/
|
||||
static getMainWalletTransactions(
|
||||
shopId: number,
|
||||
params?: MainWalletTransactionQueryParams
|
||||
): Promise<BaseResponse<MainWalletTransactionPageResult>> {
|
||||
return this.get<BaseResponse<MainWalletTransactionPageResult>>(
|
||||
`/api/admin/shops/${shopId}/main-wallet/transactions`,
|
||||
params
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import type {
|
||||
OrderListResponse,
|
||||
CreateOrderRequest,
|
||||
CreateOrderResponse,
|
||||
PurchaseCheckRequest,
|
||||
PurchaseCheckResponse,
|
||||
BaseResponse
|
||||
} from '@/types/api'
|
||||
|
||||
@@ -46,12 +44,4 @@ export class OrderService extends BaseService {
|
||||
static cancelOrder(id: number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/orders/${id}/cancel`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 套餐购买预检
|
||||
* @param data 预检请求参数
|
||||
*/
|
||||
static purchaseCheck(data: PurchaseCheckRequest): Promise<BaseResponse<PurchaseCheckResponse>> {
|
||||
return this.post<BaseResponse<PurchaseCheckResponse>>('/api/admin/orders/purchase-check', data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,14 +190,16 @@ export interface ShopCommissionRecordItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商佣金汇总项
|
||||
* 代理商资金汇总项(原佣金汇总项)
|
||||
*/
|
||||
export interface ShopCommissionSummaryItem {
|
||||
export interface ShopFundSummaryItem {
|
||||
shop_id: number // 店铺ID
|
||||
shop_code: string // 店铺编码
|
||||
shop_name: string // 店铺名称
|
||||
username?: string // 主账号用户名
|
||||
phone?: string // 主账号手机号
|
||||
main_balance: number // 预充值余额(分)
|
||||
main_frozen_balance: number // 预充值冻结余额(分)
|
||||
total_commission: number // 总佣金(分)
|
||||
available_commission: number // 可提现佣金(分)
|
||||
frozen_commission: number // 冻结中佣金(分)
|
||||
@@ -208,13 +210,23 @@ export interface ShopCommissionSummaryItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商佣金汇总查询参数
|
||||
* @deprecated 使用 ShopFundSummaryItem 代替
|
||||
*/
|
||||
export interface ShopCommissionSummaryQueryParams extends PaginationParams {
|
||||
export type ShopCommissionSummaryItem = ShopFundSummaryItem
|
||||
|
||||
/**
|
||||
* 代理商资金汇总查询参数(原佣金汇总查询参数)
|
||||
*/
|
||||
export interface ShopFundSummaryQueryParams extends PaginationParams {
|
||||
shop_name?: string // 店铺名称
|
||||
shop_code?: string // 店铺编码
|
||||
username?: string // 用户名
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 ShopFundSummaryQueryParams 代替
|
||||
*/
|
||||
export type ShopCommissionSummaryQueryParams = ShopFundSummaryQueryParams
|
||||
|
||||
// ==================== 响应类型 ====================
|
||||
|
||||
export interface WithdrawalRequestPageResult {
|
||||
@@ -242,8 +254,57 @@ export interface ShopCommissionRecordPageResult {
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface ShopCommissionSummaryPageResult {
|
||||
items: ShopCommissionSummaryItem[] | null
|
||||
export interface ShopFundSummaryPageResult {
|
||||
items: ShopFundSummaryItem[] | null
|
||||
page: number
|
||||
size: number
|
||||
total: number
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 ShopFundSummaryPageResult 代替
|
||||
*/
|
||||
export type ShopCommissionSummaryPageResult = ShopFundSummaryPageResult
|
||||
|
||||
// ==================== 预充值钱包相关 ====================
|
||||
|
||||
/**
|
||||
* 交易类型
|
||||
*/
|
||||
export enum MainWalletTransactionType {
|
||||
RECHARGE = 'recharge', // 充值入账
|
||||
DEDUCT = 'deduct', // 套餐扣款
|
||||
REFUND = 'refund' // 退款
|
||||
}
|
||||
|
||||
/**
|
||||
* 预充值钱包交易记录项
|
||||
*/
|
||||
export interface MainWalletTransactionItem {
|
||||
id: number // 交易记录ID
|
||||
transaction_type: MainWalletTransactionType // 交易类型
|
||||
transaction_subtype: string // 交易子类型
|
||||
amount: number // 交易金额(分,正数为入账,负数为扣款)
|
||||
balance_before: number // 交易前余额(分)
|
||||
balance_after: number // 交易后余额(分)
|
||||
remark: string // 备注
|
||||
created_at: string // 交易时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 预充值钱包交易记录查询参数
|
||||
*/
|
||||
export interface MainWalletTransactionQueryParams extends PaginationParams {
|
||||
transaction_type?: MainWalletTransactionType // 交易类型过滤
|
||||
start_date?: string // 开始日期 YYYY-MM-DD
|
||||
end_date?: string // 结束日期 YYYY-MM-DD
|
||||
}
|
||||
|
||||
/**
|
||||
* 预充值钱包交易记录分页结果
|
||||
*/
|
||||
export interface MainWalletTransactionPageResult {
|
||||
items: MainWalletTransactionItem[] | null
|
||||
page: number
|
||||
size: number
|
||||
total: number
|
||||
@@ -252,41 +313,51 @@ export interface ShopCommissionSummaryPageResult {
|
||||
// ==================== 我的佣金统计相关 ====================
|
||||
|
||||
/**
|
||||
* 我的佣金统计查询参数
|
||||
* 代理商佣金统计查询参数(shop_id 通过路径参数传递,不再在 query 中)
|
||||
*/
|
||||
export interface MyCommissionStatsQueryParams {
|
||||
shop_id?: number // 店铺ID
|
||||
export interface ShopCommissionStatsQueryParams {
|
||||
start_time?: string // 开始时间
|
||||
end_time?: string // 结束时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的佣金统计响应
|
||||
* @deprecated 使用 ShopCommissionStatsQueryParams 代替,shop_id 改为路径参数
|
||||
*/
|
||||
export interface MyCommissionStatsResponse {
|
||||
cost_diff_amount: number // 成本价差收入(分)
|
||||
cost_diff_count: number // 成本价差笔数
|
||||
cost_diff_percent: number // 成本价差占比(千分比)
|
||||
one_time_amount: number // 一次性佣金收入(分)
|
||||
one_time_count: number // 一次性佣金笔数
|
||||
one_time_percent: number // 一次性佣金占比(千分比)
|
||||
tier_bonus_amount: number // 梯度奖励收入(分)
|
||||
tier_bonus_count: number // 梯度奖励笔数
|
||||
tier_bonus_percent: number // 梯度奖励占比(千分比)
|
||||
export type MyCommissionStatsQueryParams = ShopCommissionStatsQueryParams
|
||||
|
||||
/**
|
||||
* 代理商佣金统计响应
|
||||
*/
|
||||
export interface CommissionStatsResponse {
|
||||
total_amount: number // 总收入(分)
|
||||
cost_diff_amount: number // 成本价差收入(分)
|
||||
one_time_amount: number // 一次性佣金收入(分)
|
||||
cost_diff_percent: number // 成本价差占比(千分比)
|
||||
one_time_percent: number // 一次性佣金占比(千分比)
|
||||
total_count: number // 总笔数
|
||||
cost_diff_count: number // 成本价差笔数
|
||||
one_time_count: number // 一次性佣金笔数
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的每日佣金统计查询参数
|
||||
* @deprecated 使用 CommissionStatsResponse 代替
|
||||
*/
|
||||
export interface MyDailyCommissionStatsQueryParams {
|
||||
shop_id?: number // 店铺ID
|
||||
export type MyCommissionStatsResponse = CommissionStatsResponse
|
||||
|
||||
/**
|
||||
* 代理商每日佣金统计查询参数(shop_id 通过路径参数传递)
|
||||
*/
|
||||
export interface DailyCommissionStatsQueryParams {
|
||||
start_date?: string // 开始日期(YYYY-MM-DD)
|
||||
end_date?: string // 结束日期(YYYY-MM-DD)
|
||||
days?: number // 查询天数(默认30天,最大365天)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 使用 DailyCommissionStatsQueryParams 代替,shop_id 改为路径参数
|
||||
*/
|
||||
export type MyDailyCommissionStatsQueryParams = DailyCommissionStatsQueryParams
|
||||
|
||||
/**
|
||||
* 每日佣金统计项
|
||||
*/
|
||||
|
||||
@@ -92,27 +92,10 @@ export interface CreateOrderRequest {
|
||||
iot_card_id?: number | null // IoT卡ID
|
||||
device_id?: number | null // 设备ID
|
||||
identifier?: string // 资产标识符(ICCID 或 VirtualNo)
|
||||
package_ids: number[] // 套餐ID列表
|
||||
package_id: number // 套餐ID(单选)
|
||||
payment_method: OrderPaymentMethod // 支付方式
|
||||
payment_voucher_key?: string // 线下支付凭证(仅 offline 必填)
|
||||
}
|
||||
|
||||
// 创建订单响应 (返回订单详情)
|
||||
export type CreateOrderResponse = Order
|
||||
|
||||
// 套餐购买预检请求
|
||||
export interface PurchaseCheckRequest {
|
||||
order_type: OrderType // 订单类型 (single_card:单卡购买, device:设备购买)
|
||||
resource_id: number // 资源ID (IoT卡ID或设备ID)
|
||||
package_ids: number[] // 套餐ID列表
|
||||
}
|
||||
|
||||
// 套餐购买预检响应
|
||||
export interface PurchaseCheckResponse {
|
||||
need_force_recharge: boolean // 是否需要强充
|
||||
force_recharge_amount?: number // 强充金额(分)
|
||||
total_package_amount?: number // 套餐总价(分)
|
||||
actual_payment?: number // 实际支付金额(分)
|
||||
wallet_credit?: number // 钱包到账金额(分)
|
||||
message?: string // 提示信息
|
||||
}
|
||||
|
||||
@@ -1083,11 +1083,10 @@
|
||||
}})
|
||||
</span>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="选择套餐" prop="package_ids">
|
||||
<ElFormItem label="选择套餐" prop="package_id">
|
||||
<ElSelect
|
||||
v-model="rechargeForm.package_ids"
|
||||
v-model="rechargeForm.package_id"
|
||||
placeholder="请选择套餐"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
@@ -1422,8 +1421,7 @@
|
||||
TransactionType,
|
||||
AssetWalletResponse,
|
||||
CreateOrderRequest,
|
||||
PackageResponse,
|
||||
PurchaseCheckRequest
|
||||
PackageResponse
|
||||
} from '@/types/api'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
@@ -1500,11 +1498,11 @@
|
||||
const rechargeLoading = ref(false)
|
||||
const rechargeFormRef = ref<FormInstance>()
|
||||
const rechargeForm = reactive({
|
||||
package_ids: [] as number[],
|
||||
package_id: 0,
|
||||
payment_method: 'wallet' as 'wallet' | 'offline'
|
||||
})
|
||||
const rechargeRules: FormRules = {
|
||||
package_ids: [{ required: true, message: '请选择套餐', trigger: 'change' }],
|
||||
package_id: [{ required: true, message: '请选择套餐', trigger: 'change' }],
|
||||
payment_method: [{ required: true, message: '请选择支付方式', trigger: 'change' }]
|
||||
}
|
||||
const packageOptions = ref<PackageResponse[]>([])
|
||||
@@ -2660,42 +2658,14 @@
|
||||
if (valid) {
|
||||
rechargeLoading.value = true
|
||||
try {
|
||||
// 获取订单类型和资源ID
|
||||
const orderType: 'single_card' | 'device' =
|
||||
cardInfo.value.asset_type === 'card' ? 'single_card' : 'device'
|
||||
const resourceId = cardInfo.value.asset_id
|
||||
// 获取资产标识符
|
||||
const identifier =
|
||||
cardInfo.value.asset_type === 'card' ? cardInfo.value.iccid : cardInfo.value.virtual_no
|
||||
|
||||
// 调用套餐购买预检接口
|
||||
const checkData: PurchaseCheckRequest = {
|
||||
order_type: orderType,
|
||||
resource_id: resourceId,
|
||||
package_ids: rechargeForm.package_ids
|
||||
}
|
||||
|
||||
const checkResponse = await OrderService.purchaseCheck(checkData)
|
||||
|
||||
// 检查预检结果
|
||||
if (checkResponse.code === 0 && checkResponse.data) {
|
||||
const checkResult = checkResponse.data
|
||||
|
||||
// 如果需要强充,显示确认对话框
|
||||
if (checkResult.need_force_recharge) {
|
||||
const confirmMessage = `${checkResult.message || '钱包余额不足'}\n\n套餐总价: ¥${(checkResult.total_package_amount! / 100).toFixed(2)}\n需要强充: ¥${(checkResult.force_recharge_amount! / 100).toFixed(2)}\n钱包到账: ¥${(checkResult.wallet_credit! / 100).toFixed(2)}\n实际支付: ¥${(checkResult.actual_payment! / 100).toFixed(2)}\n\n是否继续创建订单?`
|
||||
|
||||
await ElMessageBox.confirm(confirmMessage, '购买预检提示', {
|
||||
confirmButtonText: '继续创建',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 预检通过或用户确认后,创建订单
|
||||
// 创建订单
|
||||
const data: CreateOrderRequest = {
|
||||
identifier,
|
||||
package_ids: rechargeForm.package_ids,
|
||||
package_id: rechargeForm.package_id,
|
||||
payment_method: rechargeForm.payment_method
|
||||
}
|
||||
|
||||
@@ -2731,7 +2701,7 @@
|
||||
// 关闭充值对话框
|
||||
const handleRechargeDialogClosed = () => {
|
||||
rechargeFormRef.value?.resetFields()
|
||||
rechargeForm.package_ids = []
|
||||
rechargeForm.package_id = 0
|
||||
rechargeForm.payment_method = 'wallet'
|
||||
packageOptions.value = []
|
||||
}
|
||||
|
||||
@@ -235,6 +235,78 @@
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElTabPane>
|
||||
|
||||
<!-- 预充值钱包流水 Tab -->
|
||||
<ElTabPane label="预充值钱包流水" name="mainWallet">
|
||||
<ArtTable
|
||||
ref="mainWalletTableRef"
|
||||
row-key="id"
|
||||
:loading="mainWalletLoading"
|
||||
:data="mainWalletRecords"
|
||||
:currentPage="mainWalletPagination.page"
|
||||
:pageSize="mainWalletPagination.pageSize"
|
||||
:total="mainWalletPagination.total"
|
||||
:marginTop="10"
|
||||
:height="500"
|
||||
@size-change="handleMainWalletSizeChange"
|
||||
@current-change="handleMainWalletCurrentChange"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn label="交易类型" prop="transaction_type" width="120">
|
||||
<template #default="scope">
|
||||
<ElTag
|
||||
:type="
|
||||
scope.row.transaction_type === 'recharge'
|
||||
? 'success'
|
||||
: scope.row.transaction_type === 'deduct'
|
||||
? 'warning'
|
||||
: 'info'
|
||||
"
|
||||
>
|
||||
{{
|
||||
scope.row.transaction_type === 'recharge'
|
||||
? '充值入账'
|
||||
: scope.row.transaction_type === 'deduct'
|
||||
? '套餐扣款'
|
||||
: scope.row.transaction_type === 'refund'
|
||||
? '退款'
|
||||
: scope.row.transaction_type
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="交易金额" prop="amount" width="120">
|
||||
<template #default="scope">
|
||||
<span
|
||||
:style="{
|
||||
fontWeight: 500,
|
||||
color:
|
||||
scope.row.amount > 0 ? 'var(--el-color-success)' : 'var(--el-color-danger)'
|
||||
}"
|
||||
>
|
||||
{{ scope.row.amount > 0 ? '+' : '' }}{{ formatMoney(scope.row.amount) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="交易前余额" prop="balance_before" width="130">
|
||||
<template #default="scope">
|
||||
{{ formatMoney(scope.row.balance_before) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="交易后余额" prop="balance_after" width="130">
|
||||
<template #default="scope">
|
||||
{{ formatMoney(scope.row.balance_after) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="备注" prop="remark" min-width="200" show-overflow-tooltip />
|
||||
<ElTableColumn label="交易时间" prop="created_at" width="180">
|
||||
<template #default="scope">
|
||||
{{ formatDateTime(scope.row.created_at) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
</ElDrawer>
|
||||
|
||||
@@ -303,10 +375,11 @@
|
||||
import { ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type {
|
||||
ShopCommissionSummaryItem,
|
||||
ShopFundSummaryItem,
|
||||
ShopCommissionRecordItem,
|
||||
WithdrawalRequestItem,
|
||||
CommissionResolveAction
|
||||
CommissionResolveAction,
|
||||
MainWalletTransactionItem
|
||||
} from '@/types/api/commission'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
@@ -328,7 +401,7 @@
|
||||
// 主表格状态
|
||||
const loading = ref(false)
|
||||
const tableRef = ref()
|
||||
const summaryList = ref<ShopCommissionSummaryItem[]>([])
|
||||
const summaryList = ref<ShopFundSummaryItem[]>([])
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
@@ -345,8 +418,8 @@
|
||||
|
||||
// 详情抽屉状态
|
||||
const detailDrawerVisible = ref(false)
|
||||
const activeTab = ref<'commission' | 'withdrawal'>('commission')
|
||||
const currentShop = ref<ShopCommissionSummaryItem | null>(null)
|
||||
const activeTab = ref<'commission' | 'withdrawal' | 'mainWallet'>('commission')
|
||||
const currentShop = ref<ShopFundSummaryItem | null>(null)
|
||||
|
||||
// 佣金明细状态
|
||||
const commissionLoading = ref(false)
|
||||
@@ -396,12 +469,23 @@
|
||||
remark: [{ max: 500, message: '备注最多500字符', trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
// 预充值钱包流水状态
|
||||
const mainWalletLoading = ref(false)
|
||||
const mainWalletTableRef = ref()
|
||||
const mainWalletRecords = ref<MainWalletTransactionItem[]>([])
|
||||
const mainWalletPagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 列配置
|
||||
const columnOptions = [
|
||||
{ label: '店铺编码', prop: 'shop_code' },
|
||||
{ label: '店铺名称', prop: 'shop_name' },
|
||||
{ label: '用户名', prop: 'username' },
|
||||
{ label: '手机号', prop: 'phone' },
|
||||
{ label: '预充值余额', prop: 'main_balance' },
|
||||
{ label: '总佣金', prop: 'total_commission' },
|
||||
{ label: '可提现', prop: 'available_commission' },
|
||||
{ label: '冻结中', prop: 'frozen_commission' },
|
||||
@@ -411,7 +495,7 @@
|
||||
]
|
||||
|
||||
// 处理名称点击
|
||||
const handleNameClick = (row: ShopCommissionSummaryItem) => {
|
||||
const handleNameClick = (row: ShopFundSummaryItem) => {
|
||||
if (hasAuth('agent_commission:detail')) {
|
||||
showDetail(row)
|
||||
} else {
|
||||
@@ -431,7 +515,7 @@
|
||||
label: '店铺名称',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: ShopCommissionSummaryItem) => {
|
||||
formatter: (row: ShopFundSummaryItem) => {
|
||||
return h(
|
||||
'span',
|
||||
{
|
||||
@@ -455,17 +539,29 @@
|
||||
label: '手机号',
|
||||
width: 130
|
||||
},
|
||||
{
|
||||
prop: 'main_balance',
|
||||
label: '预充值余额',
|
||||
width: 130,
|
||||
formatter: (row: ShopFundSummaryItem) => {
|
||||
return h(
|
||||
'span',
|
||||
{ style: 'color: var(--el-color-primary); font-weight: 500' },
|
||||
formatMoney(row.main_balance)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'total_commission',
|
||||
label: '总佣金',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.total_commission)
|
||||
formatter: (row: ShopFundSummaryItem) => formatMoney(row.total_commission)
|
||||
},
|
||||
{
|
||||
prop: 'available_commission',
|
||||
label: '可提现',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => {
|
||||
formatter: (row: ShopFundSummaryItem) => {
|
||||
return h(
|
||||
'span',
|
||||
{ style: 'color: var(--el-color-success); font-weight: 500' },
|
||||
@@ -477,13 +573,13 @@
|
||||
prop: 'frozen_commission',
|
||||
label: '冻结中',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.frozen_commission)
|
||||
formatter: (row: ShopFundSummaryItem) => formatMoney(row.frozen_commission)
|
||||
},
|
||||
{
|
||||
prop: 'withdrawing_commission',
|
||||
label: '提现中',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => {
|
||||
formatter: (row: ShopFundSummaryItem) => {
|
||||
return h(
|
||||
'span',
|
||||
{ style: 'color: var(--el-color-warning)' },
|
||||
@@ -495,13 +591,13 @@
|
||||
prop: 'withdrawn_commission',
|
||||
label: '已提现',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.withdrawn_commission)
|
||||
formatter: (row: ShopFundSummaryItem) => formatMoney(row.withdrawn_commission)
|
||||
},
|
||||
{
|
||||
prop: 'unwithdraw_commission',
|
||||
label: '未提现',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.unwithdraw_commission)
|
||||
formatter: (row: ShopFundSummaryItem) => formatMoney(row.unwithdraw_commission)
|
||||
}
|
||||
])
|
||||
|
||||
@@ -519,7 +615,7 @@
|
||||
shop_name: searchForm.shop_name || undefined,
|
||||
shop_code: searchForm.shop_code || undefined
|
||||
}
|
||||
const res = await CommissionService.getShopCommissionSummary(params)
|
||||
const res = await CommissionService.getShopFundSummary(params)
|
||||
if (res.code === 0) {
|
||||
summaryList.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
@@ -563,7 +659,7 @@
|
||||
}
|
||||
|
||||
// 显示详情抽屉
|
||||
const showDetail = (row: ShopCommissionSummaryItem) => {
|
||||
const showDetail = (row: ShopFundSummaryItem) => {
|
||||
currentShop.value = row
|
||||
detailDrawerVisible.value = true
|
||||
activeTab.value = 'commission'
|
||||
@@ -571,13 +667,14 @@
|
||||
// 重置分页
|
||||
commissionPagination.page = 1
|
||||
withdrawalPagination.page = 1
|
||||
mainWalletPagination.page = 1
|
||||
|
||||
// 加载佣金明细
|
||||
loadCommissionRecords()
|
||||
}
|
||||
|
||||
// 获取操作按钮
|
||||
const getActions = (row: ShopCommissionSummaryItem) => {
|
||||
const getActions = (row: ShopFundSummaryItem) => {
|
||||
const actions: any[] = []
|
||||
|
||||
if (hasAuth('agent_commission:detail')) {
|
||||
@@ -597,6 +694,8 @@
|
||||
loadCommissionRecords()
|
||||
} else if (newTab === 'withdrawal') {
|
||||
loadWithdrawalRecords()
|
||||
} else if (newTab === 'mainWallet') {
|
||||
loadMainWalletRecords()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -691,6 +790,43 @@
|
||||
loadWithdrawalRecords()
|
||||
}
|
||||
|
||||
// 加载预充值钱包流水
|
||||
const loadMainWalletRecords = async () => {
|
||||
if (!currentShop.value) return
|
||||
|
||||
mainWalletLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: mainWalletPagination.page,
|
||||
pageSize: mainWalletPagination.pageSize
|
||||
}
|
||||
const res = await CommissionService.getMainWalletTransactions(
|
||||
currentShop.value.shop_id,
|
||||
params
|
||||
)
|
||||
if (res.code === 0) {
|
||||
mainWalletRecords.value = res.data.items || []
|
||||
mainWalletPagination.total = res.data.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
ElMessage.error('获取预充值钱包流水失败')
|
||||
} finally {
|
||||
mainWalletLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 预充值钱包流水分页
|
||||
const handleMainWalletSizeChange = (newPageSize: number) => {
|
||||
mainWalletPagination.pageSize = newPageSize
|
||||
loadMainWalletRecords()
|
||||
}
|
||||
|
||||
const handleMainWalletCurrentChange = (newCurrentPage: number) => {
|
||||
mainWalletPagination.page = newCurrentPage
|
||||
loadMainWalletRecords()
|
||||
}
|
||||
|
||||
// 处理佣金修正
|
||||
const handleResolveCommission = (
|
||||
row: ShopCommissionRecordItem,
|
||||
|
||||
@@ -218,11 +218,19 @@
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatDateTime, formatMoney } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'MyCommission' })
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户的 shop_id
|
||||
const currentShopId = computed(() => userStore.userInfo?.shop_id)
|
||||
|
||||
// 如果没有 shop_id,显示提示
|
||||
const hasShopId = computed(() => !!currentShopId.value)
|
||||
|
||||
// 标签页
|
||||
const activeTab = ref('commission')
|
||||
@@ -378,6 +386,11 @@
|
||||
|
||||
// 获取佣金明细
|
||||
const getCommissionList = async () => {
|
||||
if (!currentShopId.value) {
|
||||
ElMessage.warning('未找到店铺信息')
|
||||
return
|
||||
}
|
||||
|
||||
commissionLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
@@ -388,7 +401,7 @@
|
||||
start_time: commissionSearchForm.start_time || undefined,
|
||||
end_time: commissionSearchForm.end_time || undefined
|
||||
} as CommissionRecordQueryParams
|
||||
const res = await CommissionService.getMyCommissionRecords(params)
|
||||
const res = await CommissionService.getShopCommissionRecords(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
commissionList.value = res.data.items || []
|
||||
commissionPagination.total = res.data.total || 0
|
||||
@@ -566,6 +579,11 @@
|
||||
|
||||
// 获取提现记录
|
||||
const getWithdrawalList = async () => {
|
||||
if (!currentShopId.value) {
|
||||
ElMessage.warning('未找到店铺信息')
|
||||
return
|
||||
}
|
||||
|
||||
withdrawalLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
@@ -575,7 +593,7 @@
|
||||
start_time: withdrawalSearchForm.start_time || undefined,
|
||||
end_time: withdrawalSearchForm.end_time || undefined
|
||||
} as WithdrawalRequestQueryParams
|
||||
const res = await CommissionService.getMyWithdrawalRequests(params)
|
||||
const res = await CommissionService.getShopWithdrawalRequests(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
withdrawalList.value = res.data.items || []
|
||||
withdrawalPagination.total = res.data.total || 0
|
||||
@@ -695,6 +713,10 @@
|
||||
// 提交提现申请
|
||||
const handleSubmitWithdrawal = async () => {
|
||||
if (!withdrawalFormRef.value) return
|
||||
if (!currentShopId.value) {
|
||||
ElMessage.warning('未找到店铺信息')
|
||||
return
|
||||
}
|
||||
|
||||
await withdrawalFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
@@ -713,7 +735,7 @@
|
||||
params.bank_name = withdrawalForm.bank_name
|
||||
}
|
||||
|
||||
await CommissionService.submitWithdrawalRequest(params)
|
||||
await CommissionService.submitShopWithdrawalRequest(currentShopId.value, params)
|
||||
ElMessage.success('提现申请提交成功')
|
||||
withdrawalDialogVisible.value = false
|
||||
|
||||
@@ -735,10 +757,28 @@
|
||||
|
||||
// 加载佣金概览
|
||||
const loadSummary = async () => {
|
||||
if (!currentShopId.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await CommissionService.getMyCommissionSummary()
|
||||
if (res.code === 0) {
|
||||
summary.value = res.data
|
||||
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
|
||||
const res = await CommissionService.getShopFundSummary({
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
})
|
||||
if (res.code === 0 && res.data.items && res.data.items.length > 0) {
|
||||
// 从结果中找到当前用户的店铺数据
|
||||
const myShopData = res.data.items.find(item => item.shop_id === currentShopId.value)
|
||||
if (myShopData) {
|
||||
summary.value = {
|
||||
total_commission: myShopData.total_commission,
|
||||
available_commission: myShopData.available_commission,
|
||||
frozen_commission: myShopData.frozen_commission,
|
||||
withdrawing_commission: myShopData.withdrawing_commission,
|
||||
withdrawn_commission: myShopData.withdrawn_commission
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -755,6 +795,10 @@
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (!hasShopId.value) {
|
||||
ElMessage.warning('当前账号未关联店铺,无法查看佣金信息')
|
||||
return
|
||||
}
|
||||
loadSummary()
|
||||
getCommissionList()
|
||||
})
|
||||
|
||||
@@ -87,10 +87,16 @@
|
||||
<script setup lang="ts">
|
||||
import { CommissionService } from '@/api/modules'
|
||||
import type { MyCommissionSummary } from '@/types/api/commission'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatMoney } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'CommissionSummaryWidget' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户的 shop_id
|
||||
const currentShopId = computed(() => userStore.userInfo?.shop_id)
|
||||
|
||||
// 错误信息
|
||||
const errorMsg = ref<string>('')
|
||||
|
||||
@@ -105,13 +111,33 @@
|
||||
|
||||
// 加载佣金概览
|
||||
const loadSummary = async () => {
|
||||
if (!currentShopId.value) {
|
||||
errorMsg.value = '当前账号未关联店铺'
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await CommissionService.getMyCommissionSummary()
|
||||
if (res.code === 0) {
|
||||
summary.value = res.data
|
||||
errorMsg.value = ''
|
||||
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
|
||||
const res = await CommissionService.getShopFundSummary({
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
})
|
||||
if (res.code === 0 && res.data.items && res.data.items.length > 0) {
|
||||
// 从结果中找到当前用户的店铺数据
|
||||
const myShopData = res.data.items.find(item => item.shop_id === currentShopId.value)
|
||||
if (myShopData) {
|
||||
summary.value = {
|
||||
total_commission: myShopData.total_commission,
|
||||
available_commission: myShopData.available_commission,
|
||||
frozen_commission: myShopData.frozen_commission,
|
||||
withdrawing_commission: myShopData.withdrawing_commission,
|
||||
withdrawn_commission: myShopData.withdrawn_commission
|
||||
}
|
||||
errorMsg.value = ''
|
||||
} else {
|
||||
errorMsg.value = '未找到佣金数据'
|
||||
}
|
||||
} else {
|
||||
// 显示错误信息
|
||||
errorMsg.value = res.msg || '获取佣金概览失败'
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -120,11 +120,10 @@
|
||||
</ElOption>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="'套餐'" prop="package_ids">
|
||||
<ElFormItem :label="'套餐'" prop="package_id">
|
||||
<ElSelect
|
||||
v-model="createForm.package_ids"
|
||||
v-model="createForm.package_id"
|
||||
:placeholder="'请选择套餐'"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
@@ -300,8 +299,7 @@
|
||||
OrderCommissionStatus,
|
||||
StandaloneIotCard,
|
||||
Device,
|
||||
PackageResponse,
|
||||
PurchaseCheckRequest
|
||||
PackageResponse
|
||||
} from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
@@ -531,7 +529,7 @@
|
||||
|
||||
const createForm = reactive<CreateOrderRequest>({
|
||||
order_type: 'single_card',
|
||||
package_ids: [],
|
||||
package_id: 0,
|
||||
iot_card_id: null,
|
||||
device_id: null,
|
||||
payment_method: 'wallet', // 默认使用钱包支付
|
||||
@@ -977,7 +975,7 @@
|
||||
|
||||
// 重置表单数据到初始值
|
||||
createForm.order_type = 'single_card'
|
||||
createForm.package_ids = []
|
||||
createForm.package_id = 0
|
||||
createForm.iot_card_id = null
|
||||
createForm.device_id = null
|
||||
createForm.payment_method = 'wallet'
|
||||
@@ -1030,38 +1028,10 @@
|
||||
identifier = selectedDevice.virtual_no
|
||||
}
|
||||
|
||||
// 调用套餐购买预检接口
|
||||
const checkData: PurchaseCheckRequest = {
|
||||
order_type: createForm.order_type!,
|
||||
resource_id:
|
||||
createForm.order_type === 'single_card'
|
||||
? createForm.iot_card_id!
|
||||
: createForm.device_id!,
|
||||
package_ids: createForm.package_ids
|
||||
}
|
||||
|
||||
const checkResponse = await OrderService.purchaseCheck(checkData)
|
||||
|
||||
// 检查预检结果
|
||||
if (checkResponse.code === 0 && checkResponse.data) {
|
||||
const checkResult = checkResponse.data
|
||||
|
||||
// 如果需要强充,显示确认对话框
|
||||
if (checkResult.need_force_recharge) {
|
||||
const confirmMessage = `${checkResult.message || '钱包余额不足'}\n\n套餐总价: ¥${(checkResult.total_package_amount! / 100).toFixed(2)}\n需要强充: ¥${(checkResult.force_recharge_amount! / 100).toFixed(2)}\n钱包到账: ¥${(checkResult.wallet_credit! / 100).toFixed(2)}\n实际支付: ¥${(checkResult.actual_payment! / 100).toFixed(2)}\n\n是否继续创建订单?`
|
||||
|
||||
await ElMessageBox.confirm(confirmMessage, '购买预检提示', {
|
||||
confirmButtonText: '继续创建',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 预检通过或用户确认后,创建订单
|
||||
// 创建订单
|
||||
const data: CreateOrderRequest = {
|
||||
identifier,
|
||||
package_ids: createForm.package_ids,
|
||||
package_id: createForm.package_id,
|
||||
payment_method: createForm.payment_method
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user