巅峰演武:赛季优化修改
This commit is contained in:
@@ -9,13 +9,14 @@ import { UserShopTypeModel, UserShopTypeType } from "../db/UserShopType";
|
||||
import { GuildModel } from "../db/Guild";
|
||||
import { RoleModel } from "../db/Role";
|
||||
import { DicShop } from "../pubUtils/dictionary/DicShop";
|
||||
import { BackendSession } from "pinus";
|
||||
import { BackendSession, pinus } from "pinus";
|
||||
import { ActivityModelType } from "../db/Activity";
|
||||
import { addItems } from "./role/rewardService";
|
||||
import { LadderMatchModel } from "../db/LadderMatch";
|
||||
|
||||
export async function getAllShopList(roleId: string, serverId: number) {
|
||||
let userShopRecs = await UserShopModel.findByRoleId(roleId);
|
||||
let seasonNum = pinus.app.get('pvpSeasonNum');
|
||||
let userShopRecs = await UserShopModel.findByRoleId(roleId, seasonNum);
|
||||
let userShopTypeRecs = await UserShopTypeModel.findByRoleId(roleId);
|
||||
let activities = await getShopActivityDatas(roleId, serverId);
|
||||
|
||||
@@ -30,7 +31,8 @@ export async function getAllShopList(roleId: string, serverId: number) {
|
||||
}
|
||||
|
||||
export async function getShopListByType(shop: number, type: number, roleId: string, serverId: number) {
|
||||
let userShopRecs = await UserShopModel.findByShopType(roleId, shop, type);
|
||||
let seasonNum = pinus.app.get('pvpSeasonNum');
|
||||
let userShopRecs = await UserShopModel.findByShopType(roleId, shop, type, seasonNum);
|
||||
let activities = await getShopActivityDatas(roleId, serverId);
|
||||
let activity = activities.find(cur => cur.shop == shop && cur.type == type);
|
||||
let readRecord = await UserShopTypeModel.findByType(roleId, shop, type);
|
||||
@@ -128,6 +130,7 @@ export async function checkShopInPurchase(session: BackendSession, activityId: n
|
||||
}
|
||||
|
||||
export async function checkShopCanBuyInOrder(roleId: string, serverId: number, activity: ActivityModelType, productID: string) {
|
||||
let seasonNum = pinus.app.get('pvpSeasonNum');
|
||||
let role = await RoleModel.findByRoleId(roleId, 'guildCode createTime vipStartTime');
|
||||
let { createTime, guildCode, vipStartTime } = role;
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
@@ -136,7 +139,7 @@ export async function checkShopCanBuyInOrder(roleId: string, serverId: number, a
|
||||
let dicItem = shopData.findByProductID(productID);
|
||||
if(!dicItem) return false;
|
||||
|
||||
let userShop = await UserShopModel.findByRoleAndItem(roleId, activity.activityId, dicItem);
|
||||
let userShop = await UserShopModel.findByRoleAndItem(roleId, activity.activityId, dicItem, seasonNum);
|
||||
let result = await checkShopItemCanBuy(activity.activityId, dicItem.id, roleId, serverId, guildCode, vipStartTime, 1, userShop?.count||0, dicItem);
|
||||
return result.code == STATUS.SUCCESS.code;
|
||||
}
|
||||
@@ -188,6 +191,7 @@ export async function checkShopItemCanBuy(activityId: number, shopItemId: number
|
||||
*
|
||||
*/
|
||||
export async function makeShopOrder(roleId: string, roleName: string, sid: string, serverId: number, activityId: number, productID: string) {
|
||||
let seasonNum = pinus.app.get('pvpSeasonNum');
|
||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
||||
if (!activityData) {
|
||||
return STATUS.ACTIVITY_MISSING;
|
||||
@@ -206,7 +210,7 @@ export async function checkShopItemCanBuy(activityId: number, shopItemId: number
|
||||
}];
|
||||
await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.SHOP_PURCHASE);
|
||||
|
||||
await UserShopModel.purchase(roleId, roleName, activityId, dicItem, 1);
|
||||
await UserShopModel.purchase(roleId, roleName, activityId, dicItem, 1, seasonNum);
|
||||
return {
|
||||
code: 0,
|
||||
data: Object.assign({}, { item: { shop: dicItem.shop, type: dicItem.type, shopItemId: dicItem.id }, activityId: activityId })
|
||||
|
||||
Reference in New Issue
Block a user