huanghongfa
2021-08-21 2e64c232ab6b51b2cecf1ee96e1e9b709234f326
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java
@@ -68,20 +68,26 @@
    public R addActivity(AddEasyPhotoActivityDTO addEasyPhotoActivityDTO){
        //判断当前活动时间是否与其他时间有冲突
        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(addEasyPhotoActivityDTO.getActivityStartAt(),addEasyPhotoActivityDTO.getActivityEndAt(),null);
        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(addEasyPhotoActivityDTO.getActivityStartAt(),addEasyPhotoActivityDTO.getActivityEndAt(),null,addEasyPhotoActivityDTO.getCommunityId());
        if(count > 0){
            return R.fail("在此期间已有活动,请勿重复添加");
        }
        Date nowDate = new Date();
        ComActEasyPhotoActivityDO photoActivityDO = new ComActEasyPhotoActivityDO();
        BeanUtils.copyProperties(addEasyPhotoActivityDTO,photoActivityDO);
        photoActivityDO.setActivityStartAt(DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityStartAt(),DateUtils.ymdhm_format));
        photoActivityDO.setActivityEndAt(DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityEndAt(),DateUtils.ymdhm_format));
        photoActivityDO.setCreateAt(new Date());
        photoActivityDO.setReleaseAt(new Date());
        if(new Date().getTime() > photoActivityDO.getActivityStartAt().getTime()){
            photoActivityDO.setStatus(2);
        if(photoActivityDO.getActivityEndAt().getTime() <= nowDate.getTime()){
            return R.fail("活动结束时间不可小于当前时间");
        }
        if(nowDate.getTime() >= photoActivityDO.getActivityStartAt().getTime()){
            photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.jxz);
        }else{
            photoActivityDO.setStatus(1);
            photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.dks);
        }
        photoActivityDO.setCount(0);
@@ -104,14 +110,23 @@
            return R.fail("未查询到活动记录");
        }
        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(editEasyPhotoActivityDTO.getActivityStartAt(),editEasyPhotoActivityDTO.getActivityEndAt(),editEasyPhotoActivityDTO.getId());
        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(editEasyPhotoActivityDTO.getActivityStartAt(),editEasyPhotoActivityDTO.getActivityEndAt(),editEasyPhotoActivityDTO.getId(),photoActivityDO.getCommunityId());
        if(count > 0){
            return R.fail("在此期间已有活动,请勿重复添加");
        }
        BeanUtils.copyProperties(editEasyPhotoActivityDTO,photoActivityDO);
        photoActivityDO.setActivityStartAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityStartAt(),DateUtils.ymdhms_format));
        photoActivityDO.setActivityEndAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityEndAt(),DateUtils.ymdhms_format));
        photoActivityDO.setActivityStartAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityStartAt(),DateUtils.ymdhm_format));
        photoActivityDO.setActivityEndAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityEndAt(),DateUtils.ymdhm_format));
        if(new Date().getTime() > photoActivityDO.getActivityStartAt().getTime()){
            photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.jxz);
        }else{
            photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.dks);
        }
        if(new Date().getTime() > photoActivityDO.getActivityEndAt().getTime()){
            photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.yjs);
        }
        if(this.baseMapper.updateById(photoActivityDO) > 0){
            return R.ok();
        }
@@ -159,7 +174,7 @@
        if(!photoActivityDOS.isEmpty()){
            Date nowDate = new Date();
            photoActivityDOS.forEach(photoActivity -> {
                if(photoActivity.getActivityStartAt().getTime() >= nowDate.getTime()){
                if(photoActivity.getActivityStartAt().getTime() <= nowDate.getTime()){
                    photoActivity.setStatus(ComActEasyPhotoActivityDO.status.jxz);
                    this.baseMapper.updateById(photoActivity);
                }