|
|
@ -13,10 +13,13 @@ declare (strict_types=1); |
|
|
|
namespace app\api\model\dealer; |
|
|
|
namespace app\api\model\dealer; |
|
|
|
|
|
|
|
|
|
|
|
use app\api\service\User as UserService; |
|
|
|
use app\api\service\User as UserService; |
|
|
|
use app\common\enum\dealer\apply\ApplyType as ApplyTypeEnum; |
|
|
|
|
|
|
|
use app\common\enum\dealer\apply\ApplyStatus as ApplyStatusEnum; |
|
|
|
use app\common\enum\dealer\apply\ApplyStatus as ApplyStatusEnum; |
|
|
|
|
|
|
|
use app\common\enum\dealer\apply\ApplyType as ApplyTypeEnum; |
|
|
|
use app\common\model\dealer\Apply as ApplyModel; |
|
|
|
use app\common\model\dealer\Apply as ApplyModel; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use cores\exception\BaseException; |
|
|
|
|
|
|
|
use think\db\exception\DataNotFoundException; |
|
|
|
|
|
|
|
use think\db\exception\DbException; |
|
|
|
|
|
|
|
use think\db\exception\ModelNotFoundException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分销商申请模型 |
|
|
|
* 分销商申请模型 |
|
|
@ -50,9 +53,9 @@ class Apply extends ApplyModel |
|
|
|
* @param array $data 表单数据 |
|
|
|
* @param array $data 表单数据 |
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
* @throws \cores\exception\BaseException |
|
|
|
* @throws \cores\exception\BaseException |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
* @throws ModelNotFoundException |
|
|
|
* @throws BaseException |
|
|
|
* @throws BaseException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function submit(array $data) |
|
|
|
public function submit(array $data) |
|
|
@ -79,6 +82,47 @@ class Apply extends ApplyModel |
|
|
|
return $this->add($data); |
|
|
|
return $this->add($data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @notes:申请服务商 |
|
|
|
|
|
|
|
* @param $data |
|
|
|
|
|
|
|
* @return bool |
|
|
|
|
|
|
|
* @throws BaseException |
|
|
|
|
|
|
|
* @throws DataNotFoundException |
|
|
|
|
|
|
|
* @throws DbException |
|
|
|
|
|
|
|
* @throws ModelNotFoundException |
|
|
|
|
|
|
|
* @author: wanghousheng |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function applyServiceProviders($data): bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 当前用户ID |
|
|
|
|
|
|
|
$userId = UserService::getCurrentLoginUserId(); |
|
|
|
|
|
|
|
// 成为分销商条件 |
|
|
|
|
|
|
|
$config = Setting::getItem('condition'); |
|
|
|
|
|
|
|
if ($this->where(['user_id' => $userId])->exists()) { |
|
|
|
|
|
|
|
throwError('您已申请服务商,请勿重复提交'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 数据整理 |
|
|
|
|
|
|
|
$data = [ |
|
|
|
|
|
|
|
'user_id' => $userId, |
|
|
|
|
|
|
|
'real_name' => trim($data['real_name']), |
|
|
|
|
|
|
|
'mobile' => trim($data['mobile']), |
|
|
|
|
|
|
|
'referee_id' => Referee::getRefereeUserId($userId, 1), |
|
|
|
|
|
|
|
'apply_type' => $config['become'], |
|
|
|
|
|
|
|
'apply_time' => time(), |
|
|
|
|
|
|
|
'store_id' => self::$storeId, |
|
|
|
|
|
|
|
'shop_type' => $data['shop_type'], |
|
|
|
|
|
|
|
'shop_name' => $data['shop_name'], |
|
|
|
|
|
|
|
'business' => $data['business'], |
|
|
|
|
|
|
|
'city' => $data['city'], |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
if ($config['become'] == ApplyTypeEnum::AUDIT) { |
|
|
|
|
|
|
|
$data['apply_status'] = ApplyStatusEnum::WAIT; |
|
|
|
|
|
|
|
} elseif ($config['become'] == ApplyTypeEnum::PASS) { |
|
|
|
|
|
|
|
$data['apply_status'] = ApplyStatusEnum::PASS; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->add($data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新分销商申请信息 |
|
|
|
* 更新分销商申请信息 |
|
|
|
* @param array $data |
|
|
|
* @param array $data |
|
|
|