liugc пре 1 година
родитељ
комит
85ede4ab82

+ 11 - 5
app/adminapi/logic/property/PropertyHeadLogic.php

@@ -45,18 +45,22 @@ class PropertyHeadLogic extends BaseLogic
     {
         Db::startTrans();
         try {
+            $info = PropertyHead::where('head_mobile',$params['head_mobile'])->findOrEmpty();
+            if(!$info->isEmpty()){
+                throw new \Exception('该手机号已入驻代理');
+            }
             PropertyHead::create([
                 'property_name' => $params['property_name'],
                 'village_name' => $params['village_name'],
                 'address' => $params['address'],
                 'head_name' => $params['head_name'],
                 'head_mobile' => $params['head_mobile'],
-                'ratio' => $params['ratio'],
-                'head_bank_card' => $params['head_bank_card'],
+                'ratio' => $params['ratio']??0,
+                'head_bank_card' => $params['head_bank_card']??'',
                 'head_corporate_bank' => $params['head_corporate_bank']??'',
-                'lon' => $params['lon'],
-                'lat' => $params['lat'],
-                'remark' => $params['remark'],
+                'lon' => $params['lon']??0,
+                'lat' => $params['lat']??0,
+                'remark' => $params['remark']??'',
                 'bind_date'=>!empty($params['bind_date'])?$params['bind_date']:0,
                 'sale_type'=>$params['sale_type']??0,
                 'sale_id'=>$params['sale_id']??0,
@@ -64,6 +68,7 @@ class PropertyHeadLogic extends BaseLogic
                 'province' => $params['province']??0,
                 'city' => $params['city']??0,
                 'area_name' => $params['area_name']??'',
+                'door_images' => $params['door_images']??'',
             ]);
 
             Db::commit();
@@ -116,6 +121,7 @@ class PropertyHeadLogic extends BaseLogic
                 'province' => $params['province']??0,
                 'city' => $params['city']??0,
                 'area_name' => $params['area_name']??'',
+                'door_images' => $params['door_images']??'',
             ]);
 
 

+ 1 - 1
app/adminapi/validate/property/PropertyHeadValidate.php

@@ -66,7 +66,7 @@ class PropertyHeadValidate extends BaseValidate
      */
     public function sceneAdd()
     {
-        return $this->only(['property_name','village_name','address','head_name','head_mobile','head_bank_card']);
+        return $this->only(['property_name','village_name','address','head_name','head_mobile']);
     }
 
 

+ 4 - 1
app/common/model/property/PropertyHead.php

@@ -28,7 +28,10 @@ class PropertyHead extends BaseModel
 {
     
     protected $name = 'property_head';
-    
 
+    public function getCityTextAttr($value,$data):string{
+        $postageRegion = array_column(getPostageRegion([$data['city']]), null, 'id');
+        return $postageRegion[$data['city']]['name']??'';
+    }
     
 }

+ 64 - 0
app/workerapi/controller/PropertyHeadController.php

@@ -0,0 +1,64 @@
+<?php
+namespace app\workerapi\controller;
+
+use app\adminapi\logic\property\PropertyHeadLogic;
+use app\adminapi\logic\user\UserLogic;
+use app\adminapi\validate\property\PropertyHeadValidate;
+use app\common\enum\notice\NoticeEnum;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\model\notice\NoticeSetting;
+use app\common\model\sale\Sale;
+use app\common\service\wechat\WeChatOaService;
+use app\workerapi\lists\MasterWorkerRegisterLists;
+use app\workerapi\lists\PropertyHeadLists;
+use app\workerapi\lists\TenantRegisterLists;
+use app\workerapi\logic\DictLogic;
+use app\workerapi\logic\LoginLogic;
+use app\workerapi\logic\MasterWorkerRegisterLogic;
+
+use app\workerapi\logic\SaleLogic;
+use app\workerapi\logic\TenantRegisterLogic;
+use app\workerapi\validate\LoginAccountValidate;
+use app\workerapi\validate\RegisterValidate;
+
+
+/**
+ * 销售
+ * Class PropertyHeadController
+ * @package app\workerapi\controller
+ */
+class PropertyHeadController extends BaseApiController
+{
+
+    public array $notNeedLogin = ['register'];
+
+
+    /**
+     * @notes 注册代理
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/7 15:38
+     */
+    public function register()
+    {
+        $params = (new PropertyHeadValidate())->post()->goCheck('add');
+        $params['sale_type'] = 1;
+        // 通过 $params['city'] 查询省市区
+        if(isset($params['city']) && !empty($params['city'])){
+            $postageRegion = array_column(getPostageRegion(), null, 'id');
+            $params['province'] = $postageRegion[$params['city']]['pid'];
+            $params['province'] && $params['area_name'] = $postageRegion[$params['province']]['name'].$postageRegion[$params['city']]['name'];
+        }
+        $result = PropertyHeadLogic::add($params);
+        if (true === $result) {
+            // 通过手机号查询用户是否注册 - 已注册绑定id ,未注册注册再绑定id
+            $userId = UserLogic::getUserIdByMobile($params['head_mobile'], true);
+            PropertyHeadLogic::updateUserId($params['head_mobile'],$userId);
+            return $this->success('入驻成功', [], 1, 1);
+        }
+        return $this->fail(PropertyHeadLogic::getError());
+    }
+
+
+}

