|
@@ -5,7 +5,6 @@ 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.auth.api.client.SysUserFeignService;
|
|
|
-import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.ActivityPlanDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.ActivityPlanEvaluationDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.ActivityPlanDto;
|
|
@@ -14,6 +13,9 @@ import com.yonge.cooleshow.biz.dal.dto.ActivityPlanPayDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.ActivityPlanSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityMusicVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo;
|
|
@@ -24,24 +26,23 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.enums.ActivityTypeEnum;
|
|
|
import com.yonge.cooleshow.common.enums.RegistrationMethodEnum;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
+import com.yonge.toolset.base.util.StringUtil;
|
|
|
+import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
|
|
|
-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 org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
import java.util.Date;
|
|
|
-import java.util.Date;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
|
|
@@ -67,6 +68,9 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
@Autowired
|
|
|
private ActivityEvaluationRecordService activityEvaluationRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
+
|
|
|
@Override
|
|
|
public ActivityPlanVo detail(Long id) {
|
|
|
ActivityPlanVo detail = baseMapper.detail(id);
|
|
@@ -114,7 +118,7 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
activityPlan.setUpdateBy(user.getId());
|
|
|
updateById(activityPlan);
|
|
|
|
|
@@ -128,11 +132,25 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
|
|
|
@Override
|
|
|
public Boolean updateActivityState(Long activityId, Integer activityState, Long id) {
|
|
|
+ ActivityPlanVo detail = detail(activityId);
|
|
|
+
|
|
|
ActivityPlan activityPlan = new ActivityPlan();
|
|
|
+
|
|
|
+ if (activityState == 1) {
|
|
|
+ Date now = new Date();
|
|
|
+ if (detail.getActivityEnd().before(now)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(detail.getActivityStart().after(now)){
|
|
|
+ activityPlan.setActivityStart(now);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
activityPlan.setId(activityId);
|
|
|
activityPlan.setActivityState(activityState);
|
|
|
activityPlan.setUpdateBy(id);
|
|
|
activityPlan.setUpdateTime(new Date());
|
|
|
+
|
|
|
baseMapper.updateById(activityPlan);
|
|
|
return true;
|
|
|
}
|
|
@@ -152,21 +170,19 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public MusicActivityVo getActivityInfo(Long activityPlanId, SysUser user) {
|
|
|
ActivityPlan activityPlan = this.getById(activityPlanId);
|
|
|
|
|
|
MusicActivityVo activityVo = new MusicActivityVo();
|
|
|
- BeanUtils.copyProperties(activityPlan,activityVo);
|
|
|
+ BeanUtils.copyProperties(activityPlan, activityVo);
|
|
|
|
|
|
// 活动曲目
|
|
|
- List<ActivityMusicVo> activityMusicVoList = activityEvaluationService.getActivityMusic(activityPlanId,user.getId());
|
|
|
+ List<ActivityMusicVo> activityMusicVoList = activityEvaluationService.getActivityMusic(activityPlanId, user.getId());
|
|
|
activityVo.setActivityMusicVoList(activityMusicVoList);
|
|
|
|
|
|
// 报名状态
|
|
|
- activityVo.setJoin(activityRegistrationService.getRegistration(user.getId(),activityPlanId));
|
|
|
+ activityVo.setJoin(activityRegistrationService.getRegistration(user.getId(), activityPlanId));
|
|
|
|
|
|
// 活动奖品
|
|
|
List<ActivityReward> activityRewardList = activityRewardService.getActivityReward(activityPlanId);
|
|
@@ -182,12 +198,14 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
@Override
|
|
|
public HttpResponseResult<OrderCreateRes> orderCreate(OrderReq.OrderReqInfo orderReqInfo) {
|
|
|
|
|
|
+ log.info("活动购买 参数 --> {}",orderReqInfo);
|
|
|
+
|
|
|
+ // 检查用户
|
|
|
getSysUser(orderReqInfo.getUserId());
|
|
|
ActivityPlanPayDto activityPlanPayDto = JSON.parseObject(
|
|
|
JSON.toJSONString(orderReqInfo.getBizContent()), ActivityPlanPayDto.class);
|
|
|
|
|
|
- // 检查活动购买
|
|
|
-
|
|
|
+ // 检查活动购买是否已购买
|
|
|
checkActivityPay(activityPlanPayDto.getActivityId());
|
|
|
|
|
|
|
|
@@ -200,7 +218,7 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
if (activityPlanPayDto.getActivityId() == null) {
|
|
|
throw new BizException("活动id不能为空");
|
|
|
}
|
|
|
- ActivityPlan activityPlan = getById(activityPlanPayDto.getActivityId() );
|
|
|
+ ActivityPlan activityPlan = getById(activityPlanPayDto.getActivityId());
|
|
|
|
|
|
orderCreateRes.setRes(true);
|
|
|
orderCreateRes.setGoodType(orderCreateRes.getGoodType());
|
|
@@ -213,9 +231,9 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
|
|
|
private boolean checkoutJoinActivity(Long activityId, Long userId) {
|
|
|
return activityRegistrationService.lambdaQuery()
|
|
|
- .eq(ActivityRegistration::getActivityId, activityId)
|
|
|
- .eq(ActivityRegistration::getUserId, userId)
|
|
|
- .count() >0;
|
|
|
+ .eq(ActivityRegistration::getActivityId, activityId)
|
|
|
+ .eq(ActivityRegistration::getUserId, userId)
|
|
|
+ .count() > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -286,9 +304,25 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参与活动消息
|
|
|
+ */
|
|
|
private void sendMessage(String activityName, Long userId) {
|
|
|
+ try {
|
|
|
+ // 发送消息
|
|
|
+ SysUser user = sysUserFeignService.queryUserById(userId);
|
|
|
+
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(userId, user.getPhone());
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.ACTIVITY_JOIN_MESSAGE, receivers, null,
|
|
|
+ 0, null, ClientEnum.STUDENT.getCode(), user.getUsername(), activityName);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("活动参与发送消息失败--> {}",e.fillInStackTrace());
|
|
|
+ }
|
|
|
|
|
|
- // TODO 发送消息
|
|
|
|
|
|
}
|
|
|
|
|
@@ -301,17 +335,17 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
|
|
|
if (activityPlan.getActivityState() == 0) {
|
|
|
throw new BizException("活动已停止");
|
|
|
}
|
|
|
- if (new Date().compareTo(activityPlan.getActivityStart()) <0) {
|
|
|
- throw new BizException("活动未开始");
|
|
|
+ if (new Date().compareTo(activityPlan.getActivityStart()) < 0) {
|
|
|
+ throw new BizException("活动未开始");
|
|
|
}
|
|
|
- if (new Date().compareTo(activityPlan.getActivityEnd()) >0) {
|
|
|
+ if (new Date().compareTo(activityPlan.getActivityEnd()) > 0) {
|
|
|
throw new BizException("活动已结束");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private SysUser getSysUser(Long userId) {
|
|
|
return Optional.ofNullable(userId)
|
|
|
- .map(sysUserFeignService::queryUserById)
|
|
|
- .orElseThrow(() -> new BizException("用户不存在"));
|
|
|
+ .map(sysUserFeignService::queryUserById)
|
|
|
+ .orElseThrow(() -> new BizException("用户不存在"));
|
|
|
}
|
|
|
}
|