Commit ed9acb52 by 郑炬波

feat: 去payId

parent 332f2f17
...@@ -22,7 +22,7 @@ const globalDatabase: any = { ...@@ -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) const res = await defaultRequest.post<any, DefaultResponse>('https://testapi.ydl.com/api/consult/user/order/submitWorriesConsultOrder', globalDatabase.MOCK_GOODS)
return res.data return res.data
} }
......
...@@ -23,7 +23,7 @@ const globalDatabase: any = { ...@@ -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) const res = await defaultRequest.post<any, DefaultResponse>('https://testapi.ydl.com/api/consult/user/order/submitWorriesConsultOrder', globalDatabase.MOCK_GOODS)
return res.data return res.data
} }
......
import {describe, expect, test} from '@jest/globals' 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('测试: 创建实例', () => { describe('测试: 创建实例', () => {
test('supportCombination', () => { test('supportCombination', () => {
...@@ -38,12 +38,9 @@ describe('测试: 创建实例', () => { ...@@ -38,12 +38,9 @@ describe('测试: 创建实例', () => {
}) })
test('测试订单查询链接', () => { test('测试订单查询链接', () => {
const testPayId = 111
const testOrderId = 222 const testOrderId = 222
const backUrl = Payment.createBackInfoUrl(window.location.href, testPayId, testOrderId) const backUrl = Payment.createBackInfoUrl(window.location.href, testOrderId)
expect(backUrl).toContain(BACK_PAY_ID)
expect(backUrl).toContain(BACK_ORDER_ID) expect(backUrl).toContain(BACK_ORDER_ID)
expect(backUrl).toContain(testPayId.toString())
expect(backUrl).toContain(testOrderId.toString()) expect(backUrl).toContain(testOrderId.toString())
expect(backUrl).toContain(window.location.origin) expect(backUrl).toContain(window.location.origin)
}) })
......
{ {
"name": "@ydl-packages/toolkit", "name": "@ydl-packages/toolkit",
"version": "1.0.1-next.33", "version": "1.0.3-next.3",
"description": "", "description": "",
"main": "./dist/index.umd.js", "main": "./dist/index.umd.js",
"scripts": { "scripts": {
......
...@@ -24,7 +24,7 @@ export const UNIT_PAY = `${BASE_URL_JAVA}/api/auth/cashierV2/unityPay` ...@@ -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 COMMIT_ORDER = `${BASE_URL_JAVA}/api/consult/consult/commit-order`
export const IS_PAY = `${BASE_URL_JAVA}/api/auth/Order/isPay` export const IS_PAY = `${BASE_URL_JAVA}/api/auth/Order/orderIsPay`
export const MY_BALANCE = `${BASE_GATEWAY}/v3/uc/mybalance` export const MY_BALANCE = `${BASE_GATEWAY}/v3/uc/mybalance`
......
...@@ -5,13 +5,10 @@ export type PayMethod = { ...@@ -5,13 +5,10 @@ export type PayMethod = {
disabled: boolean disabled: boolean
} }
export const BACK_PAY_ID = 'backPayId'
export const BACK_ORDER_ID = 'backOrderId' export const BACK_ORDER_ID = 'backOrderId'
export type BackInfo = { export type BackInfo = {
orderId: number; orderId: number;
payId: number
} }
export type OrderStateCallBack = (params: BackInfo & { isPay: boolean, isLimit?: boolean }) => void export type OrderStateCallBack = (params: BackInfo & { isPay: boolean, isLimit?: boolean }) => void
...@@ -97,7 +94,6 @@ export type ToPayParams = { ...@@ -97,7 +94,6 @@ export type ToPayParams = {
/** /**
* 支付记录id, 采用余额支付的时候如果前端有此值就带过来 * 支付记录id, 采用余额支付的时候如果前端有此值就带过来
*/ */
payId?: number;
} }
export enum PayError { export enum PayError {
......
...@@ -6,7 +6,6 @@ import Decimal from 'decimal.js'; ...@@ -6,7 +6,6 @@ import Decimal from 'decimal.js';
import {createRequest, defaultRequest, DefaultResponse} from "@/Request/Request"; import {createRequest, defaultRequest, DefaultResponse} from "@/Request/Request";
import { import {
BACK_ORDER_ID, BACK_ORDER_ID,
BACK_PAY_ID,
BackInfo, BackInfo,
DoUnifiedParams, DoUnifiedParams,
FULL_PAY_METHODS, FULL_PAY_METHODS,
...@@ -190,7 +189,7 @@ export class Payment { ...@@ -190,7 +189,7 @@ export class Payment {
} }
async toPay(params: ToPayParams): Promise<ToPayReturns> { 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 let quitUrl = params.quitUrl
// validate start >>> // validate start >>>
switch (payType) { switch (payType) {
...@@ -258,7 +257,6 @@ export class Payment { ...@@ -258,7 +257,6 @@ export class Payment {
quitUrl, quitUrl,
orderId, orderId,
payType, payType,
payId,
payAmount, payAmount,
payBalance payBalance
} }
...@@ -339,7 +337,7 @@ export class Payment { ...@@ -339,7 +337,7 @@ export class Payment {
static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack, pollTime = 3000): Promise<void> { static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack, pollTime = 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 = {orderId: Number(query[BACK_ORDER_ID])}
let timer: any = null; let timer: any = null;
const checkLoop = () => { const checkLoop = () => {
if (--count > 0) { if (--count > 0) {
...@@ -351,10 +349,10 @@ export class Payment { ...@@ -351,10 +349,10 @@ export class Payment {
timer && clearTimeout(timer) timer && clearTimeout(timer)
} }
} }
if (query[BACK_PAY_ID]) { if (query[BACK_ORDER_ID]) {
try { try {
const res = await requestForJava.post<Record<string, string>, DefaultResponse>(IS_PAY, { 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) { if (res.code === '200' && res.data === true) {
callBack({isPay: true, ...returnParams}) callBack({isPay: true, ...returnParams})
...@@ -371,13 +369,11 @@ export class Payment { ...@@ -371,13 +369,11 @@ export class Payment {
/** /**
* 创建订单查询页面链接, 返回的url不做encode处理 * 创建订单查询页面链接, 返回的url不做encode处理
* @param url * @param url
* @param backPayId
* @param backOrderId * @param backOrderId
*/ */
static createBackInfoUrl(url: string, backPayId: number, backOrderId: number): string { static createBackInfoUrl(url: string, backOrderId: number): string {
const [path, queryString] = url.split('?') const [path, queryString] = url.split('?')
const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {} const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {}
query[BACK_PAY_ID] = backPayId.toString()
query[BACK_ORDER_ID] = backOrderId.toString() query[BACK_ORDER_ID] = backOrderId.toString()
return `${path}?${qs.stringify(query)}` return `${path}?${qs.stringify(query)}`
} }
......
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