登陆:玩家在线情况redis改为hash格式

This commit is contained in:
luying
2021-03-04 14:55:08 +08:00
parent 578b890630
commit d4561c2e3d
12 changed files with 131 additions and 67 deletions

View File

@@ -11,7 +11,7 @@ import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
import { getUserGuildWithRefActive } from '../../../services/guildService';
import { findIndex, findWhere } from 'underscore';
import { RoleModel } from '../../../db/Role';
import { getRedis, redisSidKey } from '../../../services/redisService';
import { getRoleOnlineInfo } from '../../../services/redisService';
import { ARMY } from '../../../pubUtils/dicParam';
export default function(app: Application) {
return new WishPoolHandler(app);
@@ -119,11 +119,11 @@ export class WishPoolHandler {
return resResult(STATUS.HAS_RECEIVE_WISH_GOOD);//已经收到
let { wishDntCnt } = await UserGuildModel.donateGoods(dntRoleId, 1, 'wishDntCnt');
let { wishGoods: resWishGoods } = await UserGuildModel.donateUpdate(wishRoleId, dntRoleName, id, 'wishGoods');
let key = redisSidKey(wishRoleId);
let sid = await getRedis(key);
await addItems(wishRoleId, role.roleName , sid , [{ id : wishGood.goodId, count: 1 }]);
if (!!sid) {
this.app.channelService.pushMessageByUids('onWishGoodsRecive', resResult(STATUS.SUCCESS, { wishGoods: resWishGoods }), [{uid:wishRoleId, sid}]);
let hisOnlineInfo = await getRoleOnlineInfo(wishRoleId);
if(hisOnlineInfo.isOnline && hisOnlineInfo.sid) {
await addItems(wishRoleId, role.roleName, hisOnlineInfo.sid , [{ id : wishGood.goodId, count: 1 }]);
this.app.channelService.pushMessageByUids('onWishGoodsRecive', resResult(STATUS.SUCCESS, { wishGoods: resWishGoods }), [{uid:wishRoleId, sid: hisOnlineInfo.sid}]);
}
await WishPoolReportModel.addReport(code, wishRoleId, role.roleName , dntRoleId, dntRoleName, wishGood.goodId, 1);
return resResult(STATUS.SUCCESS, { wishDntCnt, updateWishGoods: resWishGoods.map(({type, goodId, count, receiveCnt, drawCnt, id})=>{