|  | @@ -2,14 +2,13 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dao.ActivityPlanEvaluationDao;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dto.ActivityPlanDto;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.ActivityPlanEvaluation;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.vo.ActivityPlanEvaluationVo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.enums.ActivityTypeEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.enums.RegistrationMethodEnum;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.base.exception.BizException;
 | 
	
		
			
				|  |  | -import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
	
		
			
				|  | @@ -18,10 +17,11 @@ import com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dto.search.ActivityPlanSearch;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dao.ActivityPlanDao;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | -import javax.validation.Valid;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
	
		
			
				|  | @@ -42,16 +42,61 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public Boolean save(ActivityPlanDto activityPlan) {
 | 
	
		
			
				|  |  | +    public IPage<ActivityPlanVo> selectPage(IPage<ActivityPlanVo> page, ActivityPlanSearch query) {
 | 
	
		
			
				|  |  | +        return page.setRecords(baseMapper.selectPage(page, query));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Boolean submit(ActivityPlanDto activityPlan, SysUser user) {
 | 
	
		
			
				|  |  |          //验证参数
 | 
	
		
			
				|  |  | -        if (validParam(activityPlan)) {
 | 
	
		
			
				|  |  | +        if (!validParam(activityPlan)) {
 | 
	
		
			
				|  |  |              return false;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        activityPlan.setDraftFlag(1);
 | 
	
		
			
				|  |  | -        save(activityPlan);
 | 
	
		
			
				|  |  | -        ActivityPlanEvaluation planEvaluation = activityPlan.getPlanEvaluation();
 | 
	
		
			
				|  |  | -        planEvaluation.setId(activityPlan.getId());
 | 
	
		
			
				|  |  | -        activityPlanEvaluationDao.insert(planEvaluation);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (null == activityPlan.getId()) {
 | 
	
		
			
				|  |  | +            activityPlan.setDraftFlag(1);
 | 
	
		
			
				|  |  | +            activityPlan.setCreateBy(user.getId());
 | 
	
		
			
				|  |  | +            activityPlan.setUpdateBy(user.getId());
 | 
	
		
			
				|  |  | +            save(activityPlan);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            ActivityPlanEvaluation planEvaluation = activityPlan.getPlanEvaluation();
 | 
	
		
			
				|  |  | +            planEvaluation.setId(activityPlan.getId());
 | 
	
		
			
				|  |  | +            planEvaluation.setCreateBy(user.getId());
 | 
	
		
			
				|  |  | +            planEvaluation.setUpdateBy(user.getId());
 | 
	
		
			
				|  |  | +            activityPlanEvaluationDao.insert(planEvaluation);
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            ActivityPlan old = getById(activityPlan.getId());
 | 
	
		
			
				|  |  | +            //启用状态,只能修改活动结束时间
 | 
	
		
			
				|  |  | +            if (old.getActivityState().equals(1)) {
 | 
	
		
			
				|  |  | +                if (activityPlan.getActivityEnd().after(new Date())) {
 | 
	
		
			
				|  |  | +                    old.setActivityEnd(activityPlan.getActivityEnd());
 | 
	
		
			
				|  |  | +                    old.setUpdateBy(user.getId());
 | 
	
		
			
				|  |  | +                    updateById(activityPlan);
 | 
	
		
			
				|  |  | +                    return true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                activityPlan.setUpdateBy(user.getId());
 | 
	
		
			
				|  |  | +                updateById(activityPlan);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ActivityPlanEvaluation planEvaluation = activityPlan.getPlanEvaluation();
 | 
	
		
			
				|  |  | +                planEvaluation.setUpdateBy(user.getId());
 | 
	
		
			
				|  |  | +                activityPlanEvaluationDao.updateById(planEvaluation);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public Boolean updateActivityState(Long activityId, Integer activityState, Long id) {
 | 
	
		
			
				|  |  | +        ActivityPlan activityPlan = new ActivityPlan();
 | 
	
		
			
				|  |  | +        activityPlan.setId(activityId);
 | 
	
		
			
				|  |  | +        activityPlan.setActivityState(activityState);
 | 
	
		
			
				|  |  | +        activityPlan.setUpdateBy(id);
 | 
	
		
			
				|  |  | +        activityPlan.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +        baseMapper.updateById(activityPlan);
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -59,22 +104,16 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
 | 
	
		
			
				|  |  |          if (null == activityPlan) {
 | 
	
		
			
				|  |  |              return false;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (RegistrationMethodEnum.CHARGE.equals(activityPlan.getRegistrationMethod())
 | 
	
		
			
				|  |  | -                &&(null == activityPlan.getRegistrationPrice() || BigDecimal.ZERO.compareTo(activityPlan.getRegistrationPrice()) > 0)
 | 
	
		
			
				|  |  | -        ) {
 | 
	
		
			
				|  |  | +        if (RegistrationMethodEnum.CHARGE.equals(activityPlan.getRegistrationMethod()) && (null == activityPlan.getRegistrationPrice() || BigDecimal.ZERO.compareTo(activityPlan.getRegistrationPrice()) > 0)) {
 | 
	
		
			
				|  |  |              throw new BizException("活动收费时,报名金额不能为空");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (ActivityTypeEnum.EVALUATION.equals(activityPlan.getActivityType())
 | 
	
		
			
				|  |  | -                && (null == activityPlan.getPlanEvaluation() || null == activityPlan.getPlanEvaluation().getEvaluationDifficulty())) {
 | 
	
		
			
				|  |  | +        if (ActivityTypeEnum.EVALUATION.equals(activityPlan.getActivityType()) && (null == activityPlan.getPlanEvaluation() || null == activityPlan.getPlanEvaluation().getEvaluationDifficulty())) {
 | 
	
		
			
				|  |  |              throw new BizException("活动类型为评测活动时,评测难度不能为空");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -    public IPage<ActivityPlanVo> selectPage(IPage<ActivityPlanVo> page, ActivityPlanSearch query) {
 | 
	
		
			
				|  |  | -        return page.setRecords(baseMapper.selectPage(page, query));
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |