|
|
@@ -2,7 +2,9 @@ package com.sckw.order.serivce;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
@@ -11,15 +13,18 @@ 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.mongo.model.TradeOrderUpdateParam;
|
|
|
import com.sckw.order.dao.KwoTradeOrderMapper;
|
|
|
import com.sckw.order.model.*;
|
|
|
import com.sckw.order.model.vo.req.*;
|
|
|
+import com.sckw.order.model.vo.res.AddressInfoDetailRes;
|
|
|
+import com.sckw.order.model.vo.res.GoodsInfoDetailRes;
|
|
|
import com.sckw.order.model.vo.res.OrderDetailRes;
|
|
|
+import com.sckw.order.model.vo.res.UnitInfoDetailRes;
|
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
import com.sckw.product.api.model.KwpGoods;
|
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
@@ -28,10 +33,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @desc: 交易订单(采购订单/销售订单)service
|
|
|
@@ -91,11 +93,8 @@ public class KwoTradeOrderService {
|
|
|
Long id = tradeOrder.getId();
|
|
|
String tOrderNo = tradeOrder.getTOrderNo();
|
|
|
SckwTradeOrder order = new SckwTradeOrder();
|
|
|
- //todo: 当前线程获取企业名称
|
|
|
//提前填充这些参数防止初始创建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())
|
|
|
+ order.setFirmName(LoginUserHolder.getEntName()).setTOrderId(id).setCreateByName(LoginUserHolder.getUserName())
|
|
|
.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
BeanUtils.copyProperties(tradeOrder, order);
|
|
|
//商品信息
|
|
|
@@ -113,11 +112,10 @@ public class KwoTradeOrderService {
|
|
|
if (CollectionUtils.isNotEmpty(unitInfos)) {
|
|
|
List<KwoTradeOrderUnit> list = new ArrayList<>(unitInfos.size());
|
|
|
List<Long> entIds = unitInfos.stream().map(UnitInfo::getEntId).distinct().toList();
|
|
|
- //todo: 获取一级企业信息
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
|
|
|
unitInfos.forEach(e -> {
|
|
|
KwoTradeOrderUnit unit = BeanUtils.copyProperties(e, KwoTradeOrderUnit.class);
|
|
|
- unit.setTOrderId(id).setTOrderNo(tOrderNo)
|
|
|
- .setTopEntId(e.getEntId());
|
|
|
+ unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(entMap.get(e.getEntId()).getId());
|
|
|
list.add(unit);
|
|
|
if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
|
|
|
order.setSupplyEntId(e.getEntId()).setSupplyTopEntId(e.getEntId()).setSupplyFirmName(e.getFirmName())
|
|
|
@@ -211,12 +209,13 @@ public class KwoTradeOrderService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void addPurchaseOrderSubmit(PurchaseOrderParam param) {
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice(), false);
|
|
|
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())
|
|
|
.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), false);
|
|
|
}
|
|
|
@@ -232,9 +231,8 @@ public class KwoTradeOrderService {
|
|
|
* @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) {
|
|
|
+ private void orderCheck(Long goodId, String trading, BigDecimal price, BigDecimal amount, BigDecimal unitPrice, Boolean isAcceptanceOrder) {
|
|
|
+ if (!isAcceptanceOrder && price.compareTo(amount.multiply(unitPrice)) != 0) {
|
|
|
throw new BusinessException("订单总金额不等于商品单价*订单总量!");
|
|
|
}
|
|
|
//todo: 则先校验是否存在对供应企业的预付钱包 ;【预计采购金额】是否大于预付清单的【可用预付】金额
|
|
|
@@ -242,10 +240,9 @@ public class KwoTradeOrderService {
|
|
|
if (Objects.isNull(goods) || !Objects.equals(goods.getStatus(), 1)) {
|
|
|
throw new BusinessException("商品不存在或已下架!");
|
|
|
}
|
|
|
- if (Objects.equals(trading, DictEnum.TRADE_TYPE_0.getValue())) {
|
|
|
- if (price.compareTo(goods.getAdvancePrice()) < 0) {
|
|
|
- throw new BusinessException("采购订单金额不能小于商品最低预付款限额!");
|
|
|
- }
|
|
|
+ //受理订单不校验预付款限额
|
|
|
+ if (!isAcceptanceOrder && Objects.equals(trading, DictEnum.TRADE_TYPE_0.getValue()) && price.compareTo(goods.getAdvancePrice()) < 0) {
|
|
|
+ throw new BusinessException("采购订单金额不能小于商品最低预付款限额!");
|
|
|
}
|
|
|
if (goods.getAmount().compareTo(amount) < 0) {
|
|
|
throw new BusinessException("商品库存量小于采购数量!");
|
|
|
@@ -261,7 +258,7 @@ public class KwoTradeOrderService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addValetOrderSubmit(ValetOrderParam param) {
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice(), false);
|
|
|
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());
|
|
|
@@ -274,6 +271,7 @@ 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), false);
|
|
|
}
|
|
|
@@ -286,16 +284,65 @@ public class KwoTradeOrderService {
|
|
|
* @return: com.sckw.order.model.vo.res.OrderDetail
|
|
|
*/
|
|
|
public OrderDetailRes detail(Long id) {
|
|
|
- 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;
|
|
|
+ //订单基本信息
|
|
|
+ OrderDetailRes detail = BeanUtils.copyProperties(order, OrderDetailRes.class);
|
|
|
+ EntCacheResDto ent = remoteSystemService.queryEntCacheById(detail.getEntId());
|
|
|
+ detail.setFirmName(Objects.isNull(ent) ? null : ent.getFirmName())
|
|
|
+ .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), detail.getTrading()))
|
|
|
+ .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), detail.getPickupType()))
|
|
|
+ .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), detail.getDeliveryType()))
|
|
|
+ .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), detail.getSource()))
|
|
|
+ .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(detail.getStatus())));
|
|
|
+ //商品信息
|
|
|
+ KwoTradeOrderGoods orderGoods = kwoTradeOrderGoodsService.getByOrderId(id);
|
|
|
+ if (Objects.nonNull(orderGoods)) {
|
|
|
+ KwpGoods goods = goodsInfoService.getGoodsById(orderGoods.getGoodsId());
|
|
|
+ if (Objects.nonNull(goods)) {
|
|
|
+ EntCacheResDto entCache = remoteSystemService.queryEntCacheById(goods.getEntId());
|
|
|
+ GoodsInfoDetailRes goodsDetail = new GoodsInfoDetailRes();
|
|
|
+ goodsDetail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goods.getGoodsType()))
|
|
|
+ .setGoodsUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goods.getUnit()))
|
|
|
+ .setGoodsTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), String.valueOf(goods.getTaxRate())))
|
|
|
+ .setGoodsId(goods.getId()).setGoodsCode(goods.getCode()).setGoodsName(goods.getName())
|
|
|
+ .setGoodsType(goods.getGoodsType()).setGoodsTaxRate(goods.getTaxRate()).setGoodsSpec(goods.getSpec())
|
|
|
+ .setUnit(goods.getUnit()).setPriceRangeId(orderGoods.getPriceRangeId()).setUnitPrice(orderGoods.getUnitPrice())
|
|
|
+ .setSkuId(orderGoods.getSkuId()).setCollectionUnitId(goods.getEntId()).setCollectionUnitId(goods.getEntId())
|
|
|
+ .setCollectionUnit(Objects.isNull(entCache) ? null : entCache.getFirmName());
|
|
|
+ detail.setGoodsInfo(goodsDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //单位信息
|
|
|
+ List<KwoTradeOrderUnit> units = kwoTradeOrderUnitService.getByOrderId(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(units)) {
|
|
|
+ List<UnitInfoDetailRes> unitInfos = BeanUtils.copyToList(units, UnitInfoDetailRes.class);
|
|
|
+ unitInfos.forEach(e -> {
|
|
|
+ e.setUnitTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_UNIT_TYPE.getType(), e.getUnitType()));
|
|
|
+ });
|
|
|
+ detail.setUnitInfo(unitInfos);
|
|
|
+ }
|
|
|
+ //地址信息
|
|
|
+ List<KwoTradeOrderAddress> addressList = kwoTradeOrderAddressService.getByOrderId(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(addressList)) {
|
|
|
+ List<AddressInfoDetailRes> addressInfoDetails = BeanUtils.copyToList(addressList, AddressInfoDetailRes.class);
|
|
|
+ addressInfoDetails.forEach(e -> {
|
|
|
+ e.setAddressTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), e.getAddressType()));
|
|
|
+ e.setTypeLabel(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), e.getType()));
|
|
|
+ });
|
|
|
+ detail.setAddressInfo(addressInfoDetails);
|
|
|
+ }
|
|
|
+ //合同信息
|
|
|
+ KwoTradeOrderContract contract = kwoTradeOrderContractService.getByOrderId(id);
|
|
|
+ if (Objects.nonNull(contract)) {
|
|
|
+ ContractInfo contractInfo = BeanUtils.copyProperties(contract, ContractInfo.class);
|
|
|
+ //todo:获取合同信息
|
|
|
+ detail.setContractInfo(contractInfo);
|
|
|
+ }
|
|
|
+ return detail;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -336,7 +383,9 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException("Invalid contract status");
|
|
|
}
|
|
|
}
|
|
|
- orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheck(param.getGoodsInfo().getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getGoodsInfo().getUnitPrice(), false);
|
|
|
+ //扣减库存
|
|
|
+ goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());
|
|
|
}
|
|
|
order.setAmount(param.getAmount()).setUnit(Objects.isNull(param.getGoodsInfo()) ? null : param.getGoodsInfo().getUnit())
|
|
|
.setPrice(param.getPrice()).setTrading(param.getTrading()).setPickupType(param.getPickupType())
|
|
|
@@ -344,6 +393,7 @@ public class KwoTradeOrderService {
|
|
|
.setRemark(param.getRemark());
|
|
|
kwoTradeOrderMapper.updateById(order);
|
|
|
ValetOrderParam valetOrderParam = BeanUtils.copyProperties(param, ValetOrderParam.class);
|
|
|
+
|
|
|
addOtherOrderInfo(order, valetOrderParam, true);
|
|
|
}
|
|
|
|
|
|
@@ -494,6 +544,9 @@ public class KwoTradeOrderService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void acceptanceOrder(AcceptanceOrderParam param) {
|
|
|
+ if (param.getPrice().compareTo(param.getUnitPrice().multiply(param.getAmount())) != 0) {
|
|
|
+ throw new BusinessException("订单总金额不等于商品单价*订单总量!");
|
|
|
+ }
|
|
|
KwoTradeOrder order = getById(param.getId());
|
|
|
if (Objects.isNull(order)) {
|
|
|
throw new BusinessException("Order not found");
|
|
|
@@ -508,7 +561,9 @@ public class KwoTradeOrderService {
|
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("订单商品信息异常!");
|
|
|
}
|
|
|
- orderCheck(goods.getGoodsId(), param.getTrading(), param.getPrice(), param.getAmount(), param.getUnitPrice());
|
|
|
+ //受理订单总量-原订单总量=订单变化量
|
|
|
+ BigDecimal amount = param.getAmount().subtract(order.getAmount());
|
|
|
+ orderCheck(goods.getGoodsId(), param.getTrading(), param.getPrice(), amount, param.getUnitPrice(), true);
|
|
|
//更新订单信息
|
|
|
BeanUtils.copyProperties(param, order);
|
|
|
String contractStatus = param.getContractInfo().getContractStatus();
|
|
|
@@ -527,10 +582,14 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderContractService.insert(contract);
|
|
|
//订单状态记录
|
|
|
KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
- track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo());
|
|
|
+ track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setStatus(order.getStatus());
|
|
|
kwoTradeOrderTrackService.insert(track);
|
|
|
+ //更新库存
|
|
|
+ if (amount.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ goodsInfoService.updateGoodsAmount(goods.getGoodsId(), amount);
|
|
|
+ }
|
|
|
//更新mongodb
|
|
|
- TradeOrderUpdateParam updateParam = BeanUtils.copyProperties(param, TradeOrderUpdateParam.class);
|
|
|
+ SckwTradeOrder updateParam = BeanUtils.copyProperties(param, SckwTradeOrder.class);
|
|
|
updateParam.setTOrderId(param.getId()).setStatus(order.getStatus()).setContractId(contractInfo.getContractId())
|
|
|
.setContractNo(contractInfo.getContractNo()).setContractName(contractInfo.getContractName())
|
|
|
.setContractSigningWay(contractInfo.getContractSigningWay()).setUpdateBy(LoginUserHolder.getUserId())
|
|
|
@@ -561,13 +620,13 @@ public class KwoTradeOrderService {
|
|
|
kwoTradeOrderMapper.updateById(order);
|
|
|
//订单状态记录
|
|
|
KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
- track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setRemark(param.getRemark());
|
|
|
+ track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setRemark(param.getRemark()).setStatus(order.getStatus());
|
|
|
kwoTradeOrderTrackService.insert(track);
|
|
|
//释放商品库存
|
|
|
KwoTradeOrderGoods goods = kwoTradeOrderGoodsService.getByOrderId(order.getId());
|
|
|
- goodsInfoService.updateGoodsAmount(goods.getGoodsId(),order.getAmount());
|
|
|
+ goodsInfoService.updateGoodsAmount(goods.getGoodsId(), order.getAmount().negate());
|
|
|
//mongodb更新订单状态
|
|
|
- TradeOrderUpdateParam updateParam = new TradeOrderUpdateParam();
|
|
|
+ SckwTradeOrder updateParam = new SckwTradeOrder();
|
|
|
updateParam.setTOrderId(order.getId()).setStatus(order.getStatus()).setUpdateBy(LoginUserHolder.getUserId())
|
|
|
.setUpdateByName(LoginUserHolder.getUserName()).setUpdateTime(new Date());
|
|
|
saveMongoDb(3, updateParam);
|
|
|
@@ -601,16 +660,63 @@ public class KwoTradeOrderService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void completeOrder(CompleteOrderParam param) {
|
|
|
+ KwoTradeOrder order = getById(param.getId());
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
+ throw new BusinessException("Order not found");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
|
|
|
+ throw new BusinessException("执行中的订单才能完结订单!");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entMatch(param.getId(),LoginUserHolder.getEntId(),DictEnum.TORDER_UNIT_TYPE_2.getValue())){
|
|
|
+ throw new BusinessException("无订单操作权限!");
|
|
|
+ }
|
|
|
+ KwoTradeOrderGoods goods = kwoTradeOrderGoodsService.getByOrderId(param.getId());
|
|
|
+ if (Objects.isNull(goods)) {
|
|
|
+ throw new BusinessException("商品信息异常!");
|
|
|
+ }
|
|
|
+ order.setActualAmount(param.getActualAmount()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()));
|
|
|
+ kwoTradeOrderMapper.updateById(order);
|
|
|
+ //订单状态记录
|
|
|
+ KwoTradeOrderTrack track = new KwoTradeOrderTrack();
|
|
|
+ track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setRemark(param.getRemark()).setStatus(order.getStatus());
|
|
|
+ kwoTradeOrderTrackService.insert(track);
|
|
|
+ //更新库存
|
|
|
+ BigDecimal amount = param.getActualAmount().subtract(order.getAmount());
|
|
|
+ goodsInfoService.updateGoodsAmount(goods.getGoodsId(), amount);
|
|
|
+ //mongodb更新订单状态
|
|
|
+ SckwTradeOrder updateParam = new SckwTradeOrder();
|
|
|
+ updateParam.setTOrderId(order.getId()).setStatus(order.getStatus()).setUpdateBy(LoginUserHolder.getUserId())
|
|
|
+ .setUpdateByName(LoginUserHolder.getUserName()).setUpdateTime(new Date());
|
|
|
+ saveMongoDb(3, updateParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void export(CompleteOrderParam param) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void batchDelete(List<Long> ids) {
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @desc: 批量删除
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-17 20:35
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ public void batchDelete(BatchDeleteParam param) {
|
|
|
+ List<Long> ids = param.getIds();
|
|
|
+ LambdaQueryWrapper<KwoTradeOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwoTradeOrder::getId, ids).ne(KwoTradeOrder::getStatus, 0).eq(KwoTradeOrder::getDelFlag, Global.NO);
|
|
|
+ List<KwoTradeOrder> list = kwoTradeOrderMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ throw new BusinessException("删除操作仅针对“已保存”状态的订单");
|
|
|
+ }
|
|
|
+ if (kwoTradeOrderUnitService.entBatchMatch(ids, LoginUserHolder.getEntId(), String.valueOf(param.getOrderType()))) {
|
|
|
+ throw new BusinessException("无订单操作权限!");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwoTradeOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwoTradeOrder::getDelFlag, Global.YES).in(KwoTradeOrder::getId, ids);
|
|
|
+ kwoTradeOrderMapper.update(null, updateWrapper);
|
|
|
+ kwoTradeOrderGoodsService.delByOrderIds(ids);
|
|
|
+ kwoTradeOrderUnitService.delByOrderIds(ids);
|
|
|
+ kwoTradeOrderAddressService.delByOrderIds(ids);
|
|
|
+ kwoTradeOrderContractService.delByOrderIds(ids);
|
|
|
}
|
|
|
|
|
|
/**
|