From 334420cbe5a2dd6e569e9f4bdf00bc9611b99c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Sun, 6 Oct 2024 17:00:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TransactionBillServiceImpl.java | 2 ++ .../web/controller/ss/SmDeviceController.java | 23 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index e2590509..3e87534c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -421,6 +421,8 @@ public class TransactionBillServiceImpl implements TransactionBillService, After order.setType(TransactionBillType.RECHARGE.getType()); // 类型:充值订单 order.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.UN_RECHARGE.getStatus()); // 设备状态:未充值 order.setVersion(2); // 订单版本 + order.setCloseStatus(RechargeCloseStatus.SUCCESS.getStatus()); + order.setCloseResult("预计成功"); if (SuitFeeType.timingList().contains(suit.getFeeType())) { // 当为分时段收费,则收取押金 diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java index eaa8bd9c..70b35df3 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.ss; +import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -11,6 +12,7 @@ import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO; import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.service.DeviceAssembler; +import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.security.access.prepost.PreAuthorize; @@ -148,12 +150,25 @@ public class SmDeviceController extends BaseController return success(deviceService.bindSn(deviceId, sn)); } - @ApiOperation("设备充值时长") @PreAuthorize("@ss.hasPermi('system:device:addTime')") - @Log(title = "设备", businessType = BusinessType.OTHER) + @Log(title = "设备充值时长", businessType = BusinessType.OTHER) @PutMapping("/addTime/{deviceId}") - public AjaxResult addTime(@PathVariable @ApiParam("设备id") Long deviceId, @ApiParam("时长(分)") Long amount) { - return toAjax(deviceService.addTimeByUser(deviceId, amount * 60, true, "管理员手动充值")); + public AjaxResult addTime(@PathVariable @ApiParam("设备id") Long deviceId, + @ApiParam("时长") @RequestParam Long amount, + @ApiParam("时长单位") @RequestParam(required = false, defaultValue = "3") String timeUnit) { + SuitTimeUnit unit = SuitTimeUnit.getByValue(timeUnit); + if (unit == null) { + return error("非法的时长单位"); + } + return toAjax(deviceService.addTimeByUser(deviceId, amount * unit.getConversion(), true, "管理员手动充值时长")); + } + + @PreAuthorize("@ss.hasPermi('system:device:addEle')") + @Log(title = "设备充值电量", businessType = BusinessType.OTHER) + @PutMapping("/addEle/{deviceId}") + public AjaxResult addEle(@ApiParam("设备id") @PathVariable Long deviceId, + @ApiParam("电量(度)") @RequestParam BigDecimal amount) { + return toAjax(deviceService.addEle(deviceId, amount, true, "管理员手动充值电量")); } @ApiOperation("设备时长归零")