zhibing.pu
2024-08-15 4850df8aa4bf4a3a613b960fae1411255510667e
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
23个文件已修改
1个文件已添加
364 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponListVOVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TMonitoringEquipmentVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkingLotVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TChargingCountQuery.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipClient.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppCouponServiceImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TMonitoringEquipmentMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TParkingLotMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TParkingLotService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TMonitoringEquipmentServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingLotServiceImpl.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TMonitoringEquipmentMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingLotMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponListVOVO.java
@@ -38,4 +38,6 @@
    private BigDecimal payMoney;
    @ApiModelProperty(value = "最高折扣金额 用于判断哪一张优惠券优惠力度最大 前端忽略")
    private BigDecimal money;
    @ApiModelProperty(value = "当前用户是否为会员0否1是 前端忽略")
    private Integer isVip;
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java
@@ -25,4 +25,5 @@
    @PostMapping(value = "/t-charging-pile/getChargingPileBySiteId")
    public R<List<TChargingPile>> getChargingPileBySiteId(@RequestParam("siteId") Integer siteId);
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TMonitoringEquipmentVO.java
@@ -12,4 +12,7 @@
    @ApiModelProperty(value = "停车场名称")
    private String parkingLotName;
    @ApiModelProperty(value = "查看权限")
    private boolean authQueryInfo = true;
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkingLotVO.java
@@ -13,4 +13,18 @@
    @ApiModelProperty(value = "归属电站")
    private String siteName;
    @ApiModelProperty(value = "编辑权限")
    private boolean authUpdate = true;
    @ApiModelProperty(value = "删除权限")
    private boolean authDelete = true;
    @ApiModelProperty(value = "查看权限")
    private boolean authQueryInfo = true;
    @ApiModelProperty(value = "添加权限")
    private boolean authAddParkingLot = true;
    @ApiModelProperty(value = "车场监控权限")
    private boolean authMonitor = true;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
