|
|
package com.yohobuy.platform.operations.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yohobuy.platform.common.convert.BeanConvert;
|
|
|
import com.yohobuy.platform.common.convert.Convert;
|
|
|
import com.yohobuy.platform.common.error.ErrorCode;
|
...
|
...
|
@@ -10,24 +11,31 @@ 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.model.cms.bo.WebShareBO;
|
|
|
import com.yohobuy.platform.model.common.CheckResult;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
import com.yohobuy.platform.model.operations.ActivtyTemplatedBo;
|
|
|
import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorBo;
|
|
|
import com.yohobuy.platform.model.operations.*;
|
|
|
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.ActivityTemplatedPageBo;
|
|
|
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
|
|
|
import com.yohobuy.platform.common.helper.mvc.LogInUserHelper;
|
|
|
import com.yohobuy.platform.operations.constants.CommonStatus;
|
|
|
import com.yohobuy.platform.operations.constants.LayoutStatus;
|
|
|
import com.yohobuy.platform.operations.convert.ActivtyTemplatedConvert;
|
|
|
import com.yohobuy.platform.operations.convert.ActivtyTemplatedFloorConvert;
|
|
|
import com.yohobuy.platform.operations.helper.ActTempFloorHelper;
|
|
|
import com.yohobuy.platform.operations.helper.ActivityTemplatedFloorDetailHelper;
|
|
|
import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService;
|
|
|
import com.yohobuy.platform.operations.service.check.WebShareCheckService;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
...
|
...
|
@@ -70,6 +78,12 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
@Autowired
|
|
|
private ActivtyTemplatedFloorMapper atfMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ActivtyTemplatedFloorTableMapper atftMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ActivtyTemplatedFloorDetailMapper atfdMapper;
|
|
|
|
|
|
private static Convert convert = new BeanConvert();
|
|
|
|
|
|
@Value("${activity.url:http://activity.yoho.cn/feature/}")
|
...
|
...
|
@@ -231,13 +245,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
if(!otherInfoCR.isValidateResult()){
|
|
|
throw new PlatformException(otherInfoCR.getErrorMsg().getErrorMsg(), ErrorCode.req_param_illegal);
|
|
|
}
|
|
|
int result = doUpdate(bo);
|
|
|
upateActivityTemplate(bo);
|
|
|
// int result = doUpdate(bo);
|
|
|
//
|
|
|
// if (result > 0) {
|
|
|
// logService.recordLog(bo.getId(), LogActionType.update, JSON.toJSONString(bo));
|
|
|
// }
|
|
|
return 1;
|
|
|
|
|
|
if (result > 0) {
|
|
|
logService.recordLog(bo.getId(), LogActionType.update, JSON.toJSONString(bo));
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -380,6 +395,123 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> |
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void upateActivityTemplate(ActivtyTemplatedBo bo) throws PlatformException{
|
|
|
if (!isExists(bo.getId())){
|
|
|
logger.error("{}.doUpdate ,can not query record,bo.id {}",getClass().getSimpleName(),bo.getId());
|
|
|
return;
|
|
|
}
|
|
|
//1.修改活动主表activty_templated的相关值
|
|
|
ActivtyTemplated activtyTemplated= ActivtyTemplatedConvert.bo2Do(bo);
|
|
|
activtyTemplated.setIsDel(0);
|
|
|
activtyTemplated.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
|
|
activtyTemplated.setUpdateUser(this.buildOperatorInfo());
|
|
|
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());
|
|
|
|
|
|
//3.依次将相关数据插入以上相关表中
|
|
|
List<ActivtyTemplatedFloor> atfList = Lists.newArrayList();
|
|
|
List<ActivtyTemplatedFloorTable> atftList = Lists.newArrayList();
|
|
|
for(ActivtyTemplatedFloorBo floorBo: bo.getFloors()){
|
|
|
//处理activty_templated_floor表数据
|
|
|
ActivtyTemplatedFloor atf = ActivtyTemplatedFloorConvert.bo2Do(floorBo);
|
|
|
atf.setActivtyTemplatedId(bo.getId());
|
|
|
//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.setFloorId(atf.getId());
|
|
|
table.setTableComp(floorBo.getTableComp());
|
|
|
atftList.add(table);
|
|
|
}
|
|
|
//处理activty_templated_floor_detail表数据并入库
|
|
|
floorBo.setId(atf.getId());
|
|
|
List<ActivtyTemplatedFloorDetail> atfdp = Lists.newArrayList();
|
|
|
if (CollectionUtils.isNotEmpty(floorBo.getParams())) {
|
|
|
atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getId(), 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());
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(atfdc)){
|
|
|
atfdService.insertDetailBatch(atfdc);
|
|
|
}
|
|
|
}
|
|
|
//activty_templated_floor_table表数据批量入库
|
|
|
if (CollectionUtils.isNotEmpty(atftList)){
|
|
|
atftMapper.insertBatch(atftList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新加方法 不需要递归组件 忽略组件中套组件
|
|
|
* @param atId
|
|
|
* @param floorId
|
|
|
* @param components
|
|
|
* @return
|
|
|
* @throws PlatformException
|
|
|
*/
|
|
|
public List<ActivtyTemplatedFloorDetailBo> buildDetailBo(int atId,int floorId, List<TemplatedComponentBo> components) throws PlatformException {
|
|
|
List<ActivtyTemplatedFloorDetailBo> result = Lists.newArrayList();
|
|
|
|
|
|
for(TemplatedComponentBo componentBo: components){
|
|
|
result.addAll(buidDetailBoFromComponent(atId, floorId, componentBo));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新加方法 不需要递归组件 忽略组件中套组件
|
|
|
* @param atId
|
|
|
* @param floorId
|
|
|
* @param componentBo
|
|
|
* @return
|
|
|
*/
|
|
|
public List<ActivtyTemplatedFloorDetailBo> buidDetailBoFromComponent(int atId, int floorId, TemplatedComponentBo componentBo){
|
|
|
List<ActivtyTemplatedFloorDetailBo> result = Lists.newArrayList();
|
|
|
List<TemplatedComponentParamBo> params = componentBo.getParams();
|
|
|
if(CollectionUtils.isNotEmpty(params)) {
|
|
|
for (TemplatedComponentParamBo paramBo : params) {
|
|
|
ActivtyTemplatedFloorDetailBo floorDetailBo = new ActivtyTemplatedFloorDetailBo();
|
|
|
ActivityTemplatedFloorDetailHelper.MergeWithComponentParam(floorDetailBo,paramBo);
|
|
|
ActivityTemplatedFloorDetailHelper.MergeWithComp(floorDetailBo,atId,floorId,0,componentBo);
|
|
|
if(ActivityTemplatedFloorDetailHelper.paramTypeIntSet.contains(paramBo.getType())){
|
|
|
result.add(floorDetailBo);
|
|
|
}else if (TempCompParamType.component.getIntVal() == paramBo.getType()){
|
|
|
ActivtyTemplatedFloorDetail param = convert.convertFrom(floorDetailBo,new ActivtyTemplatedFloorDetail(),ActivtyTemplatedFloorDetail.class);
|
|
|
ActivityTemplatedFloorDetailHelper.fillStautsOfSingle(FloorDetailStatus.open,param);
|
|
|
atfdMapper.insertSelective(param);
|
|
|
List<TemplatedComponentBo> components = componentBo.getComponents();
|
|
|
for (TemplatedComponentBo tcp : components){
|
|
|
List<ActivtyTemplatedFloorDetailBo> childAtfd = Lists.newArrayList();
|
|
|
List<TemplatedComponentParamBo> tcpb = tcp.getParams();
|
|
|
if (CollectionUtils.isNotEmpty(tcpb)){
|
|
|
for (TemplatedComponentParamBo tp : tcpb){
|
|
|
ActivtyTemplatedFloorDetailBo fdb = new ActivtyTemplatedFloorDetailBo();
|
|
|
ActivityTemplatedFloorDetailHelper.MergeWithComponentParam(fdb,tp);
|
|
|
ActivityTemplatedFloorDetailHelper.MergeWithComp(fdb,atId,floorId,0,tcp);
|
|
|
fdb.setPid(param.getId());
|
|
|
childAtfd.add(fdb);
|
|
|
}
|
|
|
}
|
|
|
atfdService.insertDetailBatch(childAtfd);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private int doUpdate(ActivtyTemplatedBo bo) throws PlatformException {
|
|
|
|
|
|
//activity templated main body, update one
|
...
|
...
|
|