Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-packages
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
许振钊
ydl-packages
Commits
b669e734
Commit
b669e734
authored
Oct 23, 2023
by
zhengxiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: modify any
parent
73a41446
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletions
+11
-1
Payment.ts
packages/toolkit/src/Payment/Payment.ts
+11
-1
No files found.
packages/toolkit/src/Payment/Payment.ts
View file @
b669e734
...
...
@@ -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
})
:
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment