puzhibing
2026-08-10 a8f0bac0c2f11c5d5d2a9d5510b27c35cce66cc9
修改会员发送优惠券功能
优化充电发起支付前的状态校验
3个文件已修改
94 ■■■■■ 已修改文件
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/GiveVipUtil.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java
@@ -1,10 +1,19 @@
package com.ruoyi.account.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.TAppUserService;
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.feignClient.OtherClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Scheduled;
@@ -19,6 +28,7 @@
/**
 * 定时任务工具类
 */
@Slf4j
@Component
public class TaskUtil implements ApplicationListener<WebServerInitializedEvent> {
    
@@ -27,6 +37,13 @@
    
    @Resource
    private TAppUserService appUserService;
    @Resource
    private OtherClient otherClient;
    @Resource
    private TAppCouponService appCouponService;
    
    private Integer port = null;
    
@@ -53,10 +70,57 @@
                e.printStackTrace();
            }
        }
    }
    
    @Scheduled(cron = "0 5 0 1 * ?")
    public void pushVipCoupon() {
        if(null != port && port == 5200){
            log.info("发送季度会员和年度会员优惠券");
            try {
                //季度会员和年度会员需要每月发送会员优惠券
                LocalDateTime currentDate = LocalDateTime.now();
                List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery()
                        .le(TAppUserVipDetail::getStartTime, currentDate)
                        .ge(TAppUserVipDetail::getEndTime, currentDate)
                        .ne(TAppUserVipDetail::getVipType, 1).list();
                for (TAppUserVipDetail recentDetail : recentDetails) {
                    //[{"id":22,"number":5},{"id":21,"number":1}]
                    String couponIds = recentDetail.getCouponIds();
                    JSONArray objects = JSON.parseArray(couponIds);
                    for (int i = 0; i < objects.size(); i++) {
                        JSONObject jsonObject = objects.getJSONObject(i);
                        Integer id = jsonObject.getInteger("id");
                        Integer number = jsonObject.getInteger("number");
                        R<TCoupon> couponById = otherClient.getCouponById(id);
                        TCoupon coupon = couponById.getData();
                        for (int j = 0; j < number; j++) {
                            //将该优惠卷添加到用户优惠卷中
                            TAppCoupon tAppCoupon = new TAppCoupon();
                            tAppCoupon.setAppUserId(recentDetail.getAppUserId());
                            tAppCoupon.setCouponId(id);
                            if (coupon.getValidityPeriodMode() == 1) {
                                tAppCoupon.setEndTime(coupon.getEndTime());
                            } else {
                                tAppCoupon.setEndTime(LocalDateTime.now().plusDays(coupon.getDays()));
                            }
                            tAppCoupon.setWaysToObtain(4);
                            tAppCoupon.setStatus(1);
                            tAppCoupon.setCouponJson(com.alibaba.fastjson2.JSON.toJSONString(coupon));
                            tAppCoupon.setDetailId(recentDetail.getId());
                            appCouponService.save(tAppCoupon);
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @Scheduled(fixedRate = 1000 * 60)
    public void changeVipId() {
        if(null != port && port == 5200){
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/GiveVipUtil.java
@@ -62,8 +62,6 @@
            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();
                //将该优惠卷添加到用户优惠卷中
@@ -104,4 +102,9 @@
        }
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -610,6 +610,21 @@
        Integer payMethod = addChargingOrder.getPayMethod() == null ? 3 : addChargingOrder.getPayMethod();
        BigDecimal rechargeAmount = money(addChargingOrder.getPaymentAmount());
        TChargingGun tChargingGun = chargingGunClient.getChargingGunById(addChargingOrder.getId()).getData();
        if(tChargingGun == null){
            return AjaxResult.error("发起支付失败,请联系管理员!");
        }
        if(tChargingGun.getStatus() == 1){
            return AjaxResult.error("充电枪已离线,请更换其他设备!");
        }
        if(tChargingGun.getStatus() == 2){
            return AjaxResult.error("请先将充电枪连接车辆充电口!");
        }
        if(Arrays.asList(4, 5, 6).contains(tChargingGun.getStatus())){
            return AjaxResult.error("设备正在充电中,请更换其他设备!");
        }
        if(tChargingGun.getStatus() == 7){
            return AjaxResult.error("设备发生故障,请更换其他设备!");
        }
        TChargingPile chargingPile = chargingPileClient.getChargingPileById(tChargingGun.getChargingPileId()).getData();
        AppUserWhitelistMatchVO whitelist = appUserWhitelistClient.matchWhitelist(userId, tChargingGun.getSiteId()).getData();
        boolean whitelistMatched = whitelist != null && Boolean.TRUE.equals(whitelist.getMatched());
@@ -942,8 +957,8 @@
                list.addAll(list);
                boolean sta = false;
                for (AccountingStrategyDetailOrder accountingStrategyDetailOrder : list) {
                    Integer start = Integer.valueOf(accountingStrategyDetailOrder.getStartTime().replaceAll(":", ""));
                    Integer end = Integer.valueOf(accountingStrategyDetailOrder.getEndTime().replaceAll(":", ""));
                    int start = Integer.parseInt(accountingStrategyDetailOrder.getStartTime().replaceAll(":", ""));
                    int end = Integer.parseInt(accountingStrategyDetailOrder.getEndTime().replaceAll(":", ""));
                    String[] split = accountingStrategyDetailOrder.getEndTime().split(":");
                    if (sta || (now >= start && now < end)) {
                        sta = true;