累计充值
This commit is contained in:
parent
a5da9e1522
commit
6fd4e79fbe
@ -1,32 +1,35 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { HuoDongFun } from "../../../public/huodongfun";
|
import {HuoDongFun} from "../../../public/huodongfun";
|
||||||
import { PayFun } from '../../../public/pay';
|
import {PayFun} from '../../../public/pay';
|
||||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/leijichongzhi/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/leijichongzhi/PtlOpen";
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PublicShared} from '../../../shared/public/public';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
||||||
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
|
||||||
}
|
}
|
||||||
|
|
||||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
let sTime = db?.sTime || PublicShared.getToDayZeroTime(G.time);
|
let sTime = db?.sTime || PublicShared.getToDayZeroTime(G.time);
|
||||||
|
|
||||||
if (!db) {
|
if (!db) {
|
||||||
G.mongodb.cEvent(_dbType).updateOne(
|
G.mongodb.cEvent(_dbType).updateOne(
|
||||||
{ uid: call.uid, type: _dbType },
|
{uid: call.uid, type: _dbType},
|
||||||
{ $set: { sTime: sTime, recIndex: [] } },
|
{$set: {sTime: sTime, recIndex: []}},
|
||||||
{ upsert: true }
|
{upsert: true}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10
|
||||||
|
payNum = payNum - (db.round || 0) * R.compose(R.sum(), R.map(i => i.total))(_hdinfo.data.tasks)
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
sTime: sTime,
|
sTime: sTime,
|
||||||
recIndex: db?.recIndex || [],
|
recIndex: db?.recIndex || [],
|
||||||
payNum: (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10,
|
payNum: payNum,
|
||||||
hdinfo: _hdinfo
|
hdinfo: _hdinfo,
|
||||||
|
round: db.round || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -1,34 +1,42 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { HuoDongFun } from "../../../public/huodongfun";
|
import {HuoDongFun} from "../../../public/huodongfun";
|
||||||
import { PayFun } from '../../../public/pay';
|
import {PayFun} from '../../../public/pay';
|
||||||
import { PlayerFun } from '../../../public/player';
|
import {PlayerFun} from '../../../public/player';
|
||||||
import { ReqRec, ResRec } from "../../../shared/protocols/event/leijichongzhi/PtlRec";
|
import {ReqRec, ResRec} from "../../../shared/protocols/event/leijichongzhi/PtlRec";
|
||||||
import { HongDianChange } from "../../hongdian/fun";
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||||
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
||||||
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
|
||||||
}
|
}
|
||||||
|
|
||||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
||||||
|
|
||||||
let conf = _hdinfo.data.tasks[call.req.index];
|
let conf = _hdinfo.data.tasks[call.req.index];
|
||||||
if (!conf) return call.error('', { code: -1 });
|
if (!conf) return call.error('', {code: -1});
|
||||||
|
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
if (db.recIndex.includes(call.req.index)) return call.error('', { code: -2 });
|
if (db.recIndex.includes(call.req.index)) return call.error('', {code: -2});
|
||||||
|
|
||||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10;
|
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10;
|
||||||
if (payNum < conf.total) return call.error('', { code: -3 });
|
payNum = payNum - (db.round || 0) * R.compose(R.sum(), R.map(i => i.total))(_hdinfo.data.tasks)
|
||||||
|
if (payNum < conf.total) return call.error('', {code: -3});
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, conf.prize);
|
await PlayerFun.sendPrize(call, conf.prize);
|
||||||
|
|
||||||
G.mongodb.cEvent(_dbType).updateOne(
|
if (db.recIndex.length + 1 >= _hdinfo.data.tasks.length) {
|
||||||
{ uid: call.uid, type: _dbType },
|
await G.mongodb.cEvent(_dbType).updateOne(
|
||||||
{ $push: { recIndex: call.req.index } }
|
{uid: call.uid, type: _dbType},
|
||||||
);
|
{$set: {recIndex: []}, $inc: {round: 1}}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await G.mongodb.cEvent(_dbType).updateOne(
|
||||||
|
{uid: call.uid, type: _dbType},
|
||||||
|
{$push: {recIndex: call.req.index}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd'])
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd'])
|
||||||
call.succ({
|
call.succ({
|
||||||
|
@ -16,4 +16,6 @@ export type ResOpen = {
|
|||||||
payNum: number;
|
payNum: number;
|
||||||
/**活动信息 */
|
/**活动信息 */
|
||||||
hdinfo: ReqAddHuoDong;
|
hdinfo: ReqAddHuoDong;
|
||||||
|
/** 当前领取轮次 */
|
||||||
|
round: number
|
||||||
};
|
};
|
@ -10263,6 +10263,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": "Reference",
|
"type": "Reference",
|
||||||
"target": "../../monopoly/protocols/PtlAddHuoDong/ReqAddHuoDong"
|
"target": "../../monopoly/protocols/PtlAddHuoDong/ReqAddHuoDong"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"name": "round",
|
||||||
|
"type": {
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user