Ver código fonte

新增租赁信息

moonsflyer 9 meses atrás
pai
commit
7717864e26

+ 14 - 11
app/adminapi/controller/asset/AssetLeaseController.php

@@ -20,7 +20,9 @@ use app\adminapi\lists\asset\AssetLeaseLists;
 use app\adminapi\logic\notice\NoticeLogic;
 use app\adminapi\validate\article\ArticleValidate;
 use app\adminapi\validate\asset\AssetValidate;
+use app\adminapi\validate\asset\AssetLeaseValidate;
 use app\adminapi\validate\notice\NoticeValidate;
+use app\common\logic\PaymentLogic;
 
 /**
  * 资产租赁控制器
@@ -48,9 +50,13 @@ class AssetLeaseController extends BaseAdminController
      */
     public function add()
     {
-        $params = (new AssetValidate())->post()->goCheck('add');
-        AssetLists::add($params);
-        return $this->success('添加成功', [], 1, 1);
+        $params = (new AssetLeaseValidate())->post()->goCheck('add');
+        $result =AssetLeaseLists::add($params);
+
+        if ($result['code'] <> 200) {
+            return $this->fail($result['msg']);
+        }
+        return $this->success($result['msg'], [], 1, 1);
     }
     /**
      * @notes  编辑资产
@@ -95,18 +101,15 @@ class AssetLeaseController extends BaseAdminController
     }
 
     /**
-     * @notes 通知设置
+     * @notes 获取可租赁房产
      * @return \think\response\Json
      * @author 段誉
      * @date 2022/3/29 11:18
      */
-    public function set()
+    public function getAssetForRent()
     {
-        $params = $this->request->post();
-        $result = NoticeLogic::set($params);
-        if ($result) {
-            return $this->success('设置成功');
-        }
-        return $this->fail(NoticeLogic::getError());
+        $params = $this->request->get();
+        $result = AssetLists::getRentAssetList($params);
+        return $this->success('查询成功', $result, 1, 1);
     }
 }

+ 33 - 12
app/adminapi/lists/asset/AssetLeaseLists.php

