Merge branch 'feature/pay_for_diamond' into dev
This commit is contained in:
commit
093de3350f
@ -8,19 +8,20 @@ export async function playerCanReceive(call: ApiCall) {
|
|||||||
if (!activityInfo) {
|
if (!activityInfo) {
|
||||||
return call.error('No such activity');
|
return call.error('No such activity');
|
||||||
}
|
}
|
||||||
const remaining = typeof activityInfo.data['remaining'] === 'number'? activityInfo.data['remaining'] : activityInfo.data['totalmoney'];
|
const remaining = activityInfo.data['totalmoney'];
|
||||||
|
const showOffList = activityInfo.data['showOffList'] || [];
|
||||||
const zeroTime = PublicShared.getToDayZeroTime();
|
const zeroTime = PublicShared.getToDayZeroTime();
|
||||||
const dayPayInfo = await G.mongodb.collection('dayPay').findOne({ uid: call.uid, time: zeroTime });
|
const dayPayInfo = await G.mongodb.collection('dayPay').findOne({ uid: call.uid, time: zeroTime });
|
||||||
if (!dayPayInfo || !dayPayInfo.payNum) {
|
if (!dayPayInfo || !dayPayInfo.payNum) {
|
||||||
return {
|
return {
|
||||||
payNum: 0, remaining, result: false, activityInfo
|
payNum: 0, remaining, result: false, activityInfo, showOffList
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const payNum = dayPayInfo.payNum;
|
const payNum = dayPayInfo.payNum;
|
||||||
// 玩家充值未达标或者奖池余额耗尽则不能领取
|
// 玩家充值未达标或者奖池余额耗尽则不能领取
|
||||||
if (payNum < activityInfo.data['price'] || remaining <= 0) {
|
if (payNum < activityInfo.data['price'] || remaining <= 0) {
|
||||||
return {
|
return {
|
||||||
payNum, remaining, result: false, activityInfo
|
payNum, remaining, result: false, activityInfo, showOffList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 检查玩家今日是否已经领取
|
// 检查玩家今日是否已经领取
|
||||||
@ -28,18 +29,19 @@ export async function playerCanReceive(call: ApiCall) {
|
|||||||
if (playerActivityInfo) {
|
if (playerActivityInfo) {
|
||||||
if (playerActivityInfo[zeroTime]?.length) {
|
if (playerActivityInfo[zeroTime]?.length) {
|
||||||
return {
|
return {
|
||||||
payNum, remaining, result: false, activityInfo
|
payNum, remaining, result: false, activityInfo, showOffList
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
payNum, remaining, result: true, activityInfo
|
payNum, remaining, result: true, activityInfo, showOffList
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqCanReceive, ResCanReceive>) {
|
export default async function (call: ApiCall<ReqCanReceive, ResCanReceive>) {
|
||||||
const canReceiveResult = await playerCanReceive(call);
|
const canReceiveResult = await playerCanReceive(call);
|
||||||
if (canReceiveResult) {
|
if (canReceiveResult) {
|
||||||
call.succ(canReceiveResult);
|
const { payNum, remaining, result, showOffList } = canReceiveResult;
|
||||||
|
call.succ({ payNum, remaining, result, showOffList });
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -62,31 +62,31 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
if (!canReceiveResult.result) {
|
if (!canReceiveResult.result) {
|
||||||
return call.succ({
|
return call.succ({
|
||||||
amount: 0,
|
amount: 0,
|
||||||
timesRemaining: 0
|
timesRemaining: 0,
|
||||||
|
showOff: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const activityData = canReceiveResult.activityInfo.data;
|
const activityData = canReceiveResult.activityInfo.data;
|
||||||
const remaining = typeof activityData['remaining'] === 'number'? activityData['remaining'] : activityData['totalmoney'];
|
const remaining = activityData['totalmoney'];
|
||||||
const { group, maxAmount } = randomWithWeight(activityData['groupConf']['base']['arr']);
|
const { group, maxAmount } = randomWithWeight(activityData['groupConf']['base']['arr']);
|
||||||
const gotAmount = calcDiamondGot(remaining, group, maxAmount);
|
const gotAmount = calcDiamondGot(remaining, group, maxAmount);
|
||||||
// 减去余额
|
// 减去余额
|
||||||
const filter = {
|
const filter = {
|
||||||
hdid: call.req.activityId,
|
hdid: call.req.activityId,
|
||||||
$or: [
|
$expr: {$gte: [ `$data.totalmoney - ${gotAmount}`, 0 ]},
|
||||||
{'data.remaining': { $exists: false }},
|
|
||||||
{$expr: {$gte: [ `$data.remaining - ${gotAmount}`, 0 ]}},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
const updateDoc = {
|
const updateDoc = {
|
||||||
$set: { 'data.remaining': `$data.remaining - ${gotAmount}` }
|
$inc: { 'data.totalmoney': -1 * Math.abs(gotAmount) }
|
||||||
}
|
}
|
||||||
const updateResult = await G.mongodb.collection('hdinfo').updateOne(filter, updateDoc);
|
const updateResult = await G.mongodb.collection('hdinfo').updateOne(filter, updateDoc);
|
||||||
// 更新成功
|
// 更新成功
|
||||||
if (updateResult.modifiedCount) {
|
if (updateResult.modifiedCount) {
|
||||||
|
const showOff = gotAmount >= activityData['groupConf']['base']['loglimit'];
|
||||||
// 请求返回
|
// 请求返回
|
||||||
call.succ({
|
call.succ({
|
||||||
amount: gotAmount,
|
amount: gotAmount,
|
||||||
timesRemaining: 0
|
timesRemaining: 0,
|
||||||
|
showOff,
|
||||||
});
|
});
|
||||||
// 添加玩家领取记录
|
// 添加玩家领取记录
|
||||||
const zeroTime = PublicShared.getToDayZeroTime();
|
const zeroTime = PublicShared.getToDayZeroTime();
|
||||||
@ -95,19 +95,11 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
G.mongodb.cEvent('payForDiamond').updateOne({ uid: call.uid }, {
|
G.mongodb.cEvent('payForDiamond').updateOne({ uid: call.uid }, {
|
||||||
$set: setObj
|
$set: setObj
|
||||||
});
|
});
|
||||||
|
// 记录玩家日志. 仅保留最近 10 条
|
||||||
|
if (showOff) {
|
||||||
|
G.mongodb.collection('hdinfo').updateOne({ hdid: call.req.activityId, }, { $push: { 'data.showOffList': { $each: [{ name: call.conn.gud.name, gotAmount }], $slice: -10 }}});
|
||||||
}
|
}
|
||||||
// 发送炫耀
|
|
||||||
if (gotAmount >= activityData['groupConf']['base']['loglimit']) {
|
|
||||||
ChatFun.newMsg({
|
|
||||||
type: 'local',
|
|
||||||
msg: G.gc.pmd.get_hero_star5_pmd,
|
|
||||||
time: G.time,
|
|
||||||
sender: 'system',
|
|
||||||
otherData: {
|
|
||||||
pmd: true,
|
|
||||||
args: [gotAmount]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,4 +6,5 @@ export type ResCanReceive = {
|
|||||||
payNum: number;
|
payNum: number;
|
||||||
remaining?: number;
|
remaining?: number;
|
||||||
result: boolean;
|
result: boolean;
|
||||||
|
showOffList: any[];
|
||||||
};
|
};
|
@ -5,4 +5,5 @@ export type ReqReceive = {
|
|||||||
export type ResReceive = {
|
export type ResReceive = {
|
||||||
amount: number,
|
amount: number,
|
||||||
timesRemaining: number;
|
timesRemaining: number;
|
||||||
|
showOff: boolean;
|
||||||
};
|
};
|
||||||
|
@ -10234,6 +10234,16 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "Boolean"
|
"type": "Boolean"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "showOffList",
|
||||||
|
"type": {
|
||||||
|
"type": "Array",
|
||||||
|
"elementType": {
|
||||||
|
"type": "Any"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -10265,6 +10275,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "showOff",
|
||||||
|
"type": {
|
||||||
|
"type": "Boolean"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user