Merge remote-tracking branch 'origin/dev-leijichongzhi' into dev

This commit is contained in:
dy 2023-12-22 14:34:08 +08:00
commit a0bdc11a05
10 changed files with 805 additions and 454 deletions

View File

@ -0,0 +1,21 @@
import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/leichonglibao/PtlOpen";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let data = await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).findOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}
)
let change = {opentime: G.time}
if (!data) {
Object.assign(change, {sc: false, buy: []})
}
// 每天open红点
G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).updateOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: change}
)
let temp = Object.assign((data || {}), change) as ResOpen & { opentime }
call.succ({sc: temp.sc, buy: temp.buy});
}

View File

@ -0,0 +1,108 @@
import {ApiCall} from "tsrpc";
import {HuoDongFun} from "../../../public/huodongfun";
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/leichonglibao/PtlReceive";
import {PlayerFun} from "../../../public/player";
import {PublicShared} from "../../../shared/public/public";
export type LeiChongLiBaoData = {
intr: string
intr2: string
payRewardNum: number
dlz: { [key: string]: atn }[]
gift: {
id: string, name: string, need: atn[], free: boolean, payId: string, scale: number, buynum: number, prize: atn[]
}[]
}
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
// 无此活动
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
}
let hddata = hdinfo.filter(i => i.hdid == call.req.hdid)[0].data as LeiChongLiBaoData;
let data = await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).findOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}
)
if (data.sc) {
// 自选奖励已领取
return call.error('', {code: -1, message: globalThis.lng.task_finsh_3})
}
if (data.buy.length < hddata.payRewardNum) {
// 累计购买礼包次数不足
return call.error("", {code: -1, message: globalThis.lng.ljlibaotips_8})
}
let _prize: atn[] = [];
for (let i = 0; i < hddata.dlz.length; i++) {
_prize.push(hddata.dlz[i][call.req.select[i] || "1"])
}
PlayerFun.sendPrize(call, _prize)
call.succ({prize: _prize})
}
export async function LeiChongLiBaoBuyGift(call: ApiCall, payId: string) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
console.log(call.uid, "购买累充礼包 但是活动没有开启", payId);
return
}
let gift: LeiChongLiBaoData["gift"][0];
let hdid = hdinfo[0].hdid;
let hddata = hdinfo[0].data as LeiChongLiBaoData;
for (let g of hddata.gift) {
if (g.payId == payId) {
gift = g;
break;
}
}
if (!gift) return; // 不是购买累充礼包
let mydata = await G.mongodb.cEvent(`leichonglibao${hdid}`).findOne(
{type: `leichonglibao${hdid}`, uid: call.uid}
)
if (mydata.buy.includes(gift.payId)) {
console.log(call.uid, "购买累充礼包 重复购买", payId);
return
}
PlayerFun.sendPrize(call, gift.prize)
G.mongodb.cEvent(`leichonglibao${hdid}`).updateOne(
{uid: call.uid, type: `leichonglibao${hdid}`}, {"$push": {buy: payId}}
)
}
export async function LeiChongLiBaoGetHongDian(call: ApiCall) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
return {show: false}
}
let hdid = hdinfo[0].hdid;
let hddata = hdinfo[0].data as LeiChongLiBaoData;
let mydata = await G.mongodb.cEvent(`leichonglibao${hdid}`).findOne(
{type: `leichonglibao${hdid}`, uid: call.uid}
)
if (!mydata || mydata.opentime < PublicShared.getToDayZeroTime()) {
return {show: true}
}
if (!mydata.sc && mydata.buy.length >= hddata.payRewardNum) {
return {show: true}
}
return {show: false}
}

View File

