feat: 球局详情完善 & 订单详情完善
This commit is contained in:
@@ -1,90 +1,125 @@
|
||||
import httpService from './httpService'
|
||||
import type { ApiResponse } from './httpService'
|
||||
import { requestPayment } from '@tarojs/taro'
|
||||
import httpService from "./httpService";
|
||||
import type { ApiResponse } from "./httpService";
|
||||
|
||||
export interface SignType {
|
||||
/** 仅在微信支付 v2 版本接口适用 */
|
||||
MD5
|
||||
MD5;
|
||||
/** 仅在微信支付 v2 版本接口适用 */
|
||||
'HMAC-SHA256'
|
||||
"HMAC-SHA256";
|
||||
/** 仅在微信支付 v3 版本接口适用 */
|
||||
RSA
|
||||
RSA;
|
||||
}
|
||||
|
||||
export enum OrderStatus {
|
||||
PENDING = 0,
|
||||
PAID,
|
||||
FINISHED,
|
||||
}
|
||||
|
||||
export interface PayMentParams {
|
||||
order_id: number,
|
||||
order_no: string,
|
||||
status: number,
|
||||
appId: string,
|
||||
timeStamp: string,
|
||||
nonceStr: string,
|
||||
package: string,
|
||||
signType: keyof SignType,
|
||||
paySign: string
|
||||
order_id: number;
|
||||
order_no: string;
|
||||
status: number;
|
||||
appId: string;
|
||||
timeStamp: string;
|
||||
nonceStr: string;
|
||||
package: string;
|
||||
signType: keyof SignType;
|
||||
paySign: string;
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface OrderResponse {
|
||||
participant_id: number,
|
||||
payment_required: boolean,
|
||||
payment_params: PayMentParams
|
||||
participant_id: number;
|
||||
payment_required: boolean;
|
||||
payment_params: PayMentParams;
|
||||
}
|
||||
|
||||
export interface OrderInfo {
|
||||
time: string
|
||||
address: string
|
||||
registrant_nickname: string
|
||||
registrant_phone: string
|
||||
cost: string
|
||||
time: string;
|
||||
address: string;
|
||||
registrant_nickname: string;
|
||||
registrant_phone: string;
|
||||
cost: string;
|
||||
}
|
||||
|
||||
export interface RefundPolicy {
|
||||
application_time: string
|
||||
refund_rule: string
|
||||
application_time: string;
|
||||
refund_rule: string;
|
||||
}
|
||||
|
||||
export interface GameStatus {
|
||||
current_players: number
|
||||
max_players: number
|
||||
is_full: boolean
|
||||
can_join: boolean
|
||||
current_players: number;
|
||||
max_players: number;
|
||||
is_full: boolean;
|
||||
can_join: boolean;
|
||||
}
|
||||
|
||||
export interface GameDetails {
|
||||
game_id: number
|
||||
game_title: string
|
||||
game_description: string
|
||||
game_id: number;
|
||||
game_title: string;
|
||||
game_description: string;
|
||||
}
|
||||
|
||||
export interface GameOrderRes {
|
||||
order_info: OrderInfo
|
||||
refund_policy: RefundPolicy[]
|
||||
notice: string
|
||||
game_status: GameStatus
|
||||
game_details: GameDetails
|
||||
order_info: OrderInfo;
|
||||
refund_policy: RefundPolicy[];
|
||||
notice: string;
|
||||
game_status: GameStatus;
|
||||
game_details: GameDetails;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 发布球局类
|
||||
class OrderService {
|
||||
// 查询订单列表
|
||||
async getOrderList() {
|
||||
return httpService.post('/user/orders', {}, { showLoading: true })
|
||||
}
|
||||
// 创建订单
|
||||
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
||||
return httpService.post('/payment/create_order', { game_id }, {
|
||||
showLoading: true,
|
||||
})
|
||||
return httpService.post("/user/orders", {}, { showLoading: true });
|
||||
}
|
||||
|
||||
async getOrderInfo(game_id: number): Promise<ApiResponse<GameOrderRes>> {
|
||||
return httpService.post('/payment/check_order', { game_id }, {
|
||||
showLoading: true,
|
||||
})
|
||||
// 获取订单详情
|
||||
async getOrderDetail(order_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post(
|
||||
"/payment/order_details",
|
||||
{ order_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
||||
return httpService.post(
|
||||
"/payment/create_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 检查订单信息
|
||||
async getCheckOrderInfo(game_id: number): Promise<ApiResponse<GameOrderRes>> {
|
||||
return httpService.post(
|
||||
"/payment/check_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 获取未支付订单
|
||||
async getUnpaidOrder(game_id: number): Promise<ApiResponse<any>> {
|
||||
return httpService.post(
|
||||
"/payment/get_unpaid_order",
|
||||
{ game_id },
|
||||
{
|
||||
showLoading: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 导出认证服务实例
|
||||
export default new OrderService()
|
||||
export default new OrderService();
|
||||
|
||||
Reference in New Issue
Block a user