| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?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}]
- //2021.7.11 linqh 参数改为 只传售价,成本价和加价各取一半[{itemId:1000,classId:2,price: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);
- }
- }
|