Compare commits

..

No commits in common. "4379a95d7ec26b82ba5aa6ba248f356e74e50784" and "1090a5f8df25cc090ed42c28480478d6d70dae50" have entirely different histories.

4 changed files with 28 additions and 56 deletions

View File

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

View File

@ -1,12 +1,12 @@
import {ApiCall} from "tsrpc"; import { ApiCall } from "tsrpc";
import {PlayerFun} from '../../public/player'; import { PlayerFun } from '../../public/player';
import {TanXianFun} from '../../public/tanxian'; import { TanXianFun } from '../../public/tanxian';
import {TeQuanFun} from "../../public/tequan"; import { TeQuanFun } from "../../public/tequan";
import {ReqFastGuaJi, ResFastGuaJi} from "../../shared/protocols/tanxian/PtlFastGuaJi"; import { ReqFastGuaJi, ResFastGuaJi } from "../../shared/protocols/tanxian/PtlFastGuaJi";
import {TanXianShared} from '../../shared/public/tanxian'; import { TanXianShared } from '../../shared/public/tanxian';
import {event_dldh_addPrize} from '../event/diaoluoduihuan/ApiOpen'; import { event_dldh_addPrize } from '../event/diaoluoduihuan/ApiOpen';
import {HongDianChange} from "../hongdian/fun"; import { HongDianChange } from "../hongdian/fun";
import {getEventPrize} from './ApiEvent'; import { getEventPrize } from './ApiEvent';
export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) { export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
@ -20,12 +20,8 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
// let notFree = data.useFastGuaJiNum >= freeNum && ((data?.zztqfreeNum || 0) >= tqFree && tqFree) && (data?.useFreeGuaJiNum || 0) <= freeNum // let notFree = data.useFastGuaJiNum >= freeNum && ((data?.zztqfreeNum || 0) >= tqFree && tqFree) && (data?.useFreeGuaJiNum || 0) <= freeNum
let notFree = (data?.useFreeGuaJiNum || 0) >= freeNum let notFree = (data?.useFreeGuaJiNum || 0) >= freeNum
if (notFree) { if (notFree) {
let num = G.gc.tanxian_com.fastGuaJiNeed[data.useFastGuaJiNum - freeNum] || 0; let num = G.gc.tanxian_com.fastGuaJiNeed[data.useFastGuaJiNum - freeNum ] || 0;
let need = [{ let need = [{ a: 'attr', t: 'rmbmoney', n: num ? num : G.gc.tanxian_com.fastGuaJiNeed[G.gc.tanxian_com.fastGuaJiNeed.length - 1] }];
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.checkNeedIsMeet(call, need);
await PlayerFun.cutNeed(call, need); await PlayerFun.cutNeed(call, need);
} }
@ -40,11 +36,11 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
// await event_dldh_addPrize(_p, call, G.gc.tanxian_com.fastGuaJiTime); // await event_dldh_addPrize(_p, call, G.gc.tanxian_com.fastGuaJiTime);
await PlayerFun.sendPrize(call, _p); await PlayerFun.sendPrize(call, _p);
// let setData = { useFastGuaJiNum: data.useFastGuaJiNum + 1, useFreeGuaJiNum: (data?.useFreeGuaJiNum || 0) + (notFree ? 0 : 1)} 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["zztqfreeNum"] = tqFree TanXianFun.changeData(call, setData);
if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["$set"] = {zztqfreeNum: tqFree}
await TanXianFun.changeDataNew(call, setData); // (await call.conn.gonghui)?.addExp(20, call.uid);
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']); HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);

View File

@ -1,31 +1,16 @@
import {ApiCall} from 'tsrpc'; import {ApiCall} from 'tsrpc';
import {ResOpen} from '../shared/protocols/tanxian/PtlOpen'; import {ResOpen} from '../shared/protocols/tanxian/PtlOpen';
import {TeQuanFun} from './tequan'; import {TeQuanFun} from './tequan';
import {addGameLog} from "../gameLog";
type dataChange = Partial<ResOpen>; type dataChange = Partial<ResOpen>;
export class TanXianFun { export class TanXianFun {
/** /**修改探险数据 */
*
*
* changeDataNew和此方法一样
*/
static async changeData(call: ApiCall, change: dataChange) { static async changeData(call: ApiCall, change: dataChange) {
let {_id, uid, ...data} = (await G.mongodb.collection('tanxian').findOneAndUpdate({uid: call.uid}, {$set: {...change}}, {returnDocument: 'after'})).value; G.mongodb.collection('tanxian').updateOne({uid: call.uid}, {$set: {...change}});
G.ioredis.setex(`tanxian:${uid}`, 600, JSON.stringify(data)); let data = await this.getData(call);
} Object.assign(data, change);
G.ioredis.setex(`tanxian:${call.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防止死锁 //处理API锁极限情况下只锁10s防止死锁
//在下方postApiReturnFlow里会解锁 //在下方postApiReturnFlow里会解锁
if (call.conn.apiLock[call.service.name] && call.conn.apiLock[call.service.name] > new Date().getTime()) { if (call.conn.apiLock[call.service.name] && new Date().getTime() - call.conn.apiLock[call.service.name] < 10000) {
call.error('', {code: -100, message: '', time: 0}); call.error('', {code: -100, message: '', time: 0});
return null; return null;
} }
//API锁定到什么时候 //API锁定
if (!writeList.includes(call.service.name)) { if (!writeList.includes(call.service.name)) {
call.conn.apiLock[call.service.name] = new Date().getTime() + 10000; call.conn.apiLock[call.service.name] = new Date().getTime();
} }
//API耗时统计 //API耗时统计
call.conn.requstApiTime[call.service.name] = new Date().getTime(); call.conn.requstApiTime[call.service.name] = new Date().getTime();
@ -196,13 +196,7 @@ function setWs(server: WsServer<ServiceType>) {
} }
//API解锁 //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]; delete node.call.conn.apiLock[node.call.service.name];
}
return node; return node;
}); });