| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace addons\OperationCenter\common\services;
- use addons\OperationCenter\common\models\ApplyList;
- use addons\OperationCenter\common\models\UserCenter;
- /**
- * ApplyService
- * @package addons\OperationCenter\common\services
- */
- class ApplyService extends BaseService
- {
- /**
- * 获取申请状态
- *
- * @param integer $user_id
- * @return boolean
- */
- public function getApplyStatus(int $user_id)
- {
- $info = ApplyList::getApplyStatus($user_id);
- if (empty($info)) {
- return ['status' => 0];
- }
- if ($info->status == ApplyList::REJECTED) {
- return $info->toArray();
- }
- // 申请通过 但是运营中心被删除
- if ($info->isPassedButDelete($info)) {
- return ['status' => 0];
- }
- return ['status' => $info->status];
- }
- /**
- * 添加
- *
- * @param integer $user_id
- * @param array $data
- * @return boolean
- */
- public function addApply(int $user_id, array $data)
- {
- // 申请中 or 已通过
- if ($apply = ApplyList::hasApplyOrPassByUserId($user_id)) {
- // 审核通过 但是运营中心被删除
- if (!$apply->isPassedButDelete()) {
- return $this->error('申请中或者已审核');
- }
- }
- $res = ApplyList::addApplyList(
- $user_id,
- $this->mall_id,
- $data
- );
- return $res === true ? true : $this->modelError($res);
- }
- /**
- * 获取申请项
- *
- * @return array
- */
- public function getApplyingFor()
- {
- return $this->getSettingService()->getApplyingFor();
- }
- }
|