活动:根据订单获得活动

This commit is contained in:
luying
2022-07-02 19:03:04 +08:00
parent a3331a2b5d
commit e4d8708898
8 changed files with 126 additions and 30 deletions

View File

@@ -4,6 +4,35 @@ import { ActivityRefreshShopModelType, GoodsInfo } from '../../db/ActivityRefres
import { getZeroPoint, getZeroPointOfTime } from '../../pubUtils/timeUtil';
import { ActivityBase } from './activityField';
interface RefreshShopDataInDb {
shopType: number;
name: string;
data: RefreshShopPageInDb[];
}
interface RefreshShopPageInDb {
pageIndex: number;
viewcount: number;
name: string;
items: RefreshShopItemInDb[]
}
interface RefreshShopItemInDb {
id: number;
name: string;
price: number;
productID: string;
reward: string;
countMax: number;
discount: number;
imageName: string;
consume: string;
weight: number;
refreshType: number;
levelLimitMin: number;
levelLimitMax: number;
}
// 每个商品的内容
export class RefreshShopItem {
id: number; // 商品id
@@ -23,7 +52,7 @@ export class RefreshShopItem {
buyCount: number = 0; //购买过的次数
constructor(data: any, pageIndex: number) {
constructor(data: RefreshShopItemInDb, pageIndex: number) {
this.pageIndex = pageIndex;
this.id = data.id;
this.reward = data.reward;
@@ -60,13 +89,13 @@ export class RefreshShopPage {
name: string; //名字
viewCount: number; //随机可购买的商品个数
items: Array<RefreshShopItem> = [];//商品列表
constructor(data: any) {
constructor(data: RefreshShopPageInDb) {
this.pageIndex = data.pageIndex;
this.name = data.name;
for (let item of data.items) {
this.items.push(new RefreshShopItem(item, data.pageIndex))
}
this.viewCount = data.viewCount ? data.viewCount : this.items.length;
this.viewCount = data.viewcount ? data.viewcount : this.items.length;
}
}
@@ -164,7 +193,7 @@ export class RefreshShopData extends ActivityBase {
public initData(data: string) {
// this.nextRefreshTime = this.endTime;
let dataObj = JSON.parse(data);
let dataObj: RefreshShopDataInDb = JSON.parse(data);
this.shopType = dataObj.shopType;
this.name = dataObj.name;
let arr = dataObj.data;