sdk:修复支付回调bug
This commit is contained in:
@@ -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, '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user