| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | |
| | | |
| | | import com.panzhihua.common.model.dtos.community.integral.admin.AddComActIntegralUserDTO; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.entity.ComActActivityCode; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComActActivityCodeService; |
| | | import com.panzhihua.service_community.service.ComActIntegralUserTradeService; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private ComBpActivityDAO comBpActivityDAO; |
| | | @Resource |
| | | private ComActIntegralUserTradeService comActIntegralUserTradeService; |
| | | @Resource |
| | | private ComActActivityCodeService comActActivityCodeService; |
| | | |
| | | /** |
| | | * 新增社区活动 |
| | |
| | | comActActPictureDO.setUploadPicture(comActActivityVO.getCover()); |
| | | comActActPictureDO.setSysFlag(0); |
| | | comActActPictureDAO.insert(comActActPictureDO); |
| | | |
| | | ComActActivityCode comActActivityCode = new ComActActivityCode(); |
| | | comActActivityCode.setActivityId(comActActivityDO.getId().longValue()); |
| | | comActActivityCode.setCreateTime(new Date()); |
| | | comActActivityCode.setType(1); |
| | | comActActivityCode.setStatus(1); |
| | | comActActivityCodeService.save(comActActivityCode); |
| | | return R.ok(activityId); |
| | | } |
| | | |
| | |
| | | log.error(e.getMessage()); |
| | | } |
| | | } else { |
| | | num = comActActSignDAO |
| | | .delete(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getUserId, userId) |
| | | .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getIsVolunteer, isVolunteer)); |
| | | if (isNull(signactivityVO.getReason())) { |
| | | return R.fail("缺少取消原因"); |
| | | } |
| | | ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>() |
| | | .lambda().eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getUserId, userId)); |
| | | if (isNull(comActActSignDO)) { |
| | | return R.fail("未报名"); |
| | | } |
| | | comActActSignDO.setStatus(0); |
| | | comActActSignDO.setReason(signactivityVO.getReason()); |
| | | num = comActActSignDAO.updateById(comActActSignDO); |
| | | } |
| | | if (num > 0) { |
| | | return R.ok(); |
| | |
| | | */ |
| | | @Override |
| | | public R listActivity(Long userId) { |
| | | List<ComActActSignDO> comActActSignDOS = comActActSignDAO |
| | | .selectList(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getUserId, userId)); |
| | | if (ObjectUtils.isEmpty(comActActSignDOS)) { |
| | | List<ActivitySignVO> activitySignVOList = comActActSignDAO.selectList(userId); |
| | | if (ObjectUtils.isEmpty(activitySignVOList)) { |
| | | return R.fail(); |
| | | } |
| | | List<Long> longs = comActActSignDOS.stream().map(comActActSignDO -> comActActSignDO.getActivityId()) |
| | | List<Long> longs = activitySignVOList.stream().map(activitySignVO -> activitySignVO.getActivityId()) |
| | | .collect(Collectors.toList()); |
| | | List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectBatchIds(longs); |
| | | List<ComActActivityVO> comActActivityVOS = new ArrayList<>(); |
| | | comActActivityDOS.forEach(comActActivityDO -> { |
| | | ComActActivityVO comActActivityVO = new ComActActivityVO(); |
| | | BeanUtils.copyProperties(comActActivityDO, comActActivityVO); |
| | | List<ComActActSignDO> collect = comActActSignDOS.stream() |
| | | .filter(comActActSignDO -> comActActSignDO.getActivityId().equals(comActActivityVO.getId())).limit(1) |
| | | List<ActivitySignVO> collect = activitySignVOList.stream() |
| | | .filter(activitySignVO -> activitySignVO.getActivityId().equals(comActActivityVO.getId())).limit(1) |
| | | .collect(Collectors.toList()); |
| | | ComActActSignDO comActActSignDO = collect.get(0); |
| | | Integer isVolunteer = comActActSignDO.getIsVolunteer(); |
| | | ActivitySignVO activitySignVO = collect.get(0); |
| | | Integer isVolunteer = activitySignVO.getIsVolunteer(); |
| | | if (isVolunteer.intValue() == 1) { |
| | | comActActivityVO.setType(1); |
| | | } else { |
| | |
| | | if (status.intValue() == 3) { |
| | | comActActivityVO.setStatus(4); |
| | | } |
| | | comActActivityVO.setSingDate(comActActSignDOS.stream() |
| | | .filter(comActActSignDO1 -> comActActSignDO1.getActivityId().equals(comActActivityVO.getId())) |
| | | .collect(Collectors.toList()).get(0).getCreateAt()); |
| | | Date createAt = null; |
| | | try { |
| | | createAt = DateUtils.parseDate(activitySignVO.getCreateAt()); |
| | | } catch (ParseException e) { |
| | | log.error("时间转换异常{【】}", e.getMessage()); |
| | | } |
| | | comActActivityVO.setSingDate(createAt); |
| | | comActActivityVO.setTimes(activitySignVO.getTimes()); |
| | | comActActivityVO.setAward(activitySignVO.getAward()); |
| | | comActActivityVOS.add(comActActivityVO); |
| | | }); |
| | | return R.ok(comActActivityVOS); |
| | |
| | | }); |
| | | return R.ok(comActActRegistVOS); |
| | | } |
| | | |
| | | /** |
| | | * 获取活动报名签到记录 |
| | | * @param id 活动主键id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R listSignInRecord(Long id) { |
| | | return R.ok(comActActSignDAO.listSignInRecord(id)); |
| | | } |
| | | |
| | | /** |
| | | * 活动签到记录 |
| | | * @param id 活动主键 |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R listRegistRecord(Long id, Long userId) { |
| | | return R.ok(comActActRegistDAO.listRegistRecord(id, userId)); |
| | | } |
| | | } |