forked from gxwebsoft/mp-10550
- 配置文件中更新测试环境API基础URL - 添加ShopDealerWithdrawCreateResult类型定义以支持微信转账返回的package_info - 修改addShopDealerWithdraw函数以处理微信转账流程的特殊返回值 - 实现extractPackageInfo、canRequestMerchantTransferConfirm和requestMerchantTransferConfirm辅助函数 - 在微信钱包提现流程中集成商户转账确认页面调用 - 添加对微信小程序环境的检测和错误处理 - 更新快速金额选项,增加1元选项 - 修改微信提现提示文字,说明需要确认收款的流程
115 lines
2.9 KiB
TypeScript
115 lines
2.9 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { ShopDealerWithdraw, ShopDealerWithdrawParam } from './model';
|
|
|
|
// WeChat transfer v3: backend may return `package_info` for MiniProgram to open the
|
|
// "confirm receipt" page via `wx.requestMerchantTransfer`.
|
|
export type ShopDealerWithdrawCreateResult =
|
|
| string
|
|
| {
|
|
package_info?: string;
|
|
packageInfo?: string;
|
|
[k: string]: any;
|
|
}
|
|
| null
|
|
| undefined;
|
|
|
|
/**
|
|
* 分页查询分销商提现明细表
|
|
*/
|
|
export async function pageShopDealerWithdraw(params: ShopDealerWithdrawParam) {
|
|
const res = await request.get<ApiResult<PageResult<ShopDealerWithdraw>>>(
|
|
'/shop/shop-dealer-withdraw/page',
|
|
params
|
|
);
|
|
if (res.code === 0) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 查询分销商提现明细表列表
|
|
*/
|
|
export async function listShopDealerWithdraw(params?: ShopDealerWithdrawParam) {
|
|
const res = await request.get<ApiResult<ShopDealerWithdraw[]>>(
|
|
'/shop/shop-dealer-withdraw',
|
|
params
|
|
);
|
|
if (res.code === 0 && res.data) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 添加分销商提现明细表
|
|
*/
|
|
export async function addShopDealerWithdraw(data: ShopDealerWithdraw): Promise<ShopDealerWithdrawCreateResult> {
|
|
const res = await request.post<ApiResult<any>>(
|
|
'/shop/shop-dealer-withdraw',
|
|
data
|
|
);
|
|
if (res.code === 0) {
|
|
// Some backends return `message`, while WeChat transfer flow returns `data.package_info`.
|
|
return res.data ?? res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 修改分销商提现明细表
|
|
*/
|
|
export async function updateShopDealerWithdraw(data: ShopDealerWithdraw) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/shop/shop-dealer-withdraw',
|
|
data
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 删除分销商提现明细表
|
|
*/
|
|
export async function removeShopDealerWithdraw(id?: number) {
|
|
const res = await request.del<ApiResult<unknown>>(
|
|
'/shop/shop-dealer-withdraw/' + id
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除分销商提现明细表
|
|
*/
|
|
export async function removeBatchShopDealerWithdraw(data: (number | undefined)[]) {
|
|
const res = await request.del<ApiResult<unknown>>(
|
|
'/shop/shop-dealer-withdraw/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询分销商提现明细表
|
|
*/
|
|
export async function getShopDealerWithdraw(id: number) {
|
|
const res = await request.get<ApiResult<ShopDealerWithdraw>>(
|
|
'/shop/shop-dealer-withdraw/' + id
|
|
);
|
|
if (res.code === 0 && res.data) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|