From 02f18587bd8860b305e2c688e20465be166bb48c Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 22 七月 2021 15:14:03 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java index 5012bdb..39bd6ea 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java @@ -72,16 +72,22 @@ 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); @@ -110,8 +116,17 @@ } 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); } -- Gitblit v1.7.1