@ -15,11 +15,12 @@ import {md_redPoint} from '../gongyu/mingdao/ApiOpen';
import {HongDianFun, HuoDongHongDianFun} from "./fun";
import {FunWeiXiuChang} from "../../public/weixiuchang";
import {getShouChongRedPoint} from "../event/shouchong/ApiReceive";
import {LeiChongLiBaoGetHongDian} from "../event/leichonglibao/ApiReceive";
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao', 'pobinglibao'];
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao', 'pobinglibao', 'leichonglibao'];
export default async function (call: ApiCall<ReqGet, ResGet>) {
@ -163,6 +164,9 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
case 'zhoumolibao':
res[key] = await HongDianFun.zhoumolibao(call);
break;
case "leichonglibao":
res[key] = await LeiChongLiBaoGetHongDian(call)
break;
}
}
}

View File

@ -0,0 +1,98 @@
import {ctor} from "../global";
import {_mongodb} from "../setMongodb";
import {MongoClient} from "mongodb";
async function initMongoDB() {
console.log('connect mongodb ......');
let client = await MongoClient.connect(G.config.mongodbUrl);
G.mongodb = new _mongodb(client.db(G.config.dbName || ''));
console.log('connect mongodb succ');
}
async function start() {
await initMongoDB()
const task = {
'2001': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 50,
'cond': [],
'stype': 118
},
'2002': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 100,
'cond': [],
'stype': 118
},
'2003': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '626', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 200,
'cond': [],
'stype': 118
},
'2004': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 250,
'cond': [],
'stype': 118
},
'2005': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 300,
'cond': [],
'stype': 118
},
'2006': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 400,
'cond': [],
'stype': 118
},
'2007': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 500,
'cond': [],
'stype': 118
}
};
let hdid = [100, 101];
await G.mongodb.collection("hdinfo").updateMany(
{hdid: {$in: hdid}}, {$set: {"data.tasklist.2": task}}
)
console.log(`修复区服${G.config.serverId}人才计划活动数据完成...`);
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -351,7 +351,7 @@ class Lng {
huoqupaihang: "huoqupaihang";
wucigonghui: "wucigonghui";
nameyicunzai: "nameyicunzai";
ljlibaotips_8:"ljlibaotips_8";
"11111" = "globalThis.lng.chat_1"
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });

View File

@ -22,6 +22,7 @@ import {ResOpen as ResOpenZixuanlibao} from '../shared/protocols/event/zixuanlib
import {ResOpen as ResOpenKaifujingsai} from '../shared/protocols/kaifujingsai/PtlOpen';
import {ResOpen as ResOpenZhoumolibao} from '../shared/protocols/event/zhoumolibao/PtlOpen';
import {ResOpen as ResOpenPobinglibao} from '../shared/protocols/event/pobinglibao/PtlOpen';
import {ResOpen as ResOpenLeiChongLiBao} from '../shared/protocols/event/leichonglibao/PtlOpen';
export type eventType = {
shouchong: {
@ -65,6 +66,7 @@ export type eventType = {
[k: `zixuanlibao${number}`]: ResOpenZixuanlibao;
[k: `leijichongzhi${number}`]: Omit<ResOpenLeijichongzhi, 'payNum'>;
[k: `qiridenglu${number}`]: Pick<ResOpenQiridenglu, 'recPrize'>;
[k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number };
};
export type CollectionEvent<T extends keyof eventType> = {

View File

@ -0,0 +1,8 @@
export type ReqOpen = {
hdid: number
}
export type ResOpen = {
sc: boolean // 自选奖励领取标识
buy: string[] // 特价礼包购买记录
}

View File

@ -0,0 +1,10 @@
import {prizeType} from "../../type";
export interface ReqReceive {
hdid: number
select: string[]
}
export interface ResReceive {
prize: prizeType[]
}

View File

@ -52,7 +52,8 @@ export type hongdianKey =
| 'weixiuchang'
| 'kaifujingsai'
| 'zhoumolibao'
| 'pobinglibao';
| 'pobinglibao'
| 'leichonglibao';
export type hongdianVal = {

File diff suppressed because it is too large Load Diff