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
2c29814e
Commit
2c29814e
authored
Sep 14, 2022
by
郑炬波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: fix
parent
1433b669
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
18 deletions
+20
-18
package.json
packages/toolkit/package.json
+4
-2
Defined.ts
packages/toolkit/src/Payment/Defined.ts
+1
-1
Payment.ts
packages/toolkit/src/Payment/Payment.ts
+15
-15
No files found.
packages/toolkit/package.json
View file @
2c29814e
{
"name"
:
"@ydl-packages/toolkit"
,
"version"
:
"1.0.1-next.
25
"
,
"version"
:
"1.0.1-next.
31
"
,
"description"
:
""
,
"main"
:
"./dist/index.umd.js"
,
"scripts"
:
{
...
...
@@ -8,7 +8,9 @@
"test"
:
"npx jest __tests__"
,
"doc"
:
"npx typedoc"
,
"prepublishOnly"
:
"npm run lib"
,
"commit"
:
"git add . && npx cz-customizable"
"commit"
:
"git add . && npx cz-customizable"
,
"async"
:
"npm run lib && yalc push"
,
"watch"
:
"nodemon --ignore dist/ --ignore node_modules/ --watch src/ -C -e ts --debug -x npm run async"
},
"keywords"
:
[
"pay"
,
...
...
packages/toolkit/src/Payment/Defined.ts
View file @
2c29814e
...
...
@@ -13,7 +13,7 @@ export type BackInfo = {
orderId
:
number
;
payId
:
number
}
export
type
OrderStateCallBack
=
(
params
:
BackInfo
&
{
isPay
:
boolean
})
=>
void
export
type
OrderStateCallBack
=
(
params
:
BackInfo
&
{
isPay
:
boolean
,
isLimit
?:
boolean
})
=>
void
export
type
PaymentParams
=
{
payChannels
?:
PayChannel
[],
...
...
packages/toolkit/src/Payment/Payment.ts
View file @
2c29814e
...
...
@@ -161,15 +161,15 @@ export class Payment {
})
}
computeAmount
(
totalAmount
:
number
,
balance
:
number
=
0
):
{
payAmount
:
number
,
payBalance
:
number
}
{
computeAmount
(
totalAmount
:
number
,
payType
:
PayType
):
{
payAmount
:
number
,
payBalance
:
number
}
{
let
payBalance
=
0
,
payAmount
=
0
if
(
balance
===
0
)
{
pay
Amount
=
totalAmount
}
else
if
(
balance
>
0
&&
balance
<
totalAmount
&&
this
.
supportCombination
)
{
payBalance
=
balance
payAmount
=
subtract
(
bignumber
(
totalAmount
),
bignumber
(
balance
)).
toNumber
()
}
else
{
pay
Balance
=
totalAmount
if
(
payType
==
PayType
.
BALANCE
)
{
pay
Balance
=
totalAmount
;
payAmount
=
0
;
}
else
{
payBalance
=
0
;
pay
Amount
=
totalAmount
;
}
return
{
payAmount
,
payBalance
}
}
...
...
@@ -243,7 +243,7 @@ export class Payment {
orderId
,
payType
,
payId
,
...
this
.
computeAmount
(
totalAmount
,
this
.
balance
),
...
this
.
computeAmount
(
totalAmount
,
payType
)
}
if
(
payChannel
!==
null
)
{
doUnifiedParams
.
payChannel
=
payChannel
...
...
@@ -319,7 +319,7 @@ export class Payment {
})
}
static
async
loopValidateOrderState
(
count
=
0
,
callBack
:
OrderStateCallBack
,
poll
t
ime
=
3000
):
Promise
<
void
>
{
static
async
loopValidateOrderState
(
count
=
0
,
callBack
:
OrderStateCallBack
,
poll
T
ime
=
3000
):
Promise
<
void
>
{
const
[,
queryString
]
=
window
.
location
.
href
.
split
(
'?'
)
const
query
=
queryString
?
qs
.
parse
(
queryString
,
{
ignoreQueryPrefix
:
true
})
:
{}
const
returnParams
:
BackInfo
=
{
payId
:
Number
(
query
[
BACK_PAY_ID
]),
orderId
:
Number
(
query
[
BACK_ORDER_ID
])}
...
...
@@ -327,11 +327,11 @@ export class Payment {
const
checkLoop
=
()
=>
{
if
(
--
count
>
0
)
{
timer
=
setTimeout
(()
=>
{
this
.
loopValidateOrderState
(
count
,
callBack
,
poll
t
ime
)
},
poll
t
ime
)
this
.
loopValidateOrderState
(
count
,
callBack
,
poll
T
ime
)
},
poll
T
ime
)
}
else
{
c
learInterval
(
timer
);
callBack
({
isPay
:
false
,
...
returnParams
}
)
c
allBack
({
isPay
:
false
,
...
returnParams
,
isLimit
:
true
})
timer
&&
clearTimeout
(
timer
)
}
}
if
(
query
[
BACK_PAY_ID
])
{
...
...
@@ -340,8 +340,8 @@ export class Payment {
payId
:
query
[
BACK_PAY_ID
]
})
if
(
res
.
code
===
'200'
&&
res
.
data
===
true
)
{
clearInterval
(
timer
);
callBack
({
isPay
:
true
,
...
returnParams
})
timer
&&
clearTimeout
(
timer
)
}
else
{
checkLoop
()
}
...
...
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