| | |
| | | import com.ruoyi.goods.domain.vo.*; |
| | | import com.ruoyi.goods.mapper.lottery.LotteryEventMapper; |
| | | import com.ruoyi.goods.service.lottery.*; |
| | | import com.ruoyi.system.api.domain.dto.IntegralChangeDto; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.domain.poji.member.MemberGiftRecord; |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.service.RemoteCouponService; |
| | | import com.ruoyi.system.api.service.RemoteMemberService; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import com.ruoyi.system.api.model.AddIntegralRecordVo; |
| | | import com.ruoyi.system.api.model.AddOrderVo; |
| | | import com.ruoyi.system.api.service.*; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Resource |
| | | private ILotteryEventQuestionsService lotteryEventQuestionsService; |
| | | |
| | | @Resource |
| | | private RemoteOrderService remoteOrderService; |
| | | |
| | | /** |
| | | * 根据id查询抽奖活动信息 |
| | |
| | | vo.setId(lotteryEvent.getId()); |
| | | vo.setName(lotteryEvent.getName()); |
| | | vo.setActivityProfile(lotteryEvent.getActivityProfile()); |
| | | List<TUserLotteryEvent> userLotteryEvents = userLotteryEventService.list(new QueryWrapper<TUserLotteryEvent>().eq("lottery_event_id", id)); |
| | | List<TUserLotteryEvent> userLotteryEvents = userLotteryEventService.list(new QueryWrapper<TUserLotteryEvent>().eq("lottery_event_id", id).eq("user_id", userId)); |
| | | vo.setLaveTimes(lotteryEvent.getTimes() - userLotteryEvents.size()); |
| | | //查询抽检活动奖品 |
| | | List<TLotteryEventPrize> lotteryEventPrizeList = lotteryEventPrizeService.list(new QueryWrapper<TLotteryEventPrize>().eq("lottery_event_id", id)); |
| | |
| | | userLotteryEvent.setNumber(lotteryEventPrize.getNumber()); |
| | | //中奖优惠券 |
| | | if (1 == lotteryEventPrize.getPrizeType()) { |
| | | remoteCouponService.addMemberCoupon(lotteryEventPrize.getObjectId(), lotteryEventPrize.getNumber(), userId); |
| | | AddMemberCoupon addMemberCoupon = new AddMemberCoupon(); |
| | | addMemberCoupon.setCouponId(lotteryEventPrize.getObjectId()); |
| | | addMemberCoupon.setNumber(lotteryEventPrize.getNumber()); |
| | | addMemberCoupon.setUserId(userId); |
| | | remoteCouponService.addMemberCoupon(addMemberCoupon); |
| | | } |
| | | //中奖积分 |
| | | if (4 == lotteryEventPrize.getPrizeType()) { |
| | | remoteMemberService.addIntegralRecord(lotteryEventPrize.getNumber(), userId, id); |
| | | AddIntegralRecordVo addIntegralRecordVo = new AddIntegralRecordVo(); |
| | | addIntegralRecordVo.setIntegral(lotteryEventPrize.getNumber()); |
| | | addIntegralRecordVo.setUserId(userId); |
| | | addIntegralRecordVo.setOrderId(id); |
| | | remoteMemberService.addIntegralRecord(addIntegralRecordVo); |
| | | } |
| | | userLotteryEvent.setCreateTime(LocalDateTime.now()); |
| | | userLotteryEventService.save(userLotteryEvent); |
| | |
| | | memberGiftRecord.setGiftId(userLotteryEvent.getId()); |
| | | memberGiftRecord.setGiftFrom(1); |
| | | memberGiftRecord.setShopId(member.getRelationShopId()); |
| | | memberGiftRecord.setVerifyStatus(1); |
| | | switch (lotteryEventPrize.getPrizeType()) { |
| | | case 1: |
| | | memberGiftRecord.setGiftType(1); |
| | | memberGiftRecord.setCouponId(userLotteryEvent.getObjectId()); |
| | | memberGiftRecord.setCouponNumber(userLotteryEvent.getNumber()); |
| | | memberGiftRecord.setCouponName(userLotteryEvent.getObjectName()); |
| | | memberGiftRecord.setVerifyStatus(2); |
| | | memberGiftRecord.setVerifyTime(new Date()); |
| | | break; |
| | | case 2: |
| | | memberGiftRecord.setGiftType(2); |
| | | memberGiftRecord.setGoodsId(userLotteryEvent.getObjectId()); |
| | | memberGiftRecord.setGiftName(userLotteryEvent.getObjectName()); |
| | | memberGiftRecord.setGoodsNumber(userLotteryEvent.getNumber()); |
| | | memberGiftRecord.setGoodsName(userLotteryEvent.getObjectName()); |
| | | //添加待核销订单 |
| | | AddOrderVo orderVo = new AddOrderVo(); |
| | | orderVo.setShopId(member.getRelationShopId()); |
| | | orderVo.setUserId(member.getUserId()); |
| | | orderVo.setId(userLotteryEvent.getId()); |
| | | orderVo.setGoodsId(userLotteryEvent.getObjectId()); |
| | | orderVo.setGoodsNum(userLotteryEvent.getNumber()); |
| | | remoteOrderService.addOrder(orderVo); |
| | | break; |
| | | case 3: |
| | | memberGiftRecord.setGiftType(4); |
| | |
| | | case 4: |
| | | memberGiftRecord.setGiftType(5); |
| | | memberGiftRecord.setIntegralNumber(userLotteryEvent.getNumber()); |
| | | memberGiftRecord.setVerifyStatus(2); |
| | | memberGiftRecord.setVerifyTime(new Date()); |
| | | break; |
| | | } |
| | | memberGiftRecord.setPrizeFrom(2); |
| | | memberGiftRecord.setCreateTime(new Date()); |
| | | memberGiftRecord.setVerifyStatus(1); |
| | | remoteMemberService.saveMemberGiftRecord(memberGiftRecord); |
| | | return R.ok(lotteryEventPrize); |
| | | } |
| | |
| | | List<MgtLotteryEventPageVo> voList = this.baseMapper.pageMgtLotteryEvent(dto); |
| | | //填充创建对象 |
| | | voList.forEach(x->{ |
| | | if (x.getActivityType()!=6){ |
| | | if (null == x.getShopId()){ |
| | | x.setCreateObject("平台创建"); |
| | | }else { |
| | | //线下抽奖,获取门店名称 |