商店:rmb购买
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { SHOP_REFRESH_TYPE } from "../../consts";
|
||||
import { ActivityModelType } from "../../db/Activity";
|
||||
import { UserShopType } from "../../db/UserShop";
|
||||
import { UserShopTypeType } from "../../db/UserShopType";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { ActivityBase } from "../activityField/activityField";
|
||||
|
||||
interface ShopInDb {
|
||||
@@ -53,7 +55,13 @@ export class ShopData extends ActivityBase {
|
||||
public findByItemId(itemId: number) {
|
||||
let item = this.list.find(cur => cur.id == itemId);
|
||||
if(!item) return null;
|
||||
return {...item, shop: this.shop, type: this.type};
|
||||
return <ShopDicExtendData>{...item, shop: this.shop, type: this.type};
|
||||
}
|
||||
|
||||
public findByProductID(productID: string) {
|
||||
let item = this.list.find(cur => cur.productID == productID);
|
||||
if(!item) return null;
|
||||
return <ShopDicExtendData>{...item, shop: this.shop, type: this.type};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +102,20 @@ export class ShopDicData {
|
||||
this.beginTime = obj.beginTime;
|
||||
this.endTime = obj.endTime;
|
||||
}
|
||||
|
||||
public setReadRecord(record: UserShopTypeType) {
|
||||
let now = nowSeconds();
|
||||
if(this.beginTime <= now && this.endTime >= now) {
|
||||
let readTime = record?.readTime||0;
|
||||
if(this.createTime > readTime) this.isNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ShopDicExtendData extends ShopDicData {
|
||||
shop: number;
|
||||
type: number;
|
||||
}
|
||||
|
||||
export class ShopReturnData {
|
||||
activityId: number = 0;
|
||||
@@ -112,14 +132,26 @@ export class ShopReturnData {
|
||||
public setDicByActivity(activityData: ShopData) {
|
||||
if(!activityData || activityData.shop != this.shop || activityData.type != this.type) return;
|
||||
this.activityId = activityData.activityId;
|
||||
this.dic.push(...activityData.list)
|
||||
for(let obj of activityData.list) {
|
||||
let newDic = new ShopDicData(obj);
|
||||
this.dic.push(newDic);
|
||||
}
|
||||
}
|
||||
|
||||
public setUserRecords(record: UserShopType) {
|
||||
public addUserRecords(record: UserShopType) {
|
||||
if(!record || record.shop != this.shop || record.type != this.type) return;
|
||||
let dic = this.dic.find(cur => cur.id == record.itemId);
|
||||
console.log('######### addUserRecords', dic?.createTime, record?.createTime)
|
||||
if(!dic || (dic.createTime && dic.createTime != record.createTime)) return;
|
||||
let recordResult = new ShopReturnRecordData(record);
|
||||
if(recordResult && recordResult.shopItemId) this.records.push(recordResult)
|
||||
}
|
||||
|
||||
public setReadRecord(record: UserShopTypeType) {
|
||||
for(let obj of this.dic) {
|
||||
obj.setReadRecord(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ShopReturnRecordData {
|
||||
|
||||
Reference in New Issue
Block a user