Revert "Revert "自选类型购买改为统一方法""

This reverts commit 9837d27132.
This commit is contained in:
dy 2023-12-26 18:38:14 +08:00
parent 720dc255fe
commit 74c28c787b
3 changed files with 108 additions and 17 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
/node_modules
/.idea
/.vscode
/dist
/doc

50
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,50 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "消息服",
"type": "node",
"request": "launch",
"args": [
"${workspaceRoot}/src/index.ts",
"-serverType",
"msg",
"-logModel",
"debug"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "跨服",
"type": "node",
"request": "launch",
"args": [
"${workspaceRoot}/src/index.ts",
"-serverType",
"cross",
"-logModel",
"debug"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}

View File

@ -206,19 +206,20 @@ export class PayFun {
payArgs: payArgs,
orderNo: orderNo
}
if (payId.indexOf('zixuanlibao') != -1) {
// 后端唯一标识 htype 4 自选/定制 礼包
// @ts-ignore
let _hdList = await HuoDongFun.gethdList(call, 4)
_hdList.forEach(ele => {
let selectPrize = ele.data.gift.find(v => v.payId == payId)?.prize;
if (prize) {
let index = payArgs instanceof Array ? payArgs : [];
let select = selectPrize.map((v, i) => v[index[i]] ? v[index[i]] : v[0]);
prize.push(...select);
}
})
}
//改为统一方法,此处自选不这样用
// if (payId.indexOf('zixuanlibao') != -1) {
// // 后端唯一标识 htype 4 自选/定制 礼包
// // @ts-ignore
// let _hdList = await HuoDongFun.gethdList(call, 4)
// _hdList.forEach(ele => {
// let selectPrize = ele.data.gift.find(v => v.payId == payId)?.prize;
// if (prize) {
// let index = payArgs instanceof Array ? payArgs : [];
// let select = selectPrize.map((v, i) => v[index[i]] ? v[index[i]] : v[0]);
// prize.push(...select);
// }
// })
// }
if (payId.indexOf('ycmb') != -1) {
// @ts-ignore // 养成活动充值礼包
let _hdids = await YangChengMuBiaofun.getCon(call);
@ -235,11 +236,26 @@ export class PayFun {
let conf = await zmlbGetConf(call, {payId})
prize.push(...conf.prize)
}
/**
* todo
* todo
* todo emit事件
* todo
*/
//圣诞节活动充值
try{
try {
await Christmasfun.payChristmas(payId, call);
}catch (e) {
console.log("Christmasfun.payChristmas Error",e);
} catch (e) {
console.log("Christmasfun.payChristmas Error", e);
}
if (payArgs.selectPrize) {
let selectPrize = await G.ioredis.get(`pay:${payId}:${player.uid}`);
if (selectPrize) {
prize.push(...JSON.parse(selectPrize))
G.ioredis.del(`pay:${payId}:${player.uid}`)
}
}
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs, player)
@ -399,6 +415,31 @@ export class PayFun {
if (conf.time != -1 && buyLog.slice(-1)[0]?.eTime > G.time && conf.buys == 0 && payId.indexOf('wkdlibao') == -1) {
return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -2});
}
/**
* htype 414
* payArgs里传相应参数selectList选择的奖励列表
* 414
*/
if (payArgs.htype && payArgs.selectList) {
// @ts-ignore
let _hdInfo = (await HuoDongFun.gethdList(call, payArgs.htype))[0]
// 活动类购买不符合条件返回-5
if (!_hdInfo) G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -5})
let giftInfo = _hdInfo.data.gift.find(v => v.payId == payId);
if (!giftInfo) G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -5})
let dlzPrize = R.flatten(giftInfo.dlz.map(i => R.values(i)))
let selectPrize = payArgs.selectList.map(v => {
let sPrize = dlzPrize.find(o => o.a == v.a && o.t == v.t && o.n == v.n)
// 严格判断,自选奖励不存在奖励列表,返回-6
if (!sPrize) return G.server.sendMsgByUid(player.uid, 'msg_s2c/PayResult', {code: -6});
return sPrize
})
// 自选奖励过判断后存入redis6小时内支付有效 todo 6小时可能有些长
G.ioredis.setex(`pay:${payId}:${player.uid}`, 21600, JSON.stringify(selectPrize));
}
//针对每日礼包的单独处理
let zeroTime = PublicShared.getToDayZeroTime(G.time)
if (payId.indexOf('136Gift') != -1 && payId != '136GiftAll') {
@ -455,6 +496,7 @@ export class PayFun {
/**
*
* @param player
* @param lastTime
* @param curTime
*/