| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.GrantRewardDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActEasyPhotoCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentUserDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoCommentVO; |
| | | import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO; |
| | | import com.panzhihua.common.model.vos.community.TodoEventsVO; |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.SensitiveUtil; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComActEasyPhotoService; |
| | | import com.panzhihua.service_community.service.ComActUserWalletService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-12-07 14:31 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActEasyPhotoServiceImpl extends ServiceImpl<ComActEasyPhotoDAO, ComActEasyPhotoDO> implements ComActEasyPhotoService { |
| | | @Resource |
| | |
| | | private ComActEasyPhotoCommentUserDAO comActEasyPhotoCommentUserDAO ; |
| | | @Resource |
| | | private ComActEasyPhotoActivityMapper comActEasyPhotoActivityMapper; |
| | | @Resource |
| | | private ComActEasyPhotoRewardMapper comActEasyPhotoRewardMapper; |
| | | @Resource |
| | | private ComActUserWalletService comActUserWalletService; |
| | | /** |
| | |
| | | comActEasyPhotoVO1.setHaveGiveThumbsUp(1); |
| | | } |
| | | comActEasyPhotoVO1.setPhone(SensitiveUtil.desensitizedPhoneNumber(comActEasyPhotoVO1.getPhone())); |
| | | |
| | | if(comActEasyPhotoVO1.getActivityId() != null && comActEasyPhotoVO1.getStatus().equals(ComActEasyPhotoDO.status.ywc)){ |
| | | //查询随手拍活动 |
| | | ComActEasyPhotoActivityDO photoActivityDO = comActEasyPhotoActivityMapper.selectById(comActEasyPhotoVO1.getActivityId()); |
| | | if(comActEasyPhotoVO1.getActivityType().equals(ComActEasyPhotoDO.activityType.yz)){ |
| | | comActEasyPhotoVO1.setActivityAmount(photoActivityDO.getGoodReward()); |
| | | }else if(comActEasyPhotoVO1.getActivityType().equals(ComActEasyPhotoDO.activityType.jl)){ |
| | | comActEasyPhotoVO1.setActivityAmount(photoActivityDO.getExcellentReward()); |
| | | }else if(comActEasyPhotoVO1.getActivityType().equals(ComActEasyPhotoDO.activityType.pt)){ |
| | | comActEasyPhotoVO1.setActivityAmount(photoActivityDO.getOrdinaryReward()); |
| | | }else if(comActEasyPhotoVO1.getActivityType().equals(ComActEasyPhotoDO.activityType.yb)){ |
| | | comActEasyPhotoVO1.setActivityAmount(photoActivityDO.getCommonlyReward()); |
| | | } |
| | | } |
| | | }); |
| | | iPage.setRecords(records); |
| | | } |
| | |
| | | cmActEasyPhotoDO.setStatus(4);//已完成 |
| | | } |
| | | cmActEasyPhotoDO.setExamineAt(date); |
| | | //审核通过判断随手拍是否有活动并计算用户收益 |
| | | comActUserWalletService.examineAddMoney(comActEasyPhotoVO.getActivityType(),comActEasyPhotoVO.getId(),comActEasyPhotoVO.getUserId()); |
| | | cmActEasyPhotoDO.setActivityType(comActEasyPhotoVO.getActivityType()); |
| | | break; |
| | | case 2: |
| | | cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId()); |
| | |
| | | return R.ok(this.baseMapper.getEasyPhotoStatistics(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍发放奖励 |
| | | * @param grantRewardDTO 请求参数 |
| | | * @return 发放结果 |
| | | */ |
| | | @Override |
| | | public R grantReward(GrantRewardDTO grantRewardDTO){ |
| | | |
| | | if(grantRewardDTO.getIds() == null){ |
| | | return R.fail("参数错误"); |
| | | } |
| | | |
| | | for (Long id:grantRewardDTO.getIds()) { |
| | | //查询随手拍 |
| | | ComActEasyPhotoDO easyPhotoDO = this.baseMapper.selectById(id); |
| | | if(easyPhotoDO != null){ |
| | | if(easyPhotoDO.getActivityAmount() != null){ |
| | | log.info("该随手拍已发放过奖励,不可重复发放,随手拍id" + easyPhotoDO.getId()); |
| | | continue; |
| | | } |
| | | //审核通过判断随手拍是否有活动并计算用户收益 |
| | | comActUserWalletService.examineAddMoney(easyPhotoDO.getActivityType(),easyPhotoDO.getId(),easyPhotoDO.getSponsorId(),grantRewardDTO.getAmount()); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取最新活动和用户最新收益 |
| | | * @param userId 用户id |
| | | * @param communityId 社区id |
| | | * @return 最新活动和用户最新收益 |
| | | */ |
| | | @Override |
| | | public R getUserReward(Long userId,Long communityId){ |
| | | //结果返回参数 |
| | | ComActEasyPhotoRewardVO easyPhotoRewardVO = new ComActEasyPhotoRewardVO(); |
| | | //查询随手拍活动 |
| | | ComActEasyPhotoActivityVO photoActivityVO = new ComActEasyPhotoActivityVO(); |
| | | Date nowDate = DateUtils.getCurrentDate(DateUtils.ymdhms_format); |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = comActEasyPhotoActivityMapper.selectList( |
| | | new QueryWrapper<ComActEasyPhotoActivityDO>().lambda().eq(ComActEasyPhotoActivityDO::getCommunityId,communityId) |
| | | .eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz) |
| | | .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate)); |
| | | if(!photoActivityDOS.isEmpty()){ |
| | | ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0); |
| | | BeanUtils.copyProperties(photoActivityDO,photoActivityVO); |
| | | } |
| | | easyPhotoRewardVO.setEasyPhotoActivityVO(photoActivityVO); |
| | | |
| | | //查询用户未读奖励金额 |
| | | BigDecimal amount = comActEasyPhotoRewardMapper.getUserReward(userId,communityId); |
| | | if(amount != null){ |
| | | easyPhotoRewardVO.setAmount(amount); |
| | | } |
| | | return R.ok(easyPhotoRewardVO); |
| | | } |
| | | |
| | | /** |
| | | * 读取用户随手拍奖励 |
| | | * @param userId 用户id |
| | | * @return 读取结果 |
| | | */ |
| | | @Override |
| | | public R readUserReward(Long userId,Long communityId){ |
| | | ComActEasyPhotoRewardDO easyPhotoRewardDO = comActEasyPhotoRewardMapper.selectOne(new QueryWrapper<ComActEasyPhotoRewardDO>().lambda() |
| | | .eq(ComActEasyPhotoRewardDO::getUserId,userId).eq(ComActEasyPhotoRewardDO::getCommunityId,communityId) |
| | | .eq(ComActEasyPhotoRewardDO::getIsRead,ComActEasyPhotoRewardDO.isRead.no)); |
| | | if(easyPhotoRewardDO != null){ |
| | | easyPhotoRewardDO.setIsRead(ComActEasyPhotoRewardDO.isRead.yes); |
| | | easyPhotoRewardDO.setUpdateAt(new Date()); |
| | | comActEasyPhotoRewardMapper.updateById(easyPhotoRewardDO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |