AdminShopController.php 2.3 KB

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