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
ed9acb52
Commit
ed9acb52
authored
Oct 28, 2022
by
郑炬波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 去payId
parent
332f2f17
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
22 deletions
+11
-22
hasBalance.test.ts
packages/toolkit/__tests__/payment/hasBalance.test.ts
+1
-1
notHaveBalance.test.ts
packages/toolkit/__tests__/payment/notHaveBalance.test.ts
+1
-1
units.test.ts
packages/toolkit/__tests__/payment/units.test.ts
+2
-5
package.json
packages/toolkit/package.json
+1
-1
API.ts
packages/toolkit/src/Payment/API.ts
+1
-1
Defined.ts
packages/toolkit/src/Payment/Defined.ts
+0
-4
Payment.ts
packages/toolkit/src/Payment/Payment.ts
+5
-9
No files found.
packages/toolkit/__tests__/payment/hasBalance.test.ts
View file @
ed9acb52
...
...
@@ -22,7 +22,7 @@ const globalDatabase: any = {
}
}
const
createOrder
=
async
():
Promise
<
{
orderId
:
number
,
title
:
string
,
payId
:
number
,
money
:
number
}
>
=>
{
const
createOrder
=
async
():
Promise
<
{
orderId
:
number
,
title
:
string
,
money
:
number
}
>
=>
{
const
res
=
await
defaultRequest
.
post
<
any
,
DefaultResponse
>
(
'https://testapi.ydl.com/api/consult/user/order/submitWorriesConsultOrder'
,
globalDatabase
.
MOCK_GOODS
)
return
res
.
data
}
...
...
packages/toolkit/__tests__/payment/notHaveBalance.test.ts
View file @
ed9acb52
...
...
@@ -23,7 +23,7 @@ const globalDatabase: any = {
}
}
const
createOrder
=
async
():
Promise
<
{
orderId
:
number
,
title
:
string
,
payId
:
number
,
money
:
number
}
>
=>
{
const
createOrder
=
async
():
Promise
<
{
orderId
:
number
,
title
:
string
,
money
:
number
}
>
=>
{
const
res
=
await
defaultRequest
.
post
<
any
,
DefaultResponse
>
(
'https://testapi.ydl.com/api/consult/user/order/submitWorriesConsultOrder'
,
globalDatabase
.
MOCK_GOODS
)
return
res
.
data
}
...
...
packages/toolkit/__tests__/payment/units.test.ts
View file @
ed9acb52
import
{
describe
,
expect
,
test
}
from
'@jest/globals'
import
{
BACK_ORDER_ID
,
BACK_PAY_ID
,
PayChannel
,
PayError
,
PayErrorMessage
,
Payment
,
PayType
}
from
"@/Payment/Payment"
;
import
{
BACK_ORDER_ID
,
PayChannel
,
PayError
,
PayErrorMessage
,
Payment
,
PayType
}
from
"@/Payment/Payment"
;
describe
(
'测试: 创建实例'
,
()
=>
{
test
(
'supportCombination'
,
()
=>
{
...
...
@@ -38,12 +38,9 @@ describe('测试: 创建实例', () => {
})
test
(
'测试订单查询链接'
,
()
=>
{
const
testPayId
=
111
const
testOrderId
=
222
const
backUrl
=
Payment
.
createBackInfoUrl
(
window
.
location
.
href
,
testPayId
,
testOrderId
)
expect
(
backUrl
).
toContain
(
BACK_PAY_ID
)
const
backUrl
=
Payment
.
createBackInfoUrl
(
window
.
location
.
href
,
testOrderId
)
expect
(
backUrl
).
toContain
(
BACK_ORDER_ID
)
expect
(
backUrl
).
toContain
(
testPayId
.
toString
())
expect
(
backUrl
).
toContain
(
testOrderId
.
toString
())
expect
(
backUrl
).
toContain
(
window
.
location
.
origin
)
})
...
...
packages/toolkit/package.json
View file @
ed9acb52
{
"name"
:
"@ydl-packages/toolkit"
,
"version"
:
"1.0.
1-next.3
3"
,
"version"
:
"1.0.
3-next.
3"
,
"description"
:
""
,
"main"
:
"./dist/index.umd.js"
,
"scripts"
:
{
...
...
packages/toolkit/src/Payment/API.ts
View file @
ed9acb52
...
...
@@ -24,7 +24,7 @@ export const UNIT_PAY = `${BASE_URL_JAVA}/api/auth/cashierV2/unityPay`
export
const
COMMIT_ORDER
=
`
${
BASE_URL_JAVA
}
/api/consult/consult/commit-order`
export
const
IS_PAY
=
`
${
BASE_URL_JAVA
}
/api/auth/Order/
i
sPay`
export
const
IS_PAY
=
`
${
BASE_URL_JAVA
}
/api/auth/Order/
orderI
sPay`
export
const
MY_BALANCE
=
`
${
BASE_GATEWAY
}
/v3/uc/mybalance`
...
...
packages/toolkit/src/Payment/Defined.ts
View file @
ed9acb52
...
...
@@ -5,13 +5,10 @@ export type PayMethod = {
disabled
:
boolean
}
export
const
BACK_PAY_ID
=
'backPayId'
export
const
BACK_ORDER_ID
=
'backOrderId'
export
type
BackInfo
=
{
orderId
:
number
;
payId
:
number
}
export
type
OrderStateCallBack
=
(
params
:
BackInfo
&
{
isPay
:
boolean
,
isLimit
?:
boolean
})
=>
void
...
...
@@ -97,7 +94,6 @@ export type ToPayParams = {
/**
* 支付记录id, 采用余额支付的时候如果前端有此值就带过来
*/
payId
?:
number
;
}
export
enum
PayError
{
...
...
packages/toolkit/src/Payment/Payment.ts
View file @
ed9acb52
...
...
@@ -6,7 +6,6 @@ import Decimal from 'decimal.js';
import
{
createRequest
,
defaultRequest
,
DefaultResponse
}
from
"@/Request/Request"
;
import
{
BACK_ORDER_ID
,
BACK_PAY_ID
,
BackInfo
,
DoUnifiedParams
,
FULL_PAY_METHODS
,
...
...
@@ -190,7 +189,7 @@ export class Payment {
}
async
toPay
(
params
:
ToPayParams
):
Promise
<
ToPayReturns
>
{
const
{
totalAmount
,
payType
,
returnUrl
,
orderId
,
redirectUrl
,
payId
}
=
params
const
{
totalAmount
,
payType
,
returnUrl
,
orderId
,
redirectUrl
}
=
params
let
quitUrl
=
params
.
quitUrl
// validate start >>>
switch
(
payType
)
{
...
...
@@ -258,7 +257,6 @@ export class Payment {
quitUrl
,
orderId
,
payType
,
payId
,
payAmount
,
payBalance
}
...
...
@@ -339,7 +337,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
})
:
{}
const
returnParams
:
BackInfo
=
{
payId
:
Number
(
query
[
BACK_PAY_ID
]),
orderId
:
Number
(
query
[
BACK_ORDER_ID
])}
const
returnParams
:
BackInfo
=
{
orderId
:
Number
(
query
[
BACK_ORDER_ID
])}
let
timer
:
any
=
null
;
const
checkLoop
=
()
=>
{
if
(
--
count
>
0
)
{
...
...
@@ -351,10 +349,10 @@ export class Payment {
timer
&&
clearTimeout
(
timer
)
}
}
if
(
query
[
BACK_
PAY
_ID
])
{
if
(
query
[
BACK_
ORDER
_ID
])
{
try
{
const
res
=
await
requestForJava
.
post
<
Record
<
string
,
string
>
,
DefaultResponse
>
(
IS_PAY
,
{
payId
:
query
[
BACK_PAY
_ID
]
orderId
:
query
[
BACK_ORDER
_ID
]
})
if
(
res
.
code
===
'200'
&&
res
.
data
===
true
)
{
callBack
({
isPay
:
true
,
...
returnParams
})
...
...
@@ -371,13 +369,11 @@ export class Payment {
/**
* 创建订单查询页面链接, 返回的url不做encode处理
* @param url
* @param backPayId
* @param backOrderId
*/
static
createBackInfoUrl
(
url
:
string
,
back
PayId
:
number
,
back
OrderId
:
number
):
string
{
static
createBackInfoUrl
(
url
:
string
,
backOrderId
:
number
):
string
{
const
[
path
,
queryString
]
=
url
.
split
(
'?'
)
const
query
=
queryString
?
qs
.
parse
(
queryString
,
{
ignoreQueryPrefix
:
true
})
:
{}
query
[
BACK_PAY_ID
]
=
backPayId
.
toString
()
query
[
BACK_ORDER_ID
]
=
backOrderId
.
toString
()
return
`
${
path
}
?
${
qs
.
stringify
(
query
)}
`
}
...
...
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