| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/3/2 14:33
- */
- namespace shop\controllers;
- use biz\item\classes\ItemClass;
- use biz\item\services\ItemService;
- use common\components\util;
- use common\services\xhItemService;
- use Yii;
- 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);
- util::success($list);
- }
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $post['adminId'] = $this->adminId;
- $post['shopId'] = $this->shopId;
- $post['sjId'] = $this->sjId;
- ItemService::addItem($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()
- {
- //[id=>sort]
- $data = Yii::$app->request->post();
- if(empty($data)){
- util::fail('参数错误');
- }
- //循环修改排序值
- // todo
- }
- public function actionDelete()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- ItemService::deleteItem($id,$this->shopId,$this->adminId);
- util::complete('操作成功');
- }
- //获取平台里的花材信息
- public function actionPlatformItem()
- {
- $py = Yii::$app->request->get('py','');
- $where = [];
- if($py){
- $py = strtolower($py);
- $where = ['py' => $py];
- }
- $list = xhItemService::getItemList('*',$where,'id desc');
- util::success($list);
- }
- }
|