diff --git a/src/api_s2c/dixialeitai/ApiFight.ts b/src/api_s2c/dixialeitai/ApiFight.ts index 975dfa5..a70ac5c 100644 --- a/src/api_s2c/dixialeitai/ApiFight.ts +++ b/src/api_s2c/dixialeitai/ApiFight.ts @@ -12,7 +12,7 @@ export default async function (call: ApiCall) { let change: Partial = {}; let data = await DxltFun.getData(call); - if (data.killBoss >= G.gc.dxlt_com.dayFightLayer) return call.error(globalThis.lng.dixialeitai_2); + if (data.killBoss >= G.gc.dxlt_com.dayFightLayer) return call.error(globalThis.lng.dixialeitai_13); if (G.gc.dxlt_layer[data.curLayer].type != 1) return call.error(globalThis.lng.dixialeitai_3); if (data.over) return call.error(globalThis.lng.dixialeitai_4); if (!data.heros[call.req]) return call.error(globalThis.lng.dixialeitai_5); diff --git a/src/public/gud.ts b/src/public/gud.ts index 7ff21d5..f861e1f 100644 --- a/src/public/gud.ts +++ b/src/public/gud.ts @@ -19,18 +19,8 @@ export async function clearGud(uid) { G.ioredis.del(`gudVersion:${uid}_ver`); } - if (await G.redis.type('tanxian', uid)) { - console.log('清空tanxian Redis', uid); - // G.redis.del("tanxian", uid); - G.redis.set('tanxian', uid, {}) - } - try { - // console.log('清空friend:list Redis', uid); - // G.redis.hDel("friend:list", uid); - // G.redis.hSet('friend:list', uid, {}) - } catch (e) { - - } + //清空探险缓存 + G.ioredis.del(`tanxian:${uid}`); }; /** diff --git a/src/public/shop.ts b/src/public/shop.ts index f212ce0..85b7e16 100644 --- a/src/public/shop.ts +++ b/src/public/shop.ts @@ -1,11 +1,11 @@ -import {CollectionShop} from '../module/collection_shop'; -import {ResOpen, shopItem} from '../shared/protocols/shop/PtlOpen'; -import {PublicShared} from '../shared/public/public'; -import {ShiwuFun} from './shiwu'; +import { CollectionShop } from '../module/collection_shop'; +import { ResOpen, shopItem } from '../shared/protocols/shop/PtlOpen'; +import { PublicShared } from '../shared/public/public'; +import { ShiwuFun } from './shiwu'; type shopData = ResOpen; type changeData = { - [k in keyof shopData]: shopData[k] + [k in keyof (shopData & { version?: number | string })]: (shopData & { version?: number | string })[k] }; export class ShopFun { @@ -48,13 +48,13 @@ export class ShopFun { } static async changeShopData(uid: string, shopId: string, change: Partial) { - let where = {uid: uid, shopId: shopId} - G.mongodb.collection("shop").updateOne(where, {$set: change}) + let where = { uid: uid, shopId: shopId } + G.mongodb.collection("shop").updateOne(where, { $set: change }) } static async initShopData(uid: string, shopId: string) { - let gud = await G.mongodb.collection("user").findOne({uid: uid}, { - projection: {lv: 1, _id: 0} + let gud = await G.mongodb.collection("user").findOne({ uid: uid }, { + projection: { lv: 1, _id: 0 } }) let lv = gud?.lv || 1; @@ -69,7 +69,7 @@ export class ShopFun { } return (await G.mongodb.collection("shop").findOneAndUpdate( - {uid: uid, shopId: shopId}, + { uid: uid, shopId: shopId }, { $set: { buyNum: {}, @@ -80,7 +80,7 @@ export class ShopFun { lastFreeRefreshTime: G.time } }, - {upsert: true, returnDocument: 'after'} + { upsert: true, returnDocument: 'after' } )).value } @@ -101,11 +101,12 @@ export class ShopFun { if (shopConf.freeRefreshInterval > 0 && G.time - shopData.lastFreeRefreshTime >= shopConf.freeRefreshInterval) { shopData.useFreeRefreshNum = 0; shopData.lastFreeRefreshTime = G.time; - await this.changeShopData(uid, shopId, {useFreeRefreshNum: 0, lastFreeRefreshTime: G.time}); + await this.changeShopData(uid, shopId, { useFreeRefreshNum: 0, lastFreeRefreshTime: G.time }); } if (shopConf.version && shopConf.version != shopData.version) { - await this.changeShopData(uid, shopId, {shopItems: this.getShopItems(shopId, lv)}) + shopData.shopItems = this.getShopItems(shopId, lv); + await this.changeShopData(uid, shopId, { shopItems: shopData.shopItems, version: shopConf.version }); } return shopData diff --git a/src/public/tanxian.ts b/src/public/tanxian.ts index 00c91b8..3605819 100644 --- a/src/public/tanxian.ts +++ b/src/public/tanxian.ts @@ -9,21 +9,22 @@ export class TanXianFun { static async changeData(call: ApiCall, change: dataChange) { G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { ...change } }); - - for (let k in change) { - G.redis.set('tanxian', call.uid, k as any, change[k]); - } + let data = await this.getData(call); + Object.assign(data, change); + G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data)); } /**获取探险数据 */ static async getData(call: ApiCall, cache = true) { - if (cache && await G.redis.type('tanxian', call.uid) != null) return await G.redis.get('tanxian', call.uid); + if(cache){ + let data = await G.ioredis.get(`tanxian:${call.uid}`); + if (data) return JSON.parse(data); + } let { _id, uid, ...data } = await G.mongodb.collection('tanxian').findOne({ uid: call.uid }); if (!data.eventTime) { data.eventTime = G.time; G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { eventTime: G.time } }); } - - await G.redis.set('tanxian', call.uid, data); + await G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data)); return data; } /**获取快速探险次数 */