From 1b1de2f402f90b1a17705e3552b71d378a7c35dc Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 19 Jun 2023 13:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BsDeviceOrderServiceImpl.java | 107 ++++++++++++------ 1 file changed, 74 insertions(+), 33 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/impl/BsDeviceOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsDeviceOrderServiceImpl.java index 0786803..8c25064 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsDeviceOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsDeviceOrderServiceImpl.java @@ -173,9 +173,14 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService { for (BsDevice device : deviceList) { deviceService.editDevice(device); } - } - else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) { - List payQrCodeList = new ArrayList<>(); + } else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) { + // 查询分配数量 + List assignList = deviceOrderAssignService.getAssignListByOrderNo(order.getOrderNo()); + // 已分配数量 + 待分配数量 + int countNum = assignList.size() + deviceNoList.size(); + if (countNum > order.getDeviceNum().intValue()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,超过订单需求数量"); + } for (String serialNumber : deviceNoList) { // 查询支付码 @@ -183,11 +188,42 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService { if (payQrCode == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的支付码编号:" + serialNumber); } + if (payQrCode.getStoreBindTime() != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付码编号:" + serialNumber + "已被绑定"); + } if (!payQrCode.getStatus().equals(PayQrCodeStatusEnum.status1.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付码状态错误"); } + payQrCode.setStoreId(order.getStoreId()); + payQrCode.setStoreName(order.getStoreName()); + payQrCode.setStoreBindTime(new Date()); + payQrCode.setMerId(order.getMerId()); + payQrCode.setMerName(order.getMerName()); + payQrCodeService.editData(payQrCode, null); + - payQrCodeList.add(payQrCode); + BsDeviceOrderAssign orderAssign = new BsDeviceOrderAssign(); + orderAssign.setOrderId(order.getId()); + orderAssign.setOrderNo(order.getOrderNo()); + orderAssign.setOrderType(order.getOrderType()); + orderAssign.setDeviceType(order.getDeviceType()); + orderAssign.setPaySerialNo(order.getPaySerialNo()); + orderAssign.setDeviceId(payQrCode.getId()); + orderAssign.setDeviceNo(payQrCode.getSerialNumber()); + orderAssign.setDevicePrice(order.getOrderPrice().divide(new BigDecimal(order.getDeviceNum().toString()))); + orderAssign.setDeviceActualPrice(order.getPayPrice().divide(new BigDecimal(order.getDeviceNum().toString()))); + orderAssign.setStatus(1); + orderAssign.setCompanyId(order.getId()); + orderAssign.setCompanyName(order.getCompanyName()); + orderAssign.setAgentId(order.getAgentId()); + orderAssign.setAgentName(order.getAgentName()); + orderAssign.setSalesmanId(order.getSalesmanId()); + orderAssign.setSalesmanName(order.getSalesmanName()); + orderAssign.setMerId(order.getMerId()); + orderAssign.setMerName(order.getMerName()); + orderAssign.setStoreId(order.getStoreId()); + orderAssign.setStoreName(order.getStoreName()); + deviceOrderAssignService.editData(orderAssign); } } } @@ -202,35 +238,40 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService { if (!orderAssign.getStatus().equals(1)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); } - // 旧设备 - BsDevice oldDevice = deviceService.getDetailByNo(orderAssign.getDeviceNo()); - if (oldDevice == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到的旧设备号"); - } - oldDevice.setMerId(null); - oldDevice.setMerName(null); - oldDevice.setStoreId(null); - oldDevice.setStoreName(null); - oldDevice.setBindStatus(false); - oldDevice.setBindTime(null); - deviceService.editDevice(oldDevice); - - // 新设备 - BsDevice newDevice = deviceService.getDetailByNo(newDeviceNo); - if (newDevice == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的新设备号"); - } - newDevice.setMerId(orderAssign.getMerId()); - newDevice.setMerName(orderAssign.getMerName()); - newDevice.setStoreId(orderAssign.getStoreId()); - newDevice.setStoreName(orderAssign.getStoreName()); - newDevice.setBindStatus(true); - newDevice.setBindTime(new Date()); - deviceService.editDevice(newDevice); - - orderAssign.setDeviceId(newDevice.getId()); - orderAssign.setDeviceNo(newDevice.getDeviceNo()); - deviceOrderAssignService.editData(orderAssign); + if (orderAssign.getDeviceType().equals(1)) { + // 旧设备 + BsDevice oldDevice = deviceService.getDetailByNo(orderAssign.getDeviceNo()); + if (oldDevice == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到的旧设备号"); + } + oldDevice.setMerId(null); + oldDevice.setMerName(null); + oldDevice.setStoreId(null); + oldDevice.setStoreName(null); + oldDevice.setBindStatus(false); + oldDevice.setBindTime(null); + deviceService.editDevice(oldDevice); + + // 新设备 + BsDevice newDevice = deviceService.getDetailByNo(newDeviceNo); + if (newDevice == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的新设备号"); + } + newDevice.setMerId(orderAssign.getMerId()); + newDevice.setMerName(orderAssign.getMerName()); + newDevice.setStoreId(orderAssign.getStoreId()); + newDevice.setStoreName(orderAssign.getStoreName()); + newDevice.setBindStatus(true); + newDevice.setBindTime(new Date()); + deviceService.editDevice(newDevice); + + orderAssign.setDeviceId(newDevice.getId()); + orderAssign.setDeviceNo(newDevice.getDeviceNo()); + deviceOrderAssignService.editData(orderAssign); + + } else if (orderAssign.getDeviceType().equals(2)) { + + } } @Override