提交代码

yy_dev
胡锐 1 year ago
parent dbc007f19a
commit 1b1de2f402
  1. 47
      service/src/main/java/com/hfkj/service/impl/BsDeviceOrderServiceImpl.java

@ -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())) {
// 查询分配数量
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, "无法分配,超过订单需求数量");
} }
else if (order.getDeviceType().equals(DeviceTypeEnum.type2.getNumber())) {
List<BsPayQrCode> payQrCodeList = new ArrayList<>();
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,6 +238,7 @@ 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()); BsDevice oldDevice = deviceService.getDetailByNo(orderAssign.getDeviceNo());
if (oldDevice == null) { if (oldDevice == null) {
@ -231,6 +268,10 @@ public class BsDeviceOrderServiceImpl implements BsDeviceOrderService {
orderAssign.setDeviceId(newDevice.getId()); orderAssign.setDeviceId(newDevice.getId());
orderAssign.setDeviceNo(newDevice.getDeviceNo()); orderAssign.setDeviceNo(newDevice.getDeviceNo());
deviceOrderAssignService.editData(orderAssign); deviceOrderAssignService.editData(orderAssign);
} else if (orderAssign.getDeviceType().equals(2)) {
}
} }
@Override @Override

Loading…
Cancel
Save