弹出礼包:购买

This commit is contained in:
陆莹
2022-03-15 21:01:21 +08:00
parent 319d4cf454
commit d9b907e80b
4 changed files with 72 additions and 67 deletions
+1
View File
@@ -494,6 +494,7 @@ export const STATUS = {
ERROR_TYPE: { code: 70012, simStr: '未知活动类型' },
ORDER_PARAM_ERROR: { code: 70013, simStr: '订单参数错误' },
CHANNEL_INFO_NOT_FOUND: { code: 70014, simStr: '未找到玩家渠道数据' },
ACTIVITY_TASK_NOT_COMPLETE: { code: 70015, simStr: '条件未达成' },
}
+13
View File
@@ -91,6 +91,11 @@ export default class Activity_Pop_Up_Shop extends BaseModel {
return rec;
}
public static async findByCode(serverId: number, activityId: number, roleId: string, code: string) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOne({ serverId, activityId, roleId, code }).lean();
return rec;
}
public static async addRecord(serverId: number, activityId: number, roleId: string, code: string, productID: string) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate(
{ serverId, activityId, roleId, code, 'items.productID': productID },
@@ -98,6 +103,14 @@ export default class Activity_Pop_Up_Shop extends BaseModel {
{ new: true} ).lean();
return rec;
}
public static async addRecordById(serverId: number, activityId: number, roleId: string, code: string, itemid: number) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate(
{ serverId, activityId, roleId, code, 'items.id': itemid },
{ $set: { hasBought: true }, $inc: { 'items.$.hasBoughtCnt': 1 } },
{ new: true} ).lean();
return rec;
}
}
export const ActivityPopUpShopModel = getModelForClass(Activity_Pop_Up_Shop);
+15 -1
View File
@@ -103,7 +103,7 @@ export class PopUpShopData extends ActivityBase {
}
}
private findPackageById(id: number) {
public findPackageById(id: number) {
let index = this.packageMap.get(id);
return this.packages[index];
}
@@ -119,6 +119,13 @@ export class PopUpShopData extends ActivityBase {
let item = pkg.findItemByProductID(productID);
return item.updateItem(dataItem);
}
public updateRecordById(data: ActivityPopUpShopModelType, id: number) {
let pkg = this.findPackageById(data.id);
let dataItem = data.items.find(cur => cur.id == id);
let item = pkg.findItemById(id);
return item.updateItem(dataItem);
}
}
// 同一礼包类型为一组,共享cd,档位
@@ -135,6 +142,7 @@ export class PopUpShopPackage {
items: PopShopItem[] = []; // 礼包
keyItem: PopUpShopKeyItem[] = []; // 关键资源限制,refreshDay内可以获得Y个
private itemByProductID: Map<string, number> = new Map(); // productID => index
private itemById: Map<number, number> = new Map();
private parent: PopUpShopData;
// setPlayerRecord的时候处理的数据
@@ -159,6 +167,7 @@ export class PopUpShopPackage {
let obj = new PopShopItem(item, this);
this.items.push(obj);
this.itemByProductID.set(obj.productID, this.items.length - 1);
this.itemById.set(obj.id, this.items.length - 1);
}
for(let key of data.keyItem) {
this.keyItem.push(new PopUpShopKeyItem(key));
@@ -175,6 +184,11 @@ export class PopUpShopPackage {
return this.items[index];
}
public findItemById(id: number) {
let index = this.itemById.get(id);
return this.items[index];
}
public addPlayerRecord(data: ActivityPopUpShopModelType) {
let now = new Date();
this.hasPushCnt++;