|
|
|
@ -112,59 +112,59 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean insertReservation(DistributionReservationDTO distributionReservationDTO) { |
|
|
|
|
try { |
|
|
|
|
if (Func.isEmpty(distributionReservationDTO)) { |
|
|
|
|
log.error("参数错误+{" + distributionReservationDTO + "}"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//这里新增需要对预约列表下的订单配送单的金额进行计算
|
|
|
|
|
String idsStr = distributionReservationDTO.getIds(); |
|
|
|
|
List<Long> ids = Func.toLongList(idsStr); |
|
|
|
|
if (Func.isEmpty(ids)) { |
|
|
|
|
log.error("ids参数错误:+{" + ids + "}"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
BigDecimal collectFee = new BigDecimal("0"); |
|
|
|
|
BigDecimal replaceFee = new BigDecimal("0"); |
|
|
|
|
StringBuffer buffer = new StringBuffer(); |
|
|
|
|
List<DistributionStockArticleEntity> deliveryEntities = new ArrayList<>(); |
|
|
|
|
for (int i = 0; i < ids.size(); i++) { |
|
|
|
|
BaseMapper<DistributionStockArticleEntity> stockArticleMapper = distributionStockArticleService.getBaseMapper(); |
|
|
|
|
DistributionStockArticleEntity distributionStockArticleEntity = stockArticleMapper.selectById(ids.get(i)); |
|
|
|
|
// deliveryEntities.add(distributionDeliveryEntity);
|
|
|
|
|
// collectFee = collectFee.add(distributionDeliveryEntity.getCollectFee());
|
|
|
|
|
// //待收货款累加
|
|
|
|
|
// replaceFee = replaceFee.add(distributionDeliveryEntity.getReplaceFee());
|
|
|
|
|
// String orderId = distributionDeliveryEntity.getOrderId();
|
|
|
|
|
buffer.append(distributionStockArticleEntity.getId()).append(","); |
|
|
|
|
} |
|
|
|
|
buffer.deleteCharAt(buffer.length() - 1); |
|
|
|
|
DistributionReservationEntity distributionReservationEntity = new DistributionReservationEntity(); |
|
|
|
|
BeanUtils.copyProperties(distributionReservationDTO, distributionReservationEntity); |
|
|
|
|
distributionReservationEntity.setCollectFee(collectFee); |
|
|
|
|
distributionReservationEntity.setReplaceFee(replaceFee); |
|
|
|
|
//设置订单自编号,这里的数据属于冗余部分
|
|
|
|
|
distributionReservationEntity.setStockArticleId(buffer.toString()); |
|
|
|
|
//设置状态未备货
|
|
|
|
|
distributionReservationEntity.setStockupStatus("1"); |
|
|
|
|
//设置预约状态为待确认
|
|
|
|
|
distributionReservationEntity.setReservationStatus("1"); |
|
|
|
|
//设置预约信息来源是自建的方式
|
|
|
|
|
distributionReservationEntity.setOrderSource("3"); |
|
|
|
|
|
|
|
|
|
//这里就对新增的预约信息进行保存
|
|
|
|
|
this.save(distributionReservationEntity); |
|
|
|
|
Long reservationEntityId = distributionReservationEntity.getId(); |
|
|
|
|
//保存完之后获取新插入的预约服务获取ID然后订单派送单进行绑定
|
|
|
|
|
deliveryEntities.forEach(i -> { |
|
|
|
|
i.setReservationId(reservationEntityId); |
|
|
|
|
distributionStockArticleService.getBaseMapper().updateById(i); |
|
|
|
|
}); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
log.error("出现异常:+{" + e.getMessage() + "}"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// try {
|
|
|
|
|
// if (Func.isEmpty(distributionReservationDTO)) {
|
|
|
|
|
// log.error("参数错误+{" + distributionReservationDTO + "}");
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// //这里新增需要对预约列表下的订单配送单的金额进行计算
|
|
|
|
|
// String idsStr = distributionReservationDTO.getIds();
|
|
|
|
|
// List<Long> ids = Func.toLongList(idsStr);
|
|
|
|
|
// if (Func.isEmpty(ids)) {
|
|
|
|
|
// log.error("ids参数错误:+{" + ids + "}");
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// BigDecimal collectFee = new BigDecimal("0");
|
|
|
|
|
// BigDecimal replaceFee = new BigDecimal("0");
|
|
|
|
|
// StringBuffer buffer = new StringBuffer();
|
|
|
|
|
// List<DistributionStockArticleEntity> deliveryEntities = new ArrayList<>();
|
|
|
|
|
// for (int i = 0; i < ids.size(); i++) {
|
|
|
|
|
// BaseMapper<DistributionStockArticleEntity> stockArticleMapper = distributionStockArticleService.getBaseMapper();
|
|
|
|
|
// DistributionStockArticleEntity distributionStockArticleEntity = stockArticleMapper.selectById(ids.get(i));
|
|
|
|
|
//// deliveryEntities.add(distributionDeliveryEntity);
|
|
|
|
|
//// collectFee = collectFee.add(distributionDeliveryEntity.getCollectFee());
|
|
|
|
|
//// //待收货款累加
|
|
|
|
|
//// replaceFee = replaceFee.add(distributionDeliveryEntity.getReplaceFee());
|
|
|
|
|
//// String orderId = distributionDeliveryEntity.getOrderId();
|
|
|
|
|
// buffer.append(distributionStockArticleEntity.getId()).append(",");
|
|
|
|
|
// }
|
|
|
|
|
// buffer.deleteCharAt(buffer.length() - 1);
|
|
|
|
|
// DistributionReservationEntity distributionReservationEntity = new DistributionReservationEntity();
|
|
|
|
|
// BeanUtils.copyProperties(distributionReservationDTO, distributionReservationEntity);
|
|
|
|
|
// distributionReservationEntity.setCollectFee(collectFee);
|
|
|
|
|
// distributionReservationEntity.setReplaceFee(replaceFee);
|
|
|
|
|
// //设置订单自编号,这里的数据属于冗余部分
|
|
|
|
|
// distributionReservationEntity.setStockArticleId(buffer.toString());
|
|
|
|
|
// //设置状态未备货
|
|
|
|
|
// distributionReservationEntity.setStockupStatus("1");
|
|
|
|
|
// //设置预约状态为待确认
|
|
|
|
|
// distributionReservationEntity.setReservationStatus("1");
|
|
|
|
|
// //设置预约信息来源是自建的方式
|
|
|
|
|
// distributionReservationEntity.setOrderSource("3");
|
|
|
|
|
//
|
|
|
|
|
// //这里就对新增的预约信息进行保存
|
|
|
|
|
// this.save(distributionReservationEntity);
|
|
|
|
|
// Long reservationEntityId = distributionReservationEntity.getId();
|
|
|
|
|
// //保存完之后获取新插入的预约服务获取ID然后订单派送单进行绑定
|
|
|
|
|
// deliveryEntities.forEach(i -> {
|
|
|
|
|
// i.setReservationId(reservationEntityId);
|
|
|
|
|
// distributionStockArticleService.getBaseMapper().updateById(i);
|
|
|
|
|
// });
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
// log.error("出现异常:+{" + e.getMessage() + "}");
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|