| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace ghs\controllers;
- use biz\item\classes\PtItemClass;
- use bizGhs\item\classes\ItemClass;
- use bizGhs\item\services\ItemService;
- use common\components\util;
- use common\services\xhItemService;
- use Yii;
- class ItemController extends BaseController
- {
- public function actionList()
- {
- $classId = Yii::$app->request->get('classId', 0);
- $where['sjId'] = $this->sjId;
- if (!empty($classId)) {
- $where['classId'] = $classId;
- }
- $list = ItemClass::getGhsItemList($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::addGhsItem($post);
- util::complete('添加成功');
- }
- public function actionBatchAdd()
- {
- $post = Yii::$app->request->post();
- $data = $post['data']; //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
- if(empty($data)){
- util::fail("参数错误");
- }
- $data = json_decode($data,true);
- if(!is_array($data) || empty($data)){
- util::fail("参数格式错误");
- }
- foreach ($data as $v){
- $v['adminId'] = $this->adminId;
- $v['sjId'] = $this->sjId;
- ItemService::addGhsItem($v);
- }
- util::complete('添加成功');
- }
- public function actionUpdate()
- {
- $data = Yii::$app->request->post();
- $data['adminId'] = $this->adminId;
- $data['sjId'] = $this->sjId;
- ItemService::updateGshItem($data);
- util::complete('修改成功');
- }
- public function actionDelete()
- {
- util::fail('不能删除哦!');
- }
- //获取平台里的花材信息
- public function actionPlatformItem()
- {
- $py = Yii::$app->request->get('py', '');
- $where = [];
- if ($py) {
- $where = ['py' => $py];
- }
- $list = PtItemClass::getItemList($where);
- util::success($list);
- }
- }
|