Browse Source

入驻和合作及完成信息同步

zhangxiaobin 1 year ago
parent
commit
35badfe2e5

+ 34 - 2
application/api/controller/Companys.php

@@ -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());
+        }
+    }
 }

+ 23 - 0
application/api/controller/Cooperation.php

@@ -57,4 +57,27 @@ class Cooperation extends Api
             $this->error($e->getMessage());
         }
     }
+
+    /**
+     * 详情
+     * @return void
+     */
+    public function getInfo()
+    {
+        try {
+            $userId = $this->auth->id;
+            $field = 'id,name,mobile,servicetype_id,cooperation_status,remark,createtime';
+            $where['user_id'] = $userId;
+            $result = $this->model->where($where)->field($field)->find();
+            if (!empty($result)) {
+                $statusArr = model('Cooperation')->getCooperationStatusList();
+                $result['cooperation_status_text'] = isset($statusArr[$result['cooperation_status']]) ? $statusArr[$result['cooperation_status']] : '';
+                $result = info_domain_image($result,['aptitude_images']);
+            }
+
+            $this->success('获取成功',$result);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
 }

+ 6 - 1
application/api/controller/company/Order.php

@@ -145,7 +145,12 @@ class Order extends Apic
         }
 
         //完成
-        $rs = Db::name('order')->where('id',$id)->update(['status'=>3,'finish_time'=>time(),'staff_id'=>$this->auth->id]);
+        $time = time();
+        $updateData = ['status'=>3,'finish_time'=>time(),'staff_id'=>$this->auth->id];
+        if (empty($info['hexiao_time'])) {
+            $updateData['hexiao_time'] = $time;
+        }
+        $rs = Db::name('order')->where('id',$id)->update($updateData);
         if($rs === false){
             Db::rollback();
             $this->error('操作失败');

+ 4 - 1
application/common/model/Company.php

@@ -21,5 +21,8 @@ class Company extends Model
     // 追加属性
     protected $append = [];
 
-
+    public function getStatusList()
+    {
+        return ['-1' => '新来的', '0' => '待审核', '1' => '审核通过', '2' => '审核不通过'];
+    }
 }

+ 1 - 1
application/common/model/Cooperation.php

@@ -30,7 +30,7 @@ class Cooperation extends Model
 
     public function getCooperationStatusList()
     {
-        return ['1' =>__('Cooperation_status 1'), '2' =>__('Cooperation_status 2')];
+        return ['1' =>'待联系', '2' =>'已联系'];
     }
 
     public function getCooperationStatusTextAttr($value, $data)

+ 1 - 1
application/common/validate/Companys.php

@@ -40,6 +40,6 @@ class Companys extends Validate
     // 应用场景
     protected $scene = [
         'add' => ['contacts','mobile','province_id','city_id','area_id','address','aptitude_images'],
-        'edit' => ['id','contacts','mobile','province_id','city_id','area_id','address','aptitude_images'],
+        'edit' => ['contacts','mobile','province_id','city_id','area_id','address','aptitude_images'],
     ];
 }