|
|
@@ -22,18 +22,41 @@ class ItemController extends BaseController
|
|
|
//列出所有花材 ssh 20240222
|
|
|
public function actionGetItemList()
|
|
|
{
|
|
|
- $search = Yii::$app->request->get('search', '');
|
|
|
- $requestType = Yii::$app->request->get('requestType', 'common');
|
|
|
- $status = Yii::$app->request->get('status', 1);
|
|
|
- $delStatus = Yii::$app->request->get('delStatus', 0);
|
|
|
- $classId = Yii::$app->request->get('classId', 0);
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $search = $get['search'] ?? '';
|
|
|
+ $requestType = $get['requestType'] ?? 'kd';
|
|
|
+ $classId = $get['classId'] ?? 0;
|
|
|
+
|
|
|
$where['mainId'] = $this->mainId;
|
|
|
- $where['delStatus'] = $delStatus;
|
|
|
- if (!empty($status)) {
|
|
|
- $where['status'] = $status;
|
|
|
- }
|
|
|
- if ($requestType == 'book') {
|
|
|
+ if ($requestType == 'kd') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $where['status'] = 1;
|
|
|
+ } elseif ($requestType == 'itemList') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ unset($where['status']);
|
|
|
+ } elseif ($requestType == 'changePrice') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $where['stock>'] = 0;
|
|
|
+ } elseif ($requestType == 'hasStockList') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $where['stock>'] = 0;
|
|
|
+ } elseif ($requestType == 'book') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
unset($where['status']);
|
|
|
+ } elseif ($requestType == 'outList') {
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $where['status'] = 2;
|
|
|
+ $where['removeStatus'] = 0;
|
|
|
+ } elseif ($requestType == 'stopList') {
|
|
|
+ $where['delStatus'] = 1;
|
|
|
+ unset($where['status']);
|
|
|
+ $where['removeStatus'] = 0;
|
|
|
+ } elseif ($requestType == 'removeList') {
|
|
|
+ $where['delStatus'] = 1;
|
|
|
+ unset($where['status']);
|
|
|
+ $where['removeStatus'] = 1;
|
|
|
+ } else {
|
|
|
+ util::fail('没有定义的请求方式');
|
|
|
}
|
|
|
if (!empty($search)) {
|
|
|
if (stringUtil::isLetter($search)) {
|
|
|
@@ -55,107 +78,55 @@ class ItemController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //改价和全部有库存花材列表
|
|
|
- if ($requestType == 'changePrice' || $requestType == 'hasStockList') {
|
|
|
- $where['stock>'] = 0;
|
|
|
- }
|
|
|
- $customId = Yii::$app->request->get('customId', 0);
|
|
|
+ $customId = $get['customId'] ?? 0;
|
|
|
$level = 1;
|
|
|
if (!empty($customId)) {
|
|
|
$custom = CustomClass::getById($customId, true);
|
|
|
$level = $custom->level ?? 1;
|
|
|
}
|
|
|
- $itemInfoData = [];
|
|
|
+ $field = '*';
|
|
|
+ $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]);
|
|
|
+ $list = $result['list'] ?? [];
|
|
|
if ($requestType == 'hasStockList') {
|
|
|
- //有库存的花材列表
|
|
|
- $field = 'id,py,name,classId,itemId,price,skPrice,hjPrice,stock';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
+ util::fail('无效方式');
|
|
|
} elseif ($requestType == 'changePrice') {
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,skMore,hjAddPrice,addPrice,variety,price,hjPrice,stock,onStock,presell,frontHide,reachNum,reachNumDiscount';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::changePriceGroup($list, $level);
|
|
|
} elseif ($requestType == 'changeStock') {
|
|
|
- //修改库存列表
|
|
|
- $field = 'id,py,cover,name,cost,itemId,status,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::changeStockGroup($list, $level);
|
|
|
} elseif ($requestType == 'kd') {
|
|
|
- //开单的花材列表
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide,reachNum,reachNumDiscount';
|
|
|
- $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]);
|
|
|
- $list = $result['list'] ?? [];
|
|
|
$list = ProductClass::kdItemGroup($list, $level);
|
|
|
- $result['list'] = $list;
|
|
|
- util::success($result);
|
|
|
} elseif ($requestType == 'book') {
|
|
|
- //预订花材列表
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::bookItemGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::bookItemGroup($list, $level);
|
|
|
} elseif ($requestType == 'itemList') {
|
|
|
- //花材列表
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount';
|
|
|
- $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]);
|
|
|
- $list = $result['list'] ?? [];
|
|
|
$list = ProductClass::itemListGroup($list, $level);
|
|
|
- $result['list'] = $list;
|
|
|
- util::success($result);
|
|
|
} elseif ($requestType == 'outList') {
|
|
|
- //下架花材列表
|
|
|
- $where['status'] = 2;
|
|
|
- $where['delStatus'] = 0;
|
|
|
- $where['removeStatus'] = 0;
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::simpleGroup($list, $level);
|
|
|
} elseif ($requestType == 'stopList') {
|
|
|
- //停用花材列表
|
|
|
- unset($where['status']);
|
|
|
- $where['delStatus'] = 1;
|
|
|
- $where['removeStatus'] = 0;
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::simpleGroup($list, $level);
|
|
|
} elseif ($requestType == 'removeList') {
|
|
|
- //删除花材列表
|
|
|
- unset($where['status']);
|
|
|
- $where['delStatus'] = 1;
|
|
|
- $where['removeStatus'] = 1;
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::simpleGroup($list, $level);
|
|
|
} elseif ($requestType == 'check') {
|
|
|
- $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::checkItemGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::checkItemGroup($list, $level);
|
|
|
} elseif ($requestType == 'break') {
|
|
|
- $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::breakItemGroup($list, $level);
|
|
|
} elseif ($requestType == 'part') {
|
|
|
- //拆散花材
|
|
|
- $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::partItemGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::partItemGroup($list, $level);
|
|
|
} elseif ($requestType == 'stockOut') {
|
|
|
- $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::stockOutGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::stockOutGroup($list, $level);
|
|
|
} elseif ($requestType == 'cg') {
|
|
|
- $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,presell,ratioType,smallUnit,bigUnit,ratio,weight,frontHide';
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
- $itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
|
|
|
+ $list = ProductClass::cgItemGroup($list, $level);
|
|
|
} elseif ($requestType == 'warning') {
|
|
|
- $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,onStock,actualSold,presell,bigUnit,stockWarning,status,frontHide';
|
|
|
- $itemInfoData = Product::find()->where("mainId={$this->mainId}")
|
|
|
- ->andWhere('`stock`+`onStock`<`stockWarning`')
|
|
|
- ->andWhere("delStatus=0")
|
|
|
- ->select($field)->asArray()->all();
|
|
|
- $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
|
|
|
+ util::fail('无效方式');
|
|
|
+// $itemInfoData = Product::find()->where("mainId={$this->mainId}")
|
|
|
+// ->andWhere('`stock`+`onStock`<`stockWarning`')
|
|
|
+// ->andWhere("delStatus=0")
|
|
|
+// ->select($field)->asArray()->all();
|
|
|
+// $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
|
|
|
} else {
|
|
|
util::fail('没有数据');
|
|
|
}
|
|
|
- util::success(['list' => $itemInfoData]);
|
|
|
+ $result['list'] = $list;
|
|
|
+ util::success($result);
|
|
|
}
|
|
|
|
|
|
//花材申请平台认证 ssh 20231125
|