|
|
@@ -138,6 +138,62 @@ class ProductController extends BaseController
|
|
|
util::success($data);
|
|
|
}
|
|
|
|
|
|
+ //按分类列出所有花材
|
|
|
+ public function actionShow()
|
|
|
+ {
|
|
|
+ $py = Yii::$app->request->get('py', '');
|
|
|
+ $requestType = Yii::$app->request->get('requestType', 'common');
|
|
|
+ //默认显示上架商品
|
|
|
+ $status = Yii::$app->request->get('status', 1);
|
|
|
+ //默认显示未删除商品
|
|
|
+ $delStatus = Yii::$app->request->get('delStatus', 0);
|
|
|
+ $warning = Yii::$app->request->get('warning', 0);
|
|
|
+
|
|
|
+ //获取所有当前供货商的分类 (全部、常用)
|
|
|
+ //根据分类组装分类下的花材信息
|
|
|
+ //中央ID
|
|
|
+ $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
|
|
|
+
|
|
|
+ $where['mainId'] = $this->mainId;
|
|
|
+ if ($py) {
|
|
|
+ $pyName = strtolower($py);
|
|
|
+ $where['py'] = $pyName;
|
|
|
+ }
|
|
|
+ if ($requestType == 'hasStock') {
|
|
|
+ //改价只显示库存大于0的
|
|
|
+ $where['stock>'] = 0;
|
|
|
+ }
|
|
|
+ if (!empty($status)) {
|
|
|
+ $where['status'] = $status;
|
|
|
+ }
|
|
|
+ $where['delStatus'] = $delStatus;
|
|
|
+
|
|
|
+ //客户等级
|
|
|
+ $customId = Yii::$app->request->get('customId', 0);
|
|
|
+ $level = 1;
|
|
|
+ if (!empty($customId)) {
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ $level = $custom->level ?? 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($warning == 1) {
|
|
|
+ //库存预警
|
|
|
+ $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
|
|
|
+ $itemInfoData = Product::find()->where("mainId={$this->mainId}")
|
|
|
+ ->andWhere('`stock`<`stockWarning`')
|
|
|
+ ->andWhere("delStatus=0")
|
|
|
+ ->select($field)->asArray()->all();
|
|
|
+ } else {
|
|
|
+ $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
|
|
|
+ $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
+ }
|
|
|
+ $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
|
|
|
+
|
|
|
+ $data = ProductService::assembleItemData($classIds, $itemInfoData, true);
|
|
|
+
|
|
|
+ util::success($data);
|
|
|
+ }
|
|
|
+
|
|
|
//按分类列出所有花材
|
|
|
public function actionIndex()
|
|
|
{
|