Compare commits

..

6 Commits

Author SHA1 Message Date
dy
4379a95d7e Merge remote-tracking branch 'origin/dev' into dev 2024-01-03 20:50:19 +08:00
dy
124681d757 Merge branch 'release' into dev 2024-01-03 20:50:12 +08:00
dy
826840455c api 锁修改 2024-01-03 20:19:58 +08:00
dy
60d0e04e33 fix 探险 gamelog 2024-01-03 19:36:28 +08:00
dy
6233a6672e Merge remote-tracking branch 'origin/bugfix' into bugfix 2024-01-03 19:28:34 +08:00
dy
afd856af30 fix 探险 2024-01-03 19:28:22 +08:00
4 changed files with 56 additions and 28 deletions

View File

@ -4,6 +4,7 @@ import { PlayerFun } from "../../public/player";
import { ReqSaoDang, ResSaoDang } from "../../shared/protocols/lingzhulaixi/PtlSaoDang";
import { PublicShared } from "../../shared/public/public";
import { HongDianChange } from "../hongdian/fun";
import {ActionLog} from "../../public/actionLog/actionLog";
export default async function (call: ApiCall<ReqSaoDang, ResSaoDang>) {
let _con = await LingZhuLaiXifun.getCon(call.req.bid)
@ -91,6 +92,8 @@ export default async function (call: ApiCall<ReqSaoDang, ResSaoDang>) {
prize = PublicShared.mergePrize(prize)
await PlayerFun.sendPrize(call, prize)
ActionLog.addDayLog(call.uid, { key: "lingzhulaixi/PkBoss", val: _num });
// 扣除挑战次数
_myData.num += _num

View File

@ -21,7 +21,11 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
let notFree = (data?.useFreeGuaJiNum || 0) >= freeNum
if (notFree) {
let num = G.gc.tanxian_com.fastGuaJiNeed[data.useFastGuaJiNum - freeNum] || 0;
let need = [{ a: 'attr', t: 'rmbmoney', n: num ? num : G.gc.tanxian_com.fastGuaJiNeed[G.gc.tanxian_com.fastGuaJiNeed.length - 1] }];
let need = [{
a: 'attr',
t: 'rmbmoney',
n: num ? num : G.gc.tanxian_com.fastGuaJiNeed[G.gc.tanxian_com.fastGuaJiNeed.length - 1]
}];
await PlayerFun.checkNeedIsMeet(call, need);
await PlayerFun.cutNeed(call, need);
}
@ -36,11 +40,11 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
// await event_dldh_addPrize(_p, call, G.gc.tanxian_com.fastGuaJiTime);
await PlayerFun.sendPrize(call, _p);
let setData = { useFastGuaJiNum: data.useFastGuaJiNum + 1, useFreeGuaJiNum: (data?.useFreeGuaJiNum || 0) + (notFree ? 0 : 1)}
if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["zztqfreeNum"] = tqFree
TanXianFun.changeData(call, setData);
// (await call.conn.gonghui)?.addExp(20, call.uid);
// let setData = { useFastGuaJiNum: data.useFastGuaJiNum + 1, useFreeGuaJiNum: (data?.useFreeGuaJiNum || 0) + (notFree ? 0 : 1)}
let setData = {$inc: {useFastGuaJiNum: 1, useFreeGuaJiNum: (notFree ? 0 : 1)}}
// if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["zztqfreeNum"] = tqFree
if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["$set"] = {zztqfreeNum: tqFree}
await TanXianFun.changeDataNew(call, setData);
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);

View File

@ -1,16 +1,31 @@
import {ApiCall} from 'tsrpc';
import {ResOpen} from '../shared/protocols/tanxian/PtlOpen';
import {TeQuanFun} from './tequan';
import {addGameLog} from "../gameLog";
type dataChange = Partial<ResOpen>;
export class TanXianFun {
/**修改探险数据 */
/**
*
*
* changeDataNew和此方法一样
*/
static async changeData(call: ApiCall, change: dataChange) {
G.mongodb.collection('tanxian').updateOne({uid: call.uid}, {$set: {...change}});
let data = await this.getData(call);
Object.assign(data, change);
G.ioredis.setex(`tanxian:${call.uid}`, 600, JSON.stringify(data));
let {_id, uid, ...data} = (await G.mongodb.collection('tanxian').findOneAndUpdate({uid: call.uid}, {$set: {...change}}, {returnDocument: 'after'})).value;
G.ioredis.setex(`tanxian:${uid}`, 600, JSON.stringify(data));
}
/**
*
* inc去叠加用户限制的次数
* @param call
* @param change
*/
static async changeDataNew(call: ApiCall, change) {
let {_id, uid, ...data} = (await G.mongodb.collection('tanxian').findOneAndUpdate({uid: call.uid}, change, {returnDocument: 'after'})).value;
G.ioredis.setex(`tanxian:${uid}`, 600, JSON.stringify(data));
addGameLog(call.uid, "_fastguajiChange", {}, data)
}
/**获取探险数据 */

View File

@ -139,14 +139,14 @@ function setWs(server: WsServer<ServiceType>) {
//处理API锁极限情况下只锁10s防止死锁
//在下方postApiReturnFlow里会解锁
if (call.conn.apiLock[call.service.name] && new Date().getTime() - call.conn.apiLock[call.service.name] < 10000) {
if (call.conn.apiLock[call.service.name] && call.conn.apiLock[call.service.name] > new Date().getTime()) {
call.error('', {code: -100, message: '', time: 0});
return null;
}
//API锁定
//API锁定到什么时候
if (!writeList.includes(call.service.name)) {
call.conn.apiLock[call.service.name] = new Date().getTime();
call.conn.apiLock[call.service.name] = new Date().getTime() + 10000;
}
//API耗时统计
call.conn.requstApiTime[call.service.name] = new Date().getTime();
@ -196,7 +196,13 @@ function setWs(server: WsServer<ServiceType>) {
}
//API解锁
let now = new Date().getTime();
if(node.return.isSucc){
node.call.conn.apiLock[node.call.service.name] = now+200;
}else{
delete node.call.conn.apiLock[node.call.service.name];
}
return node;
});