|
|
@ -173,9 +173,14 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService { |
|
|
|
for (BsDevice device : deviceList) { |
|
|
|
for (BsDevice device : deviceList) { |
|
|
|
deviceService.editDevice(device); |
|
|
|
deviceService.editDevice(device); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) { |
|
|
|
else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) { |
|
|
|
// 查询分配数量
|
|
|
|
List<BsPayQrCode> payQrCodeList = new ArrayList<>(); |
|
|
|
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) { |
|
|
|
for (String serialNumber : deviceNoList) { |
|
|
|
// 查询支付码
|
|
|
|
// 查询支付码
|
|
|
@ -183,11 +188,42 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService { |
|
|
|
if (payQrCode == null) { |
|
|
|
if (payQrCode == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的支付码编号:" + serialNumber); |
|
|
|
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())) { |
|
|
|
if (!payQrCode.getStatus().equals(PayQrCodeStatusEnum.status1.getNumber())) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付码状态错误"); |
|
|
|
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)) { |
|
|
|
if (!orderAssign.getStatus().equals(1)) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
// 旧设备
|
|
|
|
if (orderAssign.getDeviceType().equals(1)) { |
|
|
|
BsDevice oldDevice = deviceService.getDetailByNo(orderAssign.getDeviceNo()); |
|
|
|
// 旧设备
|
|
|
|
if (oldDevice == null) { |
|
|
|
BsDevice oldDevice = deviceService.getDetailByNo(orderAssign.getDeviceNo()); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到的旧设备号"); |
|
|
|
if (oldDevice == null) { |
|
|
|
} |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到的旧设备号"); |
|
|
|
oldDevice.setMerId(null); |
|
|
|
} |
|
|
|
oldDevice.setMerName(null); |
|
|
|
oldDevice.setMerId(null); |
|
|
|
oldDevice.setStoreId(null); |
|
|
|
oldDevice.setMerName(null); |
|
|
|
oldDevice.setStoreName(null); |
|
|
|
oldDevice.setStoreId(null); |
|
|
|
oldDevice.setBindStatus(false); |
|
|
|
oldDevice.setStoreName(null); |
|
|
|
oldDevice.setBindTime(null); |
|
|
|
oldDevice.setBindStatus(false); |
|
|
|
deviceService.editDevice(oldDevice); |
|
|
|
oldDevice.setBindTime(null); |
|
|
|
|
|
|
|
deviceService.editDevice(oldDevice); |
|
|
|
// 新设备
|
|
|
|
|
|
|
|
BsDevice newDevice = deviceService.getDetailByNo(newDeviceNo); |
|
|
|
// 新设备
|
|
|
|
if (newDevice == null) { |
|
|
|
BsDevice newDevice = deviceService.getDetailByNo(newDeviceNo); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的新设备号"); |
|
|
|
if (newDevice == null) { |
|
|
|
} |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的新设备号"); |
|
|
|
newDevice.setMerId(orderAssign.getMerId()); |
|
|
|
} |
|
|
|
newDevice.setMerName(orderAssign.getMerName()); |
|
|
|
newDevice.setMerId(orderAssign.getMerId()); |
|
|
|
newDevice.setStoreId(orderAssign.getStoreId()); |
|
|
|
newDevice.setMerName(orderAssign.getMerName()); |
|
|
|
newDevice.setStoreName(orderAssign.getStoreName()); |
|
|
|
newDevice.setStoreId(orderAssign.getStoreId()); |
|
|
|
newDevice.setBindStatus(true); |
|
|
|
newDevice.setStoreName(orderAssign.getStoreName()); |
|
|
|
newDevice.setBindTime(new Date()); |
|
|
|
newDevice.setBindStatus(true); |
|
|
|
deviceService.editDevice(newDevice); |
|
|
|
newDevice.setBindTime(new Date()); |
|
|
|
|
|
|
|
deviceService.editDevice(newDevice); |
|
|
|
orderAssign.setDeviceId(newDevice.getId()); |
|
|
|
|
|
|
|
orderAssign.setDeviceNo(newDevice.getDeviceNo()); |
|
|
|
orderAssign.setDeviceId(newDevice.getId()); |
|
|
|
deviceOrderAssignService.editData(orderAssign); |
|
|
|
orderAssign.setDeviceNo(newDevice.getDeviceNo()); |
|
|
|
|
|
|
|
deviceOrderAssignService.editData(orderAssign); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (orderAssign.getDeviceType().equals(2)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|