Преглед на файлове

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into tel-m

liugc преди 1 година
родител
ревизия
5efd91d03d

+ 1 - 1
app/adminapi/lists/property/PropertyHeadLists.php

@@ -56,7 +56,7 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function lists(): array
     {
         return PropertyHead::where($this->searchWhere)
-            ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat'])
+            ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat','bind_date'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()

+ 4 - 2
app/adminapi/logic/property/PropertyHeadLogic.php

@@ -52,7 +52,8 @@ class PropertyHeadLogic extends BaseLogic
                 'head_bank_card' => $params['head_bank_card'],
                 'lon' => $params['lon'],
                 'lat' => $params['lat'],
-                'remark' => $params['remark']
+                'remark' => $params['remark'],
+                'bind_date'=>!empty($params['bind_date'])?$params['bind_date']:0
             ]);
 
             Db::commit();
@@ -96,7 +97,8 @@ class PropertyHeadLogic extends BaseLogic
                 'head_bank_card' => $params['head_bank_card'],
                 'lon' => $params['lon'],
                 'lat' => $params['lat'],
-                'remark' => $params['remark']
+                'remark' => $params['remark'],
+                'bind_date'=>!empty($params['bind_date'])?$params['bind_date']:0
             ]);
 
 

+ 11 - 0
app/adminapi/validate/property/PropertyOrderValidate.php

@@ -98,4 +98,15 @@ class PropertyOrderValidate extends BaseValidate
         return $this->only(['id']);
     }
 
+    /**
+     * @notes 绑定场景
+     * @return PropertyOrderValidate
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function sceneBind()
+    {
+        return $this->only(['property_head_id']);
+    }
+
 }

+ 18 - 0
app/api/controller/PropertyController.php

@@ -19,6 +19,24 @@ use think\facade\Log;
 class PropertyController extends BaseApiController
 {
     public array $notNeedLogin = ['orderByQrcode'];
+
+    /**
+     * @notes 用户绑定物业信息
+     * @return \think\response\Json
+     */
+    public function bindProperty()
+    {
+        $params = (new PropertyOrderValidate())->post()->goCheck('bind', [
+            'householder_name'=>'',
+            'householder_mobile'=>$this->userInfo['mobile']
+        ]);
+        $result = PropertyOrderLogic::bind($params);
+        if (true === $result) {
+            return $this->success('下单成功', [], 1, 1);
+        }
+        return $this->fail(PropertyOrderLogic::getError());
+    }
+
     /**
      * @notes 二维码扫码下物业单
      * @return \think\response\Json

+ 31 - 0
app/api/logic/PropertyOrderLogic.php

@@ -33,6 +33,37 @@ use think\facade\Log;
 class PropertyOrderLogic extends BaseLogic
 {
 
+    public static function bind(array $params): bool
+    {
+        // 判断户主是否存在 返回户主id
+        $propertyUserId = PropertyUserLogic::getPropertyUserIdByMobile($params);
+        Db::startTrans();
+        try {
+            $property = PropertyHead::where('id',$params['property_head_id'])->findOrEmpty();
+            $address = $property['adress'];
+            if(empty($property)){
+               throw new Exception('物业代理不存在');
+            }
+            $order = PropertyOrder::where(['property_user_id'=>$propertyUserId,'property_head_id'=>$params['property_head_id'],'order_status'=>0])->where('work_id','<>',0)->order('id desc')->findOrEmpty();
+            if(!empty($order)){
+
+            }
+            PropertyOrder::create([
+                'property_head_id' => $params['property_head_id'],
+                'property_user_id' => $propertyUserId,
+                'remark' => $params['remark']??'',
+                'address' => $address??'',
+                'order_status' => 0,
+                'work_id' => 0,
+            ]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 
     /**
      * @notes 添加 - 下物业单