75 lines
2.8 KiB
PHP
75 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saasagent\api\controller;
|
|
use app\api\controller\BaseApi;
|
|
use app\model\web\WebSite as WebsiteModel;
|
|
class Agent extends BaseApi
|
|
{
|
|
|
|
/***
|
|
* 查看代理商信息
|
|
* @return false|string
|
|
*/
|
|
public function info(){
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$website_model = new WebsiteModel();
|
|
$agnetInfo=$website_model->getWebSite(['member_id'=>$this->member_id]);
|
|
return $this->response($agnetInfo);
|
|
}
|
|
|
|
|
|
/***
|
|
* 代理商申请
|
|
* @return false|string|void
|
|
*/
|
|
public function apply(){
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$website_model = new WebsiteModel();
|
|
$agnetInfo=$website_model->getWebSite(['member_id'=>$this->member_id])['data'];
|
|
if($agnetInfo && $agnetInfo['is_apply']==1) return $this->response($this->error('您已经是代理商'));
|
|
$data = [
|
|
'status' =>1,
|
|
'is_agent' =>1,
|
|
'member_id' =>$this->member_id,
|
|
'agent_level_id' => 0,
|
|
'website_pid' =>$this->site_id,
|
|
'web_contacts' => input('web_contacts', ''),
|
|
'web_phone' => input('web_phone', ''),
|
|
'agent_info' => input('formData', ''),
|
|
];
|
|
if($agnetInfo){
|
|
$res= $website_model->setWebSite($data,['member_id'=>$this->member_id]);
|
|
}else{
|
|
$formData=json_decode($data['agent_info'],true);
|
|
if($formData){
|
|
$temp=[];
|
|
foreach ($formData as $item){
|
|
$temp[$item['controller']]=$item;
|
|
}
|
|
$area_name=explode('-',$temp['City']['val']);
|
|
$area_id=explode('-',$temp['City']['area_id']);
|
|
$data['site_area_name']=end($area_name);
|
|
$data['site_area_id']=end($area_id);
|
|
}
|
|
$res = $website_model->addWebsite($data);
|
|
}
|
|
if($res['code']<0){
|
|
return $this->response($res);
|
|
}else{
|
|
return $this->response($this->success('成功!耐心等待审核'));
|
|
}
|
|
}
|
|
|
|
} |