红点:修改推送方式
This commit is contained in:
@@ -3,14 +3,13 @@ import { gameData } from "../../../pubUtils/data";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX } from "../../../consts";
|
||||
import { DicShopListModel } from "../../../db/DicShopList";
|
||||
import { ShopItem } from "../../../domain/dbGeneral";
|
||||
import { ShopItemListParam } from '../../../domain/roleField/shop';
|
||||
import { UserShopModel } from "../../../db/UserShop";
|
||||
import { handleCost, addItems } from "../../../services/rewardService";
|
||||
import { GuildModel } from "../../../db/Guild";
|
||||
import { SHOP } from "../../../pubUtils/dicParam";
|
||||
import { getHonourObject } from "../../../pubUtils/itemUtils";
|
||||
import { HeroModel } from "../../../db/Hero";
|
||||
import { getShopListById } from "../../../services/shopService";
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ShopHandler(app);
|
||||
@@ -29,46 +28,7 @@ export class ShopHandler {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
let shopItemList = new Array<ShopItemListParam>(); // 返回
|
||||
let dbDicShop = await DicShopListModel.findByShopId(shopId);
|
||||
let userShopRecs = await UserShopModel.findMapByShopId(roleId, shopId);
|
||||
// console.log(JSON.stringify([...userShopRecs]))
|
||||
|
||||
|
||||
if(!dbDicShop || dbDicShop.useJson) { // 完全使用json中配置的商品,数据库只做排序用,数据库内没有的排到最后
|
||||
let items = dbDicShop?.items||[];
|
||||
let map = new Map<number, ShopItem>();
|
||||
for(let item of items) {
|
||||
map.set(item.id, item);
|
||||
}
|
||||
let dicShop = gameData.shop.get(shopId)||[];
|
||||
for(let { id, type } of dicShop) {
|
||||
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
||||
if(map.has(id)) {
|
||||
let item = map.get(id);
|
||||
let param = new ShopItemListParam(id, item.discount, type, buyCount, item.order);
|
||||
shopItemList.push(param);
|
||||
} else {
|
||||
let param = new ShopItemListParam(id, 1, type, buyCount, 0);
|
||||
shopItemList.push(param);
|
||||
}
|
||||
}
|
||||
|
||||
} else { // 只返回数据库内的商品
|
||||
let items = dbDicShop?.items||[];
|
||||
for(let item of items) {
|
||||
let { id, order, discount } = item;
|
||||
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
||||
let dicShop = gameData.shopItem.get(id);
|
||||
if(dicShop) {
|
||||
let param = new ShopItemListParam(id, discount, dicShop.type, buyCount, order);
|
||||
shopItemList.push(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shopItemList = shopItemList.sort((a, b) => b.order - a.order);
|
||||
|
||||
const shopItemList = await getShopListById(shopId, roleId);
|
||||
return resResult(STATUS.SUCCESS, { shopItemList });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user