Browse Source

fix bug 前端用户权益id传值问题

skyline 2 years ago
parent
commit
c53be6cc68

+ 2 - 2
miniapp/src/main/java/com/kym/miniapp/controller/ChargerController.java

@@ -93,12 +93,12 @@ public class ChargerController {
     @ApiLog("启动充电")
     @GetMapping("/startCharge/{connectorId}")
     R<?> startCharge(@PathVariable("connectorId") String connectorId,
-                     @RequestParam(value = "rechargeRightsId", required = false) Long rechargeRightsId,
+                     @RequestParam(value = "rechargeRightsId", required = false) Long userRechargeRightsId,
                      @RequestParam(value = "isBooking", defaultValue = "false") Boolean isBooking,
                      @RequestParam(value = "startTime", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
                      @RequestParam(value = "endTime", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
         var userId = StpUtil.getLoginIdAsLong();
-        return R.success(chargeService.queryStartCharge(userId, connectorId, rechargeRightsId, isBooking, startTime, endTime));
+        return R.success(chargeService.queryStartCharge(userId, connectorId, userRechargeRightsId, isBooking, startTime, endTime));
     }
 
     @ApiLog("取消预约充电")

+ 1 - 1
service/src/main/java/com/kym/service/miniapp/ChargeService.java

@@ -14,7 +14,7 @@ import java.util.Map;
  */
 public interface ChargeService {
 
-    Map<String, String> queryStartCharge(Long userId, String connectorId, Long rechargeRightsId, Boolean isBooking, LocalDateTime startTime, LocalDateTime endTime);
+    Map<String, String> queryStartCharge(Long userId, String connectorId, Long userRechargeRightsId, Boolean isBooking, LocalDateTime startTime, LocalDateTime endTime);
 
     @DS("db-admin")
     void updateEquipmentStatus(String connectorId);

+ 5 - 5
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -163,7 +163,7 @@ public class ChargeServiceImpl implements ChargeService {
      * 启动充电
      *
      * @param connectorId
-     * @param rechargeRightsId
+     * @param userRechargeRightsId
      * @param isBooking
      * @param startTime
      * @param endTime
@@ -171,7 +171,7 @@ public class ChargeServiceImpl implements ChargeService {
      */
     @Override
     @DSTransactional(rollbackFor = Exception.class)
-    public Map<String, String> queryStartCharge(Long userId, String connectorId, Long rechargeRightsId, Boolean isBooking, LocalDateTime startTime, LocalDateTime endTime) {
+    public Map<String, String> queryStartCharge(Long userId, String connectorId, Long userRechargeRightsId, Boolean isBooking, LocalDateTime startTime, LocalDateTime endTime) {
         if (isBooking) {
             // 预约时间不能超过未来24H
             if (TimeUnit.SECONDS.convert(Duration.between(LocalDateTime.now(), startTime)) > 3600 * 24) {
@@ -232,14 +232,14 @@ public class ChargeServiceImpl implements ChargeService {
             chargeOrderService.save(order);
 
             // 订单充值权益
-            if (!CommUtil.isEmptyOrNull(rechargeRightsId)) {
-                var userRechargeRights = userRechargeRightsService.lambdaQuery().eq(UserRechargeRights::getUserId, userId).eq(UserRechargeRights::getRightsId, rechargeRightsId).one();
+            if (!CommUtil.isEmptyOrNull(userRechargeRightsId)) {
+                var userRechargeRights = userRechargeRightsService.lambdaQuery().eq(UserRechargeRights::getUserId, userId).eq(UserRechargeRights::getId, userRechargeRightsId).one();
                 if (userRechargeRights != null) {
                     var orderRechargeRights = new OrderRechargeRights()
                             .setUserId(userId)
                             .setStartChargeSeq(startChargeSeq)
                             .setActivityId(userRechargeRights.getActivityId())
-                            .setRightsId(rechargeRightsId)
+                            .setRightsId(userRechargeRights.getRightsId())
                             .setDiscount(userRechargeRights.getDiscount());
                     orderRechargeRightsService.save(orderRechargeRights);
                 }