@@ -109,25 +109,46 @@ class AssetLeaseLists extends BaseAdminDataLists implements ListsSearchInterface
     }
 
     /**
-     * @notes  添加资产
+     * @notes  添加租赁资产订单
      * @param array $params
      * @author heshihu
      * @date 2022/2/22 9:57
      */
     public static function add(array $params)
     {
-        AssetInfo::create([
-            'name' => $params['name'],
-            'images' => $params['images'] ?? '',
-            'address' => $params['address'] ?? '',
-            'contacts' => $params['contacts']?? '', // 联系人
-            'mobile' => $params['mobile'] ?? '',
-            'area' => $params['area'] ?? '',
-            'content' => $params['content'] ?? '',
-//            'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
-            'status' => $params['status'] ?? 1,
-            'sort' => $params['sort'] ?? 0, // 排序
+
+        if ($params['lease_end_time']<$params['lease_start_time']) {
+            return ['code' => 0, 'msg' => '租赁时间范围有误请检查!'];
+        }
+        $where = [];
+        $where[] = ['lease_end_time', '>=', $params['lease_start_time']];
+        $where[] = ['lease_end_time', '>=', $params['lease_start_time']];
+        $where[] = ['a_id', '=', $params['a_id']];
+
+        $assetLeaseInfo = AssetLeaseInfo::where($where)->findOrEmpty();
+
+
+
+        if (!$assetLeaseInfo->isEmpty()) {
+            return ['code' => 0, 'msg' => '租赁期内有未到期的租赁信息!'];
+        }
+
+        AssetLeaseInfo::create([
+            'a_id' => $params['a_id'],
+            'tenant_name' => $params['tenant_name'] ?? '',
+            'tenant_mobile' => $params['tenant_mobile'] ?? '',
+            'license_number' => $params['license_number'] ?? '',
+            'license_image' => $params['license_image'] ?? '',
+            'lease_contract_image' => $params['lease_contract_image'] ?? '',
+            'lease_money' => $params['lease_money'] ?? 0,
+            'lease_start_time' => $params['lease_start_time'] ?? '',
+            'lease_end_time' => $params['lease_end_time'] ?? '', // 联系人
+            'purpose' => $params['purpose'] ?? '',
+            'referee_uid' => 1,
+            'remark' => $params['remark'] ?? '',
         ]);
+        return ['code' => 200, 'msg' => '新增租赁信息成功!'];
+
     }
 
     /**

+ 14 - 0
app/adminapi/lists/asset/AssetLists.php

@@ -148,4 +148,18 @@ class AssetLists extends BaseAdminDataLists implements ListsSearchInterface
     {
         return AssetInfo::findOrEmpty($params['id'])->append(['status_desc','lease_status_desc'])->toArray();
     }
+
+    public static function getRentAssetList($params) : array
+    {
+
+        $where = [] ;
+        if(!empty($params)){
+            $where[]=['name','like','%'.$params['name'].'%'];
+        }
+        $where[]=['status','=',1];
+        $where[]=['lease_status','in',[1,3]];
+        $assetList = AssetInfo::where($where)->field('id,name,area')->select()->toArray();
+
+        return $assetList;
+    }
 }

+ 126 - 0
app/adminapi/validate/asset/AssetLeaseValidate.php

@@ -0,0 +1,126 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\asset;
+
+use app\common\validate\BaseValidate;
+use app\common\model\asset\AssetInfo;
+use app\common\model\asset\AssetLeaseInfo;
+/**
+ * 资产租赁管理验证
+ * Class ArticleValidate
+ * @package app\adminapi\validate\article
+ */
+class AssetLeaseValidate extends BaseValidate
+{
+    protected $rule = [
+        'id' => 'require|checkAssetInfo',
+        'a_id' => 'require|checkAssetDataInfo',
+        'tenant_name' => 'require|length:1,50',
+        'tenant_mobile' => 'require|length:1,13',
+        'license_number' => 'require',
+        'license_image' => 'require',
+        'lease_contract_image' => 'require',
+        'lease_money' => 'require',
+        'lease_start_time' => 'require',
+        'first_status' => 'in:1,2,3',
+        'second_status' => 'in:0,1,2,3',
+    ];
+
+    protected $message = [
+        'id.require' => '资产id必传',
+        'tenant_name.require' => '租赁人姓名必传!',
+        'tenant_name.length' => '资产名称长度须在1-50位字符',
+        'tenant_mobile.require' => '租赁人联系方式必传!',
+        'tenant_mobile.length' => '租赁人联系方式长度须在1-13位字符',
+        'license_number.require' => '营业执照编号不能为空',
+        'license_image.require' => '营业执照照片必传',
+        'lease_contract_image.require' => '合同照片必传',
+        'lease_money.require' => '租赁金额必传',
+    ];
+
+    /**
+     * @notes  添加场景
+     * @return ArticleValidate
+     * @author heshihu
+     * @date 2022/2/22 9:57
+     */
+    public function sceneAdd()
+    {
+        return $this->remove(['id'])
+            ->remove('id','require|checkAssetInfo');
+    }
+
+    /**
+     * @notes  详情场景
+     * @return ArticleValidate
+     * @author heshihu
+     * @date 2022/2/22 10:15
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    /**
+     * @notes  更改状态场景
+     * @return ArticleValidate
+     * @author heshihu
+     * @date 2022/2/22 10:18
+     */
+    public function sceneStatus()
+    {
+        return $this->only(['id', 'status']);
+    }
+
+    public function sceneEdit()
+    {
+    }
+
+    /**
+     * @notes  删除场景
+     * @return ArticleValidate
+     * @author heshihu
+     * @date 2022/2/22 10:17
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+    /**
+     * @notes  检查指定资讯是否存在
+     * @param $value
+     * @return bool|string
+     * @author heshihu
+     * @date 2022/2/22 10:11
+     */
+    public function checkAssetInfo($value)
+    {
+        $article = AssetLeaseInfo::findOrEmpty($value);
+        if ($article->isEmpty()) {
+            return '租赁资产信息不存在';
+        }
+        return true;
+    }
+
+    public function checkAssetDataInfo($value){
+        $article = AssetInfo::findOrEmpty($value);
+        if ($article->isEmpty()) {
+            return '资产不存在或已删除';
+        }
+        return true;
+    }
+
+}

+ 1 - 0
app/common/model/asset/AssetInfo.php

@@ -25,6 +25,7 @@ class AssetInfo extends BaseModel
     use SoftDelete;
 
     protected $deleteTime = 'delete_time';
+
     /**
      * @notes 状态类型
      * @param $value