shish 3 лет назад
Родитель
Сommit
e55f09d647
1 измененных файлов с 18 добавлено и 0 удалено
  1. 18 0
      app-ghs/controllers/PurchaseOrderItemController.php

+ 18 - 0
app-ghs/controllers/PurchaseOrderItemController.php

@@ -4,6 +4,7 @@ namespace ghs\controllers;
 
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\order\classes\PurchaseOrderItemClass;
+use bizGhs\product\classes\ProductClass;
 use common\components\util;
 use Yii;
 
@@ -21,6 +22,23 @@ class PurchaseOrderItemController extends BaseController
         }
         $orderSn = $cg->orderSn ?? '';
         $list = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
+        if (!empty($list)) {
+            $productIdList = array_column($list, 'productId');
+            $itemList = ProductClass::getByIds($productIdList, null, 'id');
+            foreach ($list as $key => $info) {
+                $productId = $info['productId'] ?? 0;
+                $cost = $info['cost'] ?? 0;
+                $current = $itemList[$productId] ?? [];
+                $addPrice = $current['addPrice'] ?? 0;
+                $skMore = $current['skMore'] ?? 0;
+                $suggestPrice = bcadd($cost, $addPrice, 2);
+                $suggestPrice = floatval($suggestPrice);
+                $suggestSkPrice = bcadd($cost, $skMore, 2);
+                $suggestSkPrice = floatval($suggestSkPrice);
+                $list[$key]['suggestPrice'] = $suggestPrice;
+                $list[$key]['suggestSkPrice'] = $suggestSkPrice;
+            }
+        }
         util::success(['list' => $list]);
     }