xuhy
2024-11-01 bdc2c1a3fab057624165489bf75940c56452e568
修改
7个文件已修改
136 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/SiteInfoVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/SiteInfoVO.java
@@ -27,7 +27,7 @@
    @ApiModelProperty(value = "开通会员预计可省")
    private BigDecimal money;
    @ApiModelProperty(value = "额外赠送优惠券X张")
    private Integer couponCount;
    private Integer couponCount = 0;
    @ApiModelProperty(value = "超时占位费说明")
    private String spaceChargeExplain;
    @ApiModelProperty(value = "添加车辆最高可得积分 车辆信息为空 展示提示语")
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java
@@ -10,6 +10,8 @@
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 会员服务降级处理
 * 
@@ -41,6 +43,11 @@
            }
            @Override
            public R<List<TVip>> getVipList() {
                return R.fail("查询会员集合失败:" + throwable.getMessage());
            }
            @Override
            public R<TVip> getInfo1(Integer id) {
                return R.fail("根据会员id 获取会员信息:" + throwable.getMessage());
            }
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java
@@ -12,6 +12,8 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
 * 会员服务
 * @author ruoyi
@@ -41,4 +43,7 @@
    @PostMapping(value = "/t-app-user/user/give/vip")
    R giveVip(@RequestBody GiveVipDto giveVipDto);
    @GetMapping(value = "/vip/getVipList")
    R<List<TVip>> getVipList();
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserServiceImpl.java
@@ -56,7 +56,6 @@
            if(Objects.isNull(appUser)){
                appUser = new TAppUser();
                appUser.setPhone(appletUserDecodeData.getPhoneNumber());
                appUser.setInviteUserId(inviteUserId);
            }
        }
        if(Objects.nonNull(appUser.getStatus())){
@@ -71,7 +70,9 @@
                    break;
            }
        }
        if(Objects.nonNull(inviteUserId)){
            appUser.setInviteUserId(inviteUserId);
        }
        appUser.setAvatar(StringUtils.hasLength(appUser.getAvatar())?appUser.getAvatar():"http://221.182.45.100:8090/2024-10-26/logo.png");
        appUser.setName(StringUtils.hasLength(appUser.getName())?appUser.getName():RptUtils.around(appletUserDecodeData.getPhoneNumber(),3,4));
        appUser.setCity(appletUserDecodeData.getCity());
