ApplyService.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\OperationCenter\common\services;
  3. use addons\OperationCenter\common\models\ApplyList;
  4. use addons\OperationCenter\common\models\UserCenter;
  5. /**
  6. * ApplyService
  7. * @package addons\OperationCenter\common\services
  8. */
  9. class ApplyService extends BaseService
  10. {
  11. /**
  12. * 获取申请状态
  13. *
  14. * @param integer $user_id
  15. * @return boolean
  16. */
  17. public function getApplyStatus(int $user_id)
  18. {
  19. $info = ApplyList::getApplyStatus($user_id);
  20. if (empty($info)) {
  21. return ['status' => 0];
  22. }
  23. if ($info->status == ApplyList::REJECTED) {
  24. return $info->toArray();
  25. }
  26. // 申请通过 但是运营中心被删除
  27. if ($info->isPassedButDelete($info)) {
  28. return ['status' => 0];
  29. }
  30. return ['status' => $info->status];
  31. }
  32. /**
  33. * 添加
  34. *
  35. * @param integer $user_id
  36. * @param array $data
  37. * @return boolean
  38. */
  39. public function addApply(int $user_id, array $data)
  40. {
  41. // 申请中 or 已通过
  42. if ($apply = ApplyList::hasApplyOrPassByUserId($user_id)) {
  43. // 审核通过 但是运营中心被删除
  44. if (!$apply->isPassedButDelete()) {
  45. return $this->error('申请中或者已审核');
  46. }
  47. }
  48. $res = ApplyList::addApplyList(
  49. $user_id,
  50. $this->mall_id,
  51. $data
  52. );
  53. return $res === true ? true : $this->modelError($res);
  54. }
  55. /**
  56. * 获取申请项
  57. *
  58. * @return array
  59. */
  60. public function getApplyingFor()
  61. {
  62. return $this->getSettingService()->getApplyingFor();
  63. }
  64. }