|
|
@@ -98,13 +98,8 @@ public class KwoTradeOrderService {
|
|
|
.setContractName("").setContractSigningWay("").setCreateByName(LoginUserHolder.getUserName())
|
|
|
.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
BeanUtils.copyProperties(tradeOrder, order);
|
|
|
- if (isUpdate) {
|
|
|
- kwoTradeOrderGoodsService.delByOrderId(id);
|
|
|
- kwoTradeOrderUnitService.delByOrderId(id);
|
|
|
- kwoTradeOrderContractService.delByOrderId(id);
|
|
|
- kwoTradeOrderAddressService.delByOrderId(id);
|
|
|
- }
|
|
|
//商品信息
|
|
|
+ kwoTradeOrderGoodsService.delByOrderId(id);
|
|
|
GoodsInfo goodsInfo = param.getGoodsInfo();
|
|
|
KwoTradeOrderGoods goods = BeanUtils.copyProperties(goodsInfo, KwoTradeOrderGoods.class);
|
|
|
if (Objects.nonNull(goods)) {
|
|
|
@@ -113,6 +108,7 @@ public class KwoTradeOrderService {
|
|
|
BeanUtils.copyProperties(goodsInfo, order);
|
|
|
}
|
|
|
//单位信息
|
|
|
+ kwoTradeOrderUnitService.delByOrderId(id);
|
|
|
List<UnitInfo> unitInfos = param.getUnitInfo();
|
|
|
if (CollectionUtils.isNotEmpty(unitInfos)) {
|
|
|
List<KwoTradeOrderUnit> list = new ArrayList<>(unitInfos.size());
|
|
|
@@ -134,6 +130,7 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderUnitService.insertBatch(list);
|
|
|
}
|
|
|
//地址信息
|
|
|
+ kwoTradeOrderAddressService.delByOrderId(id);
|
|
|
List<AddressInfo> addressInfos = param.getAddressInfo();
|
|
|
if (CollectionUtils.isNotEmpty(addressInfos)) {
|
|
|
List<KwoTradeOrderAddress> list = new ArrayList<>(addressInfos.size());
|
|
|
@@ -154,6 +151,7 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderAddressService.insertBatch(list);
|
|
|
}
|
|
|
//合同信息
|
|
|
+ kwoTradeOrderContractService.delByOrderId(id);
|
|
|
ContractInfo contractInfo = param.getContractInfo();
|
|
|
KwoTradeOrderContract contract = BeanUtils.copyProperties(contractInfo, KwoTradeOrderContract.class);
|
|
|
if (Objects.nonNull(contract)) {
|
|
|
@@ -172,7 +170,7 @@ public class KwoTradeOrderService {
|
|
|
saveMongoDb(method, order);
|
|
|
}
|
|
|
|
|
|
- private void saveMongoDb(Integer method, Object order) {
|
|
|
+ private void saveMongoDb(Integer method, SckwTradeOrder order) {
|
|
|
SckwBusSum busSum = new SckwBusSum();
|
|
|
busSum.setBusSumType("tradeOrder");
|
|
|
busSum.setMethod(method);
|
|
|
@@ -205,7 +203,7 @@ public class KwoTradeOrderService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void addPurchaseOrderSubmit(PurchaseOrderParam param) {
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
.setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_1.getValue())
|
|
|
@@ -219,13 +217,18 @@ public class KwoTradeOrderService {
|
|
|
* @desc: 订单提交校验
|
|
|
* @author: yzc
|
|
|
* @date: 2023-07-14 14:46
|
|
|
- * @Param goodId:
|
|
|
- * @Param trading:
|
|
|
- * @Param price:
|
|
|
- * @Param amount:
|
|
|
+ * @Param goodId: 商品id
|
|
|
+ * @Param trading: 交易方式
|
|
|
+ * @Param price: 订单金额
|
|
|
+ * @Param amount: 订单总量
|
|
|
+ * @Param unitPrice: 成交价格
|
|
|
* @return: void
|
|
|
*/
|
|
|
- private void orderCheck(Long goodId, String trading, BigDecimal price, BigDecimal amount) {
|
|
|
+ private void orderCheck(Long goodId, String trading, BigDecimal price, BigDecimal amount, BigDecimal unitPrice) {
|
|
|
+ BigDecimal multiply = amount.multiply(unitPrice);
|
|
|
+ if (price.compareTo(amount.multiply(unitPrice)) != 0) {
|
|
|
+ throw new BusinessException("订单总金额不等于商品单价*订单总量!");
|
|
|
+ }
|
|
|
//todo: 则先校验是否存在对供应企业的预付钱包 ;【预计采购金额】是否大于预付清单的【可用预付】金额
|
|
|
KwpGoods goods = goodsInfoService.getGoodsById(goodId);
|
|
|
if (Objects.isNull(goods) || !Objects.equals(goods.getStatus(), 1)) {
|
|
|
@@ -250,7 +253,7 @@ public class KwoTradeOrderService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addValetOrderSubmit(ValetOrderParam param) {
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
.setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_2.getValue());
|
|
|
@@ -325,7 +328,7 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException("Invalid contract status");
|
|
|
}
|
|
|
}
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
}
|
|
|
order.setAmount(param.getAmount()).setUnit(Objects.isNull(param.getGoodsInfo()) ? null : param.getGoodsInfo().getUnit())
|
|
|
.setPrice(param.getPrice()).setTrading(param.getTrading()).setPickupType(param.getPickupType())
|
|
|
@@ -475,33 +478,124 @@ public class KwoTradeOrderService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void acceptanceOrder(AcceptanceOrderParam acceptanceOrderParam) {
|
|
|
+ /**
|
|
|
+ * @desc: 订单受理
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-14 16:59
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ public void acceptanceOrder(AcceptanceOrderParam param) {
|
|
|
+ KwoTradeOrder order = getById(param.getId());
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("Order not found");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(DictEnum.TORDER_STATUS_1.getValue(), String.valueOf(order.getStatus()))) {
|
|
|
+ throw new BusinessException("订单状态不为待受理!");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
|
|
|
+ throw new BusinessException("无订单操作权限!");
|
|
|
+ }
|
|
|
+ KwoTradeOrderGoods goods = kwoTradeOrderGoodsService.getByOrderId(order.getId());
|
|
|
+ if (Objects.isNull(goods)) {
|
|
|
+ throw new BusinessException("订单商品信息异常!");
|
|
|
+ }
|
|
|
+ orderCheck(goods.getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getUnitPrice());
|
|
|
+ //更新订单信息
|
|
|
+ BeanUtils.copyProperties(param, order);
|
|
|
+ String contractStatus = param.getContractInfo().getContractStatus();
|
|
|
+ if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_0.getValue())) {
|
|
|
+ order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()));
|
|
|
+ } else if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_1.getValue())) {
|
|
|
+ order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()));
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("Invalid contract status");
|
|
|
+ }
|
|
|
+ kwoTradeOrderMapper.updateById(order);
|
|
|
+ //保存合同信息
|
|
|
+ ContractInfo contractInfo = param.getContractInfo();
|
|
|
+ KwoTradeOrderContract contract = BeanUtils.copyProperties(contractInfo, KwoTradeOrderContract.class);
|
|
|
+ contract.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo());
|
|
|
+ kwoTradeOrderContractService.insert(contract);
|
|
|
+ //订单状态记录
|
|
|
+ KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
+ track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo());
|
|
|
+ kwoTradeOrderTrackService.insert(track);
|
|
|
+ //todo:更新mongodb
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void rejectOrder(RejectOrderParam rejectOrderParam) {
|
|
|
+ /**
|
|
|
+ * @desc: 订单驳回
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-14 17:00
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ public void rejectOrder(RejectOrderParam param) {
|
|
|
+ KwoTradeOrder order = getById(param.getId());
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("Order not found");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(DictEnum.TORDER_STATUS_1.getValue(), String.valueOf(order.getStatus()))) {
|
|
|
+ throw new BusinessException("订单状态不为待受理!");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
|
|
|
+ throw new BusinessException("无订单操作权限!");
|
|
|
+ }
|
|
|
+ order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_2.getValue()));
|
|
|
+ kwoTradeOrderMapper.updateById(order);
|
|
|
+ //订单状态记录
|
|
|
+ KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
+ track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setRemark(param.getRemark());
|
|
|
+ kwoTradeOrderTrackService.insert(track);
|
|
|
+ //mongodb更新订单状态
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc: 订单驳回查询
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-14 17:00
|
|
|
+ * @Param id:
|
|
|
+ * @return: java.lang.String
|
|
|
+ */
|
|
|
public String rejectReason(Long id) {
|
|
|
- return null;
|
|
|
+ KwoTradeOrder order = getById(id);
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("Order not found");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), null)) {
|
|
|
+ throw new BusinessException("无订单操作权限!");
|
|
|
+ }
|
|
|
+ KwoTradeOrderTrack track = kwoTradeOrderTrackService.getByOrderId(id, Integer.valueOf(DictEnum.TORDER_STATUS_2.getValue()));
|
|
|
+
|
|
|
+ return Objects.isNull(track) ? null : track.getRemark();
|
|
|
}
|
|
|
|
|
|
- public void completeOrder(CompleteOrderParam completeOrderParam) {
|
|
|
+ /**
|
|
|
+ * @desc: 完结订单
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-14 17:01
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ public void completeOrder(CompleteOrderParam param) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<OrderListRes> select(OrderListSelectParam orderListSelectParam) {
|
|
|
+ public List<OrderListRes> select(OrderListSelectParam param) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public TableStatisticRes statistic(OrderListStatisticParam orderListStatisticParam) {
|
|
|
+ public TableStatisticRes statistic(OrderListStatisticParam param) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void export(CompleteOrderParam completeOrderParam) {
|
|
|
+ public void export(CompleteOrderParam param) {
|
|
|
|
|
|
}
|
|
|
|