miduo_server/tablemanager/src/main/java/config/SGlobalActivity.java

189 lines
4.7 KiB
Java
Raw Normal View History

package config;
import manager.STableManager;
import manager.Table;
import util.TimeUtils;
2020-09-25 11:44:36 +08:00
import java.util.*;
@Table(name ="GlobalActivity")
public class SGlobalActivity implements BaseConfig {
private int id;
private int type;
private String startTime;
private String endtime;
private int time;
private long startTimeLong;
private long endTimeLong;
private static Map<Integer, SGlobalActivity> sGlobalActivityMap;
private String sesc;
private int isSaving;
private int isMail;
2019-10-15 10:22:08 +08:00
private int[] ifOpen;
2020-04-22 11:28:35 +08:00
private int[] shopId;
private int resetGrade;
2019-10-30 14:18:22 +08:00
private int openRanking;
2019-11-24 19:42:22 +08:00
private int[] openRules;
2019-11-25 11:42:07 +08:00
private int[] foreshow;
2019-12-13 17:19:26 +08:00
private int gapTime;
2020-09-25 11:44:36 +08:00
private int[] canBuyRechargeId;
2020-05-12 16:02:37 +08:00
2020-09-15 14:43:13 +08:00
private int isOpen;
2019-11-27 15:43:24 +08:00
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType;
2020-05-12 16:02:37 +08:00
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules;
2019-11-27 15:43:24 +08:00
public static Map<Integer, Integer> sRechargeId2ActivityId;
@Override
public void init() throws Exception {
2020-05-12 16:02:37 +08:00
Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByTypeTmp = new HashMap<>();
Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRulesTmp = new HashMap<>();
Map<Integer,Integer> sRechargeId2ActivityIdTemp = new HashMap<>();
Map<Integer, SGlobalActivity> config = STableManager.getConfig(SGlobalActivity.class);
for(SGlobalActivity sGlobalActivity : config.values()){
2020-09-25 11:44:36 +08:00
if(sGlobalActivity.getCanBuyRechargeId()!=null&&sGlobalActivity.getCanBuyRechargeId().length!=0){
Arrays.stream(sGlobalActivity.getCanBuyRechargeId()).forEach(n->sRechargeId2ActivityIdTemp.put(n,sGlobalActivity.getId()));
}
2020-05-12 16:02:37 +08:00
sGlobalActivityMapByTypeTmp.computeIfAbsent(sGlobalActivity.getType(),n->new ArrayList<>()).add(sGlobalActivity);
if(sGlobalActivity.getOpenRules().length>0){
sGlobalActivityMapByOpenRulesTmp.computeIfAbsent(sGlobalActivity.getOpenRules()[0],n->new ArrayList<>()).add(sGlobalActivity);
}
int time = sGlobalActivity.getTime();
String startTime = sGlobalActivity.getStartTime();
String endtime = sGlobalActivity.getEndtime();
if(time == 1 ){//ActivityType.OPEN_TYPE_TIME
if(!"0".equals(startTime)){
sGlobalActivity.setStartTimeLong(TimeUtils.parseTimeToMiles(startTime,TimeUtils.Stand_CeHua_Data_format));
}
if(!"0".equals(endtime)){
sGlobalActivity.setEndTimeLong(TimeUtils.parseTimeToMiles(endtime,TimeUtils.Stand_CeHua_Data_format));
}
continue;
}
sGlobalActivity.setStartTimeLong(Long.parseLong(startTime));
sGlobalActivity.setEndTimeLong(Long.parseLong(endtime));
2019-10-30 14:18:22 +08:00
}
sGlobalActivityMap = config;
2020-05-12 16:02:37 +08:00
sGlobalActivityMapByType = sGlobalActivityMapByTypeTmp;
sGlobalActivityMapByOpenRules = sGlobalActivityMapByOpenRulesTmp;
sRechargeId2ActivityId = sRechargeId2ActivityIdTemp;
}
public static Map<Integer, SGlobalActivity> getsGlobalActivityMap() {
return sGlobalActivityMap;
}
public int getId() {
return id;
}
public int getType() {
return type;
}
public String getStartTime() {
return startTime;
}
public String getEndtime() {
return endtime;
}
public int getTime() {
return time;
}
2021-04-06 16:49:40 +08:00
public static List<SGlobalActivity> getsGlobalActivityMapByType(int type) {
return sGlobalActivityMapByType.get(type);
}
public void setStartTimeLong(long startTimeLong) {
this.startTimeLong = startTimeLong;
}
public void setEndTimeLong(long endTimeLong) {
this.endTimeLong = endTimeLong;
}
public long getStartTimeLong() {
return startTimeLong;
}
public long getEndTimeLong() {
return endTimeLong;
}
public String getSesc() { return sesc; }
public int getIsSaving() {
return isSaving;
}
public int getIsMail() {
return isMail;
}
2019-10-15 10:22:08 +08:00
public int[] getIfOpen() {
return ifOpen;
}
2020-04-22 11:28:35 +08:00
public int[] getShopId() {
return shopId;
}
public int getResetGrade() {
return resetGrade;
}
2019-10-30 15:25:21 +08:00
public int getOpenRanking() {
return openRanking;
}
2019-11-24 19:42:22 +08:00
public int[] getOpenRules() {
return openRules;
}
2019-11-25 11:42:07 +08:00
public int[] getForeshow() {
return foreshow;
}
2019-12-13 17:19:26 +08:00
public int getGapTime() {
return gapTime;
}
public void setType(int type) {
this.type = type;
}
2020-05-12 16:02:37 +08:00
2020-09-25 11:44:36 +08:00
public int[] getCanBuyRechargeId() {
2020-05-12 16:02:37 +08:00
return canBuyRechargeId;
}
2020-09-15 14:43:13 +08:00
public int getIsOpen() {
return isOpen;
}
}