| | |
| | | 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.*; |
| | |
| | | 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.*; |
| | | |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private AppUserVipDetailClient vipDetailClient; |
| | | |
| | | /** |
| | | * 根据站点id 查询所有充电桩 |
| | |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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()); |