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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
package.json
packages/toolkit/package.json
+4
-2
Defined.ts
packages/toolkit/src/Payment/Defined.ts
+3
-2
Payment.ts
packages/toolkit/src/Payment/Payment.ts
+15
-15
No files found.
packages/toolkit/package.json
View file @
2c29814e
{
{
"name"
:
"@ydl-packages/toolkit"
,
"name"
:
"@ydl-packages/toolkit"
,
"version"
:
"1.0.1-next.
25
"
,
"version"
:
"1.0.1-next.
31
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"./dist/index.umd.js"
,
"main"
:
"./dist/index.umd.js"
,
"scripts"
:
{
"scripts"
:
{
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
"test"
:
"npx jest __tests__"
,
"test"
:
"npx jest __tests__"
,
"doc"
:
"npx typedoc"
,
"doc"
:
"npx typedoc"
,
"prepublishOnly"
:
"npm run lib"
,
"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"
:
[
"keywords"
:
[
"pay"
,
"pay"
,
...
...
packages/toolkit/src/Payment/Defined.ts
View file @
2c29814e
...
@@ -13,7 +13,7 @@ export type BackInfo = {
...
@@ -13,7 +13,7 @@ export type BackInfo = {
orderId
:
number
;
orderId
:
number
;
payId
:
number
payId
:
number
}
}
export
type
OrderStateCallBack
=
(
params
:
BackInfo
&
{
isPay
:
boolean
})
=>
void
export
type
OrderStateCallBack
=
(
params
:
BackInfo
&
{
isPay
:
boolean
,
isLimit
?:
boolean
})
=>
void
export
type
PaymentParams
=
{
export
type
PaymentParams
=
{
payChannels
?:
PayChannel
[],
payChannels
?:
PayChannel
[],
...
@@ -185,6 +185,6 @@ export const FULL_PAY_METHODS: PayMethod[] = [
...
@@ -185,6 +185,6 @@ export const FULL_PAY_METHODS: PayMethod[] = [
label
:
'花呗支付'
,
label
:
'花呗支付'
,
value
:
PayType
.
HUABEI_BALANCE
,
value
:
PayType
.
HUABEI_BALANCE
,
icon
:
'https://static.ydlcdn.com/m/order/icon-pay-hb.png'
,
icon
:
'https://static.ydlcdn.com/m/order/icon-pay-hb.png'
,
disabled
:
false
disabled
:
false
}
}
]
]
\ No newline at end of file
packages/toolkit/src/Payment/Payment.ts
View file @
2c29814e
...
@@ -161,15 +161,15 @@ export class Payment {
...
@@ -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
let
payBalance
=
0
,
payAmount
=
0
if
(
balance
===
0
)
{
if
(
payType
==
PayType
.
BALANCE
)
{
pay
Amount
=
totalAmount
pay
Balance
=
totalAmount
;
}
else
if
(
balance
>
0
&&
balance
<
totalAmount
&&
this
.
supportCombination
)
{
payAmount
=
0
;
payBalance
=
balance
}
payAmount
=
subtract
(
bignumber
(
totalAmount
),
bignumber
(
balance
)).
toNumber
()
else
{
}
else
{
payBalance
=
0
;
pay
Balance
=
totalAmount
pay
Amount
=
totalAmount
;
}
}
return
{
payAmount
,
payBalance
}
return
{
payAmount
,
payBalance
}
}
}
...
@@ -243,7 +243,7 @@ export class Payment {
...
@@ -243,7 +243,7 @@ export class Payment {
orderId
,
orderId
,
payType
,
payType
,
payId
,
payId
,
...
this
.
computeAmount
(
totalAmount
,
this
.
balance
),
...
this
.
computeAmount
(
totalAmount
,
payType
)
}
}
if
(
payChannel
!==
null
)
{
if
(
payChannel
!==
null
)
{
doUnifiedParams
.
payChannel
=
payChannel
doUnifiedParams
.
payChannel
=
payChannel
...
@@ -319,7 +319,7 @@ export class Payment {
...
@@ -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
[,
queryString
]
=
window
.
location
.
href
.
split
(
'?'
)
const
query
=
queryString
?
qs
.
parse
(
queryString
,
{
ignoreQueryPrefix
:
true
})
:
{}
const
query
=
queryString
?
qs
.
parse
(
queryString
,
{
ignoreQueryPrefix
:
true
})
:
{}
const
returnParams
:
BackInfo
=
{
payId
:
Number
(
query
[
BACK_PAY_ID
]),
orderId
:
Number
(
query
[
BACK_ORDER_ID
])}
const
returnParams
:
BackInfo
=
{
payId
:
Number
(
query
[
BACK_PAY_ID
]),
orderId
:
Number
(
query
[
BACK_ORDER_ID
])}
...
@@ -327,11 +327,11 @@ export class Payment {
...
@@ -327,11 +327,11 @@ export class Payment {
const
checkLoop
=
()
=>
{
const
checkLoop
=
()
=>
{
if
(
--
count
>
0
)
{
if
(
--
count
>
0
)
{
timer
=
setTimeout
(()
=>
{
timer
=
setTimeout
(()
=>
{
this
.
loopValidateOrderState
(
count
,
callBack
,
poll
t
ime
)
this
.
loopValidateOrderState
(
count
,
callBack
,
poll
T
ime
)
},
poll
t
ime
)
},
poll
T
ime
)
}
else
{
}
else
{
c
learInterval
(
timer
);
c
allBack
({
isPay
:
false
,
...
returnParams
,
isLimit
:
true
})
callBack
({
isPay
:
false
,
...
returnParams
}
)
timer
&&
clearTimeout
(
timer
)
}
}
}
}
if
(
query
[
BACK_PAY_ID
])
{
if
(
query
[
BACK_PAY_ID
])
{
...
@@ -340,8 +340,8 @@ export class Payment {
...
@@ -340,8 +340,8 @@ export class Payment {
payId
:
query
[
BACK_PAY_ID
]
payId
:
query
[
BACK_PAY_ID
]
})
})
if
(
res
.
code
===
'200'
&&
res
.
data
===
true
)
{
if
(
res
.
code
===
'200'
&&
res
.
data
===
true
)
{
clearInterval
(
timer
);
callBack
({
isPay
:
true
,
...
returnParams
})
callBack
({
isPay
:
true
,
...
returnParams
})
timer
&&
clearTimeout
(
timer
)
}
else
{
}
else
{
checkLoop
()
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