| | |
| | | import com.ruoyi.member.domain.dto.MgtBirthdayEditDto; |
| | | import com.ruoyi.member.domain.dto.MgtBirthdayGetDto; |
| | | import com.ruoyi.member.domain.dto.MgtBirthdayGiftDto; |
| | | import com.ruoyi.system.api.domain.poji.member.BirthdayCard; |
| | | import com.ruoyi.member.domain.pojo.birthday.BirthdayGift; |
| | | import com.ruoyi.member.domain.vo.*; |
| | | import com.ruoyi.member.mapper.birthday.BirthdayCardMapper; |
| | | import com.ruoyi.member.service.birthday.BirthdayCardService; |
| | | import com.ruoyi.member.service.birthday.BirthdayGiftService; |
| | | import com.ruoyi.member.service.member.MemberGiftRecordService; |
| | | import com.ruoyi.member.service.member.MemberService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto; |
| | | import com.ruoyi.system.api.domain.dto.MgtBaseBathDto; |
| | | import com.ruoyi.system.api.domain.poji.member.BirthdayCard; |
| | | 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.domain.vo.MgtSimpleShopVo; |
| | |
| | | |
| | | @Resource |
| | | private MemberGiftRecordService memberGiftRecordService; |
| | | |
| | | @Resource |
| | | private MemberService memberService; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | BirthdayGiftSendDto birthdayGiftSendDto; |
| | | String prizeId; |
| | | String currentYear = String.valueOf(LocalDate.now().getYear()); |
| | | Member member = memberService.getByUserId(userId); |
| | | // 获取平台生日卡信息 |
| | | BirthdayCard plBirthdayCard = birthdayCardMapper.getPlatformBirthdayCard(shopId); |
| | | BirthdayCard plBirthdayCard = this.getBirthdayCard(); |
| | | //绑定的时候需要判断范围 |
| | | if(member.getBindingFlag()==1){ |
| | | //判断指定区域全部店铺 |
| | | if(plBirthdayCard.getShopFlag()==1&&plBirthdayCard.getAreaFlag()==2){ |
| | | Shop shop = remoteShopService.getShop(member.getRelationShopId()).getData(); |
| | | if(!StringUtils.checkString(plBirthdayCard.getDesignatedArea(),shop.getShopCityCode())){ |
| | | plBirthdayCard = null; |
| | | } |
| | | } |
| | | //判断指定店铺 |
| | | if(plBirthdayCard.getShopFlag()==2&&!StringUtils.checkString(plBirthdayCard.getApplicableShop(),shopId.toString())){ |
| | | plBirthdayCard = null; |
| | | } |
| | | } |
| | | // 如果生日卡存在 |
| | | if (plBirthdayCard != null && plBirthdayCard.getCardStatus()==1) { |
| | | // 获取生日卡对应的生日礼物列表 |
| | |
| | | } |
| | | } |
| | | //获取商户营销开关状态 |
| | | Integer marketingStatus = remoteShopService.getShopMarketingStatus(shopId).getData(); |
| | | if(marketingStatus>1){ |
| | | //获取商户生日卡 |
| | | LambdaQueryWrapper<BirthdayCard> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(BirthdayCard::getDelFlag,0); |
| | | queryWrapper.eq(BirthdayCard::getShopId,shopId); |
| | | BirthdayCard shopBirthdayCard = this.getOne(queryWrapper,false); |
| | | // 如果生日卡存在 |
| | | if (shopBirthdayCard != null && shopBirthdayCard.getCardStatus()==1) { |
| | | // 获取生日卡对应的生日礼物列表 |
| | | List<BirthdayGift> birthdayGiftList = birthdayGiftService.listByCardId(shopBirthdayCard.getCardId()); |
| | | if(!birthdayGiftList.isEmpty()){ |
| | | // 遍历生日礼物列表 |
| | | for (BirthdayGift birthdayGift : birthdayGiftList) { |
| | | winningProbability = birthdayGift.getWinningProbability(); |
| | | randomProbability = new BigDecimal(new Random().nextInt(100)); |
| | | if(winningProbability.compareTo(randomProbability)>0){ |
| | | appBirthdayGiftVo = new AppBirthdayGiftVo(); |
| | | memberGiftRecord = new MemberGiftRecord(); |
| | | birthdayGiftSendDto = new BirthdayGiftSendDto(); |
| | | BeanUtils.copyProperties(birthdayGift, memberGiftRecord); |
| | | prizeId = IdUtils.simpleUUID(); |
| | | memberGiftRecord.setPrizeId(prizeId); |
| | | memberGiftRecord.setDelFlag(0); |
| | | memberGiftRecord.setVerifyStatus(1); |
| | | memberGiftRecord.setGiftFrom(2); |
| | | memberGiftRecord.setShopId(shopId); |
| | | memberGiftRecord.setGiftYear(currentYear); |
| | | memberGiftRecord.setCreateTime(new Date()); |
| | | memberGiftRecord.setUserId(userId); |
| | | birthdayGiftSendDto.setUserId(userId); |
| | | birthdayGiftSendDto.setGiftFrom(2); |
| | | birthdayGiftSendDto.setShopId(shopId); |
| | | birthdayGiftSendDto.setGiftType(birthdayGift.getGiftType()); |
| | | switch (birthdayGift.getGiftType()) { |
| | | case 1: |
| | | // 礼物类型为1,即优惠券 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber()); |
| | | birthdayGiftSendDto.setCouponId(birthdayGift.getCouponId()); |
| | | birthdayGiftSendDto.setCouponNumber(birthdayGift.getCouponNumber()); |
| | | sendGoodsList.add(birthdayGiftSendDto); |
| | | memberGiftRecord.setCouponId(birthdayGift.getCouponId()); |
| | | memberGiftRecord.setCouponName(birthdayGift.getCouponName()); |
| | | memberGiftRecord.setCouponNumber(birthdayGift.getCouponNumber()); |
| | | break; |
| | | case 2: |
| | | // 礼物类型为2,即商品 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getGoodsName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getGoodsNumber()); |
| | | birthdayGiftSendDto.setGoodsId(birthdayGift.getGoodsId()); |
| | | birthdayGiftSendDto.setCouponNumber(birthdayGift.getGoodsNumber()); |
| | | sendCouponList.add(birthdayGiftSendDto); |
| | | memberGiftRecord.setGoodsId(birthdayGift.getGoodsId()); |
| | | memberGiftRecord.setGoodsName(birthdayGift.getGoodsName()); |
| | | memberGiftRecord.setGoodsNumber(birthdayGift.getGoodsNumber()); |
| | | break; |
| | | case 3: |
| | | // 礼物类型为3,即现金 |
| | | appBirthdayGiftVo.setGiftName("现金"); |
| | | appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue()); |
| | | memberGiftRecord.setMoney(birthdayGift.getMoney()); |
| | | break; |
| | | case 4: |
| | | // 礼物类型为4,即礼品 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getGiftName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getGiftNumber()); |
| | | memberGiftRecord.setGiftName(birthdayGift.getGiftName()); |
| | | memberGiftRecord.setGiftNumber(birthdayGift.getGiftNumber()); |
| | | break; |
| | | default: |
| | | break; |
| | | if(member.getBindingFlag()==1){ |
| | | Integer marketingStatus = remoteShopService.getShopMarketingStatus(shopId).getData(); |
| | | if(marketingStatus>1){ |
| | | //获取商户生日卡 |
| | | LambdaQueryWrapper<BirthdayCard> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(BirthdayCard::getDelFlag,0); |
| | | queryWrapper.eq(BirthdayCard::getShopId,shopId); |
| | | BirthdayCard shopBirthdayCard = this.getOne(queryWrapper,false); |
| | | // 如果生日卡存在 |
| | | if (shopBirthdayCard != null && shopBirthdayCard.getCardStatus()==1) { |
| | | // 获取生日卡对应的生日礼物列表 |
| | | List<BirthdayGift> birthdayGiftList = birthdayGiftService.listByCardId(shopBirthdayCard.getCardId()); |
| | | if(!birthdayGiftList.isEmpty()){ |
| | | // 遍历生日礼物列表 |
| | | for (BirthdayGift birthdayGift : birthdayGiftList) { |
| | | winningProbability = birthdayGift.getWinningProbability(); |
| | | randomProbability = new BigDecimal(new Random().nextInt(100)); |
| | | if(winningProbability.compareTo(randomProbability)>0){ |
| | | appBirthdayGiftVo = new AppBirthdayGiftVo(); |
| | | memberGiftRecord = new MemberGiftRecord(); |
| | | birthdayGiftSendDto = new BirthdayGiftSendDto(); |
| | | BeanUtils.copyProperties(birthdayGift, memberGiftRecord); |
| | | prizeId = IdUtils.simpleUUID(); |
| | | memberGiftRecord.setPrizeId(prizeId); |
| | | memberGiftRecord.setDelFlag(0); |
| | | memberGiftRecord.setVerifyStatus(1); |
| | | memberGiftRecord.setGiftFrom(2); |
| | | memberGiftRecord.setShopId(shopId); |
| | | memberGiftRecord.setGiftYear(currentYear); |
| | | memberGiftRecord.setCreateTime(new Date()); |
| | | memberGiftRecord.setUserId(userId); |
| | | birthdayGiftSendDto.setUserId(userId); |
| | | birthdayGiftSendDto.setGiftFrom(2); |
| | | birthdayGiftSendDto.setShopId(shopId); |
| | | birthdayGiftSendDto.setGiftType(birthdayGift.getGiftType()); |
| | | switch (birthdayGift.getGiftType()) { |
| | | case 1: |
| | | // 礼物类型为1,即优惠券 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber()); |
| | | birthdayGiftSendDto.setCouponId(birthdayGift.getCouponId()); |
| | | birthdayGiftSendDto.setCouponNumber(birthdayGift.getCouponNumber()); |
| | | sendGoodsList.add(birthdayGiftSendDto); |
| | | memberGiftRecord.setCouponId(birthdayGift.getCouponId()); |
| | | memberGiftRecord.setCouponName(birthdayGift.getCouponName()); |
| | | memberGiftRecord.setCouponNumber(birthdayGift.getCouponNumber()); |
| | | break; |
| | | case 2: |
| | | // 礼物类型为2,即商品 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getGoodsName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getGoodsNumber()); |
| | | birthdayGiftSendDto.setGoodsId(birthdayGift.getGoodsId()); |
| | | birthdayGiftSendDto.setCouponNumber(birthdayGift.getGoodsNumber()); |
| | | sendCouponList.add(birthdayGiftSendDto); |
| | | memberGiftRecord.setGoodsId(birthdayGift.getGoodsId()); |
| | | memberGiftRecord.setGoodsName(birthdayGift.getGoodsName()); |
| | | memberGiftRecord.setGoodsNumber(birthdayGift.getGoodsNumber()); |
| | | break; |
| | | case 3: |
| | | // 礼物类型为3,即现金 |
| | | appBirthdayGiftVo.setGiftName("现金"); |
| | | appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue()); |
| | | memberGiftRecord.setMoney(birthdayGift.getMoney()); |
| | | break; |
| | | case 4: |
| | | // 礼物类型为4,即礼品 |
| | | appBirthdayGiftVo.setGiftName(birthdayGift.getGiftName()); |
| | | appBirthdayGiftVo.setGiftNumber(birthdayGift.getGiftNumber()); |
| | | memberGiftRecord.setGiftName(birthdayGift.getGiftName()); |
| | | memberGiftRecord.setGiftNumber(birthdayGift.getGiftNumber()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | birthdayGiftVoList.add(appBirthdayGiftVo); |
| | | memberGiftRecordList.add(memberGiftRecord); |
| | | } |
| | | birthdayGiftVoList.add(appBirthdayGiftVo); |
| | | memberGiftRecordList.add(memberGiftRecord); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (plBirthdayCard == null || plBirthdayCard.getCardStatus()!=1) { |
| | | platformBirthdayCardOpen = false; |
| | | }else{ |
| | | if(plBirthdayCard.getShopFlag()==2&&plBirthdayCard.getAreaFlag()==1){ |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | if(!StringUtils.checkString(plBirthdayCard.getDesignatedArea(),shop.getShopCityCode())){ |
| | | //绑死店铺判断区域和店铺 |
| | | if(bindingFlag==1){ |
| | | //判断指定区域全部店铺 |
| | | if(plBirthdayCard.getShopFlag()==1&&plBirthdayCard.getAreaFlag()==2){ |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | if(!StringUtils.checkString(plBirthdayCard.getDesignatedArea(),shop.getShopCityCode())){ |
| | | platformBirthdayCardOpen = false; |
| | | } |
| | | } |
| | | //判断指定店铺 |
| | | if(plBirthdayCard.getShopFlag()==2&&!StringUtils.checkString(plBirthdayCard.getApplicableShop(),shopId.toString())){ |
| | | platformBirthdayCardOpen = false; |
| | | } |
| | | } |
| | | if(plBirthdayCard.getAreaFlag()==2&&!StringUtils.checkString(plBirthdayCard.getApplicableShop(),shopId.toString())){ |
| | | platformBirthdayCardOpen = false; |
| | | } |
| | | } |
| | | //判断店铺生日卡 |
| | | BirthdayCard shopBirthdayCard = birthdayCardMapper.getMerShopBirthdayCard(shopId); |
| | | // 如果生日卡存在 |
| | | Boolean shopBirthdayCardOpen = true; |