ShopAdminController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\admin\services\AdminRoleService;
  4. use bizHd\admin\services\ShopAdminService;
  5. use bizHd\wx\services\WxOpenService;
  6. use common\components\imgUtil;
  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. public $guestAccess = ['generate-admin'];
  14. //创建管理员数据准备 ssh 2020.4.17
  15. public function actionPrepareBind()
  16. {
  17. $post = Yii::$app->request->post();
  18. $roleId = isset($post['roleId']) ? $post['roleId'] : 0;
  19. $role = AdminRoleService::getById($roleId);
  20. if (empty($role) || isset($role['merchantId']) != $this->sjId) {
  21. util::fail('请选择角色!');
  22. }
  23. unset($post['userId']);
  24. unset($post['status']);
  25. $post['shopId'] = $this->shopId;
  26. $post['adminId'] = $this->adminId;
  27. $merchant = WxOpenService::getWxInfo();
  28. $post['merchant'] = $merchant;
  29. $respond = ShopAdminService::prepareBindAdmin($post);
  30. $miniCode = isset($respond['miniCode']) ? imgUtil::getPrefix() . $respond['miniCode'] : '';
  31. util::success(['miniCode' => $miniCode]);
  32. }
  33. //创建管理员 ssh 2020.4.20
  34. public function actionGenerateAdmin()
  35. {
  36. $post = Yii::$app->request->post();
  37. $respond = ShopAdminService::generateAdmin($post);
  38. util::success($respond);
  39. }
  40. //收款通知 ssh 2020.1.4
  41. public function actionUpdateRemind()
  42. {
  43. $get = Yii::$app->request->get();
  44. $id = isset($get['id']) ? $get['id'] : 0;
  45. $remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
  46. $shopAdmin = ShopAdminService::getById($id);
  47. ShopAdminService::valid($shopAdmin, $this->shopId);
  48. ShopAdminService::updateById($id, ['remind' => $remind]);
  49. util::complete();
  50. }
  51. //启用与停用 ssh 2020.1.4
  52. public function actionUpdateStatus()
  53. {
  54. $get = Yii::$app->request->get();
  55. $id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
  56. $status = isset($get['status']) ? $get['status'] : 0;
  57. $shopAdmin = ShopAdminService::getById($id);
  58. ShopAdminService::valid($shopAdmin, $this->shopId);
  59. ShopAdminService::updateById($id, ['status' => $status]);
  60. util::complete();
  61. }
  62. //员工列表 ssh 2019.12.8
  63. public function actionList()
  64. {
  65. $get = Yii::$app->request->get();
  66. $where = [];
  67. $where['shopId'] = $this->shopId;
  68. $where['delStatus'] = 0;
  69. $list = ShopAdminService::getAdminList($where);
  70. util::success($list);
  71. }
  72. }