Merge branch 'dev' of http://git.legu.cc/qixin/HJ_Server into dev
This commit is contained in:
commit
5dea65e51a
12
oneKeyStartPm2.sh
Normal file
12
oneKeyStartPm2.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
git fetch --all && 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
|
@ -8,16 +8,23 @@ import {PlayerFun} from "../../../public/player";
|
|||||||
export default async function (call: ApiCall<ReqGame, ResGame>) {
|
export default async function (call: ApiCall<ReqGame, ResGame>) {
|
||||||
let initCon = await Christmasfun.getCon(call)
|
let initCon = await Christmasfun.getCon(call)
|
||||||
let need = initCon[call.req.hdid].data.gameneed;
|
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 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.checkNeedIsMeet(call, need);
|
||||||
// 扣除消耗
|
// 扣除消耗
|
||||||
await PlayerFun.cutNeed(call, need);
|
await PlayerFun.cutNeed(call, need);
|
||||||
|
}
|
||||||
|
|
||||||
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
|
||||||
let _setData = {}
|
let _setData = {}
|
||||||
_mydata["val"] += addval
|
_mydata["val"] += addval
|
||||||
_setData["val"] = _mydata["val"]
|
_mydata["gamenum"] += 1
|
||||||
|
_setData["val"] = _mydata.val
|
||||||
|
_setData["game"] = _mydata["gamenum"]
|
||||||
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData})
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData})
|
||||||
let changedata = { mydata: _mydata}
|
let changedata = { mydata: _mydata}
|
||||||
// 推送红点
|
// 推送红点
|
||||||
|
@ -22,13 +22,14 @@ export default async function (call: ApiCall<ReqLiBao, ResLiBao>) {
|
|||||||
// 判断是否能购买
|
// 判断是否能购买
|
||||||
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
}
|
}
|
||||||
const _select = _mydata.select[lbid] || {}
|
let _select = _mydata.select[lbid] || {}
|
||||||
if (Object.keys(_select).length >= _con.dlz.length) {
|
if (Object.keys(_select).length < _con.dlz.length) {
|
||||||
// 判断是否选择奖励了
|
// 判断是否选择奖励了
|
||||||
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let _prize: atn[] = _con.prize
|
let _prize: atn[] = _con.basep
|
||||||
|
|
||||||
for (let key in _select) {
|
for (let key in _select) {
|
||||||
_prize.push(_con.dlz[parseInt(key)][_select[key]])
|
_prize.push(_con.dlz[parseInt(key)][_select[key]])
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
let changedata = { mydata: _mydata, hdinfo: _hdinfo }
|
let changedata = { mydata: _mydata, hdinfo: _hdinfo }
|
||||||
call.succ(changedata);
|
call.succ(changedata);
|
||||||
|
@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
|
|||||||
for(let i = 0; i < _diff; i++) {
|
for(let i = 0; i < _diff; i++) {
|
||||||
if (_mydata.qiandao.includes(i)) continue
|
if (_mydata.qiandao.includes(i)) continue
|
||||||
_mydata.qiandao.push(i)
|
_mydata.qiandao.push(i)
|
||||||
_prize.push(_con[i])
|
_prize = _prize.concat(_con[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_prize){
|
if (!_prize){
|
||||||
|
@ -20,12 +20,14 @@ export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
|
|||||||
|
|
||||||
if (!_mydata.pt.includes(index)){
|
if (!_mydata.pt.includes(index)){
|
||||||
// 如果普通奖励没有领取
|
// 如果普通奖励没有领取
|
||||||
_prize.push(_con.pt)
|
|
||||||
|
_prize = _prize.concat(_con.pt)
|
||||||
_mydata.pt.push(index)
|
_mydata.pt.push(index)
|
||||||
}
|
}
|
||||||
if (_mydata.pay && !_mydata.gj.includes(index)){
|
if (_mydata.pay && !_mydata.gj.includes(index)){
|
||||||
// 如果普通奖励没有领取
|
// 如果普通奖励没有领取
|
||||||
_prize.push(_con.gj)
|
_prize = _prize.concat(_con.gj)
|
||||||
|
|
||||||
_mydata.gj.push(index)
|
_mydata.gj.push(index)
|
||||||
}
|
}
|
||||||
if (!_prize) {
|
if (!_prize) {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { strict } from 'assert';
|
import { strict } from 'assert';
|
||||||
import { ApiCall } from 'tsrpc';
|
import {ApiCall, BaseConnection} from 'tsrpc';
|
||||||
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
|
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
|
||||||
import { HuoDongFun } from '../../../public/huodongfun';
|
import { HuoDongFun } from '../../../public/huodongfun';
|
||||||
import { TaskFun } from '../../../public/task';
|
import { TaskFun } from '../../../public/task';
|
||||||
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
|
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
|
import {player} from '../../../shared/protocols/user/type';
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
|
||||||
export class Christmasfun {
|
export class Christmasfun {
|
||||||
/**配置 */
|
/**配置 */
|
||||||
@ -61,6 +62,7 @@ export class Christmasfun {
|
|||||||
taskval: await this.getTaskVal(call, hdid),
|
taskval: await this.getTaskVal(call, hdid),
|
||||||
taskfinish: [],
|
taskfinish: [],
|
||||||
refresh: G.time,
|
refresh: G.time,
|
||||||
|
gamenum: 0,
|
||||||
pt: [],
|
pt: [],
|
||||||
gj: [],
|
gj: [],
|
||||||
pay: false,
|
pay: false,
|
||||||
@ -110,18 +112,48 @@ export class Christmasfun {
|
|||||||
mydata.taskfinish = []
|
mydata.taskfinish = []
|
||||||
mydata.taskval = await this.getTaskVal(call, hdid)
|
mydata.taskval = await this.getTaskVal(call, hdid)
|
||||||
mydata.refresh = G.time
|
mydata.refresh = G.time
|
||||||
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval } })
|
mydata.gamenum = 0
|
||||||
|
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval, gamenum: mydata.gamenum} })
|
||||||
return mydata
|
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) {
|
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)
|
let hdids = await this.gethdids(call)
|
||||||
if (hdids.length <= 0) return // 活动过期,不计数
|
if (hdids.length <= 0) return // 活动过期,不计数
|
||||||
let _initCon = await this.getCon(call)
|
let _initCon = await this.getCon(call)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (let index = 0; index < hdids.length; index++) {
|
for (let index = 0; index < hdids.length; index++) {
|
||||||
const hdid = hdids[index];
|
const hdid = hdids[index];
|
||||||
let _mydata = await Christmasfun.getMyData(call, hdid)
|
let _mydata = await Christmasfun.getMyData(call, hdid)
|
||||||
|
@ -20,24 +20,32 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkResetBuyLog(call: ApiCall) {
|
export async function getConf(call, args?: { id?: string; payId?: string }) {
|
||||||
|
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
|
||||||
|
if (!_hd) return []
|
||||||
|
if (args?.id) return _hd?.data?.gift?.find(i => i.id == args.id)
|
||||||
|
if (args?.payId) return _hd?.data?.gift?.find(i => i.payId == args.payId)
|
||||||
|
return _hd?.data?.gift
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function checkResetBuyLog(call) {
|
||||||
let zeroTime = PublicShared.getToDayZeroTime()
|
let zeroTime = PublicShared.getToDayZeroTime()
|
||||||
|
|
||||||
|
|
||||||
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
|
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
|
||||||
if (data.refreshTime && data.refreshTime > zeroTime) return
|
if (data.refreshTime && data.refreshTime <= zeroTime) {
|
||||||
|
|
||||||
G.mongodb.cEvent(`zhoumolibao`).updateOne(
|
G.mongodb.cEvent(`zhoumolibao`).updateOne(
|
||||||
{uid: call.uid, type: `zhoumolibao`},
|
{uid: call.uid, type: `zhoumolibao`},
|
||||||
{$set: {record: {}}},
|
{$set: {record: {}}},
|
||||||
{upsert: true}
|
{upsert: true}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
|
let gifts = await getConf(call)
|
||||||
let payIds = _hd?.data?.gift?.filter(i => i.payId)?.map(i => i.payId)
|
|
||||||
|
let payIds = gifts.filter(i => i.payId)?.map(i => i.payId)
|
||||||
let payLogs = await PayFun.getPayLogs(call.uid, payIds)
|
let payLogs = await PayFun.getPayLogs(call.uid, payIds)
|
||||||
let payLogLength = R.values(payLogs).filter(i => i.time < zeroTime).length
|
let payLogLength = R.values(payLogs).filter(i => i.time < zeroTime).length
|
||||||
if (payLogLength) {
|
if (payLogLength) {
|
||||||
PayFun.delPayLog(call.uid, payIds.map(i => ({payId: i})))
|
PayFun.delPayLog(call.uid, payIds.map(i => ({payId: i, val: []})))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ import {ApiCall} from "tsrpc";
|
|||||||
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/zhoumolibao/PtlReceive";
|
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/zhoumolibao/PtlReceive";
|
||||||
import {HuoDongFun} from "../../../public/huodongfun";
|
import {HuoDongFun} from "../../../public/huodongfun";
|
||||||
import {PlayerFun} from "../../../public/player";
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
||||||
// 查询活动是否有当前领奖的免费选项
|
// 查询活动是否有当前领奖的免费选项
|
||||||
@ -12,7 +13,7 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
// 取奖励列表,判断是否有可领取奖励
|
// 取奖励列表,判断是否有可领取奖励
|
||||||
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
|
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
|
||||||
let rec = data?.record?.[call.req.id]
|
let rec = data?.record?.[call.req.id]
|
||||||
// if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
|
if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, gift.prize);
|
await PlayerFun.sendPrize(call, gift.prize);
|
||||||
|
|
||||||
@ -22,4 +23,5 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
|
|
||||||
call.succ({})
|
call.succ({})
|
||||||
|
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['zhoumolibao']);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import { FunWeiXiuChang } from "../../public/weixiuchang";
|
|||||||
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
|
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
|
||||||
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
|
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
|
||||||
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
|
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
|
||||||
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai'];
|
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao'];
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGet, ResGet>) {
|
export default async function (call: ApiCall<ReqGet, ResGet>) {
|
||||||
|
|
||||||
@ -160,6 +160,9 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
|
|||||||
case 'kaifujingsai':
|
case 'kaifujingsai':
|
||||||
res[key] = await HongDianFun.kaifujingsai(call);
|
res[key] = await HongDianFun.kaifujingsai(call);
|
||||||
break;
|
break;
|
||||||
|
case 'zhoumolibao':
|
||||||
|
res[key] = await HongDianFun.zhoumolibao(call);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,18 @@ export class HongDianFun {
|
|||||||
return {show: true, val: canGet}
|
return {show: true, val: canGet}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**周末礼包 */
|
||||||
|
static async zhoumolibao(call: ApiCall): Promise<hongdianVal> {
|
||||||
|
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
|
||||||
|
let gift = _hd?.data?.gift?.find(i => i.free)
|
||||||
|
if (!gift) return {show: false}
|
||||||
|
|
||||||
|
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
|
||||||
|
let rec = data?.record?.[gift.id]
|
||||||
|
if (rec && rec >= gift?.buyNum) return {show: false}
|
||||||
|
return {show: true}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -708,7 +720,8 @@ export class HuoDongHongDianFun {
|
|||||||
if (_buyNum < _tmp.buynum) {
|
if (_buyNum < _tmp.buynum) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
return _res;
|
return _res;
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
let _diff = PublicShared.getDiff(stime)
|
let _diff = PublicShared.getDiff(stime)
|
||||||
// 循环判断是否有可以领取的
|
// 循环判断是否有可以领取的
|
||||||
for (let i = 0; i < _diff; i++) {
|
for (let i = 0; i < _diff; i++) {
|
||||||
|
@ -9,6 +9,7 @@ import {ReqLottery, ResLottery} from "../../shared/protocols/jiuba/PtlLottery";
|
|||||||
import {PublicShared} from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import {HongDianChange} from '../hongdian/fun';
|
import {HongDianChange} from '../hongdian/fun';
|
||||||
import {RankKfjs} from "../../public/rank/rank_kfjs";
|
import {RankKfjs} from "../../public/rank/rank_kfjs";
|
||||||
|
import {PushGiftFun} from "../../public/pushgift";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
||||||
|
|
||||||
@ -142,4 +143,8 @@ export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
|||||||
valArr: [await rankKfjs.getRankScore(call.uid) + call.req.type]
|
valArr: [await rankKfjs.getRankScore(call.uid) + call.req.type]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 十连抽推送礼包
|
||||||
|
if (call.req.type == 10) {
|
||||||
|
PushGiftFun.chkRecruitGift(call.uid)
|
||||||
|
}
|
||||||
}
|
}
|
29
src/api_s2c/pushgift/ApiOpen.ts
Normal file
29
src/api_s2c/pushgift/ApiOpen.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import {ApiCall} from "tsrpc";
|
||||||
|
import {ReqOpen, ResOpen} from "../../shared/protocols/pushgift/PtlOpen";
|
||||||
|
import {PushGiftFun} from "../../public/pushgift";
|
||||||
|
import {Gift} from "../../module/collection_pushgift";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
let res: ResOpen = {gifts: []};
|
||||||
|
|
||||||
|
// 过滤过期的礼包 和购买完毕的礼包
|
||||||
|
(await PushGiftFun.getGift(call.uid)).forEach((gift) => {
|
||||||
|
if (gift.passTime > G.time && chkBuyNum(gift.id, gift)) {
|
||||||
|
res.gifts.push(gift)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
call.succ(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
function chkBuyNum(gift_id: string, gift_info: Gift) {
|
||||||
|
let conf = G.gc.tuisonglibao[gift_id];
|
||||||
|
for (let i = 0; i < conf.payId.length; i++) {
|
||||||
|
let pay = G.gc.pay[conf.payId[i]];
|
||||||
|
if (pay.buys > 0 && gift_info.buy[i] < pay.buys) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
@ -15,6 +15,8 @@ import { ZhanLingTasks } from './public/zhanling';
|
|||||||
import { player } from './shared/protocols/user/type';
|
import { player } from './shared/protocols/user/type';
|
||||||
import { PublicShared } from './shared/public/public';
|
import { PublicShared } from './shared/public/public';
|
||||||
import { setGud } from './public/gud';
|
import { setGud } from './public/gud';
|
||||||
|
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
|
||||||
|
import {Christmasfun} from "./api_s2c/event/christmas/fun";
|
||||||
|
|
||||||
export type gEventType = {
|
export type gEventType = {
|
||||||
/**玩家断开连接 */
|
/**玩家断开连接 */
|
||||||
@ -22,7 +24,7 @@ export type gEventType = {
|
|||||||
/**玩家修改名字 */
|
/**玩家修改名字 */
|
||||||
PLAYER_CHANGE_NAME: (gud: player, name: string) => void;
|
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调用 */
|
||||||
API_CALL: (node: { call: ApiCall, return: ApiReturn<any>; }) => void;
|
API_CALL: (node: { call: ApiCall, return: ApiReturn<any>; }) => void;
|
||||||
/**玩家每日首次登陆 */
|
/**玩家每日首次登陆 */
|
||||||
@ -165,13 +167,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);
|
let conf: any = await PayFun.getConf(payId, payArgs);
|
||||||
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
|
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
|
||||||
ActionLog.addRetainLog(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);
|
if (payId == G.gc.zhanling.payId) payZhanLing(player);
|
||||||
|
//圣诞节活动充值
|
||||||
|
Christmasfun.payChristmas(payId, call);
|
||||||
let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan'];
|
let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan'];
|
||||||
if (payEmailConf?.length > 0) {
|
if (payEmailConf?.length > 0) {
|
||||||
let sendEmailConfs = payEmailConf;
|
let sendEmailConfs = payEmailConf;
|
||||||
@ -209,6 +212,8 @@ export function addListener() {
|
|||||||
G.emit("Class_task_135", 'Class_task_135', call, 1, 0);
|
G.emit("Class_task_135", 'Class_task_135', call, 1, 0);
|
||||||
// 七日登录活动计数
|
// 七日登录活动计数
|
||||||
qiRiDengLuAddDay(call);
|
qiRiDengLuAddDay(call);
|
||||||
|
// 周末礼包检测刷新
|
||||||
|
checkResetBuyLog(call);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1773,6 +1773,24 @@ type gc_yuyuemail = {
|
|||||||
'prize': { "a": string, "t": string, "n": number, [x: string]: any }[]
|
'prize': { "a": string, "t": string, "n": number, [x: string]: any }[]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type gc_push_gift = {
|
||||||
|
[k: string]: {
|
||||||
|
/**礼包id*/
|
||||||
|
id: number
|
||||||
|
/**礼包类型*/
|
||||||
|
type: number
|
||||||
|
/**礼包参数*/
|
||||||
|
num: any[]
|
||||||
|
/**购买id*/
|
||||||
|
payId: string[]
|
||||||
|
/**持续时间*/
|
||||||
|
time: number
|
||||||
|
/**冷却时间*/
|
||||||
|
displayCD: number
|
||||||
|
/**显示返利比*/
|
||||||
|
scale: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type gcType = {
|
type gcType = {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
@ -1922,6 +1940,7 @@ type gcType = {
|
|||||||
kfcb_content: gc_kfcb_content
|
kfcb_content: gc_kfcb_content
|
||||||
kfcb_prize: gc_kfcb_prize
|
kfcb_prize: gc_kfcb_prize
|
||||||
yuyuemail: gc_yuyuemail
|
yuyuemail: gc_yuyuemail
|
||||||
|
tuisonglibao: gc_push_gift
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ export default {
|
|||||||
/**是否开发模式 */
|
/**是否开发模式 */
|
||||||
debug: true,
|
debug: true,
|
||||||
/**消息服socket端口*/
|
/**消息服socket端口*/
|
||||||
msgPort: 7778,
|
msgPort: 7785,
|
||||||
/**http端口 msg服专用*/
|
/**http端口 msg服专用*/
|
||||||
// httpPort: 7779,
|
// httpPort: 7779,
|
||||||
/**跨服socket端口 */
|
/**跨服socket端口 */
|
||||||
@ -13,7 +13,7 @@ export default {
|
|||||||
/**跨服 ws url */
|
/**跨服 ws url */
|
||||||
corssWsUrl: "ws://10.0.1.20:10003",
|
corssWsUrl: "ws://10.0.1.20:10003",
|
||||||
/**服务器id */
|
/**服务器id */
|
||||||
serverId: 0,
|
serverId: 1001,
|
||||||
/**redis url */
|
/**redis url */
|
||||||
redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0',
|
redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0',
|
||||||
/**mongodb url */
|
/**mongodb url */
|
||||||
@ -27,7 +27,7 @@ export default {
|
|||||||
/**服务器时间 */
|
/**服务器时间 */
|
||||||
time: '',
|
time: '',
|
||||||
/**开服时间 */
|
/**开服时间 */
|
||||||
openTime: '2022-10-10 1:0:0',
|
openTime: '2023-12-11 1:0:0',
|
||||||
/**项目名称 */
|
/**项目名称 */
|
||||||
projectName: 'heijiao',
|
projectName: 'heijiao',
|
||||||
/**加密key */
|
/**加密key */
|
||||||
|
13
src/module/collection_pushgift.ts
Normal file
13
src/module/collection_pushgift.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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 };
|
@ -59,6 +59,7 @@ import {CollectionPlayerBehavior} from "./collection_player_behavior";
|
|||||||
import {CollectionRmbuse} from "./collection_rmbuse";
|
import {CollectionRmbuse} from "./collection_rmbuse";
|
||||||
import {CollectionFightLog} from "./collection_fightLog";
|
import {CollectionFightLog} from "./collection_fightLog";
|
||||||
import {CollectionShop} from "./collection_shop";
|
import {CollectionShop} from "./collection_shop";
|
||||||
|
import {CollectionPushGift} from "./collection_pushgift";
|
||||||
|
|
||||||
export type MongodbCollections = {
|
export type MongodbCollections = {
|
||||||
user: CollectionUser;
|
user: CollectionUser;
|
||||||
@ -131,4 +132,5 @@ export type MongodbCollections = {
|
|||||||
rmbuse: CollectionRmbuse
|
rmbuse: CollectionRmbuse
|
||||||
fightLog: CollectionFightLog
|
fightLog: CollectionFightLog
|
||||||
shop: CollectionShop
|
shop: CollectionShop
|
||||||
|
pushgift:CollectionPushGift
|
||||||
};
|
};
|
@ -9,6 +9,7 @@ import {HeroFun} from './hero';
|
|||||||
import {UserFun} from './user';
|
import {UserFun} from './user';
|
||||||
import {re, string} from "mathjs";
|
import {re, string} from "mathjs";
|
||||||
import {getGud} from './gud';
|
import {getGud} from './gud';
|
||||||
|
import {PushGiftFun} from "./pushgift";
|
||||||
|
|
||||||
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
|
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
|
||||||
|
|
||||||
@ -86,9 +87,16 @@ export class FightFun {
|
|||||||
|
|
||||||
/**挑战竞技场 */
|
/**挑战竞技场 */
|
||||||
static async fightJJc(call: ApiCall, rankInfo: rankInfo) {
|
static async fightJJc(call: ApiCall, rankInfo: rankInfo) {
|
||||||
|
|
||||||
if (rankInfo.player.uid.indexOf('npc_') != -1) return await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
|
if (rankInfo.player.uid.indexOf('npc_') != -1) return await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
|
||||||
return this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
|
|
||||||
|
let result = this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
|
||||||
|
|
||||||
|
// 竞技场 战败触发推送礼包
|
||||||
|
if (result.winSide != 0) {
|
||||||
|
PushGiftFun.chkLoseGift(call.uid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**挑战npc */
|
/**挑战npc */
|
||||||
@ -106,7 +114,13 @@ export class FightFun {
|
|||||||
|
|
||||||
let npc = formatNpcData(npcId);
|
let npc = formatNpcData(npcId);
|
||||||
|
|
||||||
return this.fight([my, npc], 30, 'pve');
|
let result = this.fight([my, npc], 30, 'pve');
|
||||||
|
|
||||||
|
// 主线 爬塔 战败触发推送礼包
|
||||||
|
if (result.winSide != 0 && ["tanxian", "pata"].includes(type)) {
|
||||||
|
PushGiftFun.chkLoseGift(data[0].player.uid)
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import {HuoDongFun} from './huodongfun';
|
|||||||
import {call, PlayerFun} from './player';
|
import {call, PlayerFun} from './player';
|
||||||
import {number} from "mathjs";
|
import {number} from "mathjs";
|
||||||
import {getGud} from './gud';
|
import {getGud} from './gud';
|
||||||
|
import {getConf as zmlbGetConf} from '../api_s2c/event/zhoumolibao/ApiOpen';
|
||||||
|
|
||||||
async function checkPayIsActive(payId: string, logs: payLog[], payArgs) {
|
async function checkPayIsActive(payId: string, logs: payLog[], payArgs) {
|
||||||
let conf: any = await this.getConf(payId, payArgs);
|
let conf: any = await this.getConf(payId, payArgs);
|
||||||
@ -98,7 +99,7 @@ export class PayFun {
|
|||||||
}).toArray();
|
}).toArray();
|
||||||
|
|
||||||
if (payIds?.length) {
|
if (payIds?.length) {
|
||||||
return Object.fromEntries(payIds.map(id => [id, logs[id] || []]));
|
return Object.fromEntries(payIds.map(id => [id, logs.find(i => i.key == id)?.values || []]));
|
||||||
}
|
}
|
||||||
let allLogs = {}
|
let allLogs = {}
|
||||||
logs.map(i => allLogs[i.key] = i.values)
|
logs.map(i => allLogs[i.key] = i.values)
|
||||||
@ -176,13 +177,6 @@ export class PayFun {
|
|||||||
|
|
||||||
let conf: any = await this.getConf(payId, payArgs);
|
let conf: any = await this.getConf(payId, payArgs);
|
||||||
|
|
||||||
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs)
|
|
||||||
if (isReplaceConf) {
|
|
||||||
let prizePayId = `zuanshi_${conf.money}`
|
|
||||||
payArgs.toPrizePayId = prizePayId
|
|
||||||
conf = this.replacePrizeToChongzhi(prizePayId, conf)
|
|
||||||
}
|
|
||||||
|
|
||||||
let prize = [...conf.prize];
|
let prize = [...conf.prize];
|
||||||
//let player = await G.redis.get('user', uid);
|
//let player = await G.redis.get('user', uid);
|
||||||
let player = await getGud(uid);
|
let player = await getGud(uid);
|
||||||
@ -225,6 +219,22 @@ export class PayFun {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (payId.indexOf('wkdlibao') != -1) {
|
||||||
|
let call = this.getCall(player)
|
||||||
|
let conf = await zmlbGetConf(call, {payId})
|
||||||
|
prize.push(...conf.prize)
|
||||||
|
}
|
||||||
|
|
||||||
|
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs)
|
||||||
|
if (isReplaceConf) {
|
||||||
|
let prizePayId = `zuanshi_${conf.money}`
|
||||||
|
payArgs.toPrizePayId = prizePayId
|
||||||
|
conf = this.replacePrizeToChongzhi(prizePayId, conf)
|
||||||
|
prize = [...conf.prize]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
await PlayerFun.addAttr(call, conf.payExp);
|
await PlayerFun.addAttr(call, conf.payExp);
|
||||||
if (payId == 'G123SendGift') {
|
if (payId == 'G123SendGift') {
|
||||||
@ -261,7 +271,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);
|
G.emit("Class_task_116", 'Class_task_116', call, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,12 +372,20 @@ export class PayFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf.buys > 0 && buyLog.length >= conf.buys) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -1});
|
if (conf.buys > 0 && buyLog.length >= conf.buys) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -1});
|
||||||
if (conf.time != -1 && buyLog.slice(-1)[0]?.eTime > G.time && conf.buys == 0) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -2});
|
|
||||||
|
// todo 没看懂这个判断针对什么支付,不支持周末礼包这个类型的限购,所以加上判断:payId.indexOf('wkdlibao') == -1
|
||||||
|
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') {
|
if (payId.indexOf('136Gift') != -1 && payId != '136Gift1') {
|
||||||
buyLog = await this.getPayLog(player.uid, '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});
|
if (buyLog.slice(-1)[0]?.eTime > G.time) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -3});
|
||||||
}
|
}
|
||||||
|
if (payId.indexOf('wkdlibao') != -1) {
|
||||||
|
let call = this.getCall(player)
|
||||||
|
let conf = await zmlbGetConf(call, {payId})
|
||||||
|
if (buyLog.length && buyLog.length >= conf.buyNum) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -1});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G.config.debug) {
|
if (G.config.debug) {
|
||||||
|
@ -17,6 +17,7 @@ import {UserFun} from './user';
|
|||||||
import {getItemByItemId, getItemNum} from './item';
|
import {getItemByItemId, getItemNum} from './item';
|
||||||
import {getGud, setGud} from './gud';
|
import {getGud, setGud} from './gud';
|
||||||
import {addGameLog} from "../gameLog";
|
import {addGameLog} from "../gameLog";
|
||||||
|
import {PushGiftFun} from "./pushgift";
|
||||||
|
|
||||||
|
|
||||||
export type call = {
|
export type call = {
|
||||||
@ -66,6 +67,8 @@ export class PlayerFun {
|
|||||||
|
|
||||||
if (has < atn.n) {
|
if (has < atn.n) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
// 消耗不足 触发推送礼包
|
||||||
|
PushGiftFun.chkItemGift(call.uid, atn)
|
||||||
throw new TsrpcError('', {code: -104, atn: atn});
|
throw new TsrpcError('', {code: -104, atn: atn});
|
||||||
} else {
|
} else {
|
||||||
return {isOk: false, atn: atn};
|
return {isOk: false, atn: atn};
|
||||||
@ -189,6 +192,16 @@ export class PlayerFun {
|
|||||||
// 修改属性应在相关奖励领取之前,否则奖励内获取的用户数据是旧数据
|
// 修改属性应在相关奖励领取之前,否则奖励内获取的用户数据是旧数据
|
||||||
// await this.changeAttr(call.conn.uid, change);
|
// await this.changeAttr(call.conn.uid, change);
|
||||||
call.addEventMsg('msg_s2c/PlayerChange', change);
|
call.addEventMsg('msg_s2c/PlayerChange', change);
|
||||||
|
|
||||||
|
// 等级改变 触发推送礼包
|
||||||
|
if (change["lv"]) {
|
||||||
|
PushGiftFun.chkLvGift(call.uid, change["lv"])
|
||||||
|
}
|
||||||
|
// 关卡改变 触发推送礼包
|
||||||
|
if (change["mapId"]) {
|
||||||
|
PushGiftFun.chkLevelGift(call.uid, change["mapId"])
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async changeAttrLog(uid: string, change, atn, before) {
|
static async changeAttrLog(uid: string, change, atn, before) {
|
||||||
@ -290,7 +303,11 @@ export class PlayerFun {
|
|||||||
|
|
||||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
||||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
||||||
addGameLog(call.uid, "_itemChange", {"additem":1}, {"filter": upObj.filter, "update": upObj.update, "options": upObj.options})
|
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
|
||||||
|
"filter": upObj.filter,
|
||||||
|
"update": upObj.update,
|
||||||
|
"options": upObj.options
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
if (item.num + atn.n <= 0) {
|
if (item.num + atn.n <= 0) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@ -318,7 +335,12 @@ export class PlayerFun {
|
|||||||
num: item.num + atn.n,
|
num: item.num + atn.n,
|
||||||
lastTime: upObj.update.$set.lastTime
|
lastTime: upObj.update.$set.lastTime
|
||||||
});
|
});
|
||||||
addGameLog(call.uid, "_itemChange",{"attritem":1}, {"filter": upObj.filter, "update": upObj.update, "options": upObj.options,newNum:item.num + atn.n})
|
addGameLog(call.uid, "_itemChange", {"attritem": 1}, {
|
||||||
|
"filter": upObj.filter,
|
||||||
|
"update": upObj.update,
|
||||||
|
"options": upObj.options,
|
||||||
|
newNum: item.num + atn.n
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
155
src/public/pushgift.ts
Normal file
155
src/public/pushgift.ts
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
import {PayFun} from "./pay";
|
||||||
|
|
||||||
|
const PushGiftType = {
|
||||||
|
LevelGift: 1, // 关卡推送
|
||||||
|
ItemGift: 2, // 道具推送
|
||||||
|
LoseGift: 3, // 战败推送
|
||||||
|
RecruitGift: 4, // 十连推送
|
||||||
|
LvGift: 5, // 等级推送
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PushGiftFun {
|
||||||
|
|
||||||
|
static async getGift(uid: string) {
|
||||||
|
// 查询所有礼包
|
||||||
|
return (await G.mongodb.collection("pushgift").find({
|
||||||
|
uid: uid
|
||||||
|
}).toArray()).map((i) => {
|
||||||
|
let {_id, ...gift} = i;
|
||||||
|
return gift
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
static async chkItemGift(uid: string, atn: atn) {
|
||||||
|
let gift_ids = [];
|
||||||
|
for (let id in G.gc.tuisonglibao) {
|
||||||
|
let conf = G.gc.tuisonglibao[id];
|
||||||
|
if (conf.type == PushGiftType.ItemGift && conf.num[0].a == atn.a && conf.num[0].t == atn.t) {
|
||||||
|
gift_ids.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gift_ids.length <= 0) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.pushGift(uid, gift_ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async chkLevelGift(uid: string, level: number) {
|
||||||
|
let gift_ids = [];
|
||||||
|
for (let id in G.gc.tuisonglibao) {
|
||||||
|
let conf = G.gc.tuisonglibao[id];
|
||||||
|
if (conf.type == PushGiftType.LevelGift && conf.num[0] == level) {
|
||||||
|
gift_ids.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gift_ids.length <= 0) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.pushGift(uid, gift_ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async chkLvGift(uid: string, lv: number) {
|
||||||
|
let gift_ids = [];
|
||||||
|
for (let id in G.gc.tuisonglibao) {
|
||||||
|
let conf = G.gc.tuisonglibao[id];
|
||||||
|
if (conf.type == PushGiftType.LevelGift && conf.num[0] == lv) {
|
||||||
|
gift_ids.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gift_ids.length <= 0) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.pushGift(uid, gift_ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async chkLoseGift(uid: string) {
|
||||||
|
let gift_ids = [];
|
||||||
|
for (let id in G.gc.tuisonglibao) {
|
||||||
|
let conf = G.gc.tuisonglibao[id];
|
||||||
|
if (conf.type == PushGiftType.LoseGift) {
|
||||||
|
gift_ids.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gift_ids.length <= 0) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.pushGift(uid, gift_ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async chkRecruitGift(uid: string) {
|
||||||
|
let gift_ids = [];
|
||||||
|
for (let id in G.gc.tuisonglibao) {
|
||||||
|
let conf = G.gc.tuisonglibao[id];
|
||||||
|
if (conf.type == PushGiftType.RecruitGift) {
|
||||||
|
gift_ids.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gift_ids.length <= 0) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.pushGift(uid, gift_ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async pushGift(uid: string, gift_ids: string[]) {
|
||||||
|
let gifts = {};
|
||||||
|
(await this.getGift(uid)).forEach(i => gifts[i.id] = i)
|
||||||
|
for (let gift_id of gift_ids) {
|
||||||
|
let conf = G.gc.tuisonglibao[gift_id];
|
||||||
|
if (gifts[gift_id] && conf.displayCD > 0 && gifts[gift_id].ctime + conf.displayCD > G.time) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (conf.type == PushGiftType.RecruitGift) {
|
||||||
|
if (gifts[gift_id]) {
|
||||||
|
if (gift_ids[gift_id].ext_data.num + 1 >= conf.num[0]) {
|
||||||
|
this.addGift(uid, gift_id, {num: 0})
|
||||||
|
} else {
|
||||||
|
G.mongodb.collection("pushgift").updateOne({
|
||||||
|
uid: uid, id: gift_id
|
||||||
|
}, {"$inc": {"ext_data.num": 1}})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 招募礼包不存在 初始化数据 记录招募次数
|
||||||
|
G.mongodb.collection("pushgift").updateOne({
|
||||||
|
uid: uid, id: gift_id
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
ctime: 0,
|
||||||
|
passTime: 0,
|
||||||
|
ext_data: {num: 1},
|
||||||
|
buy: conf.payId.map(() => 0),
|
||||||
|
}
|
||||||
|
}, {upsert: true})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.addGift(uid, gift_id, {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async addGift(uid: string, giftid: string, ext_data: { [key: string]: any }) {
|
||||||
|
let conf = G.gc.tuisonglibao[giftid];
|
||||||
|
// 更新礼包
|
||||||
|
G.mongodb.collection("pushgift").updateOne({
|
||||||
|
uid: uid, id: giftid
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
ctime: G.time,
|
||||||
|
ext_data: ext_data,
|
||||||
|
passTime: G.time + conf.time,
|
||||||
|
buy: conf.payId.map(() => 0),
|
||||||
|
}
|
||||||
|
}, {upsert: true})
|
||||||
|
|
||||||
|
// 删除购买记录
|
||||||
|
PayFun.delPayLog(uid, ...conf.payId.map(i => {
|
||||||
|
return {payId: i, val: []}
|
||||||
|
}))
|
||||||
|
// 推送客户端消息
|
||||||
|
G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1);
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,8 @@ export type christmas = {
|
|||||||
taskval: { [id: string]: number }
|
taskval: { [id: string]: number }
|
||||||
/**任务领取标识 */
|
/**任务领取标识 */
|
||||||
taskfinish: string[]
|
taskfinish: string[]
|
||||||
|
/**小游戏挑战次数 */
|
||||||
|
gamenum: number
|
||||||
/**普通战令奖励集合 奖励id */
|
/**普通战令奖励集合 奖励id */
|
||||||
pt: number[]
|
pt: number[]
|
||||||
/**高级战令奖励集合 奖励id */
|
/**高级战令奖励集合 奖励id */
|
||||||
@ -36,7 +38,7 @@ export type christmas = {
|
|||||||
/**装扮值 */
|
/**装扮值 */
|
||||||
val: number
|
val: number
|
||||||
/**签到标识 */
|
/**签到标识 */
|
||||||
qiandao:string[],
|
qiandao:number[],
|
||||||
/**刷新时间 */
|
/**刷新时间 */
|
||||||
refresh: number
|
refresh: number
|
||||||
}
|
}
|
@ -2,11 +2,11 @@
|
|||||||
"hdid" : 91029302193,
|
"hdid" : 91029302193,
|
||||||
"htype" : 8,
|
"htype" : 8,
|
||||||
"stype" : 800,
|
"stype" : 800,
|
||||||
"ttype" : 1,
|
"ttype" : 0,
|
||||||
"stime" : 60,
|
"stime" : 1702396800,
|
||||||
"rtime" : 90,
|
"rtime" : 1703088000,
|
||||||
"etime" : 90,
|
"etime" : 1703088000,
|
||||||
"name" : "xinfupeiyang",
|
"name" : "christmas",
|
||||||
"icon" : "icon_xfdj",
|
"icon" : "icon_xfdj",
|
||||||
"showtime" : "根据玩家注册时间,游戏返回时复写",
|
"showtime" : "根据玩家注册时间,游戏返回时复写",
|
||||||
"data" : {
|
"data" : {
|
||||||
@ -53,23 +53,50 @@
|
|||||||
},
|
},
|
||||||
"gameneed": [{"a": "attr", "t":"jinbi", "n": 1}],
|
"gameneed": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
"game": [0,1, 2, 3, 4, 5],
|
"game": [0,1, 2, 3, 4, 5],
|
||||||
"zhanling":[
|
"gamefree": 3,
|
||||||
{
|
"zhanling":[{
|
||||||
"val": 1,
|
"val": 1,
|
||||||
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
"gj": [{"a": "attr", "t":"jinbi", "n": 1}]
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"val": 2,
|
"val": 2,
|
||||||
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
"pt": [{"a": "attr", "t":"rmbmoney", "n": 100}],
|
||||||
"gj": [{"a": "attr", "t":"jinbi", "n": 1}]
|
"gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"val": 3,
|
"val": 3,
|
||||||
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
"gj": [{"a": "attr", "t":"jinbi", "n": 1}]
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
}
|
},{
|
||||||
],
|
"val": 4,
|
||||||
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": 5,
|
||||||
|
"pt": [{"a": "attr", "t":"rmbmoney", "n": 100}],
|
||||||
|
"gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": 6,
|
||||||
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
},{
|
||||||
|
"val": 7,
|
||||||
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": 8,
|
||||||
|
"pt": [{"a": "attr", "t":"rmbmoney", "n": 100}],
|
||||||
|
"gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"val": 9,
|
||||||
|
"pt": [{"a": "attr", "t":"jinbi", "n": 1}],
|
||||||
|
"gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
|
||||||
|
}],
|
||||||
"zlpayid":"ycmb_1_1",
|
"zlpayid":"ycmb_1_1",
|
||||||
"libao": {
|
"libao": {
|
||||||
"1": {
|
"1": {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取红点
|
* 获取红点
|
||||||
*/
|
*/
|
||||||
@ -13,10 +11,47 @@ export const conf = {
|
|||||||
timeIntervalLimit: 0
|
timeIntervalLimit: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
export type hongdianKey = 'jiuba' | 'jiaotang' | 'shouchong' | 'dixiaqianzhuanghd' | 'taskhd' | 'xstaskhd' | 'gonghuihd' | 'jjchd' | 'hbzbhd' |
|
export type hongdianKey =
|
||||||
'clslhd' | 'lingzhulaixihd' | 'dxlthd' | 'wzcjhd' | 'slzdhd' | 'qjzzdhd' | 'kuangdonghd' | 'qiandaohd' | 'kaifukuanghuanhd' | 'jijinhd' | 'zhuishalinghd' |
|
'jiuba'
|
||||||
'yibaichouhd' | 'huobanzhaomuhd' | 'qirileichonghd' | 'jierihd' | 'kbzzhd' | 'wzryhd' | 'yuedujijin' | 'patahd' |
|
| 'jiaotang'
|
||||||
'mingdao' | 'heishihd' |'jitianhaoli'| 'huodonghd' | 'renown' | 'heishiMrjx' | 'weixiuchang' | 'kaifujingsai';
|
| 'shouchong'
|
||||||
|
| 'dixiaqianzhuanghd'
|
||||||
|
| 'taskhd'
|
||||||
|
| 'xstaskhd'
|
||||||
|
| 'gonghuihd'
|
||||||
|
| 'jjchd'
|
||||||
|
| 'hbzbhd'
|
||||||
|
|
|
||||||
|
'clslhd'
|
||||||
|
| 'lingzhulaixihd'
|
||||||
|
| 'dxlthd'
|
||||||
|
| 'wzcjhd'
|
||||||
|
| 'slzdhd'
|
||||||
|
| 'qjzzdhd'
|
||||||
|
| 'kuangdonghd'
|
||||||
|
| 'qiandaohd'
|
||||||
|
| 'kaifukuanghuanhd'
|
||||||
|
| 'jijinhd'
|
||||||
|
| 'zhuishalinghd'
|
||||||
|
|
|
||||||
|
'yibaichouhd'
|
||||||
|
| 'huobanzhaomuhd'
|
||||||
|
| 'qirileichonghd'
|
||||||
|
| 'jierihd'
|
||||||
|
| 'kbzzhd'
|
||||||
|
| 'wzryhd'
|
||||||
|
| 'yuedujijin'
|
||||||
|
| 'patahd'
|
||||||
|
|
|
||||||
|
'mingdao'
|
||||||
|
| 'heishihd'
|
||||||
|
| 'jitianhaoli'
|
||||||
|
| 'huodonghd'
|
||||||
|
| 'renown'
|
||||||
|
| 'heishiMrjx'
|
||||||
|
| 'weixiuchang'
|
||||||
|
| 'kaifujingsai'
|
||||||
|
| 'zhoumolibao';
|
||||||
|
|
||||||
|
|
||||||
export type hongdianVal = {
|
export type hongdianVal = {
|
||||||
|
1
src/shared/protocols/msg_s2c/MsgPushGiftChange.ts
Normal file
1
src/shared/protocols/msg_s2c/MsgPushGiftChange.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export type MsgPushGiftChange = 1;
|
5
src/shared/protocols/pushgift/PtlOpen.ts
Normal file
5
src/shared/protocols/pushgift/PtlOpen.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import {Gift} from "../../../module/collection_pushgift";
|
||||||
|
|
||||||
|
export type ReqOpen = {}
|
||||||
|
|
||||||
|
export type ResOpen = { gifts: Gift[] }
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user