|
|
@@ -1,12 +1,15 @@
|
|
|
package com.sckw.order.serivce;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.OrderGenerateUtils;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.mongo.model.SckwTradeOrder;
|
|
|
import com.sckw.order.dao.KwoTradeOrderMapper;
|
|
|
@@ -63,14 +66,13 @@ public class KwoTradeOrderService {
|
|
|
* @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void addPurchaseOrderDraft(PurchaseOrderParam param) {
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
.setUnit(Objects.nonNull(param.getGoodsInfo()) ? param.getGoodsInfo().getUnit() : null)
|
|
|
- .setSource(DictEnum.TORDER_SOURCE_0.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
|
|
|
+ .setSource(DictEnum.TORDER_SOURCE_1.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
|
|
|
kwoTradeOrderMapper.insert(order);
|
|
|
- addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class));
|
|
|
+ addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -82,15 +84,22 @@ public class KwoTradeOrderService {
|
|
|
* @Param tOrderNo:
|
|
|
* @Param status:
|
|
|
* @Param param:
|
|
|
+ * @Param isUpdate:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- private void addOtherOrderInfo(KwoTradeOrder tradeOrder, ValetOrderParam param) {
|
|
|
+ private void addOtherOrderInfo(KwoTradeOrder tradeOrder, ValetOrderParam param, Boolean isUpdate) {
|
|
|
Long id = tradeOrder.getId();
|
|
|
String tOrderNo = tradeOrder.getTOrderNo();
|
|
|
- SckwTradeOrder order = BeanUtils.copyProperties(tradeOrder, SckwTradeOrder.class);
|
|
|
+ SckwTradeOrder order = new SckwTradeOrder();
|
|
|
//todo: 当前线程获取企业名称
|
|
|
- order.setFirmName(String.valueOf(LoginUserHolder.get().getEntId())).setTOrderId(id);
|
|
|
- //添加商品信息
|
|
|
+ //提前填充这些参数防止初始创建mongodb集合没有这些字段
|
|
|
+ order.setFirmName(String.valueOf(LoginUserHolder.getEntId())).setTOrderId(id).setDeliveryType("").setProjectName("")
|
|
|
+ .setEntrustAmount(BigDecimal.ZERO).setActualAmount(BigDecimal.ZERO).setContractId(0L).setContractNo("")
|
|
|
+ .setContractName("").setContractSigningWay("").setCreateByName(LoginUserHolder.getUserName())
|
|
|
+ .setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ BeanUtils.copyProperties(tradeOrder, order);
|
|
|
+ //商品信息
|
|
|
+ kwoTradeOrderGoodsService.delByOrderId(id);
|
|
|
GoodsInfo goodsInfo = param.getGoodsInfo();
|
|
|
KwoTradeOrderGoods goods = BeanUtils.copyProperties(goodsInfo, KwoTradeOrderGoods.class);
|
|
|
if (Objects.nonNull(goods)) {
|
|
|
@@ -98,7 +107,8 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderGoodsService.insert(goods);
|
|
|
BeanUtils.copyProperties(goodsInfo, order);
|
|
|
}
|
|
|
- //添加单位信息
|
|
|
+ //单位信息
|
|
|
+ kwoTradeOrderUnitService.delByOrderId(id);
|
|
|
List<UnitInfo> unitInfos = param.getUnitInfo();
|
|
|
if (CollectionUtils.isNotEmpty(unitInfos)) {
|
|
|
List<KwoTradeOrderUnit> list = new ArrayList<>(unitInfos.size());
|
|
|
@@ -119,7 +129,8 @@ 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());
|
|
|
@@ -139,7 +150,8 @@ public class KwoTradeOrderService {
|
|
|
});
|
|
|
kwoTradeOrderAddressService.insertBatch(list);
|
|
|
}
|
|
|
- //添加合同信息
|
|
|
+ //合同信息
|
|
|
+ kwoTradeOrderContractService.delByOrderId(id);
|
|
|
ContractInfo contractInfo = param.getContractInfo();
|
|
|
KwoTradeOrderContract contract = BeanUtils.copyProperties(contractInfo, KwoTradeOrderContract.class);
|
|
|
if (Objects.nonNull(contract)) {
|
|
|
@@ -147,18 +159,18 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderContractService.insert(contract);
|
|
|
BeanUtils.copyProperties(contractInfo, order);
|
|
|
}
|
|
|
- //添加状态信息
|
|
|
- KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
- track.setTOrderId(id).setTOrderNo(tOrderNo).setStatus(tradeOrder.getStatus()).setRemark(tradeOrder.getRemark());
|
|
|
- kwoTradeOrderTrackService.insert(track);
|
|
|
- order.setDeliveryType("").setProjectName("").setEntrustAmount(BigDecimal.ZERO).setActualAmount(BigDecimal.ZERO)
|
|
|
- .setContractId(0L).setContractNo("").setContractName("").setContractSigningWay("")
|
|
|
- .setCreateByName(LoginUserHolder.getUserName()).setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ //状态信息(草稿更新不加状态记录)
|
|
|
+ if (!isUpdate || !Objects.equals(DictEnum.TORDER_STATUS_0.getValue(), String.valueOf(tradeOrder.getStatus()))) {
|
|
|
+ KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
+ track.setTOrderId(id).setTOrderNo(tOrderNo).setStatus(tradeOrder.getStatus()).setRemark(tradeOrder.getRemark());
|
|
|
+ kwoTradeOrderTrackService.insert(track);
|
|
|
+ }
|
|
|
+ int method = isUpdate ? 2 : 1;
|
|
|
//存MongoDb
|
|
|
- saveMongoDb(1, order);
|
|
|
+ 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);
|
|
|
@@ -174,14 +186,13 @@ public class KwoTradeOrderService {
|
|
|
* @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void addValetOrderDraft(ValetOrderParam param) {
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
.setUnit(Objects.nonNull(param.getGoodsInfo()) ? param.getGoodsInfo().getUnit() : null)
|
|
|
- .setSource(DictEnum.TORDER_SOURCE_1.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
|
|
|
+ .setSource(DictEnum.TORDER_SOURCE_2.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
|
|
|
kwoTradeOrderMapper.insert(order);
|
|
|
- addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class));
|
|
|
+ addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -191,31 +202,44 @@ public class KwoTradeOrderService {
|
|
|
* @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void addPurchaseOrderSubmit(PurchaseOrderParam param) {
|
|
|
- orderCheck(param);
|
|
|
+ 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_0.getValue())
|
|
|
+ .setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_1.getValue())
|
|
|
.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_1.getValue()));
|
|
|
kwoTradeOrderMapper.insert(order);
|
|
|
- goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(),param.getAmount());
|
|
|
- addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class));
|
|
|
+ goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());
|
|
|
+ addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
|
|
|
}
|
|
|
|
|
|
- private void orderCheck(PurchaseOrderParam param) {
|
|
|
+ /**
|
|
|
+ * @desc: 订单提交校验
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-14 14:46
|
|
|
+ * @Param goodId: 商品id
|
|
|
+ * @Param trading: 交易方式
|
|
|
+ * @Param price: 订单金额
|
|
|
+ * @Param amount: 订单总量
|
|
|
+ * @Param unitPrice: 成交价格
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ 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(param.getGoodsInfo().getGoodsId());
|
|
|
+ KwpGoods goods = goodsInfoService.getGoodsById(goodId);
|
|
|
if (Objects.isNull(goods) || !Objects.equals(goods.getStatus(), 1)) {
|
|
|
throw new BusinessException("商品不存在或已下架!");
|
|
|
}
|
|
|
- if (Objects.equals(param.getTrading(), DictEnum.TRADE_TYPE_0.getValue())) {
|
|
|
- if (param.getPrice().compareTo(goods.getAdvancePrice()) < 0){
|
|
|
+ if (Objects.equals(trading, DictEnum.TRADE_TYPE_0.getValue())) {
|
|
|
+ if (price.compareTo(goods.getAdvancePrice()) < 0) {
|
|
|
throw new BusinessException("采购订单金额不能小于商品最低预付款限额!");
|
|
|
}
|
|
|
}
|
|
|
- BigDecimal goodsAmount = goods.getAmount();
|
|
|
- if (goods.getAmount().compareTo(param.getAmount()) < 0) {
|
|
|
+ if (goods.getAmount().compareTo(amount) < 0) {
|
|
|
throw new BusinessException("商品库存量小于采购数量!");
|
|
|
}
|
|
|
}
|
|
|
@@ -229,10 +253,10 @@ public class KwoTradeOrderService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addValetOrderSubmit(ValetOrderParam param) {
|
|
|
- orderCheck(param);
|
|
|
+ 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());
|
|
|
+ .setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_2.getValue());
|
|
|
String contractStatus = param.getContractInfo().getContractStatus();
|
|
|
if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_0.getValue())) {
|
|
|
order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()));
|
|
|
@@ -242,8 +266,8 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException("Invalid contract status");
|
|
|
}
|
|
|
kwoTradeOrderMapper.insert(order);
|
|
|
- goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(),param.getAmount());
|
|
|
- addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class));
|
|
|
+ goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());
|
|
|
+ addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -254,51 +278,341 @@ public class KwoTradeOrderService {
|
|
|
* @return: com.sckw.order.model.vo.res.OrderDetail
|
|
|
*/
|
|
|
public OrderDetailRes detail(Long id) {
|
|
|
- return null;
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(id, LoginUserHolder.getEntId(), null)) {
|
|
|
+ throw new BusinessException("无权限查看数据!");
|
|
|
+ }
|
|
|
+ KwoTradeOrder order = getById(id);
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("不存在该订单!");
|
|
|
+ }
|
|
|
+ OrderDetailRes orderDetail = BeanUtils.copyProperties(order, OrderDetailRes.class);
|
|
|
+ KwoTradeOrderGoods tradeOrderGoods = kwoTradeOrderGoodsService.getByOrderId(id);
|
|
|
+ return orderDetail;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @desc: 修改订单
|
|
|
* @author: yzc
|
|
|
* @date: 2023-07-07 15:34
|
|
|
- * @Param updateOrderParam:
|
|
|
+ * @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- public void update(UpdateOrderParam updateOrderParam) {
|
|
|
+ public void update(UpdateOrderParam param) {
|
|
|
+ KwoTradeOrder order = getById(param.getId());
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("Order not found");
|
|
|
+ }
|
|
|
+ String source = order.getSource();
|
|
|
+ String status = String.valueOf(order.getStatus());
|
|
|
+ if ((!Objects.equals(status, DictEnum.TORDER_STATUS_0.getValue()) && !Objects.equals(status, DictEnum.TORDER_STATUS_2.getValue()))
|
|
|
+ && Objects.equals(source, DictEnum.TORDER_SOURCE_1.getValue())) {
|
|
|
+ throw new BusinessException("采购下单只能修改已保存及已退回状态的订单!");
|
|
|
+ }
|
|
|
+ if (Objects.equals(source, DictEnum.TORDER_SOURCE_2.getValue()) && !Objects.equals(status, DictEnum.TORDER_STATUS_0.getValue())) {
|
|
|
+ throw new BusinessException("代客下单只能修改已保存状态的订单!");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(param.getId(), LoginUserHolder.getEntId(), source)) {
|
|
|
+ throw new BusinessException("无权限修改此订单!");
|
|
|
+ }
|
|
|
+ if (Objects.equals(param.getOperateType(), 1)) {
|
|
|
+ checkParams(param, source);
|
|
|
+ if (Objects.equals(source, DictEnum.TORDER_SOURCE_1.getValue())) {
|
|
|
+ order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_1.getValue()));
|
|
|
+ } else {
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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())
|
|
|
+ .setDeliveryType(param.getDeliveryType()).setStartTime(param.getStartTime()).setEndTime(param.getEndTime())
|
|
|
+ .setRemark(param.getRemark());
|
|
|
+ kwoTradeOrderMapper.updateById(order);
|
|
|
+ ValetOrderParam valetOrderParam = BeanUtils.copyProperties(param, ValetOrderParam.class);
|
|
|
+ addOtherOrderInfo(order, valetOrderParam, true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void checkParams(UpdateOrderParam param, String source) {
|
|
|
+ if (Objects.isNull(param.getAmount())) {
|
|
|
+ throw new BusinessException("订单总量不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getPrice())) {
|
|
|
+ throw new BusinessException("订单金额不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getTrading())) {
|
|
|
+ throw new BusinessException("交易方式不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getPickupType())) {
|
|
|
+ throw new BusinessException("提货方式不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getStartTime())) {
|
|
|
+ throw new BusinessException("开始时间不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getEndTime())) {
|
|
|
+ throw new BusinessException("结束时间不能为空!");
|
|
|
+ }
|
|
|
+ ContractInfo contractInfo = param.getContractInfo();
|
|
|
+ if (Objects.equals(source, DictEnum.TORDER_SOURCE_2.getValue())) {
|
|
|
+ if (Objects.isNull(contractInfo)) {
|
|
|
+ throw new BusinessException("代客下单合同信息不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(contractInfo.getContractId())) {
|
|
|
+ throw new BusinessException("合同id不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(contractInfo.getContractNo())) {
|
|
|
+ throw new BusinessException("合同编号不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(contractInfo.getContractName())) {
|
|
|
+ throw new BusinessException("合同名称不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(contractInfo.getContractSigningWay())) {
|
|
|
+ throw new BusinessException("合同签约方式不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(contractInfo.getContractStatus())) {
|
|
|
+ throw new BusinessException("合同状态不能为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GoodsInfo goodsInfo = param.getGoodsInfo();
|
|
|
+ if (Objects.isNull(goodsInfo)) {
|
|
|
+ throw new BusinessException("商品信息不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(goodsInfo.getGoodsId())) {
|
|
|
+ throw new BusinessException("商品id不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getGoodsCode())) {
|
|
|
+ throw new BusinessException("商品编号不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getGoodsName())) {
|
|
|
+ throw new BusinessException("商品名称不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getGoodsType())) {
|
|
|
+ throw new BusinessException("商品类型不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(goodsInfo.getGoodsTaxRate())) {
|
|
|
+ throw new BusinessException("商品发票税率不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getGoodsSpec())) {
|
|
|
+ throw new BusinessException("商品尺寸大小不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getUnit())) {
|
|
|
+ throw new BusinessException("商品单位不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(goodsInfo.getPriceRangeId())) {
|
|
|
+ throw new BusinessException("价格段id不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(goodsInfo.getUnitPrice())) {
|
|
|
+ throw new BusinessException("订单成交单价不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(goodsInfo.getCollectionUnitId())) {
|
|
|
+ throw new BusinessException("收款单位id不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(goodsInfo.getCollectionUnit())) {
|
|
|
+ throw new BusinessException("收款单位名称不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UnitInfo> unitInfos = param.getUnitInfo();
|
|
|
+ if (CollectionUtils.isEmpty(unitInfos)) {
|
|
|
+ throw new BusinessException("单位信息不能为空!");
|
|
|
+ }
|
|
|
+ unitInfos.forEach(e -> {
|
|
|
+ if (Objects.isNull(e.getUnitType())) {
|
|
|
+ throw new BusinessException("单位类型不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(e.getEntId())) {
|
|
|
+ throw new BusinessException("企业id不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getFirmName())) {
|
|
|
+ throw new BusinessException("企业名称不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getContacts())) {
|
|
|
+ throw new BusinessException("联系人姓名不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getPhone())) {
|
|
|
+ throw new BusinessException("联系电话不能为空!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<AddressInfo> addressInfos = param.getAddressInfo();
|
|
|
+ if (CollectionUtils.isEmpty(addressInfos)) {
|
|
|
+ throw new BusinessException("地址信息不能为空!");
|
|
|
+ }
|
|
|
+ addressInfos.forEach(e -> {
|
|
|
+ if (StringUtils.isBlank(e.getAddressType())) {
|
|
|
+ throw new BusinessException("地址类型不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getName())) {
|
|
|
+ throw new BusinessException("地址名称不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getType())) {
|
|
|
+ throw new BusinessException("地址类型不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getContacts())) {
|
|
|
+ throw new BusinessException("联系人姓名不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getPhone())) {
|
|
|
+ throw new BusinessException("联系电话不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(e.getCityCode())) {
|
|
|
+ throw new BusinessException("所在地区code不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getCityName())) {
|
|
|
+ throw new BusinessException("所属区域名称不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getDetailAddress())) {
|
|
|
+ throw new BusinessException("详细地址不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getLat())) {
|
|
|
+ throw new BusinessException("纬度不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(e.getLng())) {
|
|
|
+ throw new BusinessException("经度不能为空!");
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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) {
|
|
|
|
|
|
}
|
|
|
|
|
|
public void batchDelete(List<Long> ids) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 根据id获取订单
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-13 17:14
|
|
|
+ * @Param id:
|
|
|
+ * @return: com.sckw.order.model.KwoTradeOrder
|
|
|
+ */
|
|
|
+ public KwoTradeOrder getById(Long id) {
|
|
|
+ LambdaQueryWrapper<KwoTradeOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwoTradeOrder::getId, id).eq(KwoTradeOrder::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
+ return kwoTradeOrderMapper.selectOne(wrapper);
|
|
|
+ }
|
|
|
}
|