商店:添加vip购买次数上限

This commit is contained in:
luying
2022-07-20 17:02:55 +08:00
parent cf03a7d4bd
commit 1157269264
3 changed files with 185 additions and 89 deletions
@@ -40,6 +40,7 @@ export class ShopHandler {
let sid = session.get('sid');
let guildCode = session.get('guildCode');
let serverId = session.get('serverId');
let vipStartTime: number = session.get('vipStartTime');
let { shopItemId, count } = msg;
if( count < 0) return resResult(STATUS.WRONG_PARMS);
@@ -65,8 +66,14 @@ export class ShopHandler {
let userShop = await UserShopModel.findByRoleAndItem(roleId, dicShopItem.id);
if(dicShopItem.purchaseLimit != -1) {
if(userShop && userShop.count + count > dicShopItem.purchaseLimit) {
return resResult(STATUS.BUY_COUNT_OVER);
if(vipStartTime > 0 && dicShopItem.purchaseLimit != -1) {
if(userShop && userShop.count + count > dicShopItem.purchaseLimit + dicShopItem.vipPurchaseLimit) {
return resResult(STATUS.BUY_COUNT_OVER);
}
} else {
if(userShop && userShop.count + count > dicShopItem.purchaseLimit) {
return resResult(STATUS.BUY_COUNT_OVER);
}
}
}