@@ -3,6 +3,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -33,6 +34,11 @@
            public R<TChargingOrder> orderDetail(Long orderId) {
                return R.fail("订单详情:" + throwable.getMessage());
            }
            @Override
            public R<Integer> getChargingCount(TChargingCountQuery req) {
                return R.fail("根据会员id和有效期查询有效期内享受充电折扣次数:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
@@ -4,8 +4,10 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
@@ -20,5 +22,11 @@
    @PostMapping(value = "/t-charging-order/detail")
    R<TChargingOrder> orderDetail(@RequestParam("orderId") Long orderId);
    /**
     * 查询会员在本月有多少次享受了充电折扣
     * @param req
     * @return
     */
    @PostMapping(value = "/t-charging-order/getChargingCount")
    public R<Integer> getChargingCount(@RequestBody TChargingCountQuery req);
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/query/TChargingCountQuery.java
New file
@@ -0,0 +1,21 @@
package com.ruoyi.order.api.query;
import com.ruoyi.common.core.web.page.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
@ApiModel(value = "查询用户在会员期 有多少次享用了充电折扣订单")
public class TChargingCountQuery  {
    @ApiModelProperty(value = "会员开始时间")
    private LocalDateTime startTime;
    @ApiModelProperty(value = "会员结束时间")
    private LocalDateTime endTime;
    @ApiModelProperty(value = "用户id")
    private Long userId;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TVip.java
@@ -134,6 +134,12 @@
    @ApiModelProperty(value = "商城专享价开关(0=否,1=是)")
    @TableField("mall_exclusive_price")
    private Integer mallExclusivePrice;
    @ApiModelProperty(value = "内部会员折扣")
    @TableField("discount")
    private BigDecimal discount;
    @ApiModelProperty(value = "会员类型 1常规 2内部")
    @TableField("type")
    private Integer type;
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipFallbackFactory.java
@@ -28,6 +28,11 @@
                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
@@ -5,6 +5,7 @@
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.api.factory.VipFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -23,5 +24,11 @@
    @PostMapping(value = "/vip/getVipInfoByType")
    R<TVip> getVipInfoByType(@RequestParam("type") Integer type);
    /**
     * 远程调用
     * @param id
     * @return
     */
    @PostMapping("/vip/getInfo1")
    public R<TVip> getInfo1(@RequestParam("id") Integer id);
}
ruoyi-service/ruoyi-account/pom.xml
@@ -21,6 +21,12 @@
            <version>3.6.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>ruoyi-api-chargingPile</artifactId>
            <version>3.6.2</version>
            <scope>compile</scope>
        </dependency>
        <!-- SpringCloud Alibaba Nacos -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -52,9 +52,7 @@
    @ApiOperation(value = "选择优惠券分页查询", tags = {"小程序-扫一扫"})
    @PostMapping(value = "/scan/couponList")
    public AjaxResult<PageInfo<CouponListVOVO>> couponList(@RequestBody CouponListDto dto) {
        // todo token获取用户id
        Long userId = 11L;
        dto.setUserId(userId);
        PageInfo<CouponListVOVO> res = tAppCouponService.couponList(dto);
        return AjaxResult.ok(res);
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppCouponServiceImpl.java
@@ -1,25 +1,38 @@
package com.ruoyi.account.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.dto.CouponListDto;
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.api.query.ExchangeRecordGoodsQuery;
import com.ruoyi.account.api.vo.CouponListVOVO;
import com.ruoyi.account.api.vo.ExchangeRecordVO;
import com.ruoyi.account.mapper.TAppCouponMapper;
import com.ruoyi.account.mapper.TAppUserMapper;
import com.ruoyi.account.service.TAppCouponService;
import com.ruoyi.account.service.TAppUserVipDetailService;
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.feignClient.OrderClient;
import com.ruoyi.order.api.query.TChargingCountQuery;
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 io.swagger.models.auth.In;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@@ -38,6 +51,15 @@
    private OrderClient orderClient;
    @Autowired
    private OtherClient otherClient;
    @Autowired
    private VipClient vipClient;
    @Autowired
    private ChargingPileClient chargingPileClient;
    @Autowired
    private ChargingOrderClient chargingOrderClient;
    @Autowired
    private TAppUserVipDetailService tAppUserVipDetailService;
    @Override
    public PageInfo<ExchangeRecordVO> pagelist(ExchangeRecordGoodsQuery dto) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -105,15 +127,54 @@
        return pageInfo;
    }
    @Autowired
    private TAppUserMapper tAppUserMapper;
    @Override
    public PageInfo<CouponListVOVO> couponList(CouponListDto dto) {
        // todo token获取用户id
        Long userId = 11L;
        dto.setUserId(userId);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        PageInfo<CouponListVOVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        List<CouponListVOVO> list = this.baseMapper.couponList(pageInfo,dto.getUserId());
        TAppUser tAppUser = tAppUserMapper.selectById(dto.getUserId());
        Integer isVip = 0;// 是否能享受会员折扣
        if (tAppUser.getVipEndTime() == null){
            // 不是会员
        }else {
            // 判断会员有没有过期
            if (tAppUser.getVipEndTime().isAfter(java.time.LocalDateTime.now())){
                // 没过期 判断用户本月会员充电折扣次数是否还有剩余
                TAppUserVipDetail tAppUserVipDetail = tAppUserVipDetailService.list(new LambdaQueryWrapper<TAppUserVipDetail>()
                        .orderByDesc(TAppUserVipDetail::getStartTime)).get(0);
                LocalDateTime startTime = tAppUserVipDetail.getStartTime();
                LocalDateTime endTime = tAppUserVipDetail.getEndTime();
                TChargingCountQuery tChargingCountQuery = new TChargingCountQuery();
                tChargingCountQuery.setStartTime(startTime);
                tChargingCountQuery.setEndTime(endTime);
                tChargingCountQuery.setUserId(dto.getUserId());
                // 当月已享受会员折扣充电次数
                Integer data = chargingOrderClient.getChargingCount(tChargingCountQuery).getData();
                // 查询用户当前会员每月享受折扣次数和折扣比例是多少
                Integer vipId = tAppUser.getVipId();
                TVip data1 = vipClient.getInfo1(vipId).getData();
                Integer discountTimes = data1.getDiscountTimes();
                if (data>=discountTimes){
                    // 不能再享受会员折扣
                }else{
                    isVip = 1;
                }
            }
        }
        for (CouponListVOVO couponListVOVO : list) {
            couponListVOVO.setValidityTime("有效期:"+format.format(couponListVOVO.getCreateTime())+" - "+format.format(couponListVOVO.getEndTime()));
        }
        List<CouponListVOVO> data = otherClient.getCouponInfoByCouponIds(list).getData();
        for (CouponListVOVO datum : data) {
            // 根据当前时间段和预付金额计算服务费
        }
        pageInfo.setRecords(data);
        return pageInfo;
    }
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingLotController.java
@@ -62,9 +62,8 @@
     */
    @ApiOperation(tags = {"后台-停车场"},value = "查询停车场列表")
    @PostMapping(value = "/list")
    public AjaxResult<List<TParkingLot>> list(@RequestBody TParkingLotQuery query) {
        return AjaxResult.ok(parkingLotService.list(Wrappers.lambdaQuery(TParkingLot.class)
                .eq(TParkingLot::getName,query.getName())));
    public AjaxResult<List<TParkingLotVO>> list(@RequestBody TParkingLotQuery query) {
        return AjaxResult.ok(parkingLotService.getList(query.getName()));
    }
    /**
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TMonitoringEquipmentMapper.java
@@ -27,5 +27,5 @@
     * @param pageInfo
     * @return
     */
    List<TMonitoringEquipmentVO> pageList(@Param("query") TMonitoringEquipmentQuery query, @Param("pageInfo")PageInfo<TMonitoringEquipmentVO> pageInfo);
    List<TMonitoringEquipmentVO> pageList(@Param("query") TMonitoringEquipmentQuery query, @Param("pageInfo")PageInfo<TMonitoringEquipmentVO> pageInfo,@Param("parkingLotIds")List<Integer> parkingLotIds);
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TParkingLotMapper.java
@@ -9,6 +9,7 @@
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
 * <p>
@@ -27,5 +28,14 @@
     * @param pageInfo
     * @return
     */
    List<TParkingLotVO> pageList(@Param("query") TParkingLotQuery query, @Param("pageInfo")PageInfo<TParkingLotVO> pageInfo);
    List<TParkingLotVO> pageList(@Param("query") TParkingLotQuery query, @Param("pageInfo")PageInfo<TParkingLotVO> pageInfo, @Param("siteIds") Set<Integer> siteIds);
    /**
     * 获取停车场列表
     * @param name
     * @param siteIds
     * @return
     */
    List<TParkingLotVO> getList(@Param("name")String name, @Param("siteIds")Set<Integer> siteIds);
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TParkingLotService.java
@@ -6,6 +6,8 @@
import com.ruoyi.chargingPile.api.vo.TParkingLotVO;
import com.ruoyi.common.core.web.page.PageInfo;
import java.util.List;
/**
 * <p>
 * 停车场 服务类
@@ -22,4 +24,11 @@
     * @return
     */
    PageInfo<TParkingLotVO> pageList(TParkingLotQuery query);
    /**
     * 查询停车场列表
     * @param name
     * @return
     */
    List<TParkingLotVO> getList(String name);
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TMonitoringEquipmentServiceImpl.java
@@ -5,12 +5,24 @@
import com.ruoyi.chargingPile.api.query.TMonitoringEquipmentQuery;
import com.ruoyi.chargingPile.api.vo.TMonitoringEquipmentVO;
import com.ruoyi.chargingPile.api.vo.TParkingLotVO;
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.mapper.TMonitoringEquipmentMapper;
import com.ruoyi.chargingPile.service.IPartnerService;
import com.ruoyi.chargingPile.service.TMonitoringEquipmentService;
import com.ruoyi.chargingPile.service.TParkingLotService;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.other.api.feignClient.RoleSiteClient;
import com.ruoyi.other.api.feignClient.UserSiteClient;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
 * <p>
@@ -22,11 +34,31 @@
 */
@Service
public class TMonitoringEquipmentServiceImpl extends ServiceImpl<TMonitoringEquipmentMapper, TMonitoringEquipment> implements TMonitoringEquipmentService {
    @Resource
    private SysUserClient sysUserClient;
    @Resource
    private IPartnerService partnerService;
    @Resource
    private TParkingLotService parkingLotService;
    @Override
    public PageInfo<TMonitoringEquipmentVO> pageList(TMonitoringEquipmentQuery query) {
        //校验合作商权限
        SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
        Integer roleType = sysUser.getRoleType();
        Integer objectId = sysUser.getObjectId();
        // 查询管理站点下的停车场
        List<TParkingLotVO> parkingLotVOS = parkingLotService.getList(null);
        List<Integer> parkingLotIds = parkingLotVOS.stream().map(TParkingLotVO::getId).collect(Collectors.toList());
        PageInfo<TMonitoringEquipmentVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
        List<TMonitoringEquipmentVO> list = this.baseMapper.pageList(query,pageInfo);
        List<TMonitoringEquipmentVO> list = this.baseMapper.pageList(query,pageInfo,parkingLotIds);
        for (TMonitoringEquipmentVO monitoringEquipmentVO : list) {
            Integer siteId = parkingLotVOS.stream().filter(park->park.getId().equals(monitoringEquipmentVO.getParkingLotId())).findFirst().get().getSiteId();
            monitoringEquipmentVO.setAuthQueryInfo(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_MONITOR));
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingLotServiceImpl.java
@@ -1,15 +1,26 @@
package com.ruoyi.chargingPile.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO;
import com.ruoyi.chargingPile.api.model.TParkingLot;
import com.ruoyi.chargingPile.api.query.TParkingLotQuery;
import com.ruoyi.chargingPile.api.vo.TParkingLotVO;
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.mapper.TParkingLotMapper;
import com.ruoyi.chargingPile.service.IPartnerService;
import com.ruoyi.chargingPile.service.TParkingLotService;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.other.api.feignClient.RoleSiteClient;
import com.ruoyi.other.api.feignClient.UserSiteClient;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
 * <p>
@@ -21,12 +32,70 @@
 */
@Service
public class TParkingLotServiceImpl extends ServiceImpl<TParkingLotMapper, TParkingLot> implements TParkingLotService {
    @Resource
    private SysUserClient sysUserClient;
    @Resource
    private IPartnerService partnerService;
    @Resource
    private UserSiteClient userSiteClient;
    @Resource
    private RoleSiteClient roleSiteClient;
    @Override
    public PageInfo<TParkingLotVO> pageList(TParkingLotQuery query) {
        Set<Integer> siteIds = null;
        //校验合作商权限
        SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
        Integer roleType = sysUser.getRoleType();
        Integer objectId = sysUser.getObjectId();
        //合作商
        if(roleType == 2){
            siteIds = partnerService.authSite(objectId, SiteMenu.PARKING_LOT);
        }else{
            //非管理员需要根据角色和用户配置查询允许的站点数据
            if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
                List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
                List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData();
                data.addAll(data1);
                siteIds = new HashSet<>(data);
            }
        }
        PageInfo<TParkingLotVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
        List<TParkingLotVO> list = this.baseMapper.pageList(query,pageInfo);
        List<TParkingLotVO> list = this.baseMapper.pageList(query,pageInfo,siteIds);
        for (TParkingLotVO parkingLotVO : list) {
            Integer siteId = parkingLotVO.getSiteId();
            parkingLotVO.setAuthAddParkingLot(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_ADD_GARAGE));
            parkingLotVO.setAuthDelete(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_DELETE));
            parkingLotVO.setAuthQueryInfo(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_QUERY_INFO));
            parkingLotVO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_UPDATE));
            parkingLotVO.setAuthMonitor(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.PARKING_LOT_MONITOR));
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public List<TParkingLotVO> getList(String name) {
        Set<Integer> siteIds = null;
        //校验合作商权限
        SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
        Integer roleType = sysUser.getRoleType();
        Integer objectId = sysUser.getObjectId();
        //合作商
        if(roleType == 2){
            siteIds = partnerService.authSite(objectId, SiteMenu.PARKING_LOT);
        }else{
            //非管理员需要根据角色和用户配置查询允许的站点数据
            if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
                List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
                List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData();
                data.addAll(data1);
                siteIds = new HashSet<>(data);
            }
        }
        return this.baseMapper.getList(name,siteIds);
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TMonitoringEquipmentMapper.xml
@@ -27,6 +27,12 @@
            <if test="query.parkingLotId != null">
                AND tme.parking_lot_id = #{query.parkingLotId}
            </if>
            <if test="parkingLotIds != null and parkingLotIds.size()>0">
                AND tme.parking_lot_id IN
                <foreach collection="parkingLotIds" item="parkingLotId" open="(" separator="," close=")">
                    #{parkingLotId}
                </foreach>
            </if>
            AND tme.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        </where>
        ORDER BY tme.create_time DESC
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingLotMapper.xml
@@ -39,9 +39,32 @@
            <if test="query.siteId != null">
                AND tpl.site_id = #{query.siteId}
            </if>
            <if test="null != siteIds and siteIds.size() > 0">
                and tcg.site_id in
                <foreach collection="siteIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            AND tpl.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        </where>
        ORDER BY tpl.create_time DESC
    </select>
    <select id="getList" resultType="com.ruoyi.chargingPile.api.vo.TParkingLotVO">
        select <include refid="Base_Column_List"></include>
        from t_parking_lot
        <where>
            <if test="name != null and name != ''">
                AND `name` LIKE concat('%',#{name},'%')
            </if>
            <if test="null != siteIds and siteIds.size() > 0">
                and site_id in
                <foreach collection="siteIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        </where>
        ORDER BY create_time DESC
    </select>
</mapper>
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -1,14 +1,13 @@
package com.ruoyi.order.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.service.TChargingOrderService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -27,6 +26,20 @@
    @Resource
    private TChargingOrderService chargingOrderService;
    /**
     * 查询会员在本月有多少次享受了充电折扣
     * @param req
     * @return
     */
    @PostMapping(value = "/getChargingCount")
    public R<Integer> getChargingCount(@RequestBody TChargingCountQuery req) {
        int size = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
                .eq(TChargingOrder::getAppUserId, req.getUserId())
                        .eq(TChargingOrder::getRechargePaymentStatus,2)
                .between(TChargingOrder::getStartTime, req.getStartTime(), req.getEndTime())).size();
        return R.ok(size);
    }
    //用户订单数量
    @PostMapping(value = "/useOrderCount")
    public R<Long> useOrderCount(@RequestParam("userId") Long userId) {
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java
@@ -124,29 +124,6 @@
            TCoupon byId = tCouponService.getById(couponListVOVO.getCouponId());
            BeanUtils.copyProperties(byId,couponListVOVO);
            couponListVOVO.setCouponName(byId.getName());
            // 根据预付金额 判断是否满足
            if (byId.getMeetTheConditions().compareTo(BigDecimal.ZERO) == 0){
                // 无门槛
                couponListVOVO.setIsUse(1);
            }else if (couponListVOVO.getPayMoney().compareTo(byId.getMeetTheConditions()) < 0){
                couponListVOVO.setIsUse(0);
            }else{
                couponListVOVO.setIsUse(1);
            }
            // 根据优惠券类型和预付金额 判断哪一个优惠券减免的金额最大 将其排在第一位
            if (couponListVOVO.getIsUse() == 1){
                switch (byId.getPreferentialMode()){
                    case 1:
                            couponListVOVO.setMoney(byId.getDiscountAmount());
                        break;
                    case 2:
                        break;
                }
            }else{
                couponListVOVO.setMoney(BigDecimal.ZERO);
            }
        }
        return R.ok(list);
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
@@ -56,6 +56,16 @@
    public AjaxResult<TVip> getInfo(Integer id) {
        return AjaxResult.ok(vipService.getById(id));
    }
    /**
     * 远程调用
     * @param id
     * @return
     */
    @PostMapping("/getInfo1")
    public R<TVip> getInfo1(@RequestParam("id")Integer id) {
        return R.ok(vipService.getById(id));
    }
    @ApiOperation(value = "会员列表分页查询")
    @PostMapping(value = "/pageList")
    @ApiImplicitParams({