CpController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\cp\classes\CpClass;
  4. use common\components\stringUtil;
  5. use common\components\util;
  6. use Yii;
  7. class CpController extends BaseController
  8. {
  9. //根据分类id取集合,带分页 ssh 20231228
  10. public function actionList()
  11. {
  12. $get = Yii::$app->request->get();
  13. $classId = $get['classId'] ?? 0;
  14. $mainId = $this->mainId ?? 0;
  15. $where = [];
  16. $where['mainId'] = $mainId;
  17. $where['delStatus'] = 0;
  18. if (!empty($classId)) {
  19. $where['classId'] = $classId;
  20. }
  21. $respond = CpClass::getCpList($where);
  22. util::success($respond);
  23. }
  24. //添加产品 ssh 20240106
  25. public function actionAddCp()
  26. {
  27. $post = Yii::$app->request->post();
  28. $post['mainId'] = $this->mainId;
  29. $post['adminId'] = $this->adminId;
  30. if (isset($post['name']) == false || empty($post['name'])) {
  31. util::fail('请填写名称');
  32. }
  33. $post['py'] = stringUtil::py($post['name']);
  34. $staff = $this->shopAdmin;
  35. $staffName = $staff->name ?? '';
  36. $post['staffName'] = $staffName;
  37. $shop = $this->shop;
  38. unset($post['id']);
  39. CpClass::addCp($post, $shop);
  40. util::complete('添加成功');
  41. }
  42. public function actionUpdateCp()
  43. {
  44. util::complete();
  45. }
  46. }