109 lines
2.5 KiB
PHP
109 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller\app\agent;
|
|
|
|
use app\common\controller\Api;
|
|
|
|
/**
|
|
* 分销员招募
|
|
*/
|
|
class Recruit extends Api
|
|
{
|
|
|
|
protected $noNeedLogin = [];
|
|
// 无需鉴权的接口,*表示全部
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
\app\common\model\fill\Handle::check('app_config','agent');
|
|
|
|
$this->model = new \app\common\model\app\agent\Member();
|
|
}
|
|
|
|
/**
|
|
* 获取当前申请状态
|
|
* @return void
|
|
*/
|
|
public function getStatus(){
|
|
$code = $this->model->getAuditStatus($this->auth->id);
|
|
$this->success("获取成功",$code);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取用户列表
|
|
* @return void
|
|
*/
|
|
public function getUserCondition(){
|
|
$data = (new \app\admin\model\order\Order())->getTransactionStatistic($this->auth->id);
|
|
$this->success("获取成功",$data);
|
|
}
|
|
|
|
/**
|
|
* 提交申请
|
|
* @return void
|
|
*/
|
|
public function apply()
|
|
{
|
|
|
|
$config = \app\common\model\app\Config::getConfig('agent');
|
|
|
|
if($config['member_recruit_status'] != 1){
|
|
$this->error("当前申请通道已经关闭");
|
|
}
|
|
|
|
|
|
$code = $this->model->getAuditStatus($this->auth->id);
|
|
|
|
if($code == 2){
|
|
$this->error("已经提交过了,请耐心等待审核");
|
|
}
|
|
|
|
if($code == 1){
|
|
$this->error("审核已通过,请刷新页面");
|
|
}
|
|
|
|
//判断加入条件
|
|
$recruitModal = new \app\common\model\app\agent\Recruit();
|
|
//检查加入条件
|
|
if(!$recruitModal->checkCondition($this->auth->id)){
|
|
$this->error("不满足加入条件");
|
|
}
|
|
|
|
|
|
|
|
if($code == 4){
|
|
//创建分销员记录
|
|
$insertData = [
|
|
'uniacid'=>UNIACID,
|
|
'user_id'=>$this->auth->id,
|
|
'createtime'=>time()
|
|
];
|
|
|
|
if($config['member_recruit_audit'] ==1){
|
|
//人工审核
|
|
$insertData['status'] = 2;
|
|
$insertData['audit'] = 2;
|
|
}else{
|
|
$insertData['status'] = 1;
|
|
$insertData['audit'] = 1;
|
|
}
|
|
|
|
$this->model->insert($insertData);
|
|
}else{
|
|
|
|
//重新申请
|
|
$this->model->where([
|
|
'user_id'=>$this->auth->id
|
|
])->delete();
|
|
|
|
$this->success("撤销成功,请重新提交");
|
|
}
|
|
|
|
$this->success("提交成功");
|
|
}
|
|
} |