ItemController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/3/2 14:33
  5. */
  6. namespace hd\controllers;
  7. use biz\item\classes\PtItemClass;
  8. use bizHd\item\classes\ItemClass;
  9. use bizHd\item\services\ItemService;
  10. use common\components\util;
  11. use common\services\xhItemService;
  12. use Yii;
  13. class ItemController extends BaseController
  14. {
  15. public function actionList()
  16. {
  17. //classId
  18. $classId = Yii::$app->request->get('classId',0);
  19. $where['sjId'] = $this->sjId;
  20. $where['classId'] = $classId;
  21. $list = ItemClass::getItemList($where);
  22. util::success($list);
  23. }
  24. public function actionAdd()
  25. {
  26. $post = Yii::$app->request->post();
  27. $post['adminId'] = $this->adminId;
  28. $post['shopId'] = $this->shopId;
  29. $post['sjId'] = $this->sjId;
  30. ItemService::addItem($post);
  31. util::complete('添加成功');
  32. }
  33. public function actionUpdate()
  34. {
  35. $data = Yii::$app->request->post();
  36. $data['adminId'] = $this->adminId;
  37. $data['sjId'] = $this->sjId;
  38. ItemService::updateItem($data);
  39. util::complete('修改成功');
  40. }
  41. //排序
  42. public function actionChangeSort()
  43. {
  44. //[id=>sort]
  45. $data = Yii::$app->request->post();
  46. if(empty($data)){
  47. util::fail('参数错误');
  48. }
  49. //循环修改排序值
  50. // todo
  51. }
  52. public function actionDelete()
  53. {
  54. $get = Yii::$app->request->get();
  55. $id = isset($get['id']) ? $get['id'] : 0;
  56. ItemService::deleteItem($id,$this->shopId,$this->adminId);
  57. util::complete('操作成功');
  58. }
  59. //获取平台里的花材信息
  60. public function actionPlatformItem()
  61. {
  62. $py = Yii::$app->request->get('py','');
  63. $where = [];
  64. if($py){
  65. $py = strtolower($py);
  66. $where = ['py' => $py];
  67. }
  68. $list = PtItemClass::getItemList($where);
  69. util::success($list);
  70. }
  71. }