|
@@ -387,106 +387,94 @@ class ProductController extends BaseController
|
|
|
$level = $custom->level ?? 1;
|
|
$level = $custom->level ?? 1;
|
|
|
}
|
|
}
|
|
|
$itemInfoData = [];
|
|
$itemInfoData = [];
|
|
|
- if ($requestType == 'hasStockList') {
|
|
|
|
|
- //有库存的花材列表
|
|
|
|
|
- $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,avCost,addPrice,hjAddPrice,skMore';
|
|
|
|
|
|
|
+ $fieldMap = [
|
|
|
|
|
+ 'hasStockList' => 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,avCost,addPrice,hjAddPrice,skMore,limitBuy',
|
|
|
|
|
+ 'hideItem' => 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,avCost,addPrice,hjAddPrice,skMore,limitBuy',
|
|
|
|
|
+ 'changePrice' => 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,skMore,hjAddPrice,variety,price,stock,onStock,presell,frontHide,reachNum,reachNumDiscount,limitBuy',
|
|
|
|
|
+ 'changeStock' => 'id,py,cover,name,cost,itemId,status,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,frontHide,limitBuy',
|
|
|
|
|
+ 'kd' => '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,limitBuy',
|
|
|
|
|
+ 'book' => 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide,limitBuy',
|
|
|
|
|
+ 'itemList' => 'id,py,cover,name,cost,avCost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount,addPrice,hjAddPrice,skMore,limitBuy',
|
|
|
|
|
+ 'cgStaffList' => '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,cgStaffId,cgStaffName,limitBuy',
|
|
|
|
|
+ 'outList' => 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status,limitBuy',
|
|
|
|
|
+ 'stopList' => 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status,delStatus,limitBuy',
|
|
|
|
|
+ 'removeList' => 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status,limitBuy',
|
|
|
|
|
+ 'check' => 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide,limitBuy',
|
|
|
|
|
+ 'break' => 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide,limitBuy',
|
|
|
|
|
+ 'part' => 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,limitBuy',
|
|
|
|
|
+ 'stockOut' => 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio,frontHide,limitBuy',
|
|
|
|
|
+ 'cg' => 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,presell,ratioType,smallUnit,bigUnit,ratio,weight,frontHide,limitBuy',
|
|
|
|
|
+ 'warning' => 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,onStock,actualSold,presell,bigUnit,stockWarning,status,frontHide,limitBuy',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset($fieldMap[$requestType])) {
|
|
|
|
|
+ util::fail('没有数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ $field = $fieldMap[$requestType];
|
|
|
|
|
+
|
|
|
|
|
+ // 获取数据
|
|
|
|
|
+ if ($requestType == 'warning') {
|
|
|
|
|
+ $itemInfoData = Product::find()->where("mainId={$this->mainId}")
|
|
|
|
|
+ ->andWhere('`stock`+`onStock`<`stockWarning`')
|
|
|
|
|
+ ->andWhere("delStatus=0")
|
|
|
|
|
+ ->select($field)->asArray()->all();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 处理特殊的 where 条件
|
|
|
|
|
+ if ($requestType == 'cgStaffList') {
|
|
|
|
|
+ unset($where['status']);
|
|
|
|
|
+ $where['delStatus'] = 0;
|
|
|
|
|
+ } elseif ($requestType == 'outList') {
|
|
|
|
|
+ $where['status'] = 2;
|
|
|
|
|
+ $where['delStatus'] = 0;
|
|
|
|
|
+ $where['removeStatus'] = 0;
|
|
|
|
|
+ } elseif ($requestType == 'stopList') {
|
|
|
|
|
+ unset($where['status']);
|
|
|
|
|
+ $where['delStatus'] = 1;
|
|
|
|
|
+ $where['removeStatus'] = 0;
|
|
|
|
|
+ } elseif ($requestType == 'removeList') {
|
|
|
|
|
+ unset($where['status']);
|
|
|
|
|
+ $where['delStatus'] = 1;
|
|
|
|
|
+ $where['removeStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
$itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 数据后处理
|
|
|
|
|
+ if ($requestType == 'hasStockList') {
|
|
|
if (!empty($itemInfoData)) {
|
|
if (!empty($itemInfoData)) {
|
|
|
foreach ($itemInfoData as $key => $val) {
|
|
foreach ($itemInfoData as $key => $val) {
|
|
|
- //以下参数主要是网页批量改价要用到
|
|
|
|
|
$shortCover = $val['cover'] ?? '';
|
|
$shortCover = $val['cover'] ?? '';
|
|
|
$itemInfoData[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
|
|
$itemInfoData[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
|
|
|
$itemInfoData[$key]['shortCover'] = $shortCover;
|
|
$itemInfoData[$key]['shortCover'] = $shortCover;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- } elseif ($requestType == 'hideItem') {
|
|
|
|
|
- //隐藏花材列表
|
|
|
|
|
- $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,avCost,addPrice,hjAddPrice,skMore';
|
|
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
} elseif ($requestType == 'changePrice') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'changeStock') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'kd') {
|
|
} 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';
|
|
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
$itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level, $custom);
|
|
$itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level, $custom);
|
|
|
} elseif ($requestType == 'book') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::bookItemGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'itemList') {
|
|
} elseif ($requestType == 'itemList') {
|
|
|
- //花材列表
|
|
|
|
|
- $field = 'id,py,cover,name,cost,avCost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount,addPrice,hjAddPrice,skMore';
|
|
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
$itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
|
|
$itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'cgStaffList') {
|
|
} elseif ($requestType == 'cgStaffList') {
|
|
|
- unset($where['status']);
|
|
|
|
|
- $where['delStatus'] = 0;
|
|
|
|
|
- $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,cgStaffId,cgStaffName';
|
|
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
$itemInfoData = ProductClass::cgStaffListGroup($itemInfoData, $level);
|
|
$itemInfoData = ProductClass::cgStaffListGroup($itemInfoData, $level);
|
|
|
- } 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);
|
|
|
|
|
- } 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,delStatus';
|
|
|
|
|
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
|
|
|
|
|
- $itemInfoData = ProductClass::simpleGroup($itemInfoData, $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);
|
|
|
|
|
|
|
+ } elseif (in_array($requestType, ['outList', 'stopList', 'removeList'])) {
|
|
|
$itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
|
|
$itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'check') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::checkItemGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'break') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'part') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::partItemGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'stockOut') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::stockOutGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'cg') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
|
|
|
} elseif ($requestType == 'warning') {
|
|
} 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);
|
|
$itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
|
|
|
- } else {
|
|
|
|
|
- util::fail('没有数据');
|
|
|
|
|
}
|
|
}
|
|
|
$data = ProductService::assembleItemData($classInfo, $itemInfoData);
|
|
$data = ProductService::assembleItemData($classInfo, $itemInfoData);
|
|
|
util::success($data);
|
|
util::success($data);
|