| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace ghs\controllers;
- use bizGhs\order\classes\PurchaseOrderClass;
- use bizGhs\order\classes\PurchaseOrderItemClass;
- use bizGhs\product\classes\ProductClass;
- use common\components\util;
- use Yii;
- class PurchaseOrderItemController extends BaseController
- {
- //获取采购单的明细
- public function actionGetItemList()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $cg = PurchaseOrderClass::getById($id, true);
- if (isset($cg->mainId) == false || $cg->mainId != $this->mainId) {
- util::fail('没有权限');
- }
- $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;
- $cost = round($cost);
- $current = $itemList[$productId] ?? [];
- $addPrice = $current['addPrice'] ?? 0;
- $skMore = $current['skMore'] ?? 0;
- $suggestPrice = bcadd($cost, $addPrice, 2);
- $suggestPrice = floatval($suggestPrice);
- $suggestSkPrice = bcadd($suggestPrice, $skMore, 2);
- $suggestSkPrice = floatval($suggestSkPrice);
- $list[$key]['suggestPrice'] = $suggestPrice;
- $list[$key]['suggestSkPrice'] = $suggestSkPrice;
- $list[$key]['skMore'] = $skMore;
- $list[$key]['addPrice'] = $addPrice;
- }
- }
- util::success(['list' => $list]);
- }
- }
|