wangzhuo 3 лет назад
Родитель
Сommit
acccfa6a0b

+ 1 - 1
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsDescController.java

@@ -479,7 +479,7 @@ public class GoodsDescController extends BladeController {
 				stockGoods.setGoodsId(e.getId());
 				stockGoods.setTradeType("GN");
 				stockGoods.setItemType(e.getTypeno());
-				stockGoods.setTenantId(SecureUtil.getTenantId());
+				stockGoods.setTenantId(AuthUtil.getTenantId());
 				List<StockGoods> stockGoodsList = stockGoodsClient.postListStockByCondition(stockGoods);
 				if (CollectionUtils.isNotEmpty(stockGoodsList)) {
 					goodsOutExcel.setStorageQuantity(stockGoodsList.stream().map(StockGoods::getSurplusRouteQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));

+ 6 - 1
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryServiceImpl.java

@@ -147,6 +147,9 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 	@Transactional(rollbackFor = Exception.class)
 	public R submitDelivery(Delivery delivery) {
 		String status = null;//订单状态
+		if(ObjectUtil.isEmpty(delivery.getSalesCompany())){
+			throw new SecurityException("单据所属公司不能为空");
+		}
 		if (StringUtils.isBlank(delivery.getDeliveryStatus())) {
 			status = DeliveryStatusEnum.REPEAL.getType();
 		} else {
@@ -462,6 +465,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			String saleOrderNo = select.getOrderNo();
 			//采购订单号
 			String purchaseOrderNo = null;
+			String deliveryAmount = null;
 			//根据销售订单号,查询采购订单号
 			Order order = new Order();
 			order.setBillType("XS");
@@ -470,6 +474,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			R<List<Order>> listR = orderDescClient.getByCgList(order);
 			if (listR.isSuccess() && CollectionUtils.isNotEmpty(listR.getData())) {
 				purchaseOrderNo = listR.getData().get(0).getOrderNo();
+				deliveryAmount = listR.getData().get(0).getDebitAmount().toString();
 			}
 
 
@@ -507,7 +512,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			String purchaseTotalAmount = CollectionUtils.isEmpty(deliveryItems) ? "0" : pricetotal1.toString();
 			//明细总销售价
 			/*String deliveryAmount = CollectionUtils.isEmpty(deliveryItems) ? "0" : pricetotal2.toString();*/
-			String deliveryAmount = delivery.getDeliveryAmount().toString();
+			/*String deliveryAmount = delivery.getDeliveryAmount().toString();*/
 
 			//=============生成凭证所需信息==============
 			String accountName = select.getBelongCompany();

+ 19 - 18
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml

@@ -1461,7 +1461,7 @@ ORDER BY
         SELECT
             BO.charge_member as chargeMember,
             SUM(BOI.quantity) AS quantity,
-            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.debit_amount) - SUM(BOI.purchaseAmount) AS grossProfit,
             SUM(BO.debit_amount) AS amount
         FROM
         business_order BO
@@ -1469,7 +1469,8 @@ ORDER BY
             SELECT
                 pid,
                 item_id,
-                IFNULL( SUM( actual_quantity ), 0 ) AS quantity
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity,
+                IFNULL( sum( actual_quantity * purchase_amount ), 0 ) AS purchaseAmount
             FROM
                 business_order_items
             WHERE is_deleted = 0
@@ -1558,10 +1559,10 @@ ORDER BY
             SUM(BOI.quantity) AS quantity,
             SUM(BOI.purchaseAmount) AS purchaseAmount,
             SUM(BO.this_used_profit) AS thisUsedProfit,
-            SUM(BO.gross_profit) AS grossProfit,
+            SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) AS grossProfit,
             SUM(BO.predict_ocean_freight) AS predictOceanFreight,
-            SUM(BO.gross_profit) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
-            SUM( BO.gross_profit ) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
+            SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
+            (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
         FROM
             business_order BO
         LEFT JOIN (
@@ -1611,10 +1612,10 @@ ORDER BY
         SUM(BOI.quantity) AS quantity,
         SUM(BOI.purchaseAmount) AS purchaseAmount,
         SUM(BO.this_used_profit) AS thisUsedProfit,
-        SUM(BO.gross_profit) AS grossProfit,
+        SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) AS grossProfit,
         SUM(BO.predict_ocean_freight) AS predictOceanFreight,
-        SUM(BO.gross_profit) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
-        SUM( BO.gross_profit ) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
+        SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
+        (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
         FROM
         business_order BO
         LEFT JOIN (
@@ -1664,10 +1665,10 @@ ORDER BY
             SUM( BOI.quantity ) AS quantity,
             SUM( BOI.purchaseAmount ) AS purchaseAmount,
             SUM( BO.this_used_profit ) AS thisUsedProfit,
-            SUM( BO.gross_profit ) AS grossProfit,
+            SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) AS grossProfit,
             SUM( BO.predict_ocean_freight ) AS predictOceanFreight,
-            SUM( BO.gross_profit ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
-            SUM( BO.gross_profit ) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
+            SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
+            (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
         FROM
         business_order BO
         LEFT JOIN (
@@ -1715,10 +1716,10 @@ ORDER BY
         SUM( BOI.quantity ) AS quantity,
         SUM( BOI.purchaseAmount ) AS purchaseAmount,
         SUM( BO.this_used_profit ) AS thisUsedProfit,
-        SUM( BO.gross_profit ) AS grossProfit,
+        SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) AS grossProfit,
         SUM( BO.predict_ocean_freight ) AS predictOceanFreight,
-        SUM( BO.gross_profit ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
-        SUM( BO.gross_profit ) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
+        SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount ) - SUM( BO.predict_ocean_freight ) AS netGrossProfit,
+        (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
         FROM
         business_order BO
         LEFT JOIN (
@@ -1767,11 +1768,11 @@ ORDER BY
             SUM( BOI.quantity ) AS quantity,
             SUM( BO.this_used_profit ) AS thisUsedProfit,
             ( SUM( BO.debit_amount ) / SUM( BOI.quantity ) ) AS price,
-            (SUM( BO.gross_profit ) + (-SUM( BO.this_used_profit ))) / SUM( BOI.quantity ) AS singleGrossProfit,
+            ((SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) + (-SUM( BO.this_used_profit ))) / SUM( BOI.quantity ) AS singleGrossProfit,
             SUM( BO.predict_ocean_freight ) AS predictOceanFreight,
-            SUM( BO.gross_profit )  AS netGrossProfit,
-            SUM( BO.gross_profit ) + (-SUM( BO.this_used_profit )) AS grossProfit,
-            (SUM( BO.gross_profit ) + (-SUM( BO.this_used_profit ))) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
+            SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )  AS netGrossProfit,
+            (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) + (-SUM( BO.this_used_profit )) AS grossProfit,
+            ((SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) + (-SUM( BO.this_used_profit ))) / SUM( BO.debit_amount ) * 100 AS grossProfitRate
         FROM
             business_order BO
                 LEFT JOIN (

+ 1 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -745,6 +745,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 				selectById.setBillType(order.getBillType());
 				selectById.setTradeType(order.getTradeType());
 				selectById.setCreateFreight(0);
+				selectById.setBelongToCorpId(null);
 				if (order.getBusinesDate() == null) {
 					selectById.setBusinesDate(new Date());
 				}

+ 1 - 1
blade-service/blade-stock/src/main/java/org/springblade/stock/feign/StockGoodsClient.java

@@ -284,7 +284,7 @@ public class StockGoodsClient implements IStockGoodsClient {
 			.eq(StringUtils.isNotBlank(stockGoods.getBillNo()), StockGoods::getBillNo, stockGoods.getBillNo())
 			.eq(StringUtils.isNotBlank(stockGoods.getCntrNo()), StockGoods::getCntrNo, stockGoods.getCntrNo())
 			.eq(StockGoods::getIsDeleted, 0)
-			.eq(StockGoods::getTenantId, AuthUtil.getTenantId());
+			.eq(StockGoods::getTenantId, stockGoods.getTenantId());
 		List<StockGoods> goodsList = stockGoodsService.list(stockGoodsLambdaQueryWrapper);
 		if (CollectionUtils.isNotEmpty(goodsList)) {
 			goodsList.forEach(e -> {