sdk:修复支付回调bug
This commit is contained in:
@@ -161,7 +161,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
||||
return resResult(result);
|
||||
}
|
||||
//推送
|
||||
console.log('*****', order.roleId, sid)
|
||||
console.log('***** settleOrder', order.roleId, sid)
|
||||
if(!!sid) {
|
||||
pinus.app.channelService.pushMessageByUids('onOrder', resResult(STATUS.SUCCESS, {
|
||||
...result.data,
|
||||
@@ -234,6 +234,9 @@ export async function settleOrderAli(order: UserOrderModelType, serverId: number
|
||||
}
|
||||
|
||||
export async function settleOrderFromRedisPub(message: string) {
|
||||
console.log('**********settleOrderFromRedisPub*******')
|
||||
console.log('message: ', message);
|
||||
|
||||
let params: PayCallback37Data;
|
||||
try {
|
||||
params = JSON.parse(message);
|
||||
@@ -250,7 +253,7 @@ export async function settleOrderFromRedisPub(message: string) {
|
||||
console.log('订单玩家错误');
|
||||
return false;
|
||||
}
|
||||
if(order.price.toFixed(2) != params.money.toFixed(2)) {
|
||||
if(order.price != parseFloat(params.money)) {
|
||||
console.log('订单金额错误');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -489,6 +489,9 @@ export async function redisSubScribe() {
|
||||
let treatGuildChannel = getRedisSubChannel(REDIS_KEY.TREAT_GUILD_CHANNEL, env);
|
||||
await redisClientPub().subscribeAsync(payChannel, treatRoleChannel, treatGuildChannel);
|
||||
redisClientPub().on('message', (channel, message) => {
|
||||
console.log('**********redisSubScribe*******')
|
||||
console.log('channel: ', channel, payChannel);
|
||||
|
||||
if(channel == payChannel) {
|
||||
let servers = pinus.app.getServersByType('order');
|
||||
let server = getRandSingleEelm(servers);
|
||||
|
||||
@@ -61,7 +61,7 @@ export class PayCallback37Data {
|
||||
actor_id: string; // 角色id
|
||||
order_id: string; // 37平台id
|
||||
order_no: string; // 我方订单id
|
||||
money: number; // 订单金额
|
||||
money: string; // 订单金额
|
||||
game_coin: number; // 元宝数
|
||||
product_id: string; // 商品id
|
||||
time: number; // 请求时间
|
||||
|
||||
@@ -186,5 +186,9 @@
|
||||
{
|
||||
"channel": "local",
|
||||
"ip": "::1"
|
||||
},
|
||||
{
|
||||
"channel": "bantushanghai",
|
||||
"ip": "180.158.8.235"
|
||||
}
|
||||
]
|
||||
@@ -19,7 +19,7 @@ import { GuildModel } from '@db/Guild';
|
||||
export default class Sdk extends Service {
|
||||
|
||||
public check37Sign(params: PayCallback37Data) {
|
||||
let sign = get37Md5Sign(params.getBody, SDK_37_CONST.PAY_KEY);
|
||||
let sign = get37Md5Sign(params.getBody(), SDK_37_CONST.PAY_KEY);
|
||||
console.log('******37Sign', sign);
|
||||
return sign == params.sign;
|
||||
}
|
||||
@@ -27,42 +27,52 @@ export default class Sdk extends Service {
|
||||
public async pay37Callback(params: PayCallback37Data) {
|
||||
const { ctx } = this;
|
||||
const { app } = ctx;
|
||||
const ip = ctx.request.ip;
|
||||
let ip = ctx.header['x-real-ip'];
|
||||
console.log('*****pay37Callback', ip)
|
||||
|
||||
let checkResult = this.check37Sign(params);
|
||||
if(!checkResult) return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.MD5_ERR, '');
|
||||
|
||||
console.log('*****pay37Callback check sign ok')
|
||||
if(gameData.whiteip.indexOf(ip) == -1) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.IP_LIMIT, '');
|
||||
}
|
||||
|
||||
console.log('*****pay37Callback check ip ok')
|
||||
if(nowSeconds() - params.time > 15 * 60) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.TIME_IS_EXPIRED, '');
|
||||
}
|
||||
console.log('*****pay37Callback check time ok')
|
||||
|
||||
let order = await UserOrderModel.findOrder(params.order_no);
|
||||
if(!order) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.FAIL, '');
|
||||
}
|
||||
console.log('*****pay37Callback check order ok')
|
||||
if(order.state != ORDER_STATE.APPLY) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SUCCESS, '');
|
||||
}
|
||||
if(order.price.toFixed(2) != params.money.toFixed(2)) {
|
||||
console.log('*****pay37Callback check order status ok', params.money, typeof params.money)
|
||||
if(order.price != parseFloat(params.money)) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.PAY_ERR, '');
|
||||
}
|
||||
console.log('*****pay37Callback check money ok', order.price, params.money)
|
||||
|
||||
let role = await RoleModel.findByRoleId(order.roleId);
|
||||
if(!role) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.ROLE_NOT_FOUND, '');
|
||||
}
|
||||
console.log('*****pay37Callback check role ok')
|
||||
if(role.serverId != params.sid) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_NOT_FOUND, '');
|
||||
}
|
||||
console.log('*****pay37Callback check server ok')
|
||||
|
||||
order = await UserOrderModel.check(order.roleId, order.localOrderID);
|
||||
if(!order) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.FAIL, '');
|
||||
}
|
||||
console.log('*****pay37Callback save order check ok')
|
||||
|
||||
let redisClient: RedisClient = app.context.redisClient;
|
||||
let name = getRedisSubChannel(REDIS_KEY.PAY_CHANNEL, app.config.env);
|
||||
@@ -70,6 +80,7 @@ export default class Sdk extends Service {
|
||||
if(result == 0) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_IS_BUSY, '');
|
||||
}
|
||||
console.log('*****pay37Callback redis publish ok')
|
||||
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SUCCESS, '');
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"isbn": "cross-env EGG_SERVER_ENV=isbn npm run dev",
|
||||
"monitor": "cross-env EGG_SERVER_ENV=monitor npm run dev",
|
||||
"distribute": "cross-env EGG_SERVER_ENV=distribute npm run dev",
|
||||
"lylocal": "cross-env EGG_SERVER_ENV=lylocal npm run dev"
|
||||
"lylocal": "cross-env EGG_SERVER_ENV=lylocal npm run dev",
|
||||
"alpha": "cross-env EGG_SERVER_ENV=alpha npm run dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/underscore": "^1.11.3",
|
||||
|
||||
Reference in New Issue
Block a user