|
@@ -1,26 +1,30 @@
|
|
|
package com.fjhx.service.purchase.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.entity.apply.ApplyPurchase;
|
|
|
import com.fjhx.entity.order.OrderDetails;
|
|
|
import com.fjhx.entity.order.OrderInfo;
|
|
|
import com.fjhx.entity.purchase.Purchase;
|
|
|
import com.fjhx.entity.purchase.PurchaseBack;
|
|
|
+import com.fjhx.mapper.purchase.PurchaseBackMapper;
|
|
|
import com.fjhx.params.purchase.PurchaseBackEx;
|
|
|
import com.fjhx.params.purchase.PurchaseBackVo;
|
|
|
-import com.fjhx.mapper.purchase.PurchaseBackMapper;
|
|
|
import com.fjhx.service.apply.ApplyPurchaseService;
|
|
|
import com.fjhx.service.order.OrderDetailsService;
|
|
|
import com.fjhx.service.order.OrderInfoService;
|
|
|
import com.fjhx.service.purchase.PurchaseBackService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.service.purchase.PurchaseService;
|
|
|
import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 采购退货 服务实现类
|
|
@@ -55,7 +59,6 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
|
|
|
save(purchaseBackVo);
|
|
|
//查询采购订单信息
|
|
|
Purchase purchase = purchaseService.getById(purchaseBackVo.getPurchaseId());
|
|
|
- ApplyPurchase applyPurchase = applyPurchaseService.getById(purchase.getApplyId());
|
|
|
//创建退货订单
|
|
|
OrderInfo orderInfo = new OrderInfo();
|
|
|
orderInfo.setType(7);
|
|
@@ -70,12 +73,19 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
|
|
|
orderInfo.setDetailedAddress(purchaseBackVo.getDetailedAddress());//详细地址
|
|
|
orderInfoService.save(orderInfo);
|
|
|
//创建订单明细
|
|
|
- OrderDetails orderDetails = new OrderDetails();
|
|
|
- orderDetails.setOrderId(orderInfo.getId());
|
|
|
- orderDetails.setProductId(applyPurchase.getGoodsId());
|
|
|
- orderDetails.setQuantity(purchaseBackVo.getQuantity());
|
|
|
- orderDetails.setPrice(applyPurchase.getUnitPrice());
|
|
|
- orderDetails.setNotIssuedQuantity(purchaseBackVo.getQuantity());
|
|
|
- orderDetailsService.save(orderDetails);
|
|
|
+ List<OrderDetails> orderDetailsList = new ArrayList<>();
|
|
|
+ for (ApplyPurchase applyPurchase : purchaseBackVo.getGoodsList()) {
|
|
|
+ //忽略退货数量为0或小于0的物品
|
|
|
+ if(applyPurchase.getQuantity().compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ OrderDetails orderDetails = new OrderDetails();
|
|
|
+ orderDetails.setOrderId(orderInfo.getId());
|
|
|
+ orderDetails.setProductId(applyPurchase.getGoodsId());
|
|
|
+ orderDetails.setQuantity(applyPurchase.getQuantity());
|
|
|
+ orderDetails.setPrice(applyPurchase.getUnitPrice());
|
|
|
+ orderDetails.setNotIssuedQuantity(applyPurchase.getQuantity());
|
|
|
+ orderDetailsList.add(orderDetails);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderDetailsService.saveBatch(orderDetailsList);
|
|
|
}
|
|
|
}
|