init
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
|
||||
import { Service } from 'egg';
|
||||
import { REDIS_KEY, PAY_37_CALLBACK_CODE, SDK_37_CONST, ORDER_STATE, SDK_37_TREAT_CODE, SERVER_STATUS, SDK_37_REFUND_CODE, SDK_37_ACTIVITY_CODE, PUBLIC_ACCOUNT_GIFT, GIFT_GENERATE_TYPE, GIFT_TYPE } from '@consts';
|
||||
import { GetGuildInfoByUserParam, GetRoleByServerParam, GetRoleByUidParam, GetServerAndUidParam, GetServerListParam, GetServerParam, GuildNameCallBackParam, IOSRefundParam, PayCallback37Data, RoleNameCallBackParam, SendGiftCodeParam } from '../domain/sdk';
|
||||
import { REDIS_KEY, PAY_37_CALLBACK_CODE, SDK_37_CONST, ORDER_STATE, SDK_37_TREAT_CODE, SERVER_STATUS, SDK_37_REFUND_CODE, SDK_37_ACTIVITY_CODE, PUBLIC_ACCOUNT_GIFT, GIFT_GENERATE_TYPE, GIFT_TYPE } from '../../../shared/consts';
|
||||
import { GetGuildInfoByUserParam, GetRoleByServerParam, GetRoleByUidParam, GetServerAndUidParam, GetServerListParam, GetServerParam, GuildNameCallBackParam, IOSRefundParam, PayCallback37Data, RoleNameCallBackParam, SendGiftCodeParam } from '../../../shared/domain/sdk';
|
||||
import { RedisClient } from 'redis';
|
||||
import { checkParamPrice, get37GetServerMd5Sign, get37Md5SignA, get37Md5SignB, getChannelId, getRedisSubChannel, md5 } from '../pubUtils/sdkUtil';
|
||||
import { UserOrderModel } from '@db/UserOrder';
|
||||
import { nowSeconds } from 'app/pubUtils/timeUtil';
|
||||
import { RoleModel } from '@db/Role';
|
||||
import { gameData } from 'app/pubUtils/data';
|
||||
import { resResult } from 'app/pubUtils/util';
|
||||
import { UserModel } from '@db/User';
|
||||
import { UserGuildModel } from '@db/UserGuild';
|
||||
import { GuildModel } from '@db/Guild';
|
||||
import { ServerlistModel } from '@db/Serverlist';
|
||||
import { checkParamPrice, get37GetServerMd5Sign, get37Md5SignA, get37Md5SignB, getChannelId, getRedisSubChannel, md5 } from '../../../shared/pubUtils/sdkUtil';
|
||||
import { UserOrderModel } from '../../../shared/db/UserOrder';
|
||||
import { nowSeconds } from '../../../shared/pubUtils/timeUtil';
|
||||
import { RoleModel } from '../../../shared/db/Role';
|
||||
import { gameData } from '../../../shared/pubUtils/data';
|
||||
import { resResult } from '../../../shared/pubUtils/util';
|
||||
import { UserModel } from '../../../shared/db/User';
|
||||
import { UserGuildModel } from '../../../shared/db/UserGuild';
|
||||
import { GuildModel } from '../../../shared/db/Guild';
|
||||
import { ServerlistModel } from '../../../shared/db/Serverlist';
|
||||
import moment = require('moment');
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { ActivityPublicAccountCodeModel } from '@db/ActivityPublicAccountCode';
|
||||
import { GiftCodeDetailModel } from '@db/GiftCodeDetail';
|
||||
import { GiftCodeModel } from '@db/GiftCode';
|
||||
import { UserGiftCodeDetailModel } from '@db/UserGiftCodeDetail';
|
||||
import { RegionModel } from '../../../shared/db/Region';
|
||||
import { ActivityPublicAccountCodeModel } from '../../../shared/db/ActivityPublicAccountCode';
|
||||
import { GiftCodeDetailModel } from '../../../shared/db/GiftCodeDetail';
|
||||
import { GiftCodeModel } from '../../../shared/db/GiftCode';
|
||||
import { UserGiftCodeDetailModel } from '../../../shared/db/UserGiftCodeDetail';
|
||||
|
||||
/**
|
||||
* Test Service
|
||||
@@ -79,9 +79,9 @@ export default class Sdk extends Service {
|
||||
}
|
||||
ctx.service.utils.log('DEBUG', `[${ctx.request.url}] [${ctx.logcode}] pay37Callback save order check ok`);
|
||||
|
||||
let redisClient: RedisClient = app.context.redisClient;
|
||||
let redisClient: RedisClient = (app.context as any).redisClient;
|
||||
let name = getRedisSubChannel(REDIS_KEY.PAY_CHANNEL, app.config.env);
|
||||
let result = await redisClient.publishAsync(name, JSON.stringify(params));
|
||||
let result = await (redisClient as any).publishAsync(name, JSON.stringify(params));
|
||||
if(result == 0) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_IS_BUSY, '');
|
||||
}
|
||||
@@ -140,7 +140,7 @@ export default class Sdk extends Service {
|
||||
|
||||
// let redisClient: RedisClient = app.context.redisClient;
|
||||
// let name = getRedisSubChannel(REDIS_KEY.PAY_CHANNEL, app.config.env);
|
||||
// let result = await redisClient.publishAsync(name, JSON.stringify(params));
|
||||
// let result = await (redisClient as any).publishAsync(name, JSON.stringify(params));
|
||||
// if(result == 0) {
|
||||
// return ctx.service.utils.resResult(PAY_IOS_37_CALLBACK_CODE.SERVER_IS_BUSY, '');
|
||||
// }
|
||||
@@ -193,9 +193,9 @@ export default class Sdk extends Service {
|
||||
}
|
||||
console.log('*****refundIOSCallback save order check ok')
|
||||
|
||||
let redisClient: RedisClient = app.context.redisClient;
|
||||
let redisClient: RedisClient = (app.context as any).redisClient;
|
||||
let name = getRedisSubChannel(REDIS_KEY.REFUND_CHANNEL, app.config.env);
|
||||
let result = await redisClient.publishAsync(name, JSON.stringify(params));
|
||||
let result = await (redisClient as any).publishAsync(name, JSON.stringify(params));
|
||||
if(result == 0) {
|
||||
return ctx.service.utils.resResult(SDK_37_REFUND_CODE.FAIL, '');
|
||||
}
|
||||
@@ -262,9 +262,9 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
// 2. redis发布
|
||||
let redisClient: RedisClient = app.context.redisClient;
|
||||
let redisClient: RedisClient = (app.context as any).redisClient;
|
||||
let name = getRedisSubChannel(REDIS_KEY.TREAT_ROLE_CHANNEL, app.config.env);
|
||||
let result = await redisClient.publishAsync(name, role.roleId);
|
||||
let result = await (redisClient as any).publishAsync(name, role.roleId);
|
||||
if(result == 0) {
|
||||
console.error('用户名违规处理, 未发布到订阅频道');
|
||||
return SDK_37_TREAT_CODE.ERR.code;
|
||||
@@ -288,10 +288,10 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
// 2. redis发布
|
||||
let redisClient: RedisClient = app.context.redisClient;
|
||||
let redisClient: RedisClient = (app.context as any).redisClient;
|
||||
let name = getRedisSubChannel(REDIS_KEY.TREAT_GUILD_CHANNEL, app.config.env);
|
||||
let content = JSON.stringify({ code: guild.code, serverId: params.sid, type: params.type });
|
||||
let result = await redisClient.publishAsync(name, content);
|
||||
let result = await (redisClient as any).publishAsync(name, content);
|
||||
if(result == 0) {
|
||||
return SDK_37_TREAT_CODE.ERR.code;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
public reportTAEventWithDistinctId(distinctId: string, eventName: string, properties: any, ip: string) {
|
||||
let ta = this.app.context.ta;
|
||||
let ta = (this.app.context as any).ta;
|
||||
if(!ta) return
|
||||
let event = {
|
||||
// 账号 ID (可选)
|
||||
@@ -390,7 +390,7 @@ export default class Sdk extends Service {
|
||||
ip: ip,
|
||||
// 事件属性 (可选)
|
||||
properties,
|
||||
callback(err) {
|
||||
callback(err: any) {
|
||||
console.log('*****测试接入事件', err)
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
public reportTAEventWithRoleIdAndDistinctId(roleId: string, distinctId: string, eventName: string, properties: any, ip?: string) {
|
||||
let ta = this.app.context.ta;
|
||||
let ta = (this.app.context as any).ta;
|
||||
if(!ta) return
|
||||
let event = {
|
||||
// 账号 ID (可选)
|
||||
@@ -414,7 +414,7 @@ export default class Sdk extends Service {
|
||||
ip: ip,
|
||||
// 事件属性 (可选)
|
||||
properties,
|
||||
callback(err) {
|
||||
callback(err: any) {
|
||||
console.log('*****测试接入事件', err)
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ export default class Sdk extends Service {
|
||||
await GiftCodeDetailModel.increaseUsedNum(giftCodeDetail.code);
|
||||
await GiftCodeModel.increaseUsedNum(giftCode.id);
|
||||
|
||||
await ctx.service.utils.pushGiftCodeChannel(role.roleId, giftCode.id);
|
||||
await ctx.service.utils.pushGiftCodeChannel(String(role.roleId), String(giftCode.id));
|
||||
}
|
||||
|
||||
return resResult(SDK_37_ACTIVITY_CODE.SUCCESS, []);
|
||||
@@ -564,8 +564,8 @@ export default class Sdk extends Service {
|
||||
let user = await UserModel.findUserByChannel(channelId);
|
||||
if(!user) return resResult(SDK_37_ACTIVITY_CODE.ROLE_NOT_FOUND);
|
||||
|
||||
let redisClient: RedisClient = this.ctx.app.context.redisClient;
|
||||
let servers = await redisClient.hgetallAsync(REDIS_KEY.SERVER);
|
||||
let redisClient: RedisClient = (this.ctx.app.context as any).redisClient;
|
||||
let servers = await (redisClient as any).hgetallAsync(REDIS_KEY.SERVER);
|
||||
let roles = await RoleModel.findAllByUid(user.uid);
|
||||
let result = roles
|
||||
.filter(role => !role.closeTime || role.closeTime > nowSeconds())
|
||||
@@ -661,7 +661,7 @@ export default class Sdk extends Service {
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
return { state: 0, data: null, msg: SDK_37_ACTIVITY_CODE.INTERNAL_ERR };
|
||||
return { state: 0, data: null as any, msg: SDK_37_ACTIVITY_CODE.INTERNAL_ERR };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user