From 7960c085ddb86e44e2b2520a21e6d4e6bebed056 Mon Sep 17 00:00:00 2001 From: SjS Date: Tue, 1 Apr 2025 09:05:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AE=BE=E5=A4=87=E6=95=85?= =?UTF-8?q?=E9=9A=9C=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DeviceServiceImpl.java | 12 +++++---- .../controller/app/AppAbnormalController.java | 27 +++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index 3d079542..75f38566 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -245,11 +245,7 @@ public class DeviceServiceImpl implements DeviceService data.setUpdateTime(DateUtils.getNowDate()); Integer result = transactionTemplate.execute(status -> { - deviceMapper.selectByDeviceNo(data.getDeviceNo()); - - // 更新主表 - int update = deviceMapper.updateSmDevice(data); - ServiceUtil.assertion(update != 1, "更新设备失败"); + // deviceMapper.selectByDeviceId(data.getDeviceNo()); // 生成SnLog记录 SnLog snLog = new SnLog(); @@ -257,6 +253,12 @@ public class DeviceServiceImpl implements DeviceService snLog.setUserId(SecurityUtils.getUserId()); snLog.setMac(data.getMac()); + // 更新主表 + int update = deviceMapper.updateSmDevice(data); + ServiceUtil.assertion(update != 1, "更新设备失败"); + + + // 后校验 DeviceVO vo = this.selectById(data.getDeviceId()); deviceAssembler.assembleBonusList(vo); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java index 051c8624..97bb1c09 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java @@ -53,17 +53,28 @@ public class AppAbnormalController extends BaseController { public AjaxResult submit(@RequestBody @Validated(ValidGroup.FrontCreate.class) AbnormalSubmitDTO data) { data.setUserId(getUserId()); data.setCreateBy(getUsername()); - TransactionBillVO vo = transactionBillService.selectSmTransactionBillByBillId(data.getOrderId()); - if (vo != null) { - data.setOrderNo(vo.getBillNo()); - // 获取订单商户id - if (vo.getMchId() != null) { - data.setStoreId(vo.getMchId()); + TransactionBillVO transactionBillVO = transactionBillService.selectSmTransactionBillByBillId(data.getOrderId()); + DeviceVO deviceVO = deviceService.selectByDeviceNo(data.getDeviceNo()); + if (data.getOrderId() != null && data.getDeviceNo() != null) { + if (transactionBillVO == null) { + return AjaxResult.error("当前订单不存在"); + } + if (deviceVO == null) { + return AjaxResult.error("当前设备不存在"); + } + if (!transactionBillVO.getDeviceNo().equals(data.getDeviceNo())) { + return AjaxResult.error("当前设备与订单无关联"); + } + } + // 获取订单商户id + if ( data.getOrderId()!= null) { + data.setOrderNo(transactionBillVO.getBillNo()); + if(transactionBillVO.getMchId()!=null){ + data.setStoreId(transactionBillVO.getMchId()); } } // 获取设备商户id - DeviceVO deviceVO = deviceService.selectByDeviceNo(data.getDeviceNo()); - if (deviceVO != null) { + if (data.getDeviceNo() != null) { Long storeId = deviceVO.getStoreId(); if (storeId != null) { data.setStoreId(storeId);