From 07d73df3d817d01ce47f6c7b7a8d8514cd389295 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期四, 13 三月 2025 10:19:44 +0800 Subject: [PATCH] release: @life-payment/core v0.0.3 --- packages/core/src/lifeRechargeServices.ts | 435 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 396 insertions(+), 39 deletions(-) diff --git a/packages/core/src/lifeRechargeServices.ts b/packages/core/src/lifeRechargeServices.ts index 19fd7f9..e62802a 100644 --- a/packages/core/src/lifeRechargeServices.ts +++ b/packages/core/src/lifeRechargeServices.ts @@ -1,37 +1,44 @@ -import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import { IRequest, BlLifeRechargeServicesOptions } from './types'; +import { BlLifeRechargeServicesOptions } from './types'; import { LifeRechargeConstants } from './lifeRechargeConstants'; +import { Request, IRequest } from 'senior-request'; +import { BlLifeRecharge } from './lifeRecharge'; export interface RequestConfig {} -export class BlLifeRechargeServices<T extends IRequest> { - private request: T; - request2: T; - constructor({ request, axiosOptions }: BlLifeRechargeServicesOptions<T>) { - this.request = request; - const axiosInstance = axios.create(axiosOptions); - // @ts-expect-error - this.request2 = (url: string, opts: any = { method: 'GET' }) => { - return new Promise((resolve, reject) => { - axiosInstance - .request({ ...opts, url }) - .then((res) => { - //@ts-ignore - resolve(res); - }) - .catch((error) => { - try { - // const handler = config?.errorConfig?.errorHandler; - // if (handler) { - // handler(error, opts, config); - // } - } catch (e) { - reject(e); +export class BlLifeRechargeServices<TResponse = any, TRequestOptions = any> { + private request: IRequest; + ctx: BlLifeRecharge<TResponse, TRequestOptions>; + + constructor( + ctx: BlLifeRecharge<TResponse, TRequestOptions>, + { axiosConfig }: BlLifeRechargeServicesOptions<TResponse, TRequestOptions> + ) { + this.ctx = ctx; + this.request = Request.create({ + ...axiosConfig, + // baseURL: process.env.NODE_ENV === 'development' ? '/' : 'https://api.81812333.com', + requestInterceptors: [ + [ + (config) => { + if (config.params) { + config.params.checkChannelId = this.ctx.accountModel.channlesNum; } - reject(error); - }); - }); - }; + if (config.data) { + config.data.checkChannelId = this.ctx.accountModel.channlesNum; + } + return config; + }, + ], + ...axiosConfig.requestInterceptors, + ], + timeout: 10 * 1000, + headers: { + Accept: 'application/json, text/plain, */*', + 'Content-Type': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + }, + withCredentials: true, + }); } async lifePayPhoneMesssageCodeLogin(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) { @@ -53,18 +60,38 @@ }); } - /** 鑾峰彇鐢佃垂闈㈠�� GET /api/LifePay/GetElectricParValue */ - async getElectricParValue(options?: RequestConfig) { + /** 鑾峰彇鐢佃垂鍏呭�煎尯鍩� GET /api/LifePay/GetElectricSupportArea */ + async getElectricSupportArea(body: ChannelsBaseInput, options?: RequestConfig) { + return this.request<ElectricSupportAreaResponse>('/api/LifePay/GetElectricSupportArea', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鑾峰彇鐢佃垂闈㈠�� POST /api/LifePay/GetElectricParValue */ + async getElectricParValue(body: ChannelsBaseInput, options?: RequestConfig) { return this.request<ElectricParValueResponse>('/api/LifePay/GetElectricParValue', { - method: 'GET', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, ...(options || {}), }); } /** 鑾峰彇璇濊垂闈㈠�� GET /api/LifePay/GetPhoneParValue */ - async getPhoneParValue(options?: RequestConfig) { + async getPhoneParValue(body: ChannelsBaseInput, options?: RequestConfig) { return this.request<PhoneParValueResponse>('/api/LifePay/GetPhoneParValue', { - method: 'GET', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, ...(options || {}), }); } @@ -100,14 +127,15 @@ } /** 鏍规嵁璁㈠崟鍙疯幏鍙栨敮浠樼姸鎬� GET /api/LifePay/GetPayStatusByOrderNo */ - async getPayStatusByOrderNo(params: APIgetPayStatusByOrderNoParams, options?: RequestConfig) { + async getPayStatusByOrderNo(body: GetPayStatusByOrderNoInput, options?: RequestConfig) { return this.request<LifeRechargeConstants.LifePayStatusEnum>( '/api/LifePay/GetPayStatusByOrderNo', { - method: 'GET', - params: { - ...params, + method: 'POST', + headers: { + 'Content-Type': 'application/json', }, + data: body, ...(options || {}), } ); @@ -162,13 +190,138 @@ ...(options || {}), }); } + + /** 鑾峰彇鎴戠殑鍏ㄩ儴鎴峰彿鍒楄〃 POST /api/LifePay/GetUserAccountAllList */ + async getUserAccountAllList(body: QueryUserAccountAllListInput, options?: RequestConfig) { + return this.request<UserAccountListOutput[]>('/api/LifePay/GetUserAccountAllList', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鑾峰彇鎴戠殑鎴峰彿鍒楄〃 POST /api/LifePay/GetUserAccountList */ + async getUserAccountList(body: QueryUserAccountListInput, options?: RequestConfig) { + return this.request<UserAccountListOutputPageOutput>('/api/LifePay/GetUserAccountList', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 娣诲姞鎴栦慨鏀规垜鐨勬埛鍙� POST /api/LifePay/AddUpdateUserAccount */ + async addUpdateUserAccount(body: AddUpdateUserAccountInput, options?: RequestConfig) { + return this.request<number>('/api/LifePay/AddUpdateUserAccount', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鍒涘缓鐢熸椿缂磋垂鐕冩皵璁㈠崟 POST /api/LifePay/CreateLifePayGasOrder */ + async createLifePayGasOrder(body: LifeGasDataCreateLifePayOrderInput, options?: RequestConfig) { + return this.request<CreateLifePayOrderOutput>('/api/LifePay/CreateLifePayGasOrder', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鑾峰彇鐕冩皵闈㈠�� GET /api/LifePay/GetGasParValue */ + async getGasParValue(body: ChannelsBaseInput, options?: RequestConfig) { + return this.request<GasParValueResponse>('/api/LifePay/GetGasParValue', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鐢ㄦ埛鍙戣捣鐢熸椿缂磋垂閫�娆� POST /api/LifePay/RefundUserLifePayOrder */ + async refundUserLifePayOrder(body: RefundUserLifePayOrderInput, options?: RequestConfig) { + return this.request<number>('/api/LifePay/RefundUserLifePayOrder', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); + } + + /** 鍒犻櫎鎴戠殑鎴峰彿 POST /api/LifePay/DeleteUserAccount */ + async deleteUserAccount( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: APIdeleteUserAccountParams, + options?: RequestConfig + ) { + return this.request<number>('/api/LifePay/DeleteUserAccount', { + method: 'POST', + params: { + ...params, + }, + ...(options || {}), + }); + } + + /** 鑾峰彇鎴戠殑鎴峰彿璇︽儏 GET /api/LifePay/GetUserAccountDetail */ + async getUserAccountDetail( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: APIgetUserAccountDetailParams, + options?: RequestConfig + ) { + return this.request<UserAccountOutput>('/api/LifePay/GetUserAccountDetail', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); + } + + /** 鑾峰彇鎴戠殑璁㈠崟璇︽儏 GET /api/LifePay/GetUserLifePayOrderDetail */ + async getUserLifePayOrderDetail( + // 鍙犲姞鐢熸垚鐨凱aram绫诲瀷 (闈瀊ody鍙傛暟swagger榛樿娌℃湁鐢熸垚瀵硅薄) + params: APIgetUserLifePayOrderDetailParams, + options?: RequestConfig + ) { + return this.request<UserLifePayOrderOutput>('/api/LifePay/GetUserLifePayOrderDetail', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); + } + + /** 鎼滅储绠$悊--鍒楄〃(鍖哄煙绠$悊) GET /api/Area/GetRegionalManagementList */ + async getRegionalManagementList(options?: RequestConfig) { + return this.request<AreaInfo[]>('/api/Area/GetRegionalManagementList', { + method: 'GET', + ...(options || {}), + }); + } } export interface PhoneMesssageCodeLoginInput { /** 鎵嬫満鍙� */ phoneNumber: string; /** 楠岃瘉鐮� */ - code: string; + // code: string; } export interface LifePayRateListOutput { @@ -225,6 +378,8 @@ export interface LifePhoneDataCreateLifePayOrderInput { userId?: string; + /** 娓犻亾Id */ + channelId?: string; productData?: LifePhoneData; } @@ -245,6 +400,8 @@ export interface LifeElectricDataCreateLifePayOrderInput { userId?: string; + /** 娓犻亾Id */ + channelId?: string; productData?: LifeElectricData; } @@ -334,8 +491,44 @@ creationTime?: string; /** 閫�娆炬椂闂� */ refundTime?: string; + /** 閫�娆惧嚟璇� */ + refundCredentialsImgUrl?: string; + refundApplyRemark?: string; + refundCheckRemark?: string; + /** 娓犻亾娴佹按鍙� */ + acoolyOrderNo?: string; } +export interface ElectricSupportAreaResponse { + success?: boolean; + requestNo?: string; + partnerId?: string; + service?: string; + version?: string; + protocol?: string; + context?: string; + ext?: any; + code?: string; + message?: string; + detail?: string; + electricAreaList?: ElectricSupportAreaListOutput[]; +} + +export interface ElectricSupportAreaListOutput { + childCityList?: ElectricSupportAreaChildCityListOutput[]; + cityName?: string; + cityParentId?: string; + ciytId?: string; + electricType?: string; + parValue?: string[]; + rate?: number; +} + +export interface ElectricSupportAreaChildCityListOutput { + cityName?: string; + cityParentId?: string; + ciytId?: string; +} export interface APIgetLifePayWxIndentityParams { /** 鐢ㄦ埛鐧诲綍鍑瘉 */ code?: string; @@ -356,6 +549,7 @@ lifePayType?: LifeRechargeConstants.LifePayTypeEnum; openId?: string; attach?: string; + payAppId?: string; } export interface ModelPaymentMiniPay { @@ -367,3 +561,166 @@ timeExpire?: string; message?: string; } + +export interface QueryUserAccountAllListInput { + /** 鐢ㄦ埛Id */ + userId?: string; + lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum; +} + +export interface UserAccountListOutput { + id?: string; + lifePayType?: LifeRechargeConstants.LifePayOrderTypeEnum; + /** 杩愯惀鍟� */ + operators?: string; + /** 鎵嬫満鍙�/鎴峰彿 */ + content?: string; + /** 鐪� */ + province?: string; + /** 甯� */ + city?: string; + /** 鎷撳睍瀛楁锛堢數璐圭被鍨嬶級 */ + extraProperties?: string; + /** 澶囨敞 */ + remark?: string; + /** 鍒涘缓鏃堕棿 */ + creationTime?: string; + isDeleted?: boolean; +} + +export interface AddUpdateUserAccountInput { + id?: string; + /** 鐢ㄦ埛缂栧彿 */ + userId?: string; + lifePayType?: LifeRechargeConstants.LifePayOrderTypeEnum; + /** 杩愯惀鍟� */ + operators?: string; + /** 鎵嬫満鍙�/鎴峰彿 */ + content?: string; + /** 鐪� */ + province?: string; + /** 甯� */ + city?: string; + /** 鎷撳睍瀛楁锛堢數璐圭被鍨嬶級 */ + extraProperties?: string; + /** 澶囨敞 */ + remark?: string; +} + +export interface LifeGasDataCreateLifePayOrderInput { + userId?: string; + /** 娓犻亾Id */ + channelId?: string; + productData?: LifeGasData; +} + +export interface LifeGasData { + /** 鍏呭�奸潰棰濓紝鍗曚綅涓哄厓銆� */ + parValue: number; + /** 澶╃劧姘斿叕鍙哥被鍨嬶紝"zhong_ran"浠h〃涓噧鐕冩皵锛�"bei_jing"浠h〃鍖椾含鐕冩皵銆� */ + gasOrgType: string; + /** 鐕冩皵鎴峰彿 */ + gasAccount: string; + /** 鐪佷唤 */ + province: string; + /** 鍩庡競 */ + city?: string; +} + +export interface GasParValueResponse { + success?: boolean; + requestNo?: string; + partnerId?: string; + service?: string; + version?: string; + protocol?: string; + context?: string; + ext?: any; + code?: string; + message?: string; + detail?: string; + gasParValue?: GasParValueOutput[]; +} + +export interface GasParValueOutput { + gasOrgName?: string; + gasOrgCode?: string; + parValue?: string[]; + rate?: number; + comments?: string; +} + +export interface RefundUserLifePayOrderInput { + id?: string; + /** 鐢ㄦ埛Id */ + userId?: string; + refundApplyRemark?: string; +} + +export interface QueryUserAccountListInput { + pageModel?: Pagination; + /** 鐢ㄦ埛Id */ + userId?: string; + lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum; +} + +export interface UserAccountListOutputPageOutput { + pageModel?: Pagination; + objectData?: any; + data?: UserAccountListOutput[]; +} + +export interface APIdeleteUserAccountParams { + id?: string; +} + +export interface APIgetUserAccountDetailParams { + id?: string; +} + +export interface UserAccountOutput { + id?: string; + lifePayType?: LifeRechargeConstants.LifePayOrderTypeEnum; + /** 杩愯惀鍟� */ + operators?: string; + /** 鎵嬫満鍙�/鎴峰彿 */ + content?: string; + /** 鐪� */ + province?: string; + /** 甯� */ + city?: string; + /** 鎷撳睍瀛楁锛堢數璐圭被鍨嬶級 */ + extraProperties?: string; + /** 澶囨敞 */ + remark?: string; + /** 鍒涘缓鏃堕棿 */ + creationTime?: string; + isDeleted?: boolean; +} + +export interface APIgetUserLifePayOrderDetailParams { + orderNo?: string; +} + +export interface ChannelsBaseInput { + checkChannelId?: string; +} + +export interface AreaInfo { + areaCode?: number; + parentId?: number; + areaName?: string; + /** 1鐪� 2甯� 3鍖� 4闀� */ + layer?: number; + sort?: number; + children?: AreaInfo[]; + /** 绠�鏄撴嫾闊� */ + simpleSpelling?: string; + /** 蹇�熸绱� */ + quickQuery?: string; +} + +export interface GetPayStatusByOrderNoInput { + checkChannelId?: string; + orderNo?: string; +} -- Gitblit v1.9.1