...
|
...
|
@@ -11,14 +11,8 @@ import com.yohobuy.platform.common.util.DateUtil; |
|
|
import com.yohobuy.platform.common.util.IntegerUtils;
|
|
|
import com.yohobuy.platform.dal.cms.IWebShareDao;
|
|
|
import com.yohobuy.platform.dal.cms.model.WebShare;
|
|
|
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorDetailMapper;
|
|
|
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper;
|
|
|
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorTableMapper;
|
|
|
import com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper;
|
|
|
import com.yohobuy.platform.dal.operations.model.ActivtyTemplated;
|
|
|
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloor;
|
|
|
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorDetail;
|
|
|
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorTable;
|
|
|
import com.yohobuy.platform.dal.operations.*;
|
|
|
import com.yohobuy.platform.dal.operations.model.*;
|
|
|
import com.yohobuy.platform.model.cms.bo.WebShareBO;
|
|
|
import com.yohobuy.platform.model.common.CheckResult;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
...
|
...
|
@@ -27,6 +21,7 @@ import com.yohobuy.platform.model.operations.consistant.ActivtyTemplatedStatus; |
|
|
import com.yohobuy.platform.model.operations.consistant.FloorDetailStatus;
|
|
|
import com.yohobuy.platform.model.operations.consistant.LogActionType;
|
|
|
import com.yohobuy.platform.model.operations.consistant.TempCompParamType;
|
|
|
import com.yohobuy.platform.model.operations.request.ActivityTemplateLinkBo;
|
|
|
import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo;
|
|
|
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
|
|
|
import com.yohobuy.platform.operations.constants.CommonStatus;
|
...
|
...
|
@@ -84,6 +79,9 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
@Autowired
|
|
|
private ActivtyTemplatedFloorDetailMapper atfdMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ActivtyTemplateLinkMapper activityTemplateLinkMapper;
|
|
|
|
|
|
private static Convert convert = new BeanConvert();
|
|
|
|
|
|
@Value("${activity.url:http://activity.yoho.cn/feature/}")
|
...
|
...
|
@@ -337,12 +335,43 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
return null;
|
|
|
}
|
|
|
logger.info("in getById, ActivtyTemplated id {}, title {}, status {}", id, templated.getTitle(), templated.getStatus());
|
|
|
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(templated.getId());
|
|
|
List<ActivtyTemplateLink> atlList = activityTemplateLinkMapper.selectActivityTemplateLinkList(id);
|
|
|
if (CollectionUtils.isEmpty(atlList)){
|
|
|
return null;
|
|
|
}
|
|
|
ActivtyTemplateLink activtyTemplateLink = getCurrentTemplateId(atlList);
|
|
|
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(activtyTemplateLink.getTemplateId());
|
|
|
ActivtyTemplatedBo templatedBo = ActivtyTemplatedConvert.do2Bo(templated);
|
|
|
templatedBo.setFloors(floorBos);
|
|
|
List<ActivityTemplateLinkBo> linkList = convert.convertFromList(atlList,ActivityTemplateLinkBo.class);
|
|
|
ActivityTemplateLinkBo atlBo = new ActivityTemplateLinkBo();
|
|
|
convert.convertFrom(activtyTemplateLink, atlBo, ActivityTemplateLinkBo.class);
|
|
|
atlBo.setShowTimeStr(DateUtil.int2DateStr(atlBo.getShowTime(),DateUtil.DATE_TIME_FORMAT));
|
|
|
templatedBo.setLinkList(linkList);
|
|
|
templatedBo.setAtLink(atlBo);
|
|
|
return templatedBo;
|
|
|
}
|
|
|
|
|
|
public ActivtyTemplateLink getCurrentTemplateId(List<ActivtyTemplateLink> atlList){
|
|
|
Integer currentTime = DateUtil.getCurrentTimeSeconds();
|
|
|
ActivtyTemplateLink atl = null;
|
|
|
for (ActivtyTemplateLink activtyTemplateLink : atlList){
|
|
|
if (null != activtyTemplateLink.getShowTime() && activtyTemplateLink.getShowTime() < currentTime){
|
|
|
atl = activtyTemplateLink;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (atl == null){
|
|
|
for (ActivtyTemplateLink activtyTemplateLink : atlList){
|
|
|
if (null != activtyTemplateLink.getIsDefault() && activtyTemplateLink.getIsDefault() == 1){
|
|
|
atl = activtyTemplateLink;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return atl;
|
|
|
}
|
|
|
|
|
|
|
|
|
public ActivtyTemplatedBo getBaseInfoById(Integer id) {
|
|
|
if (!IntegerUtils.withInBizSign(id)){
|
...
|
...
|
@@ -471,9 +500,9 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
activtyTemplated.setUpdateUser(this.buildOperatorInfo(bo.getUserInfoResponseBO()));
|
|
|
activtyTemplatedMapper.updateByPrimaryKeySelective(activtyTemplated);
|
|
|
//2.根据模板ID依次删除除主表外其他表的相关数据,activty_templated_floor,activty_templated_floor_detail,activty_templated_floor_table
|
|
|
atfMapper.deleteByTempId(bo.getId());
|
|
|
atftMapper.deleteByTempId(bo.getId());
|
|
|
atfdMapper.deleteByTempId(bo.getId());
|
|
|
atfMapper.deleteByTempId(bo.getTemplateId());
|
|
|
atftMapper.deleteByTempId(bo.getTemplateId());
|
|
|
atfdMapper.deleteByTempId(bo.getTemplateId());
|
|
|
|
|
|
//3.依次将相关数据插入以上相关表中
|
|
|
List<ActivtyTemplatedFloor> atfList = Lists.newArrayList();
|
...
|
...
|
@@ -481,14 +510,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
for(ActivtyTemplatedFloorBo floorBo: bo.getFloors()){
|
|
|
//处理activty_templated_floor表数据
|
|
|
ActivtyTemplatedFloor atf = ActivtyTemplatedFloorConvert.bo2Do(floorBo);
|
|
|
atf.setActivtyTemplatedId(bo.getId());
|
|
|
atf.setActivtyTemplatedId(bo.getTemplateId());
|
|
|
//activty_templated_floor表数据入库
|
|
|
atfMapper.insertSelective(atf);
|
|
|
//处理activty_templated_floor_table表数据
|
|
|
if (StringUtils.isNotBlank(floorBo.getTableComp())){
|
|
|
ActivtyTemplatedFloorTable table = new ActivtyTemplatedFloorTable();
|
|
|
table.setStatus(1);
|
|
|
table.setActivtyTemplatedId(bo.getId());
|
|
|
table.setActivtyTemplatedId(bo.getTemplateId());
|
|
|
table.setFloorId(atf.getId());
|
|
|
table.setTableComp(floorBo.getTableComp());
|
|
|
atftList.add(table);
|
...
|
...
|
@@ -497,14 +526,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
floorBo.setId(atf.getId());
|
|
|
List<ActivtyTemplatedFloorDetail> atfdp = Lists.newArrayList();
|
|
|
if (CollectionUtils.isNotEmpty(floorBo.getParams())) {
|
|
|
atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getId(), FloorDetailStatus.open.getIntVal(), floorBo);
|
|
|
atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getTemplateId(), FloorDetailStatus.open.getIntVal(), floorBo);
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(atfdp)){
|
|
|
atfdMapper.insertBatch(atfdp);
|
|
|
}
|
|
|
List<ActivtyTemplatedFloorDetailBo> atfdc = Lists.newArrayList();
|
|
|
if (CollectionUtils.isNotEmpty(floorBo.getComponents())){
|
|
|
atfdc = buildDetailBo(bo.getId(), floorBo.getId(), floorBo.getComponents());
|
|
|
atfdc = buildDetailBo(bo.getTemplateId(), floorBo.getId(), floorBo.getComponents());
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(atfdc)){
|
|
|
atfdService.insertDetailBatch(atfdc);
|
...
|
...
|
@@ -687,14 +716,36 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
row += activtyTemplatedMapper.insertSelective(templated);
|
|
|
// clone activity templated id(new)
|
|
|
int cloneATId = templated.getId();
|
|
|
//
|
|
|
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(id);
|
|
|
//根据原活动ID查询其默认模板
|
|
|
List<ActivtyTemplateLink> activtyTemplateLinkList = activityTemplateLinkMapper.selectActivityTemplateLinkList(id);
|
|
|
if (CollectionUtils.isEmpty(activtyTemplateLinkList)){
|
|
|
return 0;
|
|
|
}
|
|
|
Integer templateId = 0;
|
|
|
for (ActivtyTemplateLink activtyTemplateLink : activtyTemplateLinkList){
|
|
|
if (activtyTemplateLink.getIsDefault() == 1){
|
|
|
templateId = activtyTemplateLink.getTemplateId();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (templateId == 0){
|
|
|
return 0;
|
|
|
}
|
|
|
//生成颗粒活动的默认复制模板
|
|
|
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
|
|
|
activtyTemplateLink.setActivityId(cloneATId);
|
|
|
activtyTemplateLink.setIsDefault(1);
|
|
|
activtyTemplateLink.setTemplateName("默认模板");
|
|
|
activtyTemplateLink.setCreateTime(DateUtil.getCurrentTimeSeconds());
|
|
|
activtyTemplateLink.setShowTime(DateUtil.getCurrentTimeSeconds());
|
|
|
activityTemplateLinkMapper.insertActivityTemplateLink(activtyTemplateLink);
|
|
|
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(templateId);
|
|
|
if (CollectionUtils.isEmpty(floors)){
|
|
|
logger.warn("{}.deepClone floors of id {} is empty", getClass().getSimpleName(),id);
|
|
|
return row;
|
|
|
}
|
|
|
logger.warn("{}.deepClone floors of id {} size {}", getClass().getSimpleName(), id, floors.size());
|
|
|
row += atfService.cloneFloors(id, cloneATId, floors);
|
|
|
row += atfService.cloneFloors(templateId, activtyTemplateLink.getTemplateId(), floors);
|
|
|
//add log
|
|
|
if (row > 0) {
|
|
|
logService.recordLog(id, LogActionType.clone, null, vo.getUserInfoResponseBO());
|
...
|
...
|
@@ -833,4 +884,89 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加活动与模板的关联关系
|
|
|
*
|
|
|
* @param req
|
|
|
*/
|
|
|
public Integer addActivityTemplateLink(ActivityTemplateLinkBo req) {
|
|
|
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
|
|
|
convert.convertFrom(req, activtyTemplateLink, ActivtyTemplateLink.class);
|
|
|
activtyTemplateLink.setShowTime(DateUtil.getTimeSeconds(req.getShowTimeStr()));
|
|
|
ActivtyTemplateLink activtyTemplateLinkDefault = activityTemplateLinkMapper.selectDefaultTemplateById(req.getActivityId());
|
|
|
if (activtyTemplateLinkDefault != null){
|
|
|
activtyTemplateLink.setIsDefault(2);
|
|
|
}else {
|
|
|
activtyTemplateLink.setTemplateName("默认模板");
|
|
|
activtyTemplateLink.setIsDefault(1);
|
|
|
}
|
|
|
activtyTemplateLink.setCreateTime(DateUtil.getCurrentTimeSeconds());
|
|
|
activityTemplateLinkMapper.insertActivityTemplateLink(activtyTemplateLink);
|
|
|
if (req.getCopy()){
|
|
|
req.setTemplateId(activtyTemplateLink.getTemplateId());
|
|
|
copyDefaultTemplate(req);
|
|
|
}
|
|
|
return activtyTemplateLink.getTemplateId();
|
|
|
}
|
|
|
|
|
|
public void copyDefaultTemplate(ActivityTemplateLinkBo req){
|
|
|
//查询出默认模板,对默认模板进行复制
|
|
|
ActivtyTemplateLink activtyTemplateLinkDefault = activityTemplateLinkMapper.selectDefaultTemplateById(req.getActivityId());
|
|
|
if (activtyTemplateLinkDefault != null){
|
|
|
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(activtyTemplateLinkDefault.getTemplateId());
|
|
|
atfService.cloneFloors(activtyTemplateLinkDefault.getTemplateId(),req.getTemplateId(),floors);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public ActivtyTemplatedBo getTemplateInfoByTemplateId(Integer templateId) {
|
|
|
if (!IntegerUtils.withInBizSign(templateId)){
|
|
|
logger.warn("{}.getTemplateInfoByTemplateId param id {}", getClass().getSimpleName(), templateId);
|
|
|
return null;
|
|
|
}
|
|
|
ActivtyTemplateLink activtyTemplateLink = activityTemplateLinkMapper.selectTemplateInfoByTemplateId(templateId);
|
|
|
if (null == activtyTemplateLink){
|
|
|
logger.warn("ActivtyTemplatedService :: getTemplateInfoByTemplateId get no data!");
|
|
|
return null;
|
|
|
}
|
|
|
List<ActivtyTemplateLink> atlList = activityTemplateLinkMapper.selectActivityTemplateLinkList(activtyTemplateLink.getActivityId());
|
|
|
if (CollectionUtils.isEmpty(atlList)){
|
|
|
return null;
|
|
|
}
|
|
|
ActivtyTemplated templated = activtyTemplatedMapper.selectByPrimaryKey(activtyTemplateLink.getActivityId());
|
|
|
if (templated==null){
|
|
|
logger.warn("{}.getTemplateInfoByTemplateId param id {}, ActivtyTemplated not exist in db", getClass().getSimpleName(), activtyTemplateLink.getActivityId());
|
|
|
return null;
|
|
|
}
|
|
|
logger.info("in getTemplateInfoByTemplateId, ActivtyTemplated id {}, title {}, status {}", activtyTemplateLink.getActivityId(), templated.getTitle(), templated.getStatus());
|
|
|
|
|
|
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(activtyTemplateLink.getTemplateId());
|
|
|
ActivtyTemplatedBo templatedBo = ActivtyTemplatedConvert.do2Bo(templated);
|
|
|
templatedBo.setFloors(floorBos);
|
|
|
List<ActivityTemplateLinkBo> linkList = convert.convertFromList(atlList,ActivityTemplateLinkBo.class);
|
|
|
ActivityTemplateLinkBo atlBo = new ActivityTemplateLinkBo();
|
|
|
convert.convertFrom(activtyTemplateLink, atlBo, ActivityTemplateLinkBo.class);
|
|
|
atlBo.setShowTimeStr(DateUtil.int2DateStr(atlBo.getShowTime(),DateUtil.DATE_TIME_FORMAT));
|
|
|
templatedBo.setLinkList(linkList);
|
|
|
templatedBo.setAtLink(atlBo);
|
|
|
return templatedBo;
|
|
|
}
|
|
|
|
|
|
public void upateActivityTemplateLink(ActivityTemplateLinkBo req) {
|
|
|
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
|
|
|
convert.convertFrom(req, activtyTemplateLink, ActivtyTemplateLink.class);
|
|
|
activtyTemplateLink.setShowTime(DateUtil.getTimeSeconds(req.getShowTimeStr()));
|
|
|
activityTemplateLinkMapper.upateActivityTemplateLink(activtyTemplateLink);
|
|
|
if (req.getCopy()){
|
|
|
copyDefaultTemplate(req);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteActivityTemplate(Integer templateId) {
|
|
|
//删除link表
|
|
|
activityTemplateLinkMapper.deleteByTempId(templateId);
|
|
|
//删除其他相关数据
|
|
|
atfMapper.deleteByTempId(templateId);
|
|
|
atftMapper.deleteByTempId(templateId);
|
|
|
atfdMapper.deleteByTempId(templateId);
|
|
|
}
|
|
|
} |
...
|
...
|
|