diff --git a/src/api_s2c/event/yuandan/ApiDMRec.ts b/src/api_s2c/event/yuandan/ApiDMRec.ts index bcbec2f..758a4f6 100644 --- a/src/api_s2c/event/yuandan/ApiDMRec.ts +++ b/src/api_s2c/event/yuandan/ApiDMRec.ts @@ -9,12 +9,12 @@ export default async function (call: ApiCall) { let _hd = (await HuoDongFun.gethdList(call, 14))[0] if (!_hd) return call.errorCode(-1) - // 校验当前领取奖励 + // 奖励不符合 let toPrize = call.req.prize let prize = _hd.data.game.find(i => i.a == toPrize.a && i.t == toPrize.t && i.n == toPrize.n) - if (toPrize && !prize) return call.errorCode(-2) + if (toPrize && !prize) return call.errorCode(-4) - // 取奖励列表,判断是否有可领取奖励 + // 扣除免费次数或相应货币 let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`}) let rec = data?.gameNum diff --git a/src/api_s2c/event/yuandan/ApiDZRec.ts b/src/api_s2c/event/yuandan/ApiDZRec.ts index ce3f3f2..a801b42 100644 --- a/src/api_s2c/event/yuandan/ApiDZRec.ts +++ b/src/api_s2c/event/yuandan/ApiDZRec.ts @@ -10,15 +10,24 @@ export default async function (call: ApiCall) { let gift = _hd?.data?.gift?.find(i => i.free && i.id == call.req.id) if (!gift) return call.errorCode(-1) - // 取奖励列表,判断是否有可领取奖励 + // 超出限购次数 let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`}) let rec = data?.gift?.[call.req.id] if (rec && rec >= gift.buynum) return call.errorCode(-2) - await PlayerFun.sendPrize(call, gift.prize); + // 奖励不符合,严格判断 + let dlzList = R.flatten(gift.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 prize = [...gift.prize, ...call.req.dlz] + + await PlayerFun.sendPrize(call, prize); await G.mongodb.cEvent(`yuandan${_hd.hdid}`).updateOne({uid: call.uid, type: `yuandan${_hd.hdid}`}, { - $inc: {[`gift.${gift.id}`]: 1}, + $set: {[`gift.${gift.id}`]: JSON.stringify(prize)}, }, {upsert: true}) call.succ({}) diff --git a/src/api_s2c/event/yuandan/ApiExchange.ts b/src/api_s2c/event/yuandan/ApiExchange.ts index a3285db..72bbe41 100644 --- a/src/api_s2c/event/yuandan/ApiExchange.ts +++ b/src/api_s2c/event/yuandan/ApiExchange.ts @@ -5,12 +5,12 @@ import {PlayerFun} from "../../../public/player"; import {HongDianChange} from "../../hongdian/fun"; export default async function (call: ApiCall) { - // 查询活动是否有当前领奖的免费选项 + // 礼包不存在 let _hd = (await HuoDongFun.gethdList(call, 14))[0] let gift = _hd?.data?.duihuan?.find(i => i.id == call.req.id) if (!gift) return call.errorCode(-1) - // 取奖励列表,判断是否有可领取奖励 + // 超出限购次数 let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`}) let rec = data?.exchange?.[call.req.id] if (rec && rec >= gift?.buyNum) return call.errorCode(-2) diff --git a/src/api_s2c/event/yuandan/ApiZLRec.ts b/src/api_s2c/event/yuandan/ApiZLRec.ts index 7adb47c..b810694 100644 --- a/src/api_s2c/event/yuandan/ApiZLRec.ts +++ b/src/api_s2c/event/yuandan/ApiZLRec.ts @@ -30,7 +30,7 @@ export default async function (call: ApiCall) { await PlayerFun.sendPrize(call, prize); await G.mongodb.cEvent(`yuandan${_hd.hdid}`).updateOne({uid: call.uid, type: `yuandan${_hd.hdid}`}, { - $inc: {[`qiandao.${call.req.id}`]: prize}, + $set: {[`qiandao.${call.req.id}`]: JSON.stringify(prize)}, }, {upsert: true}) call.succ({}) diff --git a/src/api_s2c/event/yuandan/fun.ts b/src/api_s2c/event/yuandan/fun.ts index 20a4c68..f815ece 100644 --- a/src/api_s2c/event/yuandan/fun.ts +++ b/src/api_s2c/event/yuandan/fun.ts @@ -50,8 +50,8 @@ export class Yuandanfun { /**设置数据 */ static async setData(uid: string, hdid: number, set: {}) { - await G.mongodb.cEvent(`christmas${hdid}`).updateOne( - {uid: uid, type: `christmas${hdid}`}, + await G.mongodb.cEvent(`yuandan${hdid}`).updateOne( + {uid: uid, type: `yuandan${hdid}`}, set ) } diff --git a/src/shared/protocols/event/yuandan/PtlDZRec.ts b/src/shared/protocols/event/yuandan/PtlDZRec.ts index 1942987..03db521 100644 --- a/src/shared/protocols/event/yuandan/PtlDZRec.ts +++ b/src/shared/protocols/event/yuandan/PtlDZRec.ts @@ -3,6 +3,7 @@ */ export type ReqDZRec = { id: string + dlz: { a: string, t: string, n: number }[] } export type ResDZRec = { diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 41a4fae..b8e538b 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -11460,6 +11460,39 @@ export const serviceProto: ServiceProto = { "type": { "type": "String" } + }, + { + "id": 1, + "name": "dlz", + "type": { + "type": "Array", + "elementType": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "a", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "t", + "type": { + "type": "String" + } + }, + { + "id": 2, + "name": "n", + "type": { + "type": "Number" + } + } + ] + } + } } ] },