Merge branch 'dev' into release

# Conflicts:
#	src/json/herogrow_ewai.json
#	src/json/huodong.json5
#	src/json/item.json
#	src/json/pay.json
This commit is contained in:
dy 2023-12-19 10:10:20 +08:00
commit d1b9aa476b
32 changed files with 1003 additions and 643 deletions

12
oneKeyStartPm2.sh Normal file
View File

@ -0,0 +1,12 @@
git fetch origin dev && git reset --hard origin/dev && git pull
npm run build_linux
cp src/config.json dist/
pm2 del heijiao_msg_s0
cd dist && pm2 start js_pm2.config.js
pm2 save

View File

@ -3,6 +3,7 @@ import {EventFun} from '../public/event/event';
import {PayFun} from '../public/pay';
import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn";
import {PublicShared} from '../shared/public/public';
import {HuoDongFun} from "../public/huodongfun";
const defaultKeys: syncBtnKeys[] = [
'huobanzhaomu', 'yibaichou', 'shouchong',
@ -10,7 +11,8 @@ const defaultKeys: syncBtnKeys[] = [
'zhanling',
'xianshilibao',
'xianshizhaomu',
'G123Gift'
'G123Gift',
'christmas',
// 'kaifukuanghuan',
// 'qiridenglu',
@ -36,6 +38,17 @@ export default async function (call: ApiCall<ReqSyncBtn, ResSyncBtn>) {
change[key] = data[key];
}
break;
case 'christmas':
//领完消失
if (!data[key]) {
let _hdList = await HuoDongFun.gethdList(call, 8)
if (_hdList) {
// 无此活动
data[key] = {active: true};
change[key] = data[key];
}
}
break;
case 'dayjijin':
case 'dengjijijin':
case 'guanqiajijin':

View File

@ -1,7 +1,35 @@
import { ApiCall } from "tsrpc";
import { ReqGame, ResGame } from "../../../shared/protocols/event/christmas/PtlGame";
import { HongDianChange } from "../../hongdian/fun";
import { Christmasfun } from "./fun";
import {PlayerFun} from "../../../public/player";
export default async function (call: ApiCall<ReqGame, ResGame>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let need = initCon[call.req.hdid].data.gameneed;
let freenum = initCon[call.req.hdid].data.gamefree
let addval = initCon[call.req.hdid].data.game[call.req.index];
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
// 判断是否有免费配置
if (_mydata.gamenum >= freenum) {
// 判断消耗是否满足
await PlayerFun.checkNeedIsMeet(call, need);
// 扣除消耗
await PlayerFun.cutNeed(call, need);
}
let _setData = {}
_mydata["val"] += addval
_mydata["gamenum"] += 1
_setData["val"] = _mydata.val
_setData["gamenum"] = _mydata["gamenum"]
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData})
// 监听任务
G.emit("Class_task_154", 'Class_task_154', call, 1, 0);
let changedata = { mydata: _mydata}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -1,7 +1,47 @@
import { ApiCall } from "tsrpc";
import { ReqLiBao, ResLiBao } from "../../../shared/protocols/event/christmas/PtlLiBao";
import {Christmasfun} from "./fun";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqLiBao, ResLiBao>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let lbid = call.req.lbid;
let _con = initCon[call.req.hdid].data.libao[call.req.lbid];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
if (_con.payid) {
// 判断是否能购买
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let _buyNum = _mydata.libao[lbid] || 0
if (_buyNum >= _con.buynum) {
// 判断是否能购买
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
let _select = _mydata.select[lbid] || {}
if (Object.keys(_select).length < _con.dlz.length) {
// 判断是否选择奖励了
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
let _prize: atn[] = _con.basep
for (let key in _select) {
_prize.push(_con.dlz[parseInt(key)][_select[key]])
}
let _setData = {}
_mydata.libao[lbid] = _buyNum + 1
_setData["libao"] = _mydata.libao
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -1,7 +1,17 @@
import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/christmas/PtlOpen";
import { HuoDongFun } from "../../../public/huodongfun";
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/yangchengmubiao/PtlOpen";
import { Christmasfun } from "./fun";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
// TODO
call.error('API Not Implemented');
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let changedata = { mydata: _mydata, hdinfo: _hdinfo }
call.succ(changedata);
}

View File

@ -1,7 +1,38 @@
import { ApiCall } from "tsrpc";
import { ReqQianDao, ResQianDao } from "../../../shared/protocols/event/christmas/PtlQianDao";
import {Christmasfun} from "./fun";
import {PublicShared} from "../../../shared/public/public";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let _con = initCon[call.req.hdid].data.qiandao;
let _stime = initCon[call.req.hdid].stime
let _diff = PublicShared.getDiff(_stime)
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
// 循环判断是否有可以领取的
let _prize = []
for(let i = 0; i < _diff; i++) {
if (_mydata.qiandao.includes(i)) continue
_mydata.qiandao.push(i)
_prize = _prize.concat(_con[i])
}
if (!_prize){
// 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _setData = {}
_setData["qiandao"] = _mydata.qiandao
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -1,7 +1,39 @@
import { ApiCall } from "tsrpc";
import { ReqSelect, ResSelect } from "../../../shared/protocols/event/christmas/PtlSelect";
import {Christmasfun} from "./fun";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqSelect, ResSelect>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let index = call.req.index;
let pid = call.req.pid;
let lbid = call.req.lbid;
let _con = initCon[call.req.hdid].data.libao[lbid];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
if (index >= _con.dlz.length){
// 礼包id 不存在
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
}
if (index >= _con.dlz.length){
// 礼包id 不存在
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
if (!_con.dlz[index][pid]){
// 礼包id 不存在
return call.error('', { code: -4, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let lb_select = _mydata.select[lbid] || {}
lb_select[index.toString()] = pid
_mydata.select[lbid] = lb_select
let _setData = {}
_setData["select"] = _mydata.select
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
let changedata = { mydata: _mydata}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -1,7 +1,37 @@
import { ApiCall } from "tsrpc";
import { ReqTaskRec, ResTaskRec } from "../../../shared/protocols/event/christmas/PtlTaskRec";
import {Christmasfun} from "./fun";
import {HongDianChange} from "../../hongdian/fun";
import {PlayerFun} from "../../../public/player";
export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let taskid = call.req.taskid;
let _con = initCon[call.req.hdid].data.task[taskid];
if (!_con) {
// 任务id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
if (_mydata.taskval[taskid] < _con.pval) {
// 任务未完成
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_3 })
}
if (_mydata.taskfinish.includes(taskid)) {
// 任务已领取
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_4 })
}
_mydata.taskfinish.push(taskid)
let _setData = {}
_setData["taskfinish"] = _mydata.taskfinish
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
let _prize = _con.prize
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -1,7 +1,48 @@
import { ApiCall } from "tsrpc";
import { ReqZhanLingRec, ResZhanLingRec } from "../../../shared/protocols/event/christmas/PtlZhanLingRec";
import {Christmasfun} from "./fun";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
// TODO
call.error('API Not Implemented');
let initCon = await Christmasfun.getCon(call)
let index = call.req.index;
let _con = initCon[call.req.hdid].data.zhanling[index];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
if (_mydata.val < _con.val) {
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _prize = []
if (!_mydata.pt.includes(index)){
// 如果普通奖励没有领取
_prize = _prize.concat(_con.pt)
_mydata.pt.push(index)
}
if (_mydata.pay && !_mydata.gj.includes(index)){
// 如果普通奖励没有领取
_prize = _prize.concat(_con.gj)
_mydata.gj.push(index)
}
if (!_prize) {
// 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _setData = {}
_setData["gj"] = _mydata.gj
_setData["pt"] = _mydata.pt
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
}

View File

@ -0,0 +1,200 @@
import { strict } from 'assert';
import {ApiCall, BaseConnection} from 'tsrpc';
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
import { HuoDongFun } from '../../../public/huodongfun';
import { TaskFun } from '../../../public/task';
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
import { PublicShared } from '../../../shared/public/public';
import {player} from '../../../shared/protocols/user/type';
import {PlayerFun} from "../../../public/player";
export class Christmasfun {
/**配置 */
static async getCon(call: ApiCall) {
let _con: { [id: string]: ReqAddHuoDong } = {}
let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) {
const element = _hd[index];
if (element && element._id) delete element._id
_con[element.hdid] = element
}
return _con
}
/**获取所有符合时间的活动 */
static async gethdids(call: ApiCall) {
let _hdids = []
let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) {
const element = _hd[index];
_hdids.push(element.hdid)
}
return _hdids
}
/**获取我的数据 */
static async getMyData(call: ApiCall, hdid: number) {
let db: any = await G.mongodb.cEvent(`christmas${hdid}`).findOne({ uid: call.uid, type: `christmas${hdid}`, hdid: hdid });
if (!db) {
db = await this.initData(call, hdid)
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
{ uid: call.uid, type: `christmas${hdid}`, hdid: hdid },
{ $set: db },
{ upsert: true }
)
}
let { _id, ..._myData } = db
if (!PublicShared.chkSameDate(_myData.refresh, G.time)) {
// 刷新每日任务
_myData = await this.refreTask(call, _myData, hdid)
}
return _myData
}
/**初始数据 */
static async initData(call: ApiCall, hdid: number) {
let _initCon = await this.getCon(call)
let _con = _initCon[hdid]
let _r: christmas = {
type: `christmas${hdid}`,
uid: call.uid,
hdid: hdid,
taskval: await this.getTaskVal(call, hdid),
taskfinish: [],
refresh: G.time,
gamenum: 0,
pt: [],
gj: [],
pay: false,
select:{},
val: 0,
qiandao: [],
libao:{}
}
return _r
}
/**设置数据 */
static async setMyData(uid: string, hdid: number, set: {}) {
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
{ uid: uid, type: `christmas${hdid}`, hdid: hdid },
set
)
}
/**获取所有taskid 及对应的值 */
static async getTaskVal(call: ApiCall, hdid: number) {
let _initCon = await this.getCon(call)
let _tasks = _initCon[hdid].data.task
let _res = {}
for (let index = 0; index < Object.keys(_tasks).length; index++) {
const element = Object.keys(_tasks)[index];
let _tmp = _tasks[element]
_tmp["id"] = element
// 每日登录直接完成
if (element == "1"){
_res[element] = 1
}
else{
_res[element] = 0
}
}
return _res
}
/**刷新每日任务 */
static async refreTask(call: ApiCall, mydata: christmas, hdid: number) {
let _initCon = await this.getCon(call)
let _con = _initCon[hdid].data.task
if (!_con) return mydata
mydata.taskfinish = []
mydata.taskval = await this.getTaskVal(call, hdid)
mydata.refresh = G.time
mydata.gamenum = 0
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval, gamenum: mydata.gamenum} })
return mydata
}
static async payChristmas(payid, call: ApiCall) {
let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) {
const hdinfo = _hd[index];
const _hdid = hdinfo.hdid
if (payid == hdinfo.data.zlpayid){
let _mydata = await Christmasfun.getMyData(call, _hdid)
if (_mydata.pay) continue
await this.setMyData(call.uid, _hdid, { $set: { pay: true} })
let _prize = hdinfo.data.zlpayprize
await PlayerFun.sendPrize(call, _prize);
}
else{
const libaos = hdinfo.data.libao
for (let index = 0; index < Object.keys(libaos).length; index++){
const lbid = Object.keys(libaos)[index];
let _tmp = libaos[lbid]
if (_tmp['payid'] != payid) continue
let _mydata = await Christmasfun.getMyData(call, _hdid)
let _buyNum = _mydata.libao[lbid] || 0
if (_buyNum >= _tmp["buynum"]) continue
_mydata.libao[lbid] = _buyNum + 1
this.setMyData(call.uid, _hdid, { $set: { libao: _mydata.libao} })
break
}
}
}
}
/**设置任务 */
static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) {
let hdids = await this.gethdids(call)
if (hdids.length <= 0) return // 活动过期,不计数
let _initCon = await this.getCon(call)
for (let index = 0; index < hdids.length; index++) {
const hdid = hdids[index];
let _mydata = await Christmasfun.getMyData(call, hdid)
let _tasks = _initCon[hdid].data.task
let _setData= {
$inc: {},
$set: {}
}
let isset = 0
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
const ele = Object.keys(_tasks)[indextask];
// 具体任务配置
let _taskCon = _tasks[ele]
if (_taskCon.stype != stype) continue
let _pval = _taskCon.pval
// 不符合任务要求
if (!(await chkCall(_taskCon["cond"], chkval, arg))) continue
// 根据需求改写
val = await alchangeVal(call, _taskCon, val, arg)
isset = 1
if (isinc == 1) { // 累加
_setData["$inc"][`taskval.${ele}`] = val
} else {
_setData["$set"][`taskval.${ele}`] = val
}
}
// 设置任务
if (isset == 1) {
await G.mongodb.collection('event').updateMany(
{ uid: call.uid, type: { $regex: "christmas" }, hdid: parseInt(hdid) },
_setData
)
}
}
}
}

