Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
60bbb97a40
@ -12,7 +12,7 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
let change: Partial<ResOpen> = {};
|
let change: Partial<ResOpen> = {};
|
||||||
let data = await DxltFun.getData(call);
|
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 (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.over) return call.error(globalThis.lng.dixialeitai_4);
|
||||||
if (!data.heros[call.req]) return call.error(globalThis.lng.dixialeitai_5);
|
if (!data.heros[call.req]) return call.error(globalThis.lng.dixialeitai_5);
|
||||||
|
@ -19,18 +19,8 @@ export async function clearGud(uid) {
|
|||||||
G.ioredis.del(`gudVersion:${uid}_ver`);
|
G.ioredis.del(`gudVersion:${uid}_ver`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await G.redis.type('tanxian', uid)) {
|
//清空探险缓存
|
||||||
console.log('清空tanxian Redis', uid);
|
G.ioredis.del(`tanxian:${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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ import {ShiwuFun} from './shiwu';
|
|||||||
|
|
||||||
type shopData = ResOpen;
|
type shopData = ResOpen;
|
||||||
type changeData = {
|
type changeData = {
|
||||||
[k in keyof shopData]: shopData[k]
|
[k in keyof (shopData & { version?: number | string })]: (shopData & { version?: number | string })[k]
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ShopFun {
|
export class ShopFun {
|
||||||
@ -105,7 +105,8 @@ export class ShopFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shopConf.version && shopConf.version != shopData.version) {
|
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
|
return shopData
|
||||||
|
@ -9,21 +9,22 @@ export class TanXianFun {
|
|||||||
static async changeData(call: ApiCall, change: dataChange) {
|
static async changeData(call: ApiCall, change: dataChange) {
|
||||||
|
|
||||||
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { ...change } });
|
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { ...change } });
|
||||||
|
let data = await this.getData(call);
|
||||||
for (let k in change) {
|
Object.assign(data, change);
|
||||||
G.redis.set('tanxian', call.uid, k as any, change[k]);
|
G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**获取探险数据 */
|
/**获取探险数据 */
|
||||||
static async getData(call: ApiCall, cache = true) {
|
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 });
|
let { _id, uid, ...data } = await G.mongodb.collection('tanxian').findOne({ uid: call.uid });
|
||||||
if (!data.eventTime) {
|
if (!data.eventTime) {
|
||||||
data.eventTime = G.time;
|
data.eventTime = G.time;
|
||||||
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { eventTime: G.time } });
|
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { eventTime: G.time } });
|
||||||
}
|
}
|
||||||
|
await G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data));
|
||||||
await G.redis.set('tanxian', call.uid, data);
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
/**获取快速探险次数 */
|
/**获取快速探险次数 */
|
||||||
|
Loading…
Reference in New Issue
Block a user