From c264057e02200ca58868cfe927ecec0899eef8ce Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期六, 17 八月 2024 16:04:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
index be05f28..1894f70 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
@@ -3,17 +3,24 @@
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.dto.SendCouponDto;
+import com.ruoyi.account.api.feignClient.AppCouponClient;
+import com.ruoyi.account.api.model.TAppCoupon;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.mapper.TAppUserVipDetailMapper;
+import com.ruoyi.account.service.TAppCouponService;
import com.ruoyi.account.service.TAppUserVipDetailService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
+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.Service;
import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.List;
/**
@@ -28,20 +35,47 @@
public class TAppUserVipDetailServiceImpl extends ServiceImpl<TAppUserVipDetailMapper, TAppUserVipDetail> implements TAppUserVipDetailService {
@Resource
private VipClient vipClient;
+ @Resource
+ private OtherClient otherClient;
+ @Resource
+ private TAppCouponService appCouponService;
+ @Resource
+ private TAppUserVipDetailService tAppUserVipDetailService;
+
+
@Override
- public void giveVipCoupun(Long appUserId, Integer vipId) {
- //给这个用户发放对应vip的优惠卷以及充电次数加满 ,重置抵扣金额
- R<TVip> info = vipClient.getInfo(vipId);
- TVip data = info.getData();
- String coupon = data.getCoupon();
- if (coupon!=null) {
- List<SendCouponDto> sendList = JSON.parseArray(coupon).toJavaList(SendCouponDto.class);
- for (SendCouponDto sendCouponDto : sendList) {
-
+ 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()));
+ }
+ tAppCoupon.setWaysToObtain(4);
+ tAppCoupon.setStatus(1);
+ tAppCoupon.setCouponJson(JSON.toJSONString(coupon));
+ appCouponService.save(tAppCoupon);
+ }
+ }
+
}
-
-
+ byId.setChargeNum(byId.getSendChargeNum());
+ tAppUserVipDetailService.updateById(byId);
}
- }
+
}
--
Gitblit v1.7.1