ItemController.php 1.9 KB

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