|
|
@@ -360,7 +360,6 @@ class ProductController extends BaseController
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
|
|
|
- $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock', 'id');
|
|
|
|
|
|
//获取所有当前供货商的分类 (全部、常用)
|
|
|
//根据分类组装分类下的花材信息
|
|
|
@@ -380,9 +379,19 @@ class ProductController extends BaseController
|
|
|
$field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,skPrice,skDiscountPrice,hjPrice,hjDiscountPrice,actualSold,stock,stockWarning,discountPrice,presell,presellDate,reachNum,reachNumDiscount';
|
|
|
$itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
$itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
|
|
|
-print_r($itemInfoData);die;
|
|
|
+ $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning', 'id');
|
|
|
+ if (!empty($itemInfoData)) {
|
|
|
+ foreach ($itemInfoData as $key => $val) {
|
|
|
+ $productId = $val['id'] ?? 0;
|
|
|
+ $myStock = $myProduct[$productId]['stock'] ?? 0;
|
|
|
+ $myOnStock = $myProduct[$productId]['onStock'] ?? 0;
|
|
|
+ $myStockWarning = $myProduct[$productId]['stockWarning'] ?? 5;
|
|
|
+ $itemInfoData[$key]['myStock'] = $myStock;
|
|
|
+ $itemInfoData[$key]['myOnStock'] = $myOnStock;
|
|
|
+ $itemInfoData[$key]['myStockWarning'] = $myStockWarning;
|
|
|
+ }
|
|
|
+ }
|
|
|
$data = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
-
|
|
|
util::success($data);
|
|
|
} catch (\Exception $e) {
|
|
|
$transaction->rollBack();
|