团购:debug接口
This commit is contained in:
@@ -21,6 +21,7 @@ import { getActivityById } from "./activityService";
|
||||
*/
|
||||
export async function getGroupShopData(activityId: number, roleId: string) {
|
||||
let activityData = await getActivityById(activityId);
|
||||
if(!activityData) return null
|
||||
let createTime = await getRoleCreateTime(roleId);
|
||||
|
||||
let playerData = new GroupShopData(activityData, createTime, 0);
|
||||
@@ -76,16 +77,16 @@ export async function setGroupShopToSetSum(arr: { activityId: number, itemId: nu
|
||||
}
|
||||
}
|
||||
|
||||
export async function refundGroupShop() {
|
||||
export async function refundGroupShop(isDebug = false) {
|
||||
let activities = await ActivityModel.findActivityByType(ACTIVITY_TYPE.GROUP_SHOP);
|
||||
|
||||
for(let activityData of activities) {
|
||||
let hasRefund = await ActivityGroupShopRefundModel.check(activityData.activityId);
|
||||
if(!hasRefund) continue;
|
||||
if(!isDebug && !hasRefund) continue;
|
||||
|
||||
let recs = new Map<string, { itemId: number, diff: number }[]>();
|
||||
let playerData = await getGroupShopServerData(activityData);
|
||||
if(playerData.endTime >= Date.now()) continue;
|
||||
if(!isDebug && playerData.endTime >= Date.now()) continue;
|
||||
|
||||
let items = playerData.items||[];
|
||||
for(let item of items) {
|
||||
|
||||
@@ -106,6 +106,8 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
case 'activity.treasureHuntHandler.getTreasureHuntActivity':
|
||||
case 'activity.vipRechargeMoneyHandler.getVipRechargeMoneyActivity':
|
||||
case 'activity.yuanbaoShopHandler.getShopActivity':
|
||||
case 'activity.groupShopHandler.getGroupShopPage':
|
||||
case 'activity.groupShopHandler.leaveGroupShopPage':
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.activityId)) return false;
|
||||
break;
|
||||
@@ -406,6 +408,12 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
if(msg.count < 0 && msg.count > 100) return false
|
||||
break;
|
||||
}
|
||||
case 'activity.groupShopHandler.buy':
|
||||
{
|
||||
let { activityId, price, id, buyCnt } = msg;
|
||||
if(!checkNaturalNumbers(activityId, price, id, buyCnt)) return false;
|
||||
break;
|
||||
}
|
||||
case "battle.barrageHandler.getBarrageList":
|
||||
{
|
||||
if(!checkNaturalStrings(msg.rid)) return false;
|
||||
@@ -1638,6 +1646,9 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
case "guild.cityActivityHandler.debugStartHitGate":
|
||||
case "guild.cityActivityHandler.debugStopHitGate":
|
||||
case "guild.cityActivityHandler.debugTestAutoDeclare":
|
||||
case "activity.groupShopHandler.debugRefund":
|
||||
case "activity.groupShopHandler.debugSetSum":
|
||||
case "activity.groupShopHandler.debugClearCnt":
|
||||
{
|
||||
if (msg.magicWord !== DEBUG_MAGIC_WORD || !isDevelopEnv()) return false;
|
||||
break;
|
||||
|
||||
@@ -804,7 +804,13 @@ async function ladderDailyReward() {
|
||||
|
||||
// —————————————— 团购定时器 start —————————————— //
|
||||
async function initGroupShopSchedule() {
|
||||
initSumSchedule();
|
||||
scheduleJob('groupShopRefund', '0 30 5 * * ?', () => {
|
||||
refundGroupShop();
|
||||
});
|
||||
}
|
||||
|
||||
async function initSumSchedule() {
|
||||
let activities = await ActivityModel.findActivityByType(ACTIVITY_TYPE.GROUP_SHOP);
|
||||
let scheduleMap = new Map<number, { activityId: number, itemId: number, sum: number }[]>(); // 时间 => data
|
||||
for(let activity of activities) {
|
||||
@@ -825,8 +831,6 @@ async function initGroupShopSchedule() {
|
||||
await setGroupShopToSetSum(arr);
|
||||
});
|
||||
}
|
||||
|
||||
scheduleJob('groupShopRefund', '0 30 5 * * ?', refundGroupShop);
|
||||
}
|
||||
|
||||
// —————————————— 团购定时器 end —————————————— //
|
||||
Reference in New Issue
Block a user