View File

@ -1,41 +1,42 @@
import { UpdateFilter } from 'mongodb';
import { ApiCall } from "tsrpc";
import { CollectionEvent } from '../../../module/collection_event';
import { PayFun } from '../../../public/pay';
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/shiwuleichong/PtlOpen";
import { PublicShared } from '../../../shared/public/public';
import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/shiwuleichong/PtlOpen";
import {PayFun} from "../../../public/pay";
import {PublicShared} from "../../../shared/public/public";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
let update: UpdateFilter<CollectionEvent<'15leichong'>>;
let sTime = PublicShared.getToDayZeroTime(G.time);
let payids = G.gc.shiwuleichong.tasks.map(
(i) => i.payid
);
if (!db) {
update = {
$set: { index: 0, sTime: sTime, recIndex: [] }
};
let day: number = 1;
let _zt = PublicShared.getToDayZeroTime();
let pays = await PayFun.getPayLogs(call.uid, payids);
for (; day <= G.gc.shiwuleichong.tasks.length; day++) {
let pay = pays[G.gc.shiwuleichong.tasks[day - 1].payid];
if (!pay || pay.length == 0) {
break
} else {
if (db.sTime + G.gc.shiwuleichong.data[db.index].time < G.time) {
db.sTime = sTime;
db.index = G.gc.shiwuleichong.data[db.index + 1] == undefined ? db.index : db.index + 1;
db.recIndex = [];
update = {
$set: { index: db.index, sTime: db.sTime, recIndex: [] }
};
} else {
sTime = db.sTime;
// 如果是最后一天奖励
if (day >= G.gc.shiwuleichong.tasks.length) {
// 充值订单隔天了
if (pay.slice(-1)[0].time < _zt) {
// 重置所有订单
await PayFun.delPayLog(call.uid, ...payids.map(i => {
return {payId: i, val: []}
}))
day = 1;
pays = {};
}
break;
} else if (pay.slice(-1)[0].time >= _zt) {
break
}
}
}
update && G.mongodb.cEvent('15leichong').updateOne({ uid: call.uid, type: '15leichong' }, update, { upsert: true });
let index = db?.index || 0;
call.succ({
index: index,
sTime: sTime,
recIndex: db?.recIndex || [],
payDay: await PayFun.getPayDaysBuyPayNum(call.uid, sTime, sTime + G.gc.shiwuleichong.data[index].time, G.gc.shiwuleichong.dayPayNeed)
day: day,
payIds: Object.keys(pays).filter((i) => pays[i].length > 0)
});
}

View File

@ -1,26 +0,0 @@
import { ApiCall } from "tsrpc";
import { PayFun } from '../../../public/pay';
import { PlayerFun } from '../../../public/player';
import { ReqRec, ResRec } from "../../../shared/protocols/event/shiwuleichong/PtlRec";
export default async function (call: ApiCall<ReqRec, ResRec>) {
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
let confArr = G.gc.shiwuleichong.data[db.index];
if (!confArr.tasks[call.req.index]) return call.error('', { code: -1 });
if (db.recIndex.includes(call.req.index)) return call.error('', { code: -2 });
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + confArr.time, G.gc.shiwuleichong.dayPayNeed);
if (payDay < confArr.tasks[call.req.index].total) return call.error('', { code: -3 });
await PlayerFun.sendPrize(call, confArr.tasks[call.req.index].prize);
G.mongodb.cEvent('15leichong').updateOne(
{ uid: call.uid, type: '15leichong' },
{ $push: { recIndex: call.req.index } }
);
call.succ({
prize: confArr.tasks[call.req.index].prize
});
}

