|
|
@@ -226,22 +226,44 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderAddressService.delByOrderId(id);
|
|
|
List<AddressInfo> addressInfos = param.getAddressInfo();
|
|
|
if (CollectionUtils.isNotEmpty(addressInfos)) {
|
|
|
+ BigDecimal amount = Objects.isNull(param.getAmount()) ? BigDecimal.ZERO : param.getAmount();
|
|
|
List<KwoTradeOrderAddress> list = new ArrayList<>(addressInfos.size());
|
|
|
- addressInfos.forEach(e -> {
|
|
|
+ BigDecimal totalLoadAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalUnloadAmount = BigDecimal.ZERO;
|
|
|
+ boolean loadFlag = false;
|
|
|
+ boolean unloadFlag = false;
|
|
|
+ for (AddressInfo e : addressInfos) {
|
|
|
KwoTradeOrderAddress address = BeanUtils.copyProperties(e, KwoTradeOrderAddress.class);
|
|
|
address.setTOrderId(id).setTOrderNo(tOrderNo);
|
|
|
list.add(address);
|
|
|
if (Objects.equals(e.getAddressType(), OrderAddressTypeEnum.LOAD.getType())) {
|
|
|
+ //todo MongoDB如何存多个地址信息?
|
|
|
order.setLoadName(e.getName()).setLoadType(e.getType()).setLoadContacts(e.getContacts())
|
|
|
.setLoadPhone(e.getPhone()).setLoadCityCode(String.valueOf(e.getCityCode())).setLoadCityName(e.getCityName())
|
|
|
.setLoadDetailAddress(e.getDetailAddress()).setLoadLat(e.getLat()).setLoadLng(e.getLng());
|
|
|
+ totalLoadAmount = totalLoadAmount.add(e.getAmount());
|
|
|
+ loadFlag = true;
|
|
|
} else {
|
|
|
+ //todo MongoDB如何存多个地址信息?
|
|
|
order.setUnloadName(e.getName()).setUnloadType(e.getType()).setUnloadContacts(e.getContacts())
|
|
|
.setUnloadPhone(e.getPhone()).setUnloadCityCode(String.valueOf(e.getCityCode())).setUnloadCityName(e.getCityName())
|
|
|
.setUnloadDetailAddress(e.getDetailAddress()).setUnloadLat(e.getLat()).setUnloadLng(e.getLng());
|
|
|
+ totalUnloadAmount = totalUnloadAmount.add(e.getAmount());
|
|
|
+ unloadFlag = true;
|
|
|
}
|
|
|
- });
|
|
|
+ Long addressId = kwoTradeOrderAddressService.add(address);
|
|
|
+ KwoTradeOrderAmount orderAmount = new KwoTradeOrderAmount();
|
|
|
+ orderAmount.setTOrderId(id).setAmount(e.getAmount())
|
|
|
+ .setAddressId(addressId);
|
|
|
+ }
|
|
|
+ if (loadFlag && totalLoadAmount.compareTo(amount) != 0) {
|
|
|
+ throw new BusinessException("装货分配量总量与订单总量不符!");
|
|
|
+ }
|
|
|
+ if (unloadFlag && totalUnloadAmount.compareTo(amount) != 0) {
|
|
|
+ throw new BusinessException("卸货分配量总量与订单总量不符!");
|
|
|
+ }
|
|
|
kwoTradeOrderAddressService.insertBatch(list);
|
|
|
+ //分配量信息
|
|
|
}
|
|
|
|
|
|
//合同信息
|
|
|
@@ -263,7 +285,7 @@ public class KwoTradeOrderService {
|
|
|
int method = isUpdate ? 2 : 1;
|
|
|
//存MongoDb
|
|
|
saveMongoDb(method, order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
@@ -460,7 +482,7 @@ public class KwoTradeOrderService {
|
|
|
String trading = param.getTrading();
|
|
|
BigDecimal price = param.getPrice();
|
|
|
KwpGoods goods = goodsInfoService.getGoodsById(param.getGoodsId());
|
|
|
- if (Objects.isNull(goods) || Objects.equals(goods.getDelFlag(), Global.YES) ) {
|
|
|
+ if (Objects.isNull(goods) || Objects.equals(goods.getDelFlag(), Global.YES)) {
|
|
|
throw new BusinessException("商品不存在!");
|
|
|
}
|
|
|
if (Boolean.FALSE.equals(isAcceptanceOrder)) {
|
|
|
@@ -558,6 +580,7 @@ public class KwoTradeOrderService {
|
|
|
|
|
|
/**
|
|
|
* 生成贸易订单号
|
|
|
+ *
|
|
|
* @return 订单编号
|
|
|
*/
|
|
|
private String getOrderNo() {
|
|
|
@@ -817,7 +840,7 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException(updateResult.getMsg());
|
|
|
}
|
|
|
//代客下单冻结金额
|
|
|
- if (Objects.equals(source, OrderSourceEnum.SALE.getType()) && param.getTrading().startsWith("1")){
|
|
|
+ if (Objects.equals(source, OrderSourceEnum.SALE.getType()) && param.getTrading().startsWith("1")) {
|
|
|
HttpResult freezeResult = paymentDubboService.freezeMoney(orderCheck.getProcureTopEntId(),
|
|
|
ChannelEnum.getByTrading(param.getTrading()), orderCheck.getSupplyTopEntId(), param.getPrice(), order.getId());
|
|
|
if (!Objects.equals(HttpStatus.SUCCESS_CODE, freezeResult.getCode())) {
|
|
|
@@ -1366,8 +1389,8 @@ public class KwoTradeOrderService {
|
|
|
* @Param topEntId:
|
|
|
* @return: java.util.List<com.sckw.order.api.model.TradeOrderCountStatisticsDTO>
|
|
|
*/
|
|
|
- public List<TradeOrderCountStatisticsDTO> getOrderNumByTopEntId(Long topEntId,List<Long> enterpriseIds) {
|
|
|
- return kwoTradeOrderMapper.getOrderNumByTopEntId(topEntId,enterpriseIds);
|
|
|
+ public List<TradeOrderCountStatisticsDTO> getOrderNumByTopEntId(Long topEntId, List<Long> enterpriseIds) {
|
|
|
+ return kwoTradeOrderMapper.getOrderNumByTopEntId(topEntId, enterpriseIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1415,7 +1438,7 @@ public class KwoTradeOrderService {
|
|
|
}
|
|
|
Map<String, String> finalUnitMap = unitMap;
|
|
|
unitDetails.forEach(e -> {
|
|
|
- e.setLabel( finalUnitMap != null ? finalUnitMap.get(e.getValue()) : null);
|
|
|
+ e.setLabel(finalUnitMap != null ? finalUnitMap.get(e.getValue()) : null);
|
|
|
//组装合理损耗
|
|
|
if (CollectionUtils.isNotEmpty(dicts)) {
|
|
|
for (SysDictResDto ee : dicts)
|