Commit b669e734 by zhengxiao

feat: modify any

parent 73a41446
......@@ -28,7 +28,7 @@ const requestForJava = defaultRequest
export class Payment {
balance = 0;
limitPayChannels: PayChannel[] = [];
isEnabledCombinationPay: boolean = true; // 配置的是否开组合支付
isEnabledCombinationPay: boolean = true; // 配置的是否开组合支付
supportCombination: boolean = true; // 余额开关的改变是否支持组合支付
constructor(paymentParams?: PaymentParams) {
this.limitPayChannels = paymentParams?.payChannels ?? Object.keys(PayChannel).map(key => key) as PayChannel[];
......@@ -41,10 +41,12 @@ export class Payment {
}
}
// 原型方法设置是否支持组合支付
setIsSupportCombination (value: boolean) {
this.supportCombination = value
}
// 获取余额
getBalance() {
return new Promise<number|null>(async (resolve, reject) =>{
try {
......@@ -83,6 +85,7 @@ export class Payment {
})
}
// 获取支付方式列表
getPayMethodList (totalAmount:number, doctorId?:string, orderId?:string) {
// 计算支付方式列表
const List = this.supportCombination ? this.getPayMethodListForCombination(totalAmount) : this.getPayMethodListForNotCombination(totalAmount)
......@@ -102,6 +105,7 @@ export class Payment {
})
}
// 不支持组合支付的情况下获取支付方式列表
private getPayMethodListForNotCombination(totalAmount: number): PayMethod[] {
return FULL_PAY_METHODS.filter(({value}) => {
switch (value) {
......@@ -133,6 +137,8 @@ export class Payment {
return item
})
}
// 支持组合支付的情况下获取支付方式列表
private getPayMethodListForCombination(totalAmount: number): PayMethod[] {
return FULL_PAY_METHODS.filter(({value}) => {
switch (value) {
......@@ -164,6 +170,7 @@ export class Payment {
})
}
// 计算非组合支付金额
computeAmount(totalAmount: number, payType: PayType): { payAmount: number, payBalance: number } {
let payBalance = 0, payAmount = 0
if(payType == PayType.BALANCE){
......@@ -177,6 +184,7 @@ export class Payment {
return {payAmount, payBalance}
}
// 计算组合支付金额
computeAmountForCombination(totalAmount: number, balance: number = 0): { payAmount: number, payBalance: number } {
console.log("🚀 ~ file: Payment.ts:171 ~ Payment ~ computeAmountForCombination ~ balance:", balance)
let payBalance = 0, payAmount = 0
......@@ -193,6 +201,7 @@ export class Payment {
return {payAmount, payBalance}
}
// 去支付
async toPay(params: ToPayParams): Promise<ToPayReturns> {
console.log("🚀 ~ file: Payment.ts:179 ~ Payment ~ toPay ~ params:", params)
const {totalAmount, payType, returnUrl, orderId, subOrderIds, redirectUrl} = params
......@@ -341,6 +350,7 @@ export class Payment {
})
}
// 支付结果轮询
static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack, pollTime = 3000): Promise<void> {
const [, queryString] = window.location.href.split('?')
const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment