|
|
|
@ -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<BsPayQrCode> payQrCodeList = new ArrayList<>(); |
|
|
|
|
} else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) { |
|
|
|
|
// 查询分配数量
|
|
|
|
|
List<BsDeviceOrderAssign> 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 |
|
|
|
|