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 /node_modules
/.idea /.idea
/.vscode
/dist /dist
/doc /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, payArgs: payArgs,
orderNo: orderNo orderNo: orderNo
} }
if (payId.indexOf('zixuanlibao') != -1) { //改为统一方法,此处自选不这样用
// 后端唯一标识 htype 4 自选/定制 礼包 // if (payId.indexOf('zixuanlibao') != -1) {
// @ts-ignore // // 后端唯一标识 htype 4 自选/定制 礼包
let _hdList = await HuoDongFun.gethdList(call, 4) // // @ts-ignore
_hdList.forEach(ele => { // let _hdList = await HuoDongFun.gethdList(call, 4)
let selectPrize = ele.data.gift.find(v => v.payId == payId)?.prize; // _hdList.forEach(ele => {
if (prize) { // let selectPrize = ele.data.gift.find(v => v.payId == payId)?.prize;
let index = payArgs instanceof Array ? payArgs : []; // if (prize) {
let select = selectPrize.map((v, i) => v[index[i]] ? v[index[i]] : v[0]); // let index = payArgs instanceof Array ? payArgs : [];
prize.push(...select); // let select = selectPrize.map((v, i) => v[index[i]] ? v[index[i]] : v[0]);
} // prize.push(...select);
}) // }
} // })
// }
if (payId.indexOf('ycmb') != -1) { if (payId.indexOf('ycmb') != -1) {
// @ts-ignore // 养成活动充值礼包 // @ts-ignore // 养成活动充值礼包
let _hdids = await YangChengMuBiaofun.getCon(call); let _hdids = await YangChengMuBiaofun.getCon(call);
@ -235,11 +236,26 @@ export class PayFun {
let conf = await zmlbGetConf(call, {payId}) let conf = await zmlbGetConf(call, {payId})
prize.push(...conf.prize) prize.push(...conf.prize)
} }
/**
* todo
* todo
* todo emit事件
* todo
*/
//圣诞节活动充值 //圣诞节活动充值
try{ try {
await Christmasfun.payChristmas(payId, call); await Christmasfun.payChristmas(payId, call);
}catch (e) { } catch (e) {
console.log("Christmasfun.payChristmas Error",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) 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) { 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}); 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) let zeroTime = PublicShared.getToDayZeroTime(G.time)
if (payId.indexOf('136Gift') != -1 && payId != '136GiftAll') { if (payId.indexOf('136Gift') != -1 && payId != '136GiftAll') {
@ -455,6 +496,7 @@ export class PayFun {
/** /**
* *
* @param player
* @param lastTime * @param lastTime
* @param curTime * @param curTime
*/ */