Merge branch 'bugfix' into dev
This commit is contained in:
commit
058529ea6a
@ -15,10 +15,21 @@ export default async function (call: ApiCall<ReqBuy, ResBuy>) {
|
||||
let conf = _hdinfo.data.gift[call.req.index];
|
||||
if (!conf || conf.payId) return call.errorCode(-1);
|
||||
|
||||
let selectPrize = conf.prize.map((v, i) => v[call.req.prizeIndex[i]]).filter(p => !!p);
|
||||
if (selectPrize.length < conf.prize.length) return call.errorCode(-2);
|
||||
let data = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType})
|
||||
let rec = data?.rec?.[call.req.index]
|
||||
if (rec) return call.errorCode(-3)
|
||||
|
||||
// 奖励不符合,严格判断
|
||||
let dlzList = R.flatten(conf.dlz.map(i => R.values(i)))
|
||||
call.req.dlz.map(i => {
|
||||
let item = dlzList.find(v => i.a == v.a && i.t == v.t && i.n == v.n)
|
||||
if (!item) call.errorCode(-4)
|
||||
})
|
||||
|
||||
let event = (await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType }));
|
||||
|
||||
let buyNum = R.values(event?.rec)?.length || 0
|
||||
|
||||
let buyNum = (await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType }))?.record?.[call.req.index] || 0;
|
||||
if (buyNum >= conf.buyNum) return call.errorCode(-3);
|
||||
|
||||
if (conf.need.length > 0) {
|
||||
@ -26,15 +37,15 @@ export default async function (call: ApiCall<ReqBuy, ResBuy>) {
|
||||
await PlayerFun.cutNeed(call, conf.need);
|
||||
}
|
||||
|
||||
await PlayerFun.sendPrize(call, selectPrize);
|
||||
let prize = [...conf.prize,...call.req.dlz]
|
||||
|
||||
G.mongodb.cEvent(_dbType).updateOne(
|
||||
{ uid: call.uid, type: _dbType },
|
||||
{ $inc: G.mongodb.createTreeObj({ key: `record.${call.req.index}`, val: 1 }) },
|
||||
{ upsert: true }
|
||||
);
|
||||
await PlayerFun.sendPrize(call, prize);
|
||||
|
||||
await G.mongodb.cEvent(_dbType).updateOne({uid: call.uid, type: _dbType}, {
|
||||
$set: {[`rec.${call.req.index}`]: prize},
|
||||
}, {upsert: true})
|
||||
|
||||
call.succ({
|
||||
prize: selectPrize
|
||||
prize: prize
|
||||
});
|
||||
}
|
@ -13,7 +13,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
||||
|
||||
call.succ({
|
||||
record: db?.record || {},
|
||||
rec: db?.rec || {},
|
||||
hdinfo: _hdinfo
|
||||
});
|
||||
}
|
@ -7,7 +7,7 @@ export type ReqBuy = {
|
||||
/**礼包index */
|
||||
index: number;
|
||||
/**礼包的每个奖励index */
|
||||
prizeIndex: number[];
|
||||
dlz: prizeType[]
|
||||
hdid: number
|
||||
};
|
||||
|
||||
|
@ -10,8 +10,8 @@ export type ReqOpen = {
|
||||
|
||||
export type ResOpen = {
|
||||
/**购买记录 */
|
||||
record: {
|
||||
[k: string]: number;
|
||||
rec: {
|
||||
[k: string]: any;
|
||||
};
|
||||
hdinfo: ReqAddHuoDong
|
||||
};
|
@ -11957,11 +11957,12 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "prizeIndex",
|
||||
"name": "dlz",
|
||||
"type": {
|
||||
"type": "Array",
|
||||
"elementType": {
|
||||
"type": "Number"
|
||||
"type": "Reference",
|
||||
"target": "type/prizeType"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -12007,13 +12008,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "record",
|
||||
"name": "rec",
|
||||
"type": {
|
||||
"type": "Interface",
|
||||
"indexSignature": {
|
||||
"keyType": "String",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
"type": "Any"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user