View File

@ -20,7 +20,7 @@ export default async function (call: ApiCall<ReqBuyLv, ResBuyLv>) {
let change: ResBuyLv['change'] = {};
change.lv = data.lv + lv;
change.exp = G.gc.zhanling.lv[change.lv];
change.exp = data.exp + 1000;
G.mongodb.cEvent('zhanling').updateOne(
{ uid: call.uid, type: 'zhanling' },

View File

@ -11,10 +11,10 @@ import {WangZheRongYaofun} from "../../public/wzry";
import {XstaskFun} from "../../public/xstask";
import {ReqGet, ResGet, hongdianKey} from "../../shared/protocols/hongdian/PtlGet";
import {PublicShared} from '../../shared/public/public';
import {getShouChongRedPoint} from '../event/shouchong/ApiReceive';
import {md_redPoint} from '../gongyu/mingdao/ApiOpen';
import {HongDianFun, HuoDongHongDianFun} from "./fun";
import {FunWeiXiuChang} from "../../public/weixiuchang";
import {getShouChongRedPoint} from "../event/shouchong/ApiReceive";
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',

View File

@ -20,6 +20,7 @@ import {PlayerFun} from "../../public/player";
import kfjsFun from "../../public/kaifujingsai";
import {RankKfjs} from "../../public/rank/rank_kfjs";
import {ShopFun} from "../../public/shop";
import {Christmasfun} from '../event/christmas/fun';
export class HongDianFun {
/**黑榜争霸红点 */
@ -689,6 +690,68 @@ export class HuoDongHongDianFun {
return _res;
}
/**圣诞节活动红点 */
static async christmasHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
let _res: hongdianVal = {
show: false,
};
let _hdCon = hdCon.data;
let stime = hdCon.stime
let _mydata = await Christmasfun.getMyData(call, hdCon.hdid);
let _tasks = hdCon.data.task; // 所有任务 taskid 为key
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
const elementtask = Object.keys(_tasks)[indextask];
let _tmp = _tasks[elementtask];
if (_tmp.pval <= (_mydata.taskval[elementtask] || 0) && !_mydata.taskfinsih.includes(elementtask)) {
// 任务完成且没有领取
_res.show = true;
return _res;
}
}
let libaos = _hdCon.libao
for (let indexlibao = 0; indexlibao < Object.keys(libaos).length; indexlibao++) {
const elementlibao = Object.keys(libaos)[indexlibao];
let _tmp = _tasks[elementlibao];
if (_tmp.payid) continue
let _buyNum = _mydata.libao[elementlibao] || 0
if (_buyNum < _tmp.buynum) {
_res.show = true;
return _res;
}
}
let _diff = PublicShared.getDiff(stime)
// 循环判断是否有可以领取的
for (let i = 0; i < _diff; i++) {
if (_mydata.qiandao.includes(i)) continue
_res.show = true;
return _res;
}
let need = _hdCon.gameneed;
// 判断消耗是否满足
let meet = await PlayerFun.checkNeedIsMeet(call, need, false);
if (meet.isOk == true) {
_res.show = true;
return _res;
}
let zhanling = _hdCon.zhanling
for (let indexzhanling = 0; indexzhanling < zhanling.length; indexzhanling++) {
if (!_mydata.pt.includes(indexzhanling)) {
_res.show = true;
return _res;
}
if (_mydata.pay && !_mydata.gj.includes(indexzhanling)) {
_res.show = true;
return _res;
}
}
return _res;
}
/**养成目标红点 */
static async yangchengmubiaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
let _res: hongdianVal = {
@ -814,7 +877,7 @@ export class HuoDongHongDianFun {
}
};
_res.val.meirijingxuan = await this.heiShiHongDian(call)
_res.val.jitianhaoli = await this.heiShiLCHongDian(call)
// _res.val.jitianhaoli = await this.heiShiLCHongDian(call)
_res.val.niudanji = await this.heiShiNiuDanJi(call)
Object.values(_res.val).forEach(x => _res.show = _res.show || x.show)
return _res
@ -850,25 +913,25 @@ export class HuoDongHongDianFun {
}
/**黑市 积天豪礼 */
static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
let _res: hongdianVal = {
show: false
};
let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
if (!db) return _res;
let _con = G.gc.shiwuleichong.data[db.index];
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
for (let index = 0; index < _con.tasks.length; index++) {
const element = _con.tasks[index];
if (db.recIndex.includes(index)) continue;
if (payDay < element.total) continue;
_res.show = true;
break;
}
return _res;
}
// static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
// let _res: hongdianVal = {
// show: false
// };
// let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
//
// if (!db) return _res;
//
// let _con = G.gc.shiwuleichong.data[db.index];
// let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
// for (let index = 0; index < _con.tasks.length; index++) {
// const element = _con.tasks[index];
// if (db.recIndex.includes(index)) continue;
// if (payDay < element.total) continue;
// _res.show = true;
// break;
// }
// return _res;
// }
/**黑市 扭蛋机 */
static async heiShiNiuDanJi(call: ApiCall): Promise<hongdianVal> {

View File

@ -1,7 +0,0 @@
import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../shared/protocols/pushgift/PtlOpen";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -42,6 +42,12 @@ export default async function (call: ApiCall<ReqAllFinsh, ResAllFinsh>) {
// 设置数据
await TaskFun.setTask(call.uid, { type: _type, taskid: { $in: _finishTaks } }, { finish: 1 })
let prize = await PlayerFun.sendPrize(call, _prize)
// 是否是每日任务奖励最终宝箱
if (_type == 4 && 25 in _finishTaks){
// 监听任务
G.emit("Class_task_155", 'Class_task_155', call, 1, 0);
}
let data = {
finishtask: _finishTaks,

View File

@ -44,6 +44,11 @@ export default async function (call: ApiCall<ReqFinsh, ResFinsh>) {
}
// 设置数据
await TaskFun.setTask(call.uid, {taskid: taskid}, {finish: 1})
// 是否是每日任务奖励最终宝箱
if (_task["type"] == 4 && 25 == taskid){
// 监听任务
G.emit("Class_task_155", 'Class_task_155', call, 1, 0);
}
let _prize = await PlayerFun.sendPrize(call, _con["prize"])
_task["finish"] = 1

View File

@ -9,7 +9,10 @@ async function connGameLogDB() {
}else{
logDBUrl = "mongodb://root:lyMaple525458@10.0.1.20:27017/heijiao_gamelog?authSource=admin";
}
let client = await MongoClient.connect(logDBUrl,{maxPoolSize:10});
let client = await MongoClient.connect(logDBUrl,{
maxPoolSize:10,
maxIdleTimeMS: 5*60*1000
});
logDB = client.db(`gameLog${G.config.serverId}`);
return logDB;
}

View File

@ -16,6 +16,7 @@ import { player } from './shared/protocols/user/type';
import { PublicShared } from './shared/public/public';
import { setGud } from './public/gud';
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
import {Christmasfun} from "./api_s2c/event/christmas/fun";
export type gEventType = {
/**玩家断开连接 */
@ -23,7 +24,7 @@ export type gEventType = {
/**玩家修改名字 */
PLAYER_CHANGE_NAME: (gud: player, name: string) => void;
/**玩家充值 */
PLAYER_PAY: (gud: player, payId: string, type: 'user' | 'system') => void;
PLAYER_PAY: (gud: player, payId: string, type: 'user' | 'system', call) => void;
/**玩家发生api调用 */
API_CALL: (node: { call: ApiCall, return: ApiReturn<any>; }) => void;
/**玩家每日首次登陆 */
@ -138,6 +139,10 @@ export type gEventType = {
Class_task_152: (eventname, call, val, chkVal) => void;
/**合成x次装备 */
Class_task_153: (eventname, call, val, chkVal) => void;
/**参与圣诞活动小游戏 */
Class_task_154: (eventname, call, val, chkVal) => void;
/**每日任务宝箱领取 */
Class_task_155: (eventname, call, val, chkVal) => void;
};
export function addListener() {
@ -166,13 +171,14 @@ export function addListener() {
}
});
G.on('PLAYER_PAY', async (player, payId, payArgs) => {
G.on('PLAYER_PAY', async (player, payId, payArgs,call) => {
let conf: any = await PayFun.getConf(payId, payArgs);
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
ActionLog.addRetainLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
if (payId == G.gc.zhanling.payId) payZhanLing(player);
//圣诞节活动充值
Christmasfun.payChristmas(payId, call);
let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan'];
if (payEmailConf?.length > 0) {
let sendEmailConfs = payEmailConf;
@ -202,18 +208,17 @@ export function addListener() {
ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 });
ZhanLingTasks.clearLog(gud.uid, 'day');
PayFun.checkGiftDayEmail(gud, lastTime, curTime);
reissuePrize(gud, lastTime, curTime);
addDay(gud);
// 任务累计登录天数
let call = PayFun.getCall(gud);
G.emit("Class_task_135", 'Class_task_135', call, 1, 0);
// 七日登录活动计数
qiRiDengLuAddDay(call);
// 周末礼包检测刷新
checkResetBuyLog(call)
checkResetBuyLog(call);
});
G.on('API_CALL', node => {

View File

@ -1179,7 +1179,7 @@ type gc_shiwucom = {
}, "comment": { "jichu_colour": string, "fujia_colour": string, "fujianum_colour": string, "putongxilian": string, "gaojixilian": string, "hero_zhuanshu": string, "buff_zhuanshu": string, "skill_zhuanshu": string, "chongzhuneed": string, "chongzhurate": string, "tilianhuobi": string, [x: string]: any }, [x: string]: any
}
type gc_shiwuleichong = { "dayPayNeed": number, "data": { "time": number, "tasks": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }[], [x: string]: any }[], [x: string]: any }
type gc_shiwuleichong = { tasks: { day: number, payid: string }[] }
type gc_shoot = { [key: string]: { "name": string, "num": number, "speed": number, "cartridge": number, "time": number, "prize": { [key: string]: { "describe": string, "hit": number, "content": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any } }, [x: string]: any } }

View File

@ -13,7 +13,7 @@ export default {
/**跨服 ws url */
corssWsUrl: "ws://10.0.1.20:10003",
/**服务器id */
serverId: 0,
serverId: 1001,
/**redis url */
redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0',
/**mongodb url */
@ -27,7 +27,7 @@ export default {
/**服务器时间 */
time: '',
/**开服时间 */
openTime: '2022-10-10 1:0:0',
openTime: '2023-12-11 1:0:0',
/**项目名称 */
projectName: 'heijiao',
/**加密key */

View File

@ -1,13 +0,0 @@
import {ObjectId} from "mongodb";
import {ResOpen} from "../shared/protocols/pushgift/PtlOpen";
export type Gift = {
id: string
uid: string
buy: number[]
ctime: number
passTime: number
ext_data: { [key: string]: any }
}
export type CollectionPushGift = Gift & { _id: ObjectId };

View File

@ -149,6 +149,12 @@ export class PayFun {
needVip: 0,
front: {}
}
} else if (payId == '136GiftAll') {
// 136礼包一键购买加入所有礼包奖励
conf = {
...conf,
prize: R.compose(R.flatten(), R.map(i => i.prize), R.filter(i => i.id.indexOf('136Gift') != -1), R.values())(G.gc.pay)
}
}
return conf
}
@ -225,7 +231,7 @@ export class PayFun {
prize.push(...conf.prize)
}
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs)
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs, player)
if (isReplaceConf) {
let prizePayId = `zuanshi_${conf.money}`
payArgs.toPrizePayId = prizePayId
@ -270,7 +276,7 @@ export class PayFun {
}
});
G.emit('PLAYER_PAY', player, payId, payArgs);
G.emit('PLAYER_PAY', player, payId, payArgs, call);
G.emit("Class_task_116", 'Class_task_116', call, 1, 0);
}
@ -314,8 +320,9 @@ export class PayFun {
* @param payId
* @param conf
* @param payArgs
* @param player
*/
static async checkBuysAfterPay(uid, payId, conf, payArgs) {
static async checkBuysAfterPay(uid, payId, conf, payArgs, player) {
if (payId == 'G123SendGift') {
let giftInfo = await G.mongodb.collection('giftLog').findOne({popup_id: payArgs.popup_id});
if (giftInfo.purchaseLimitAmount && giftInfo.buyNumber >= giftInfo.purchaseLimitAmount && number(giftInfo.price) > 0) {
@ -327,6 +334,12 @@ export class PayFun {
buyLog = buyLog.filter(v => v.time >= PublicShared.getToDayZeroTime(G.time));
}
if (conf.buys > 0 && buyLog.length >= conf.buys) return true;
//针对周末礼包的单独处理
if (payId.indexOf('wkdlibao') != -1) {
let call = this.getCall(player)
let conf = await zmlbGetConf(call, {payId})
if (buyLog.length && buyLog.length >= conf.buyNum) return true
}
}
return false
}
@ -376,10 +389,20 @@ export class PayFun {
if (conf.time != -1 && buyLog.slice(-1)[0]?.eTime > G.time && conf.buys == 0 && payId.indexOf('wkdlibao') == -1) {
return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -2});
}
if (payId.indexOf('136Gift') != -1 && payId != '136Gift1') {
buyLog = await this.getPayLog(player.uid, '136Gift1');
if (buyLog.slice(-1)[0]?.eTime > G.time) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -3});
//针对每日礼包的单独处理
let zeroTime = PublicShared.getToDayZeroTime(G.time)
if (payId.indexOf('136Gift') != -1 && payId != '136GiftAll') {
let buyLog136 = await this.getPayLog(player.uid, '136GiftAll');
buyLog136 = buyLog136.filter(v => v.time >= zeroTime);
if (buyLog136.length) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -1});
}
if (payId.indexOf('136Gift') != -1 && payId == '136GiftAll') {
let ids = R.compose(R.map(i => i.id), R.filter(i => i.id.indexOf('136Gift') != -1 && i.id != '136GiftAll'), R.values())(G.gc.pay)
let buyLog136 = await this.getPayLogs(player.uid, ids);
let buyLog136list = R.compose(R.filter(v => v.time >= zeroTime), R.flatten(), R.values())(buyLog136)
if (buyLog136list.length) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -1});
}
//针对周末礼包的单独处理
if (payId.indexOf('wkdlibao') != -1) {
let call = this.getCall(player)
let conf = await zmlbGetConf(call, {payId})

View File

@ -1,5 +1,6 @@
import {ApiCall} from "tsrpc"
import {YangChengMuBiaofun} from "../api_s2c/event/yangchengmubiao/fun"
import {Christmasfun} from "../api_s2c/event/christmas/fun"
// import { YangChengMuBiaofun } from "../api_s2c/event/yangchengmubiao/fun"
import {Wjjl} from "../module/collection_wjjl"
import {PublicShared} from "../shared/public/public"
@ -73,6 +74,8 @@ export module manager {
TaskFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
// 养成目标任务计数
YangChengMuBiaofun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
// 圣诞活动任务计数
Christmasfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
}
// 任务数值, 和检测值,看情况需要上层复写
@ -763,6 +766,24 @@ export module manager {
return call.conn.gud?.helpHeros?.length || 0;
}
}
// 第56个任务 完成圣诞活动小游戏
export class Class_task_154 extends BaseClass {
stype = 154
isinc = 1
async initVal(call: ApiCall, con) {
return 1;
}
}
// 第57个任务 领取每日任务最终宝箱
export class Class_task_155 extends BaseClass {
stype = 155
isinc = 0
async initVal(call: ApiCall, con) {
return 1;
}
}
}