@@ -100,7 +101,6 @@
            if(Objects.isNull(appUser)){
                appUser = new TAppUser();
                appUser.setPhone(phone);
                appUser.setInviteUserId(inviteUserId);
            }
        }
        if(Objects.nonNull(appUser.getStatus())){
@@ -115,6 +115,9 @@
                    break;
            }
        }
        if(Objects.nonNull(inviteUserId)){
            appUser.setInviteUserId(inviteUserId);
        }
        appUser.setAliOpenid(response.getOpenId());
        appUser.setAvatar(StringUtils.hasLength(appUser.getAvatar())?appUser.getAvatar():"http://221.182.45.100:8090/2024-10-26/logo.png");
        appUser.setName(StringUtils.hasLength(appUser.getName())?appUser.getName():RptUtils.around(phone,3,4));
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -1,10 +1,16 @@
package com.ruoyi.chargingPile.controller;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
import com.ruoyi.chargingPile.api.model.*;
@@ -41,6 +47,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -100,7 +107,8 @@
    private TokenService tokenService;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private AppUserVipDetailClient vipDetailClient;
    /**
     * 根据站点id 查询所有充电桩
@@ -132,23 +140,26 @@
            if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0
                    && DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
                siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
                if(null != byId1.getDiscount()){
                    siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
                }else{
                    // 获取当前登录用户id
                    Long userId = tokenService.getLoginUserApplet().getUserId();
                    // 根据id查询用户信息
                    TAppUser appUser = appUserClient.getUserById(userId).getData();
                    if(Objects.nonNull(appUser)){
                        TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                        if(Objects.nonNull(vip) && vip.getType() == 2){
                            siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
                        }else {
                            siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
                        }
                // 获取当前登录用户id
                Long userId = tokenService.getLoginUserApplet().getUserId();
                // 根据id查询用户信息
                TAppUser appUser = appUserClient.getUserById(userId).getData();
                if(Objects.nonNull(appUser)){
//                    TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                    GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
                    getAppUserVipDetail.setAppUserId(userId);
                    getAppUserVipDetail.setVipId(appUser.getVipId());
                    R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
                    TAppUserVipDetail data1 = appUserVipDetail.getData();
                    String vipJson = data1.getVipJson();
                    TVip vip = JSON.parseObject(vipJson, TVip.class);
                    if(Objects.nonNull(vip) && vip.getType() == 2){
                        siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
                    }else {
                        siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
                        siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
                    }
                }else {
                    siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
                }
            }
        }
@@ -177,26 +188,41 @@
            if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0
                    && DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
                siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
                if(null != byId1.getDiscount()){
                    siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
                }else{
                    // 获取当前登录用户id
                    Long userId = tokenService.getLoginUserApplet().getUserId();
                    // 根据id查询用户信息
                    TAppUser appUser = appUserClient.getUserById(userId).getData();
                    if(Objects.nonNull(appUser)){
                        TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                        if(Objects.nonNull(vip) && vip.getType() == 2){
                            siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
                        }else {
                            siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
                        }
                    }else {
                        siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
                // 获取当前登录用户id
                Long userId = tokenService.getLoginUserApplet().getUserId();
                // 根据id查询用户信息
                TAppUser appUser = appUserClient.getUserById(userId).getData();
                if(Objects.nonNull(appUser)){
//                    TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                    GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
                    getAppUserVipDetail.setAppUserId(userId);
                    getAppUserVipDetail.setVipId(appUser.getVipId());
                    R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
                    TAppUserVipDetail data1 = appUserVipDetail.getData();
                    String vipJson = data1.getVipJson();
                    TVip vip = JSON.parseObject(vipJson, TVip.class);
                    if(Objects.nonNull(vip) && vip.getType() == 2){
                        siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
                    }else{
                        siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
                    }
                }else {
                    siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
                }
            }
        }
        List<TVip> vips = vipClient.getVipList().getData();
        if(!CollectionUtils.isEmpty(vips)){
            TVip tVip = vips.get(0);
            JSONArray objects = JSONArray.parseArray(tVip.getCoupon());
            Integer num = 0;
            for (Object object : objects) {
                JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
                Integer number1 = jsonObject.getInteger("number");
                num += number1;
            }
            siteInfoVO.setCouponCount(num);
        }
        siteInfoVO.setChargingPileId(one.getId());
        siteInfoVO.setName(byId.getName());
        siteInfoVO.setNumber(one.getNumber().toString());
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TAccountingStrategyDetailServiceImpl.java
@@ -1,9 +1,13 @@
package com.ruoyi.chargingPile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TAccountingStrategy;
import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail;
@@ -15,6 +19,7 @@
import com.ruoyi.chargingPile.service.ISiteService;
import com.ruoyi.chargingPile.service.TAccountingStrategyDetailService;
import com.ruoyi.chargingPile.service.TChargingGunService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.service.TokenService;
@@ -52,6 +57,8 @@
    private TChargingGunService chargingGunService;
    @Autowired
    private AppUserClient appUserClient;
    @Resource
    private AppUserVipDetailClient vipDetailClient;
    @Override
    public List<TAccountingStrategyDetailVO> queryAccountingStrategyDetailByStrategyId(Integer strategyId) {
        return this.baseMapper.queryAccountingStrategyDetailByStrategyId(strategyId);
@@ -72,7 +79,16 @@
        TAppUser appUser = appUserClient.getUserById(userId).getData();
        if(Objects.nonNull(appUser)){
            // 查询会员信息
            TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
//            TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
            GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
            getAppUserVipDetail.setAppUserId(userId);
            getAppUserVipDetail.setVipId(appUser.getVipId());
            R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
            TAppUserVipDetail data1 = appUserVipDetail.getData();
            String vipJson = data1.getVipJson();
            TVip vip = JSON.parseObject(vipJson, TVip.class);
            TAccountingStrategyDetailVO accountingStrategyDetailVO;
            TAccountingStrategyDetailVO accountingStrategyDetailNext;
            // 获取当前时间段的计费策略明细
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
@@ -93,6 +93,11 @@
        return R.ok(vipService.getById(id));
    }
    @GetMapping(value = "/getVipList")
    public R<List<TVip>> getVipList(){
        return  R.ok(vipService.lambdaQuery().eq(TVip::getReveal, 1).list());
    }
    /**
     * 远程调用
     * @param id