支付回调

This commit is contained in:
luying
2021-11-09 19:24:00 +08:00
parent 173481a60c
commit 106493b878
26 changed files with 424 additions and 135 deletions
+1
View File
@@ -231,6 +231,7 @@ export enum REDIS_KEY {
HERO_RANK ="heroRank", // 武将排行榜
SHOW_LINEUP ="showLineup", // 展示阵容
SYS_SERVER ='sysServer', // 全服connector服
PAY_CHANNEL = 'pay', // 支付订阅频道
}
// 各排行榜对应hash的key
+14
View File
@@ -448,3 +448,17 @@ export const STATUS = {
CHANNEL_INFO_NOT_FOUND: { code: 70014, simStr: '未找到玩家渠道数据' },
}
export const PAY_37_CALLBACK_CODE = {
SUCCESS: { code: 1, simStr: '发货成功' },
FAIL: { code: -1, simStr: '发货失败' },
USER_NOT_FOUND: { code: -2, simStr: '用户不存在' },
IP_LIMIT: { code: -3, simStr: 'IP限制' },
MD5_ERR: { code: -4, simStr: 'md5校验错误' },
ROLE_NOT_FOUND: { code: -5, simStr: '角色不存在' },
TIME_IS_EXPIRED: { code: -6, simStr: 'time时间已过期' },
SERVER_IS_BUSY: { code: -7, simStr: '游戏服务器繁忙' },
WRONG_PARAM: { code: -8, simStr: '参数错误' },
SERVER_NOT_FOUND: { code: -9, simStr: '游戏服不存在' },
PAY_ERR: { code: 10, simStr: '充值失败' }
}
+6 -4
View File
@@ -18,6 +18,8 @@ export default class UserOrder extends BaseModel {
@prop({ required: true })
orderID: string; // 平台订单号
@prop({ required: true })
rewardResult: string; // 奖励结果
@prop({ required: true })
localOrderID: string; // 本地订单号
@prop({ required: true })
payType: number; // 支付类型 PAY_TYPE
@@ -34,9 +36,9 @@ export default class UserOrder extends BaseModel {
//保存平台订单号
public static async saveOrderID(roleId: string, localOrderID: string, aliOrderID: string) {
public static async saveOrderID(roleId: string, localOrderID: string, orderID: string, rewardResult: string) {
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ roleId, localOrderID },
{ $set: { orderID: aliOrderID } },
{ $set: { orderID, rewardResult, state: ORDER_STATE.RESULT_SUCCESS } },
{ new: true }).lean(true);
return result;
}
@@ -58,9 +60,9 @@ export default class UserOrder extends BaseModel {
}
//订单支付成功
public static async success(roleId: string, localOrderID: string, message: string = '') {
public static async success(roleId: string, localOrderID: string, rewardResult: string, message: string = '') {
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
{ $set: { state: ORDER_STATE.RESULT_SUCCESS, message } },
{ $set: { state: ORDER_STATE.RESULT_SUCCESS, rewardResult, message } },
{ new: true }).lean(true);
return result;
}
+15 -1
View File
@@ -1,6 +1,20 @@
import { HeroUpdate } from '../../db/Hero';
import { HeroType, HeroUpdate } from '../../db/Hero';
export interface CreateHeroParam extends HeroUpdate {
hid: number;
count: number;
}
export class HeroShowParam {
hid: number;
seqId: number;
skinId: number;
quality: number;
constructor(hero: HeroType) {
this.hid = hero.hid;
this.seqId = hero.seqId;
this.skinId = hero.skinId;
this.quality = hero.quality;
}
}
+18 -1
View File
@@ -39,4 +39,21 @@ export interface LoginValidataReturn37 {
data: LoginValidateData37;
}
export type ChannelInfo = LoginValidataReturn37|{};
export type ChannelInfo = LoginValidataReturn37|{};
export interface PayCallback37Data {
appid: string; // 平台id
uid: number; // 37用户id
game_id: number; // 游戏id
fc_c_game_id: string; // 子游戏id
sid: number; // 区服id
actor_id: string; // 角色id
order_id: string; // 37平台id
order_no: string; // 我方订单id
money: number; // 订单金额
game_coin: number; // 元宝数
product_id: string; // 商品id
time: number; // 请求时间
ext: string; // 扩展参数
sign: string;
}
+4 -1
View File
@@ -70,7 +70,10 @@ declare module 'redis' {
smembersAsync(key: string): Promise<string[]>;
// 增加集合成员
saddAsync(key: string, values: string[]): Promise<string>;
// 将信息发送到指定的频道
publishAsync(channel: string, message: string): Promise<number>;
// 订阅给定的一个或多个频道的信息
subscribeAsync(...channels: string[]): Promise<number>;
}
export interface Multi extends Commands<Multi> {
execAsync(...args: any[]): Promise<any>;
+8 -1
View File
@@ -99,6 +99,7 @@ import { UserTaskHistoryModel } from '../db/UserTaskHistory';
import { UserTaskRecModel } from '../db/UserTaskRec';
import { WishPoolReportModel } from '../db/WishPoolReport';
import { pick } from "underscore";
import { HeroShowParam } from '../domain/roleField/hero';
// 储存在内存中的初始数据
export function getInitRoleInfo() {
@@ -341,11 +342,17 @@ export class CreateHeroes extends UpdateHeroes {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, this.skinPushMessages), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes: this.resultHeroes }), uids);
}
public getResultHeroes() {
return this.resultHeroes
}
public getShowHeroes() {
return this.resultHeroes.map(cur => {
return { ...cur, ce: reduceCe(cur.ce)}
let hero = new HeroShowParam(cur);
return { ...hero, ce: reduceCe(cur.ce)}
});
}
}
+5 -1
View File
@@ -1,4 +1,4 @@
import { SDK_37_ADDR, SDK_37_CONST } from '../consts';
import { REDIS_KEY, SDK_37_ADDR, SDK_37_CONST } from '../consts';
import { request37 } from './httpUtil';
import { nowSeconds } from './timeUtil';
import { LoginValidataReturn37 } from '../domain/sdk';
@@ -85,4 +85,8 @@ export function checkVidObjSign(obj: any) {
function treatVid(str) {
return 'vId' + str;
}
export function getRedisSubChannel(key: REDIS_KEY, env: string) {
return `${key}:${env}`;
}