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
|
||||
}};
|
||||
}
|
||||
@@ -44,9 +44,9 @@ export async function applyOrderALI(localOrderID: string, price: number, message
|
||||
// }
|
||||
console.log('applyOrderALI result: ', result)
|
||||
if (result.code == 0) {
|
||||
return { code: 1, data: result.data };
|
||||
return { code: 0, data: result.data };
|
||||
}
|
||||
return { code: 0, data: JSON.stringify(result) };
|
||||
return { code: -1, data: JSON.stringify(result) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ export async function applyOrderWX(localOrderID: string, price: number, message:
|
||||
// sign: '7A1B41C577E78602344D03DE4A2F7B0A' }
|
||||
console.log('applyOrderWX result: ', result)
|
||||
if (result.appid == config.appid && result.partnerid == config.mchid) {
|
||||
return { code: 1, data: result };
|
||||
return { code: 0, data: result };
|
||||
}
|
||||
return { code: 0, data: JSON.stringify(result) };
|
||||
return { code: -1, data: JSON.stringify(result) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user