| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private VipClient vipClient; |
| | | @Resource |
| | | private TAppUserVipDetailService tAppUserVipDetailService; |
| | | @Resource |
| | | private OtherClient otherClient; |
| | | @Resource |
| | | private TAppCouponService appCouponService; |
| | | public void sendVip(TAppUser nowUser,Integer vipId,Integer plusDay){ |
| | | if (nowUser.getVipEndTime()==null||nowUser.getVipEndTime().isBefore(LocalDateTime.now())) { |
| | | |
| | |
| | | tAppUserVipDetail.setSendChargeNum(vip.getDiscountTimes()); |
| | | tAppUserVipDetail.setChargeNum(vip.getDiscountTimes()); |
| | | tAppUserVipDetail.setDiscountMoney(vip.getMaximumDeduction()); |
| | | tAppUserVipDetail.setSendMonth(1); |
| | | tAppUserVipDetailService.save(tAppUserVipDetail); |
| | | //直接赠送优惠卷 |
| | | for (SendCouponDto sendCouponDto : javaList) { |
| | | Integer number = sendCouponDto.getNumber(); |
| | | for (Integer i = 0; i < number; i++) { |
| | | |
| | | |
| | | |
| | | R<TCoupon> couponById = otherClient.getCouponById(sendCouponDto.getId()); |
| | | TCoupon coupon = couponById.getData(); |
| | | //将该优惠卷添加到用户优惠卷中 |
| | | TAppCoupon tAppCoupon = new TAppCoupon(); |
| | | tAppCoupon.setAppUserId(nowUser.getId()); |
| | | tAppCoupon.setCouponId(Integer.valueOf(sendCouponDto.getId())); |
| | | if (coupon.getValidityPeriodMode() == 1) { |
| | | tAppCoupon.setEndTime(coupon.getEndTime()); |
| | | } else { |
| | | tAppCoupon.setEndTime(LocalDateTime.now().plusDays(coupon.getDays())); |
| | | } |
| | | tAppCoupon.setWaysToObtain(4); |
| | | tAppCoupon.setStatus(1); |
| | | tAppCoupon.setCouponJson(JSON.toJSONString(coupon)); |
| | | appCouponService.save(tAppCoupon); |
| | | } |
| | | } |
| | | |
| | | |
| | | }else { |