sdk:37sdk发起支付接口
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { SDK_37_CONST, STATUS } from "../../consts";
|
||||
import { RoleModel, RoleType } from "../../db/Role";
|
||||
import { UserModel } from "../../db/User";
|
||||
import { LoginValidateData37 } from "../../domain/sdk";
|
||||
import { DicRMB } from "../../pubUtils/dictionary/DicRMB";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { resResult } from "../../pubUtils/util";
|
||||
import { get37Md5Sign } from "../../pubUtils/sdkUtil";
|
||||
|
||||
/**
|
||||
* 37支付下单
|
||||
*
|
||||
* @param {number} price 价格订单金额(分)
|
||||
* @param {string} message 商品信息
|
||||
* @param {string} localOrderID 本地订单号
|
||||
*
|
||||
*/
|
||||
export async function applyOrder37(localOrderID: string, roleId: string, productInfo: DicRMB) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let user = await UserModel.findUserByUid(role.userInfo.uid);
|
||||
if(!user || !user.channelInfo || !(<LoginValidateData37>user.channelInfo).uid)
|
||||
return {
|
||||
code: -1, resData: resResult(STATUS.CHANNEL_INFO_NOT_FOUND)
|
||||
}
|
||||
|
||||
let ext = '';
|
||||
let body = {
|
||||
game_id: SDK_37_CONST.GAME_ID,
|
||||
uid: user.uid,
|
||||
sid: role.serverId,
|
||||
actor_id: role.roleId,
|
||||
order_no: localOrderID,
|
||||
money: productInfo.price.toFixed(2).toString(),
|
||||
game_coin: role.gold,
|
||||
product_id: productInfo.productID,
|
||||
subject: productInfo.message,
|
||||
time: nowSeconds(),
|
||||
ext
|
||||
}
|
||||
|
||||
let sign = get37Md5Sign(body, SDK_37_CONST.PAY_KEY);
|
||||
|
||||
|
||||
return { code: 0, data: {
|
||||
timestamp: nowSeconds(),
|
||||
ext,
|
||||
sign: sign
|
||||
}};
|
||||
}
|
||||
Reference in New Issue
Block a user