ShopAdminController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace pt\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\shop\classes\ShopAdminClass;
  5. use biz\sj\classes\SjClass;
  6. use bizHd\admin\services\ShopAdminService;
  7. use bizHd\saas\classes\ApplyClass;
  8. use common\components\util;
  9. use Yii;
  10. class ShopAdminController extends BaseController
  11. {
  12. //员工列表 ssh 2019.12.8
  13. public function actionList()
  14. {
  15. $where = [];
  16. $where['delStatus'] = 0;
  17. $list = ShopAdminService::getAdminList($where);
  18. util::success($list);
  19. }
  20. //删除员工、商家、和申请信息 shish
  21. public function actionDelete()
  22. {
  23. $id = Yii::$app->request->get('id');
  24. $shopAdmin = ShopAdminClass::getAdminInfo($id);
  25. if (empty($shopAdmin)) {
  26. util::fail('没有找到员工');
  27. }
  28. if (getenv('YII_ENV', 'local') == 'production') {
  29. util::fail('生产环境不能执行删除操作');
  30. }
  31. $adminId = $shopAdmin['adminId'] ?? 0;
  32. $sjId = $shopAdmin['merchantId'] ?? 0;
  33. $sj = SjClass::getById($sjId, true);
  34. if (!empty($sj)) {
  35. $sj->delete();
  36. }
  37. $apply = ApplyClass::getByCondition(['sjId' => $sjId], true);
  38. if (!empty($apply)) {
  39. $apply->delete();
  40. }
  41. $admin = AdminClass::getById($adminId);
  42. if (!empty($admin)) {
  43. $admin->delete();
  44. }
  45. $shopAdmin = ShopAdminClass::getById($id);
  46. if (!empty($shopAdmin)) {
  47. $shopAdmin->delete();
  48. }
  49. util::complete();
  50. }
  51. }