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