Pu Zhibing
2025-03-31 db2d7720496c66c2007e7e3a0be88dbff81148ad
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
@@ -40,39 +40,26 @@
    private TAppUserVipDetailService tAppUserVipDetailService;
    @Override
    public void giveVipCoupun(Long appUserId, Integer vipId,Long recordId,Integer monthNum) {
        //如果不包含,则更新sendNum,并且赠送优惠卷
        TAppUserVipDetail byId = tAppUserVipDetailService.getById(recordId);
        if (byId.getStartTime().plusMonths(byId.getSendMonth()).toLocalDate().compareTo(LocalDate.now())==0&&LocalDate.now().isBefore(byId.getEndTime().toLocalDate())){
            byId.setSendMonth(byId.getSendMonth()+1);
        //给这个用户发放对应vip的优惠卷以及充电次数加满
            List<SendCouponDto> javaList = JSON.parseArray(byId.getCouponIds()).toJavaList(SendCouponDto.class);
            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(appUserId);
                    tAppCoupon.setCouponId(sendCouponDto.getId());
                    if (coupon.getValidityPeriodMode() == 1) {
                        tAppCoupon.setEndTime(coupon.getEndTime());
                    } else {
                        tAppCoupon.setEndTime(LocalDateTime.now().plusDays(coupon.getDays()));
   public void giveVipCoupun(TAppUserVipDetail recentDetail) {
      Integer vipType = recentDetail.getVipType();
      Integer sendMonth = recentDetail.getSendMonth();
      //月卡
      if(1 == vipType && 1 == sendMonth){
         return;
                    }
                    tAppCoupon.setWaysToObtain(4);
                    tAppCoupon.setStatus(1);
                    tAppCoupon.setCouponJson(JSON.toJSONString(coupon));
                    appCouponService.save(tAppCoupon);
      //季卡
      if(2 == vipType && 3 == sendMonth){
         return;
                }
      //年卡
      if(3 == vipType && 12 == sendMonth){
         return;
                }
            }
        byId.setChargeNum(byId.getSendChargeNum());
        tAppUserVipDetailService.updateById(byId);
      recentDetail.setSendMonth(sendMonth + 1);
      recentDetail.setChargeNum(recentDetail.getSendChargeNum());
      recentDetail.setMonthEndTime(LocalDateTime.now().plusMonths(1));
      tAppUserVipDetailService.updateById(recentDetail);
        }
}