|
|
@@ -152,10 +152,9 @@ class ProductController extends BaseController
|
|
|
$field = 'id,cover,name,cost,itemId,classId,property,skPrice,skMore,addPrice,variety,price,discountPrice,skDiscountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio,actualSold';
|
|
|
$itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
$itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
|
|
|
-
|
|
|
- $data = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
-
|
|
|
- util::success($data);
|
|
|
+ $respond = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
+ $classItem = $respond['classItem'] ?? [];
|
|
|
+ util::success($classItem);
|
|
|
}
|
|
|
|
|
|
//当前门店所有花材分类
|
|
|
@@ -359,8 +358,68 @@ class ProductController extends BaseController
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
+ //获取所有当前供货商的分类 (全部、常用)
|
|
|
+ //根据分类组装分类下的花材信息
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $classIds = ItemClassClass::getGhsItemClassAll($mainId);
|
|
|
+ $where['mainId'] = $mainId;
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ //是否显示全部花材,包括下架的
|
|
|
+ $showAll = $get['showAll'] ?? 0;
|
|
|
+ if ($showAll == 0) {
|
|
|
+ $where['status'] = 1;
|
|
|
+ }
|
|
|
+ $where['frontHide'] = 0;
|
|
|
|
|
|
+ $level = $ghs['giveLevel'] ?? 1;
|
|
|
+ $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);
|
|
|
+ $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');
|
|
|
+ if (!empty($itemInfoData)) {
|
|
|
+ $myShop = $this->shop;
|
|
|
+ $myDisplay = isset($myShop->pfShopId) && $myShop->pfShopId > 0 ? 1 : 0;
|
|
|
+ foreach ($itemInfoData as $key => $val) {
|
|
|
+ $ptItemId = $val['itemId'] ?? 0;
|
|
|
+ $myStock = $myProduct[$ptItemId]['stock'] ?? 0;
|
|
|
+ $myStock = floatval($myStock);
|
|
|
+ $myOnStock = $myProduct[$ptItemId]['onStock'] ?? 0;
|
|
|
+ $myStockWarning = $myProduct[$ptItemId]['stockWarning'] ?? 5;
|
|
|
+ $myLack = bcadd($myStock, $myOnStock, 2) > $myStockWarning ? 0 : 1;
|
|
|
+ $itemInfoData[$key]['myStock'] = $myStock;
|
|
|
+ $itemInfoData[$key]['myOnStock'] = $myOnStock;
|
|
|
+ $itemInfoData[$key]['myStockWarning'] = $myStockWarning;
|
|
|
+ $itemInfoData[$key]['myLack'] = $myLack;
|
|
|
+ $itemInfoData[$key]['myDisplay'] = $myDisplay;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $respond = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
+ $classItem = $respond['classItem'] ?? [];
|
|
|
+ util::success($classItem);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("报错内容:" . $e->getMessage());
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ public function actionGhsItemV2()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $ghs = GhsClass::getGhsInfo($id);
|
|
|
+ if (empty($ghs)) {
|
|
|
+ util::fail('没有找到供货商');
|
|
|
+ }
|
|
|
+ $shopId = $ghs['shopId'] ?? 0;
|
|
|
+ $black = $ghs['black'] ?? 2;
|
|
|
+ if ($black == 2) {
|
|
|
+ util::fail('暂无花材');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
//获取所有当前供货商的分类 (全部、常用)
|
|
|
//根据分类组装分类下的花材信息
|
|
|
$shop = ShopClass::getById($shopId, true);
|
|
|
@@ -397,14 +456,44 @@ class ProductController extends BaseController
|
|
|
$itemInfoData[$key]['myDisplay'] = $myDisplay;
|
|
|
}
|
|
|
}
|
|
|
- $data = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
- util::success($data);
|
|
|
+ $respond = ProductService::assembleData($classIds, $itemInfoData, true);
|
|
|
+ if ($showAll == 1) {
|
|
|
+ if (isset($respond['classItem']) && !empty($respond['classItem'])) {
|
|
|
+ foreach ($respond['classItem'] as $bigKey => $bigVal) {
|
|
|
+ if (isset($bigVal['child']) && !empty($bigVal['child'])) {
|
|
|
+ foreach ($bigVal['child'] as $key => $val) {
|
|
|
+ unset($bigVal['child'][$key]['cover']);
|
|
|
+ unset($bigVal['child'][$key]['actualSold']);
|
|
|
+ unset($bigVal['child'][$key]['defaultGradePrice']);
|
|
|
+ unset($bigVal['child'][$key]['discountPrice']);
|
|
|
+ unset($bigVal['child'][$key]['hjDiscountPrice']);
|
|
|
+ unset($bigVal['child'][$key]['hjPrice']);
|
|
|
+ unset($bigVal['child'][$key]['presellDateShow']);
|
|
|
+ unset($bigVal['child'][$key]['prePrice']);
|
|
|
+ unset($bigVal['child'][$key]['print']);
|
|
|
+ unset($bigVal['child'][$key]['reachNum']);
|
|
|
+ unset($bigVal['child'][$key]['reachNumDiscount']);
|
|
|
+ unset($bigVal['child'][$key]['reachPrice']);
|
|
|
+ unset($bigVal['child'][$key]['skDiscountPrice']);
|
|
|
+ unset($bigVal['child'][$key]['skPrice']);
|
|
|
+ unset($bigVal['child'][$key]['bigUnit']);
|
|
|
+ unset($bigVal['child'][$key]['weight']);
|
|
|
+ unset($bigVal['child'][$key]['stockWarning']);
|
|
|
+ //unset($bigVal['child'][$key]['smallPrice']);
|
|
|
+ //unset($bigVal['child'][$key]['smallRatio']);
|
|
|
+ }
|
|
|
+ $respond['classItem'][$bigKey]['child'] = $bigVal['child'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ util::success($respond);
|
|
|
} catch (\Exception $e) {
|
|
|
$transaction->rollBack();
|
|
|
Yii::info("报错内容:" . $e->getMessage());
|
|
|
util::fail();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public function actionDetail()
|