|
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
+use think\Exception;
|
|
|
|
|
|
class Companys extends Api
|
|
|
{
|
|
@@ -168,6 +169,13 @@ class Companys extends Api
|
|
|
//验证参数
|
|
|
$id = $this->request->param('id',0);
|
|
|
$userId = $this->auth->id;
|
|
|
+ if (empty($id)) {
|
|
|
+ $companyWhere['user_id'] = $userId;
|
|
|
+ $company = $this->model->where($companyWhere)->find();
|
|
|
+ if (!empty($company)) {
|
|
|
+ $id = $company['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
$scene = !empty($id) ? 'edit' : 'add';
|
|
|
$validate = validate('Companys');
|
|
|
if(!$validate->check($this->request->param(),[],$scene)){
|
|
@@ -182,6 +190,7 @@ class Companys extends Api
|
|
|
}
|
|
|
} else {
|
|
|
$where['user_id'] = $userId;
|
|
|
+ $where['status'] = 1;//状态:-1=新来的,0=待审核,1=审核通过,2=审核不通过
|
|
|
$companyData = $this->model->where($where)->find();
|
|
|
if (!empty($companyData)) {
|
|
|
throw new Exception('您已申请过入驻');
|
|
@@ -191,7 +200,6 @@ class Companys extends Api
|
|
|
$areaData = getProvince($this->request->param());
|
|
|
$fullAddress = $areaData['full_address'];
|
|
|
$data = [
|
|
|
- 'image' => '/assets/img/avatar.png',//默认头像
|
|
|
'contacts' => $this->request->param('contacts', ''),
|
|
|
'mobile' => $this->request->param('mobile', ''),
|
|
|
'province_id' => $this->request->param('province_id', 0),
|
|
@@ -203,9 +211,10 @@ class Companys extends Api
|
|
|
'address' => $this->request->param('address', ''),
|
|
|
'full_address' => $fullAddress,
|
|
|
'aptitude_images' => $this->request->param('aptitude_images', ''),
|
|
|
- 'status' => 1,
|
|
|
+ 'status' => 0,
|
|
|
];
|
|
|
if (empty($id)) {
|
|
|
+ $data['image'] = '/assets/img/avatar.png';//默认头像
|
|
|
$data['user_id'] = $userId;
|
|
|
$data['createtime'] = $time;
|
|
|
$res = $this->model->insertGetId($data);
|
|
@@ -223,4 +232,27 @@ class Companys extends Api
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 入驻详情
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function getCompanyInfo()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $userId = $this->auth->id;
|
|
|
+ $field = 'id,contacts,mobile,province_id,city_id,area_id,province_name,city_name,area_name,address,aptitude_images,status';
|
|
|
+ $where['user_id'] = $userId;
|
|
|
+ $result = $this->model->where($where)->field($field)->find();
|
|
|
+ if (!empty($result)) {
|
|
|
+ $statusArr = model('Company')->getStatusList();
|
|
|
+ $result['status_text'] = isset($statusArr[$result['status']]) ? $statusArr[$result['status']] : '';
|
|
|
+ $result = info_domain_image($result,['aptitude_images']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('获取成功',$result);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|