ShopAdminController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\admin\classes\ShopAdminClass;
  4. use bizGhs\admin\services\AdminRoleService;
  5. use bizGhs\admin\services\ShopAdminService;
  6. use biz\wx\services\WxOpenService;
  7. use common\components\jwt;
  8. use common\components\util;
  9. use Yii;
  10. use yii\web\Controller;
  11. class ShopAdminController extends BaseController
  12. {
  13. //创建管理员数据准备 shish 2020.4.17
  14. public function actionPrepareBind()
  15. {
  16. $post = Yii::$app->request->post();
  17. $roleId = isset($post['roleId']) ? $post['roleId'] : 0;
  18. $role = AdminRoleService::getById($roleId);
  19. if (empty($role) || isset($role['ghsId']) != $this->ghsId) {
  20. util::fail('请选择角色!');
  21. }
  22. unset($post['userId']);
  23. unset($post['status']);
  24. $post['shopId'] = $this->shopId;
  25. $post['adminId'] = $this->adminId;
  26. $merchant = WxOpenService::getGhsWxInfo();
  27. $post['merchant'] = $merchant;
  28. $respond = ShopAdminService::prepareBindAdmin($post);
  29. $miniCode = isset($respond['miniCode']) ? Yii::$app->params['imgHost'] . $respond['miniCode'] : '';
  30. util::success(['miniCode' => $miniCode]);
  31. }
  32. //创建管理员 shish 2020.4.20
  33. public function actionGenerateAdmin()
  34. {
  35. $post = Yii::$app->request->post();
  36. $respond = ShopAdminService::generateAdmin($post);
  37. util::success($respond);
  38. }
  39. //收款通知 shish 2020.1.4
  40. public function actionUpdateRemind()
  41. {
  42. $get = Yii::$app->request->get();
  43. $id = isset($get['id']) ? $get['id'] : 0;
  44. $remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
  45. $shopAdmin = ShopAdminService::getById($id);
  46. ShopAdminService::valid($shopAdmin, $this->shopId);
  47. ShopAdminService::updateById($id, ['remind' => $remind]);
  48. util::complete();
  49. }
  50. //启用与停用 shish 2020.1.4
  51. public function actionUpdateStatus()
  52. {
  53. $get = Yii::$app->request->get();
  54. $id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
  55. $status = isset($get['status']) ? $get['status'] : 0;
  56. $shopAdmin = ShopAdminService::getById($id);
  57. ShopAdminService::valid($shopAdmin, $this->shopId);
  58. ShopAdminService::updateById($id, ['status' => $status]);
  59. util::complete();
  60. }
  61. //员工列表 shish 2019.12.8
  62. public function actionList()
  63. {
  64. $get = Yii::$app->request->get();
  65. $where = [];
  66. $where['shopId'] = $this->shopId;
  67. $where['delStatus'] = 0;
  68. $list = ShopAdminService::getAdminList($where);
  69. util::success($list);
  70. }
  71. //获取员工信息 shish 2021.1.13
  72. public function actionDetail()
  73. {
  74. $get = Yii::$app->request->get();
  75. $id = isset($get['id']) ? $get['id'] : 0;
  76. $respond = ShopAdminService::getShopAdmin($id);
  77. ShopAdminClass::valid($respond, $this->ghsId);
  78. util::success($respond);
  79. }
  80. }