|
|
@@ -7,8 +7,8 @@
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
use biz\item\classes\PtItemClass;
|
|
|
-use bizHd\item\classes\ItemClass;
|
|
|
-use bizHd\item\services\ItemService;
|
|
|
+use bizGhs\item\classes\ItemClass;
|
|
|
+use bizGhs\item\services\ItemService;
|
|
|
use common\components\util;
|
|
|
use common\services\xhItemService;
|
|
|
use Yii;
|
|
|
@@ -16,11 +16,12 @@ class ItemController extends BaseController
|
|
|
{
|
|
|
public function actionList()
|
|
|
{
|
|
|
- //classId
|
|
|
- $classId = Yii::$app->request->get('classId',0);
|
|
|
- $where['sjId'] = $this->sjId;
|
|
|
- $where['classId'] = $classId;
|
|
|
- $list = ItemClass::getItemList($where);
|
|
|
+ $classId = Yii::$app->request->get('classId', 0);
|
|
|
+ $where['merchantId'] = $this->sjId;
|
|
|
+ if (!empty($classId)) {
|
|
|
+ $where['classId'] = $classId;
|
|
|
+ }
|
|
|
+ $list = ItemClass::getGhsItemList($where);
|
|
|
util::success($list);
|
|
|
}
|
|
|
|
|
|
@@ -28,50 +29,56 @@ class ItemController extends BaseController
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
$post['adminId'] = $this->adminId;
|
|
|
- $post['shopId'] = $this->shopId;
|
|
|
- $post['sjId'] = $this->sjId;
|
|
|
- ItemService::addItem($post);
|
|
|
+ // $post['shopId'] = $this->shopId;
|
|
|
+ $post['merchantId'] = $this->sjId;
|
|
|
+ ItemService::addGhsItem($post);
|
|
|
util::complete('添加成功');
|
|
|
}
|
|
|
|
|
|
- public function actionUpdate()
|
|
|
- {
|
|
|
- $data = Yii::$app->request->post();
|
|
|
- $data['adminId'] = $this->adminId;
|
|
|
- $data['sjId'] = $this->sjId;
|
|
|
- ItemService::updateItem($data);
|
|
|
- util::complete('修改成功');
|
|
|
- }
|
|
|
-
|
|
|
- //排序
|
|
|
- public function actionChangeSort()
|
|
|
+ public function actionBatchAdd()
|
|
|
{
|
|
|
- //[id=>sort]
|
|
|
- $data = Yii::$app->request->post();
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $data = $post['data']; //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
|
|
|
if(empty($data)){
|
|
|
- util::fail('参数错误');
|
|
|
+ util::fail("参数错误");
|
|
|
+ }
|
|
|
+ $data = json_decode($data,true);
|
|
|
+ if(!is_array($data) || empty($data)){
|
|
|
+ util::fail("参数格式错误");
|
|
|
}
|
|
|
- //循环修改排序值
|
|
|
- // todo
|
|
|
|
|
|
+ foreach ($data as $v){
|
|
|
+ $v['adminId'] = $this->adminId;
|
|
|
+ $v['merchantId'] = $this->sjId;
|
|
|
+ ItemService::addGhsItem($v);
|
|
|
+ }
|
|
|
+ util::complete('添加成功');
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ public function actionUpdate()
|
|
|
+ {
|
|
|
+ $data = Yii::$app->request->post();
|
|
|
+ $data['adminId'] = $this->adminId;
|
|
|
+ $data['merchantId'] = $this->sjId;
|
|
|
+ ItemService::updateGshItem($data);
|
|
|
+ util::complete('修改成功');
|
|
|
}
|
|
|
|
|
|
public function actionDelete()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $id = isset($get['id']) ? $get['id'] : 0;
|
|
|
- ItemService::deleteItem($id,$this->shopId,$this->adminId);
|
|
|
- util::complete('操作成功');
|
|
|
+// $get = Yii::$app->request->get();
|
|
|
+// $id = isset($get['id']) ? $get['id'] : 0;
|
|
|
+// ItemService::deleteGhsItem($id, $this->shopId, $this->sjId, $this->adminId);
|
|
|
+ util::fail('不能删除哦!');
|
|
|
}
|
|
|
|
|
|
//获取平台里的花材信息
|
|
|
public function actionPlatformItem()
|
|
|
{
|
|
|
- $py = Yii::$app->request->get('py','');
|
|
|
+ $py = Yii::$app->request->get('py', '');
|
|
|
$where = [];
|
|
|
- if($py){
|
|
|
- $py = strtolower($py);
|
|
|
+ if ($py) {
|
|
|
$where = ['py' => $py];
|
|
|
}
|
|
|
$list = PtItemClass::getItemList($where);
|