元旦活动
This commit is contained in:
parent
21994f214a
commit
08d0bed291
@ -9,12 +9,12 @@ export default async function (call: ApiCall<ReqDMRec, ResDMRec>) {
|
|||||||
let _hd = (await HuoDongFun.gethdList(call, 14))[0]
|
let _hd = (await HuoDongFun.gethdList(call, 14))[0]
|
||||||
if (!_hd) return call.errorCode(-1)
|
if (!_hd) return call.errorCode(-1)
|
||||||
|
|
||||||
// 校验当前领取奖励
|
// 奖励不符合
|
||||||
let toPrize = call.req.prize
|
let toPrize = call.req.prize
|
||||||
let prize = _hd.data.game.find(i => i.a == toPrize.a && i.t == toPrize.t && i.n == toPrize.n)
|
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 data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`})
|
||||||
let rec = data?.gameNum
|
let rec = data?.gameNum
|
||||||
|
|
||||||
|
@ -10,15 +10,24 @@ export default async function (call: ApiCall<ReqDZRec, ResDZRec>) {
|
|||||||
let gift = _hd?.data?.gift?.find(i => i.free && i.id == call.req.id)
|
let gift = _hd?.data?.gift?.find(i => i.free && i.id == call.req.id)
|
||||||
if (!gift) return call.errorCode(-1)
|
if (!gift) return call.errorCode(-1)
|
||||||
|
|
||||||
// 取奖励列表,判断是否有可领取奖励
|
// 超出限购次数
|
||||||
let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`})
|
let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`})
|
||||||
let rec = data?.gift?.[call.req.id]
|
let rec = data?.gift?.[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);
|
// 奖励不符合,严格判断
|
||||||
|
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}`}, {
|
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})
|
}, {upsert: true})
|
||||||
|
|
||||||
call.succ({})
|
call.succ({})
|
||||||
|
@ -5,12 +5,12 @@ import {PlayerFun} from "../../../public/player";
|
|||||||
import {HongDianChange} from "../../hongdian/fun";
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqExchange, ResExchange>) {
|
export default async function (call: ApiCall<ReqExchange, ResExchange>) {
|
||||||
// 查询活动是否有当前领奖的免费选项
|
// 礼包不存在
|
||||||
let _hd = (await HuoDongFun.gethdList(call, 14))[0]
|
let _hd = (await HuoDongFun.gethdList(call, 14))[0]
|
||||||
let gift = _hd?.data?.duihuan?.find(i => i.id == call.req.id)
|
let gift = _hd?.data?.duihuan?.find(i => i.id == call.req.id)
|
||||||
if (!gift) return call.errorCode(-1)
|
if (!gift) return call.errorCode(-1)
|
||||||
|
|
||||||
// 取奖励列表,判断是否有可领取奖励
|
// 超出限购次数
|
||||||
let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`})
|
let data = await G.mongodb.cEvent(`yuandan${_hd.hdid}`).findOne({uid: call.uid, type: `yuandan${_hd.hdid}`})
|
||||||
let rec = data?.exchange?.[call.req.id]
|
let rec = data?.exchange?.[call.req.id]
|
||||||
if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
|
if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
|
||||||
|
@ -30,7 +30,7 @@ export default async function (call: ApiCall<ReqZLRec, ResZLRec>) {
|
|||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
|
|
||||||
await G.mongodb.cEvent(`yuandan${_hd.hdid}`).updateOne({uid: call.uid, type: `yuandan${_hd.hdid}`}, {
|
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})
|
}, {upsert: true})
|
||||||
|
|
||||||
call.succ({})
|
call.succ({})
|
||||||
|
@ -50,8 +50,8 @@ export class Yuandanfun {
|
|||||||
|
|
||||||
/**设置数据 */
|
/**设置数据 */
|
||||||
static async setData(uid: string, hdid: number, set: {}) {
|
static async setData(uid: string, hdid: number, set: {}) {
|
||||||
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
|
await G.mongodb.cEvent(`yuandan${hdid}`).updateOne(
|
||||||
{uid: uid, type: `christmas${hdid}`},
|
{uid: uid, type: `yuandan${hdid}`},
|
||||||
set
|
set
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
export type ReqDZRec = {
|
export type ReqDZRec = {
|
||||||
id: string
|
id: string
|
||||||
|
dlz: { a: string, t: string, n: number }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResDZRec = {
|
export type ResDZRec = {
|
||||||
|
@ -11460,6 +11460,39 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "String"
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user