+ 18 - 1
app/workerapi/controller/SaleController.php

@@ -21,10 +21,12 @@ use app\common\model\notice\NoticeSetting;
 use app\common\model\sale\Sale;
 use app\common\service\wechat\WeChatOaService;
 use app\workerapi\lists\MasterWorkerRegisterLists;
+use app\workerapi\lists\PropertyHeadLists;
 use app\workerapi\lists\TenantRegisterLists;
 use app\workerapi\logic\DictLogic;
 use app\workerapi\logic\LoginLogic;
 use app\workerapi\logic\MasterWorkerRegisterLogic;
+use app\workerapi\logic\PropertyHeadLogic;
 use app\workerapi\logic\SaleLogic;
 use app\workerapi\logic\TenantRegisterLogic;
 use app\workerapi\validate\LoginAccountValidate;
@@ -104,6 +106,21 @@ class SaleController extends BaseApiController
     }
 
 
-
+    /**
+     * 销售查看代理列表
+     */
+    public function getPropertyList()
+    {
+        return $this->dataLists(new PropertyHeadLists());
+    }
+    /**
+     * 销售查看代理详情
+     */
+    public function getPropertyDetail()
+    {
+        $params = request()->get();
+        $result = PropertyHeadLogic::detail($params);
+        return $this->data($result);
+    }
 
 }

+ 68 - 0
app/workerapi/lists/PropertyHeadLists.php

@@ -0,0 +1,68 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyHead;
+use app\common\model\works\ServiceWork;
+use app\workerapi\logic\SaleLogic;
+use think\facade\Db;
+
+
+/**
+ * PropertyHeadLists列表
+ * Class PropertyHeadLists
+ * @package app\workerapi\lists
+ */
+class PropertyHeadLists extends BaseWorkerDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/25 09:29
+     */
+    public function setSearch(): array
+    {
+        $sale_id = SaleLogic::getSaleIdByToken($this->params['sale_token']??'00000');
+        $this->params['sale_id'] = $sale_id;
+        return [
+            '=' => ['sale_id'],
+            '%like%' => ['property_name', 'village_name', 'head_name'],
+        ];
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/25 09:29
+     */
+    public function lists(): array
+    {
+        return PropertyHead::where($this->searchWhere)
+            ->field(['*'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/25 09:29
+     */
+    public function count(): int
+    {
+        return PropertyHead::where($this->searchWhere)->count();
+    }
+
+}

+ 35 - 0
app/workerapi/logic/PropertyHeadLogic.php

@@ -0,0 +1,35 @@
+<?php
+namespace app\workerapi\logic;
+
+
+use app\adminapi\logic\user\UserLogic;
+use app\common\model\property\PropertyHead;
+use app\common\logic\BaseLogic;
+use app\common\model\user\User;
+use app\common\service\wechat\WeChatMnpService;
+use Exception;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * PropertyHead逻辑
+ * Class PropertyHeadLogic
+ * @package app\adminapi\logic
+ */
+class PropertyHeadLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function detail($params): array
+    {
+        return PropertyHead::findOrEmpty($params['id'])->append(['city_text'])->toArray();
+    }
+}