|
@@ -2,6 +2,7 @@ package com.fjhx.victoriatourist.service.order.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.area.service.AreaInfoService;
|
|
@@ -20,11 +21,18 @@ import com.fjhx.victoriatourist.service.order.OrderDetailsService;
|
|
|
import com.fjhx.victoriatourist.service.order.OrderInfoService;
|
|
|
import com.fjhx.victoriatourist.utils.Assert;
|
|
|
import com.fjhx.victoriatourist.utils.CodeEnum;
|
|
|
+import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
|
|
|
+import com.fjhx.wms.entity.stock.emums.StockWaitType;
|
|
|
+import com.fjhx.wms.entity.stock.po.StockWait;
|
|
|
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
|
|
|
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
+import com.fjhx.wms.service.stock.StockWaitService;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -47,6 +55,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
OrderDetailsService orderDetailsService;
|
|
|
@Autowired
|
|
|
ProductInfoService productInfoService;
|
|
|
+ @Autowired
|
|
|
+ StockWaitService stockWaitService;
|
|
|
+ @Autowired
|
|
|
+ StockWaitDetailsService stockWaitDetailsService;
|
|
|
|
|
|
@Override
|
|
|
public Page<OrderInfoVo> getPage(OrderInfoSelectDto dto) {
|
|
@@ -98,6 +110,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void add(OrderInfoDto orderInfoDto) {
|
|
|
// 订单明细
|
|
@@ -131,12 +144,35 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
this.save(orderInfoDto);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 添加订单明细
|
|
|
for (OrderDetails orderDetails : orderDetailsList) {
|
|
|
orderDetails.setOrderId(orderInfoDto.getId());
|
|
|
orderDetails.setNotIssuedQuantity(orderDetails.getQuantity());
|
|
|
}
|
|
|
orderDetailsService.saveBatch(orderDetailsList);
|
|
|
+
|
|
|
+
|
|
|
+ //添加待出库记录
|
|
|
+ StockWait stockWait = new StockWait();
|
|
|
+ stockWait.setType(2);//待出库
|
|
|
+ stockWait.setBusinessType(StockWaitType.SALE_ORDER_OUT.getDetailType());
|
|
|
+ stockWait.setBusinessId(orderInfoDto.getId());
|
|
|
+ stockWait.setBusinessCode(orderInfoDto.getCode());
|
|
|
+ stockWait.setStatus(0);//待出库
|
|
|
+ stockWaitService.save(stockWait);
|
|
|
+ //创建待出库明细
|
|
|
+ List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|
|
|
+ for (OrderDetails orderDetails : orderDetailsList) {
|
|
|
+ StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
+ stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
+ stockWaitDetails.setBusinessDetailsId(orderDetails.getId());
|
|
|
+ stockWaitDetails.setProductId(orderDetails.getProductId());
|
|
|
+ stockWaitDetails.setQuantity(orderDetails.getQuantity());
|
|
|
+ stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
+ stockWaitDetailsList.add(stockWaitDetails);
|
|
|
+ }
|
|
|
+ stockWaitDetailsService.saveBatch(stockWaitDetailsList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -149,4 +185,38 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 销售订单待出库出库
|
|
|
+ */
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void outbound(StockWaitDetailsDto stockWaitDetailsDto) {
|
|
|
+ //操作销售订单
|
|
|
+ StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
|
|
|
+ OrderDetails orderDetails = orderDetailsService.getById(stockWaitDetails.getBusinessDetailsId());
|
|
|
+ //减少未出库数量
|
|
|
+ orderDetails.setNotIssuedQuantity(orderDetails.getNotIssuedQuantity().subtract(stockWaitDetailsDto.getQuantity()));
|
|
|
+ orderDetailsService.updateById(orderDetails);
|
|
|
+ //修改销售订单状态
|
|
|
+ Integer statusFlag = 0;
|
|
|
+ List<OrderDetails> orderDetailsList = orderDetailsService.list(q -> q.eq(OrderDetails::getOrderId, orderDetails.getOrderId()));
|
|
|
+ for (OrderDetails details : orderDetailsList) {
|
|
|
+ //统计已经完全出库的条数
|
|
|
+ if(details.getNotIssuedQuantity().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ statusFlag++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OrderInfo orderInfo = getById(orderDetails.getOrderId());
|
|
|
+ if(statusFlag == orderDetailsList.size()){
|
|
|
+ //完全出库
|
|
|
+ orderInfo.setStatus(2);//订单状态 1进行中 2已完成 3已取消
|
|
|
+ orderInfo.setIssueStatus(3);//出库状态 1未出库 2进行中 3已出库
|
|
|
+ }else{
|
|
|
+ //部分出库
|
|
|
+ orderInfo.setStatus(1);//订单状态 1进行中 2已完成 3已取消
|
|
|
+ orderInfo.setIssueStatus(2);//出库状态 1未出库 2进行中 3已出库
|
|
|
+ }
|
|
|
+ updateById(orderInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|