ItemController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\item\classes\ItemClass;
  4. use bizGhs\item\services\ItemService;
  5. use common\components\util;
  6. use common\services\xhItemService;
  7. use Yii;
  8. class ItemController extends BaseController
  9. {
  10. public function actionList()
  11. {
  12. //classId
  13. $classId = Yii::$app->request->get('classId',0);
  14. $where['merchantId'] = $this->sjId;
  15. $where['classId'] = $classId;
  16. $list = ItemClass::getGhsItemList($where);
  17. util::success($list);
  18. }
  19. public function actionAdd()
  20. {
  21. $post = Yii::$app->request->post();
  22. $post['adminId'] = $this->adminId;
  23. $post['shopId'] = $this->shopId;
  24. $post['merchantId'] = $this->sjId;
  25. ItemService::addGhsItem($post);
  26. util::complete('添加成功');
  27. }
  28. public function actionUpdate()
  29. {
  30. $data = Yii::$app->request->post();
  31. $data['adminId'] = $this->adminId;
  32. $data['merchantId'] = $this->sjId;
  33. ItemService::updateGshItem($data);
  34. util::complete('修改成功');
  35. }
  36. public function actionDelete()
  37. {
  38. $get = Yii::$app->request->get();
  39. $id = isset($get['id']) ? $get['id'] : 0;
  40. ItemService::deleteGhsItem($id,$this->shopId,$this->adminId);
  41. util::complete('操作成功');
  42. }
  43. //获取平台里的花材信息
  44. public function actionPlatformItem()
  45. {
  46. $py = Yii::$app->request->get('py','');
  47. $where = [];
  48. if($py){
  49. $where = ['py' => $py];
  50. }
  51. $list = xhItemService::getItemList('*',$where,'id desc');
  52. util::success($list);
  53. }
  54. }