View File

@ -443,13 +443,22 @@ export async function initMongoDB() {
//可结合查看node_modules\mongodb\lib\connection_string.js
//maxPoolSize默认值100
let option:MongoClientOptions;
/**
* MongoDB连接池具有多个参数
* maxPoolSize100
* minPoolSize0
* maxIdleTimeMS0
* waitQueueTimeoutMS0
*/
let option:MongoClientOptions = {
//空闲5分钟后关闭
maxIdleTimeMS: 5*60*1000
};
//跨服只有1个直接采用默认配置就行
if(G.argv.serverType != 'cross'){
if(PublicShared.getOpenServerDay() > 3){
option = {
maxPoolSize: 10
}
option.maxPoolSize=10;
}
}
@ -463,7 +472,8 @@ export async function initMongoDB() {
console.log('connect crossmongodb ......');
//本服里,维持住跟跨服数据库的链接
let crossClient = await MongoClient.connect(G.config.crossMongodbUrl,{
maxPoolSize:10
maxPoolSize:10,
maxIdleTimeMS: 5*60*1000
});
G.crossmongodb = new _mongodb(crossClient.db(G.config.corssDBName || ""));
console.log('connect crossmongodb succ');

View File

@ -30,4 +30,4 @@ export type defaultSyncBtn = {
export type syncBtnKeys = 'shouchong' | 'kaifukuanghuan' | jijinType | 'zhanling' | 'qiridenglu'
| 'xianshilibao' | 'yibaichou' | 'huobanzhaomu' | 'xianshizhaomu'
| 'leijichongzhi' | 'xinshoulibao' | 'jierihuodong' | 'yuedujijin' | 'zixuanlibao' | 'diaoluoduihuan' | 'chuanshuozhilu'
| 'yangchengmubiao' | 'G123Gift'
| 'yangchengmubiao' | 'G123Gift' | 'christmas'

View File

@ -1,18 +1,10 @@
/**
* 15
*/
export type ReqOpen = {
};
export type ReqOpen = {};
export type ResOpen = {
/**礼包组 取G.gc.shiwuleichong[index] */
index: number;
/**开始时间 倒计时显示 sTime+G.gc.shiwuleichong[index].time */
sTime: number;
/**已领取的奖励下标 */
recIndex: number[];
/**已充值的天数 */
payDay: number;
day: number;
payIds: string[];
};

View File

@ -1,13 +0,0 @@
import { prizeType } from '../../type';
/**
* 15
*/
export type ReqRec = {
index: number;
};
export type ResRec = {
prize: prizeType[];
};

View File

@ -1 +0,0 @@
export type MsgPushGiftChange = 1;

View File

@ -1,5 +0,0 @@
import {Gift} from "../../../module/collection_pushgift";
export type ReqOpen = {}
export type ResOpen = { gifts: Gift[] }

File diff suppressed because it is too large Load Diff