ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserIntegralChangeClient.java
@@ -22,7 +22,7 @@ * @return */ @PostMapping("/t-app-user-integral-change/addAppUserIntegralChange") R addAppUserIntegralChange(TAppUserIntegralChange appUserIntegralChange); R addAppUserIntegralChange(@RequestBody TAppUserIntegralChange appUserIntegralChange); /** @@ -30,6 +30,6 @@ * @param code * @return */ @PostMapping("/t-app-user-integral-change/addAppUserIntegralChange") @PostMapping("/t-app-user-integral-change/getTAppUserIntegralChangeByOrderCode") R<TAppUserIntegralChange> getTAppUserIntegralChangeByOrderCode(@RequestParam("code") String code); } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppCoupon.java
@@ -34,6 +34,8 @@ @ApiModelProperty(value = "主键") @TableId("id") private Long id; @TableField(exist = false) private String uid; @ApiModelProperty(value = "用户id") @TableField("app_user_id") ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java
@@ -106,4 +106,6 @@ private String orderId; @TableField(exist = false) private String userId; @TableField(exist = false) private String uid; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -695,6 +695,7 @@ @GetMapping(value = "/user/coupon/getById") public R<TAppCoupon> couponGetById(@RequestParam("id")Long id) { TAppCoupon appCoupon = appCouponService.getById(id); appCoupon.setUid(id.toString()); return R.ok(appCoupon); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TInviteUserController.java
@@ -38,7 +38,7 @@ */ @PostMapping("/getInviteUser") public R<TInviteUser> getInviteUser(@RequestBody GetInviteUser query){ TInviteUser one = inviteUserService.getOne(new LambdaQueryWrapper<TInviteUser>().eq(TInviteUser::getAppUserId, query.getBeInvitedAppUserId()) TInviteUser one = inviteUserService.getOne(new LambdaQueryWrapper<TInviteUser>().eq(TInviteUser::getAppUserId, query.getAppUserId()) .eq(TInviteUser::getBeInvitedAppUserId, query.getBeInvitedAppUserId())); return R.ok(one); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WxLoginController.java
@@ -71,8 +71,8 @@ /** * 上传文件存储在本地的根路径 */ @Value("${file.upload.location}") private String localFilePath; // @Value("${file.upload.location}") // private String localFilePath; ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml
@@ -46,7 +46,7 @@ enabled: true application-id: ${spring.application.name} tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 enable-auto-data-source-proxy: true enable-auto-data-source-proxy: false service: vgroup-mapping: seata_tx_group: default ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -181,7 +181,7 @@ payOrderInfoDto.setTradeNo(byId.getRechargeSerialNumber()); payOrderInfoDto.setPayType(byId.getRechargePaymentType()); payOrderInfoDto.setPayAmount(byId.getPaymentAmount()); payOrderInfoDto.setPayTime(byId.getPayTime()); payOrderInfoDto.setPayTime(byId.getCreateTime()); payOrderInfoDto.setRefundAmount(byId.getRefundAmount()); return R.ok(payOrderInfoDto); case 2: @@ -192,7 +192,7 @@ payOrderInfoDto1.setTradeNo(byId1.getSerialNumber()); payOrderInfoDto1.setPayType(byId1.getPaymentType()); payOrderInfoDto1.setPayAmount(byId1.getPaymentAmount()); payOrderInfoDto1.setPayTime(byId1.getPayTime()); payOrderInfoDto1.setPayTime(byId1.getCreateTime()); payOrderInfoDto1.setRefundAmount(byId1.getRefundAmount()); return R.ok(payOrderInfoDto1); case 3: @@ -203,7 +203,7 @@ payOrderInfoDto2.setTradeNo(byId2.getSerialNumber()); payOrderInfoDto2.setPayType(byId2.getPaymentType()); payOrderInfoDto2.setPayAmount(byId2.getPaymentAmount()); payOrderInfoDto2.setPayTime(byId2.getPayTime()); payOrderInfoDto2.setPayTime(byId2.getCreateTime()); payOrderInfoDto2.setRefundAmount(byId2.getRefundAmount()); return R.ok(payOrderInfoDto2); //todo luo 停车场订单 @@ -278,7 +278,11 @@ @PostMapping(value = "/pay/order/refund/list") @ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"}) public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) { return chargingOrderService.getRefundList(chargingRefundDto); R<PageInfo<TChargingOrderRefund>> refundList = chargingOrderService.getRefundList(chargingRefundDto); for (TChargingOrderRefund record : refundList.getData().getRecords()) { record.setUid(record.getId().toString()); } return refundList; } @ResponseBody @@ -781,6 +785,7 @@ LocalDate end = null; if (statisticsQueryDto.getDayType()==1){ start = LocalDate.now(); end = LocalDate.now().plusDays(1); }else if (statisticsQueryDto.getDayType()==2){ LocalDate today = LocalDate.now(); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderEvaluateController.java
@@ -127,7 +127,7 @@ @ApiImplicitParam(value = "订单id", name = "orderId", required = true), @ApiImplicitParam(value = "订单类型(1=充电订单,2=购物订单,3=兑换订单,4=会员订单)", name = "orderType", required = true), }) public AjaxResult<OrderEvaluateVo> getOrderEvaluate(@PathVariable Integer orderId, Integer orderType){ public AjaxResult<OrderEvaluateVo> getOrderEvaluate(Integer orderId, Integer orderType){ OrderEvaluateVo orderEvaluate = orderEvaluateService.getOrderEvaluate(orderId, orderType); return AjaxResult.success(orderEvaluate); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -651,116 +651,10 @@ log.error(chargingOrder.getCode() + ":-------------------远程调起开始充电请求-------------------" + platformStartCharging.toString()); sendMessageClient.platformStartCharging(platformStartCharging); //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 Long id = chargingOrder.getId(); //执行5分钟的定时任务检测 ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(()->{ if(timingDetection(id)){ scheduler.shutdown(); } }, 5, 1, TimeUnit.SECONDS); return AjaxResult.success(); } /** * 定时检测mongodb数据库数据 * @param id * @return */ public boolean timingDetection(Long id){ TChargingOrder chargingOrder = this.getById(id); if(chargingOrder.getStatus() != 2){ return true; } String code = chargingOrder.getCode(); String key = "AQJC_" + chargingOrder.getChargingGunId(); //获取安全校验 com.ruoyi.integration.api.model.SecurityDetection securityDetection = securityDetectionClient.getSecurityDetection(chargingOrder.getCode()).getData(); if(null != securityDetection){ PreChargeCheck preChargeCheck1 = redisService.getCacheObject("AQJC_" + chargingOrder.getChargingGunId()); if(null != preChargeCheck1){ preChargeCheck1.setElectronicLockLock(true); preChargeCheck1.setInsulationTesting(true); preChargeCheck1.setSecureConnectionDetection(securityDetection.getSecure_connection() == 1); preChargeCheck1.setStartupSuccess(1); redisService.setCacheObject("AQJC_" + chargingOrder.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); } } List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData(); if(null == data){ return false; } log.error(code + ":-------------------开始检查调起充电结果-------------------" + data.toString()); if(data.size() != 0){ PlatformStartChargingReply platformStartChargingReply = data.get(1); Integer startup_result = platformStartChargingReply.getStartup_result(); Integer failure_cause = platformStartChargingReply.getFailure_cause(); Integer counter = counter_map.get(code); PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); //5分钟内还未插枪则取消充电,退回金额。 if(failure_cause == 5 && (null == counter || counter < 300)){ counter = (null == counter ? 0 : counter) + 1; counter_map.put(code, counter); //启动失败 preChargeCheck1.setStartupSuccess(3); preChargeCheck1.setFailureCause(failure_cause); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); return false; } //清除计时器中的无效数据 counter_map.remove(code); TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); if(0 == startup_result){ //启动失败 preChargeCheck1.setStartupSuccess(3); preChargeCheck1.setFailureCause(failure_cause); //启动失败后取消订单,退款操作 refund(code); order.setStatus(-1); order.setEndMode(0); }else{ //启动成功 preChargeCheck1.setStartupSuccess(2); order.setStatus(3); order.setStartTime(LocalDateTime.now()); } this.updateById(order); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); return true; }else{ Integer counter = boot_failed_map.get(code); log.error(code + ":-------------------未上传开启充电结果-------------------" + counter); PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); //5分钟内未启动成功,退回金额。 if(null == counter || counter < 300){ counter = (null == counter ? 0 : counter) + 1; boot_failed_map.put(code, counter); //启动失败 preChargeCheck1.setStartupSuccess(3); preChargeCheck1.setFailureCause(0); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); return false; } //清除计时器中的无效数据 boot_failed_map.remove(code); TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); //启动失败 preChargeCheck1.setStartupSuccess(3); preChargeCheck1.setFailureCause(0); //启动失败后取消订单,退款操作 refund(code); order.setStatus(-1); order.setEndMode(0); this.updateById(order); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); return true; } } /** @@ -927,7 +821,7 @@ if(null != data){ chargingDetails.setChargeCurrent(data.getOutput_current()); chargingDetails.setChargeVoltage(data.getOutput_voltage()); BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000)); BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000), new MathContext(4, RoundingMode.HALF_EVEN)); chargingDetails.setChargePower(power); chargingDetails.setCompletionRatio(data.getSoc()); chargingDetails.setRemainingChargeTime(data.getTime_remaining()); @@ -982,70 +876,6 @@ sendMessageClient.platformStopCharging(platformStopCharging); log.error(code1 + ":-------------------远程停止充电请求-------------------"); log.error(platformStopCharging.toString()); //开始查询停机应答,成功后开始计费费用 boolean stop_status = false; for (int i = 0; i < 60; i++) { TChargingOrder chargingOrder1 = this.getById(id); if(chargingOrder1.getStatus() != 3){ stop_status = true; break; } GetPlatformStopChargingReply query = new GetPlatformStopChargingReply(); query.setCharging_gun_code(chargingGun.getCode()); query.setCharging_pile_code(chargingPile.getCode()); //将时间转换成UTC时间后查询数据(mongodb存储时间以UTC格式存储) ZoneId zoneId = ZoneId.systemDefault(); ZonedDateTime zonedDateTime = ZonedDateTime.of(chargingOrder.getEndTime(), zoneId); ZonedDateTime endTime = zonedDateTime.withZoneSameInstant(ZoneId.of("UTC")); query.setEnd_time(endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); PlatformStopChargingReply reply = platformStopChargingReplyClient.getPlatformStopChargingReply(query).getData(); log.error(code1 + ":-------------------查询远程停止充电应答-------------------"); if(null == reply){ log.error(code1 + ":-------------------远程停止充电应答无数据-------------------"); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } continue; } log.error(reply.toString()); if(0 == reply.getStop_result()){ String failure_cause = ""; switch (reply.getFailure_cause()){ case 0: failure_cause = "无"; break; case 1: failure_cause = "设备编号不匹配"; break; case 2: failure_cause = "枪未处于充电状态"; break; case 3: failure_cause = "其他"; break; } log.error(code1 + ":停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } }else{ log.error(code1 + ":-------------------远程停止充电请求成功-------------------"); stop_status = true; break; } } if(stop_status){ chargingOrder.setEndMode(1); this.updateById(chargingOrder); }else{ log.error(code1 + ":-------------------远程停止充电应答最终失败-------------------"); } }); return AjaxResult.success(); } @@ -1786,11 +1616,6 @@ return; } //计算用户标签 editUserTag(chargingOrder); //用户推荐奖励 referralReward(chargingOrder); //如果使用优惠券需要判断优惠券是否满足使用条件 //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) //退款金额=优惠券金额+剩余充电金额 @@ -1882,7 +1707,8 @@ if(null != chargingOrder.getVipDiscount()){ //服务费折扣 discountAmount = periodServicePrice_total.multiply((new BigDecimal(1).subtract(chargingOrder.getVipDiscount()))); periodServicePrice_total = periodServicePrice_total.multiply(chargingOrder.getVipDiscount()); TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); if(null != appUser.getVipId()){ //判断会员是否还有充电优惠次数 @@ -1935,9 +1761,17 @@ if(1 == preferentialMode){ //满减 if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ refundAmount = refundAmount.add(tCoupon.getDiscountAmount()); order.setCouponDiscountAmount(tCoupon.getDiscountAmount()); payAmount = payAmount.subtract(tCoupon.getDiscountAmount()); BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); //如果优惠金额大于服务费金额,以服务费作为最大限制 if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ refundAmount = refundAmount.add(periodServicePrice_total); order.setCouponDiscountAmount(periodServicePrice_total); payAmount = payAmount.subtract(periodServicePrice_total); }else{ refundAmount = refundAmount.add(couponDiscountAmount); order.setCouponDiscountAmount(couponDiscountAmount); payAmount = payAmount.subtract(couponDiscountAmount); } }else{ order.setAppCouponId(null); order.setCouponDiscountAmount(BigDecimal.ZERO); @@ -1950,9 +1784,16 @@ //折扣金额 BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10)); divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; refundAmount = refundAmount.add(divide); order.setCouponDiscountAmount(divide); payAmount = payAmount.subtract(divide); //如果优惠金额大于服务费金额,以服务费作为最大限制 if(periodServicePrice_total.compareTo(divide) < 0){ refundAmount = refundAmount.add(periodServicePrice_total); order.setCouponDiscountAmount(periodServicePrice_total); payAmount = payAmount.subtract(periodServicePrice_total); }else{ refundAmount = refundAmount.add(divide); order.setCouponDiscountAmount(divide); payAmount = payAmount.subtract(divide); } }else{ order.setAppCouponId(null); order.setCouponDiscountAmount(BigDecimal.ZERO); @@ -2000,7 +1841,11 @@ appUserClient.updateAppUser(appUser); appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); } //计算用户标签 editUserTag(chargingOrder); //用户推荐奖励 referralReward(chargingOrder); //开始构建退款费用 if(refundAmount.compareTo(BigDecimal.ZERO) > 0){ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -153,7 +153,9 @@ discount = discount.add(tActivityStatisticslVO.getVipDiscountAmount()); stringBuilder1.append("会员抵扣").append("+"); } stringBuilder1.deleteCharAt(stringBuilder1.length()-1); if (stringBuilder1.length()>0){ stringBuilder1.deleteCharAt(stringBuilder1.length()-1); } tActivityStatisticslVO.setType(stringBuilder1.toString()); tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime()); break; ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -52,7 +52,7 @@ <select id="getMyChargingOrderList" resultMap="BaseResultMap"> select * from t_charging_order where del_flag = 0 and app_user_id = #{appUserId} select * from t_charging_order where del_flag = 0 and app_user_id = #{appUserId} and recharge_payment_status = 2 <if test="1 == type"> and id not in (select order_id from t_order_evaluate where order_type = 1 and app_user_id = #{appUserId} and del_flag = 0) </if> ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -107,13 +107,13 @@ and t2.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="req.type != null and req.type != '' and req.type == 1"> and t2.coupon_discount_amount IS NOT NULL and t2.coupon_discount_amount != 0 and (t2.coupon_discount_amount > 0) </if> <if test="req.type != null and req.type != '' and req.type == 2"> and t2.vip_discount_amount IS NOT NULL and t2.vip_discount_amount != 0 and ( t2.vip_discount_amount > 0) </if> <if test="req.type == null "> and t2.vip_discount_amount IS NOT NULL and t2.vip_discount_amount != 0 and t2.coupon_discount_amount IS NOT NULL and t2.coupon_discount_amount != 0 and (t2.vip_discount_amount > 0 or t2.coupon_discount_amount > 0) </if> <if test="null != req.userIds and req.userIds.size()>0" > and t2.app_user_id in @@ -124,7 +124,6 @@ <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''"> AND (t2.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59')) </if> and t2.refund_status !=2 and t2.payment_status =2 AND t2.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} </if> ruoyi-service/ruoyi-order/src/test/java/com/ruoyi/order/RuoYiOrderApplicationTests.java
@@ -1,15 +1,37 @@ package com.ruoyi.order; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.account.api.feignClient.*; import com.ruoyi.account.api.model.TAppUserCar; import com.ruoyi.chargingPile.api.feignClient.*; import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.chargingPile.api.model.TChargingGun; import com.ruoyi.chargingPile.api.model.TChargingPile; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.integration.api.feignClient.*; import com.ruoyi.integration.api.model.ChargingHandshake; import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; import com.ruoyi.order.api.model.TChargingOrder; import com.ruoyi.order.dto.ChargingDetails; import com.ruoyi.order.dto.MyChargingOrderInfo; import com.ruoyi.order.service.TChargingOrderService; import com.ruoyi.order.mapper.TSettlementConfirmMapper; import com.ruoyi.order.service.*; import com.ruoyi.other.api.feignClient.IntegralRuleClient; import com.ruoyi.other.api.feignClient.UserTagClient; import com.ruoyi.other.api.feignClient.VipClient; import com.ruoyi.payment.api.feignClient.AliPaymentClient; import com.ruoyi.payment.api.feignClient.WxPaymentClient; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import javax.annotation.Resource; import java.io.PrintWriter; import java.math.BigDecimal; import java.util.Arrays; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = RuoYiOrderApplication.class) public class RuoYiOrderApplicationTests { @@ -17,10 +39,137 @@ @Resource private TChargingOrderService chargingOrderService; @Resource private ChargingGunClient chargingGunClient; @Resource private TSettlementConfirmMapper tSettlementConfirmMapper; @Resource private SiteClient siteClient; @Resource private AppUserCarClient appUserCarClient; @Resource private AppUserClient appUserClient; @Resource private ChargingPileClient chargingPileClient; @Resource private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService; @Resource private TokenService tokenService; @Resource private WxPaymentClient wxPaymentClient; @Resource private AliPaymentClient aliPaymentClient; @Resource private AppCouponClient appCouponClient; @Resource private AppUserVipDetailClient appUserVipDetailClient; @Resource private RedisService redisService; @Resource private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; @Resource private ChargingHandshakeClient chargingHandshakeClient; @Resource private SendMessageClient sendMessageClient; @Resource private TOrderEvaluateService orderEvaluateService; @Resource private AccountingStrategyDetailClient accountingStrategyDetailClient; @Resource private AccountingStrategyDetailOrderClient accountingStrategyDetailOrderClient; @Resource private AccountingStrategyClient accountingStrategyClient; @Resource private PlatformStartChargingReplyClient platformStartChargingReplyClient; @Resource private TChargingOrderRefundService chargingOrderRefundService; @Resource private PlatformStopChargingReplyClient platformStopChargingReplyClient; @Resource private AccountingStrategyOrderService accountingStrategyOrderService; @Resource private AccountingStrategyDetailOrderService accountingStrategyDetailOrderService; @Resource private InviteUserClient inviteUserClient; @Resource private AppUserIntegralChangeClient appUserIntegralChangeClient; @Resource private IntegralRuleClient integralRuleClient; @Resource private VipClient vipClient; @Resource private UserTagClient userTagClient; @Resource private AppUserTagClient appUserTagClient; @Resource private SecurityDetectionClient securityDetectionClient; @Test public void test(){ ChargingDetails chargingDetails = chargingOrderService.getChargingDetails(75); Integer id = 75; TChargingOrder one = chargingOrderService.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, 1839480334642704385L).eq(TChargingOrder::getChargingGunId, id) .eq(TChargingOrder::getRechargePaymentStatus, 2).eq(TChargingOrder::getDelFlag, 0).orderByDesc(TChargingOrder::getStartTime).last(" limit 0, 1")); ChargingDetails chargingDetails = new ChargingDetails(); chargingDetails.setId(one.getId().toString()); TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); Site site = siteClient.getSiteByIds(Arrays.asList(chargingPile.getSiteId())).getData().get(0); chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); chargingDetails.setCode(one.getCode()); chargingDetails.setStatus(one.getStatus()); chargingDetails.setChargingCost(one.getResidualAmount()); UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(one.getCode()).getData(); if(null != data){ chargingDetails.setChargeCurrent(data.getOutput_current()); chargingDetails.setChargeVoltage(data.getOutput_voltage()); BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000)); chargingDetails.setChargePower(power); chargingDetails.setCompletionRatio(data.getSoc()); chargingDetails.setRemainingChargeTime(data.getTime_remaining()); chargingDetails.setChargedDegrees(data.getCharging_degree()); Integer h = Integer.valueOf(data.getCumulative_charging_time() / 60); Integer m = Integer.valueOf(data.getCumulative_charging_time() % 60); chargingDetails.setChargedTime(String.format("%02d", h) + ":" + String.format("%02d", m)); } ChargingHandshake chargingHandshake = chargingHandshakeClient.getDataByOrderCode(one.getCode()).getData(); if(null != chargingHandshake && null != data && null != one.getAppUserCarId()){ BigDecimal bms_battery_capacity = chargingHandshake.getBms_battery_capacity(); TAppUserCar appUserCar = appUserCarClient.getCarByIds(Arrays.asList(one.getAppUserCarId())).getData().get(0); // 续航 = 电池容量 / 续航里程 * soc BigDecimal divide = bms_battery_capacity.divide(new BigDecimal(appUserCar.getEndurance())); BigDecimal multiply = new BigDecimal(data.getSoc() / 100).multiply(divide); chargingDetails.setEndurance(multiply); } System.err.println(JSON.toJSONString(chargingDetails)); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -131,14 +131,20 @@ if (byId==null||byId.getStatus()==2){ return R.fail(2,"该商品已不存在"); } return R.ok(byId);} // List<Integer> data = orderClient.getSalesCountByGoodsId(String.valueOf(id)).getData(); // for (int i = 0; i < list.size(); i++) { // list.get(i).setSalesCount(data.get(i)); // } return R.ok(byId); } else { TCoupon byId = couponService.getById(id); if (byId==null||byId.getStatus()==2){ return R.fail(2,"该商品已不存在"); } return R.ok(byId); } return R.ok(byId); } } @@ -209,8 +215,10 @@ return AjaxResult.error("当前用户已兑换"+count+"张"); }else { //减少库存 good.setInventory(good.getInventory()-exchangeDto.getNum()); goodsService.updateById(good); if (good.getInventory()!=-1) { good.setInventory(good.getInventory() - exchangeDto.getNum()); goodsService.updateById(good); } } if (user.getPoints()<good.getRedeemPoints()){ return AjaxResult.error("当前用户积分不足"); @@ -226,8 +234,10 @@ if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); }else { coupon.setInventoryQuantity(coupon.getInventoryQuantity()-1); couponService.updateById(coupon); if (coupon.getInventoryQuantity()!=-1) { coupon.setInventoryQuantity(coupon.getInventoryQuantity() - 1); couponService.updateById(coupon); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java
@@ -83,10 +83,10 @@ // 订单号加上商品类型 String res = string+"-"+dto.getType(); // List<Integer> data = orderClient.getSalesCountByGoodsId(res).getData(); // for (int i = 0; i < list.size(); i++) { // list.get(i).setSalesCount(data.get(i)); // } List<Integer> data = orderClient.getSalesCountByGoodsId(res).getData(); for (int i = 0; i < list.size(); i++) { list.get(i).setSalesCount(data.get(i)); } pageInfo.setRecords(list); return pageInfo; }