ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -306,6 +306,14 @@ appUserService.updateById(appUser); return R.ok(); } // @ApiOperation(value = "个人中心信息", tags = {"小程序-个人中心"}) // @PostMapping(value = "/user/info") // public R info() { // Long userId = 1L; // TAppUser byId = appUserService.getById(userId); // // // } @ApiOperation(value = "赠送会员", tags = {"用户管理-用户列表"}) ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
@@ -48,19 +48,19 @@ public void giveVipCoupun(Long appUserId, Integer vipId,Long recordId,Integer monthNum) { //如果不包含,则更新sendNum,并且赠送优惠卷 TAppUserVipDetail byId = tAppUserVipDetailService.getById(recordId); if (byId.getStartTime().toLocalDate().plusMonths(byId.getSendMonth()).compareTo(LocalDate.now())==0&&LocalDate.now().isBefore(byId.getEndTime().toLocalDate())){ if (byId.getStartTime().plusMonths(byId.getSendMonth()).toLocalDate().compareTo(LocalDate.now())==0&&LocalDate.now().isBefore(byId.getEndTime().toLocalDate())){ byId.setSendMonth(byId.getSendMonth()+1); //给这个用户发放对应vip的优惠卷以及充电次数加满 if (byId.getCouponIds()!=null) { String[] sendList = byId.getCouponIds().split(","); for (String sendCouponDto : sendList) { R<TCoupon> couponById = otherClient.getCouponById(Integer.valueOf(sendCouponDto)); 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(Integer.valueOf(sendCouponDto)); tAppCoupon.setCouponId(sendCouponDto.getId()); if (coupon.getValidityPeriodMode() == 1) { tAppCoupon.setEndTime(coupon.getEndTime()); } else { @@ -71,9 +71,11 @@ tAppCoupon.setCouponJson(JSON.toJSONString(coupon)); appCouponService.save(tAppCoupon); } } } byId.setChargeNum(byId.getSendChargeNum()); tAppUserVipDetailService.updateById(byId); } } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/GiveVipUtil.java
@@ -3,11 +3,15 @@ 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; @@ -22,6 +26,10 @@ 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())) { @@ -42,11 +50,31 @@ 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 {