moonsflyer 9 kuukautta sitten
vanhempi
commit
d4cbd967c4

+ 112 - 0
app/adminapi/controller/asset/AssetLeaseController.php

@@ -0,0 +1,112 @@
+<?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\controller\asset;
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\asset\AssetLists;
+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\notice\NoticeValidate;
+
+/**
+ * 资产租赁控制器
+ * Class NoticeController
+ * @package app\adminapi\controller\notice
+ */
+class AssetLeaseController extends BaseAdminController
+{
+    /**
+     * @notes 查看资产列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 9:55
+     */
+    public function lists()
+    {
+        return $this->dataLists(new AssetLeaseLists());
+    }
+
+    /**
+     * @notes  添加资产
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/22 9:57
+     */
+    public function add()
+    {
+        $params = (new AssetValidate())->post()->goCheck('add');
+        AssetLists::add($params);
+        return $this->success('添加成功', [], 1, 1);
+    }
+    /**
+     * @notes  编辑资产
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/22 10:12
+     */
+    public function edit()
+    {
+        $params = (new AssetValidate())->post()->goCheck('edit');
+        $result = AssetLists::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(AssetLists::getError());
+    }
+
+    /**
+     * @notes  删除资讯
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/22 10:17
+     */
+    public function delete()
+    {
+        $params = (new AssetValidate())->post()->goCheck('delete');
+        AssetLists::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+    /**
+     * @notes  资产详情
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/22 10:15
+     */
+    public function detail()
+    {
+        $params = (new AssetValidate())->goCheck('detail');
+        $result = AssetLists::detail($params);
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 通知设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:18
+     */
+    public function set()
+    {
+        $params = $this->request->post();
+        $result = NoticeLogic::set($params);
+        if ($result) {
+            return $this->success('设置成功');
+        }
+        return $this->fail(NoticeLogic::getError());
+    }
+}

+ 179 - 0
app/adminapi/lists/asset/AssetLeaseLists.php

@@ -0,0 +1,179 @@
+<?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\lists\asset;
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\asset\AssetInfo;
+use app\common\model\asset\AssetLeaseInfo;
+use app\common\model\auth\Admin as adminModel ;
+use app\common\service\FileService;
+
+/**
+ * 资产租赁管理
+ * Class AssetLists
+ * @package app\adminapi\lists\asset
+ */
+class AssetLeaseLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+    /**
+     * @notes 搜索条件
+     * @return \string[][]
+     * @author
+     * @date 2025/04/12 2:21 下午
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['name', 'status']
+        ];
+    }
+
+    /**
+     * @notes 资产信息列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2022/2/16 3:18 下午
+     */
+    public function lists(): array
+    {
+
+        $parms =  $this->request->get();
+        $where = [] ;
+        if(!empty($parms))
+        {
+            if(isset($parms['asset_name'])){
+                $awhere = [] ;
+                $awhere[] = ['name', 'like', '%' . $parms['asset_name']. '%'];
+                $assetList = AssetInfo::where($awhere)->select()->toArray();
+                $a_id_Arr = array_column($assetList,'id');
+                $where[]=['a_id','in',$a_id_Arr];
+            }
+
+            if(isset($parms['tenant_name'])){
+                if(!empty($parms['tenant_name'])){
+                    $where[] = ['tenant_name', 'like', '%' . $parms['tenant_name']. '%'];
+                }
+            }
+        }
+
+        $lists = (new AssetLeaseInfo())->field('*')
+            ->append(['first_status_desc','second_status_desc'])
+            ->with('asset')
+            ->with('referee')
+            ->where($where)
+//            ->where($this->searchWhere)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->Order('id desc')
+            ->select()
+            ->toArray();
+
+
+        foreach($lists as &$v){
+            $v['first_name'] = adminModel::where(['id'=>$v['first_uid']])->value('name') ?? '';
+            $v['second_name'] = adminModel::where(['id'=>$v['second_uid']])->value('name') ?? '' ;
+        }
+        return $lists;
+    }
+
+    /**
+     * @notes 资产信息数量
+     * @return int
+     * @author ljj
+     * @date 2022/2/16 3:18 下午
+     */
+    public function count(): int
+    {
+        return (new AssetLeaseInfo())->where($this->searchWhere)->count();
+    }
+
+    /**
+     * @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, // 排序
+        ]);
+    }
+
+    /**
+     * @notes  编辑资产
+     * @param array $params
+     * @return bool
+     * @author heshihu
+     * @date 2022/2/22 10:12
+     */
+    public static function edit(array $params) : bool
+    {
+        try {
+            AssetInfo::update([
+                'id' => $params['id'],
+                'name' => $params['name'],
+                'images' => $params['images'],
+                'address' => $params['address'],
+                'contacts' => $params['contacts'],
+                'mobile' => $params['mobile'],
+                'area' => $params['area'] ?? '',
+                'content' => $params['content'] ?? '',
+                'status' => $params['status'] ?? 1,
+                'sort' => $params['sort'] ?? 0,
+                'content' => $params['content'] ?? '',
+            ]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * @notes  删除资产
+     * @param array $params
+     * @author heshihu
+     * @date 2022/2/22 10:17
+     */
+    public static function delete(array $params)
+    {
+        AssetInfo::destroy($params['id']);
+    }
+
+    /**
+     * @notes  查看资产详情
+     * @param $params
+     * @return array
+     * @author heshihu
+     * @date 2022/2/22 10:15
+     */
+    public static function detail($params) : array
+    {
+        return AssetInfo::findOrEmpty($params['id'])->append(['status_desc','lease_status_desc'])->toArray();
+    }
+}

+ 74 - 0
app/common/enum/asset/AssetEnum.php

@@ -43,6 +43,80 @@ class AssetEnum
         self::LEASE_END_USED,
     ];
 
+    //一审状态类型
+    const first_unapprove = 1;//等待初审
+    const first_approve = 2;//初审通过
+    const first_approve_fail = 3;//初审驳回
+    /**
+     * 显示状态场景
+     */
+    const FIRST_STATUS_SCENE = [
+        self::first_unapprove,
+        self::first_approve,
+        self::first_approve_fail,
+    ];
+
+    //二审状态类型
+    const unstart = 0;//未开始
+    const second_unapprove = 1;//等待终审
+    const second_approve = 2;//终审通过
+    const second_approve_fail = 3;//终审驳回
+    /**
+     * 显示状态场景 second_status
+     */
+    const SECOND_STATUS_SCENE = [
+        self::unstart,
+        self::second_unapprove,
+        self::second_approve,
+        self::second_approve_fail,
+    ];
+
+    /**
+     * @notes 获取一审状态描述
+     * @param $sceneId
+     * @param false $flag
+     * @return string|string[]
+     * @author 段誉
+     * @date 2022/3/29 11:33
+     */
+    public static function getFirstStatusDesc($sceneId, $flag = false)
+    {
+        $desc = [
+            self::unstart=>'未开始',
+            self::first_unapprove => '等待初审',
+            self::first_approve =>'初审通过',
+            self::first_approve_fail => '初审驳回',
+        ];
+
+        if ($flag) {
+            return $desc;
+        }
+
+        return $desc[$sceneId] ?? '';
+    }
+    /**
+     * @notes 获取一审状态描述
+     * @param $sceneId
+     * @param false $flag
+     * @return string|string[]
+     * @author 段誉
+     * @date 2022/3/29 11:33
+     */
+    public static function getSecondStatusDesc($sceneId, $flag = false)
+    {
+        $desc = [
+            self::unstart => '未开始',
+            self::second_unapprove => '等待终审',
+            self::second_approve =>'终审通过',
+            self::second_approve_fail => '终审驳回',
+        ];
+
+        if ($flag) {
+            return $desc;
+        }
+
+        return $desc[$sceneId] ?? '';
+    }
     /**
      * @notes 获取显示状态描述
      * @param $sceneId

+ 53 - 0
app/common/model/BaseModel.php

@@ -75,4 +75,57 @@ class BaseModel extends Model
             return '';
         }
     }
+
+    /**
+     * @notes 公共处理图片,补全路径
+     * @param $value
+     * @return string
+     * @author 张无忌
+     * @date 2021/9/10 11:02
+     */
+    public function getLicenseImageAttr($value)
+    {
+        return trim($value) ? FileService::getFileUrl($value) : '';
+    }
+
+    /**
+     * @notes 公共图片处理,去除图片域名
+     * @param $value
+     * @return mixed|string
+     * @author 张无忌
+     * @date 2021/9/10 11:04
+     */
+    public function setLicenseImageAttr($value)
+    {
+        return trim($value) ? FileService::setFileUrl($value) : '';
+    }
+
+    public function getLeaseContractImageAttr($value)
+    {
+        if(trim($value)){
+            $imgArr = explode(',',$value);
+            foreach ($imgArr as &$v){
+                $v = FileService::getFileUrl($v);
+            }
+
+            return implode(',',$imgArr);
+        }else{
+            return '';
+        }
+    }
+
+    public function setLeaseContractImageAttr($value)
+    {
+        if(trim($value)){
+            $imgArr = explode(',',$value);
+            foreach ($imgArr as &$v){
+                $v = FileService::setFileUrl($v);
+            }
+
+            return implode(',',$imgArr);
+        }else{
+            return '';
+        }
+    }
+
 }

+ 88 - 0
app/common/model/asset/AssetLeaseInfo.php

@@ -0,0 +1,88 @@
+<?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\common\model\asset;
+
+
+use app\common\enum\DefaultEnum;
+use app\common\enum\asset\AssetEnum;
+use app\common\model\auth\Admin;
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+class AssetLeaseInfo extends BaseModel
+{
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    /**
+     * @notes 关联资产表
+     * @return \think\model\relation\HasOne
+     * @author 令狐冲
+     * @date 2021/7/5 14:39
+     */
+    public function asset()
+    {
+        return $this->hasOne(AssetInfo::class, 'id', 'a_id')
+            ->field('id,name,images,address,address,mobile,area');
+    }
+    /**
+     * @notes 关联管理员表
+     * @return \think\model\relation\HasOne
+     * @author 令狐冲
+     * @date 2021/7/5 14:39
+     */
+    public function referee()
+    {
+        return $this->hasOne(Admin::class, 'id', 'referee_uid')
+            ->field('id,name');
+    }
+    /**
+     * @notes 关联管理员表
+     * @return \think\model\relation\HasOne
+     * @author 令狐冲
+     * @date 2021/7/5 14:39
+     */
+    public function first()
+    {
+        return $this->hasOne(Admin::class, 'id', 'first_uid')
+            ->field('id,name');
+    }
+    /**
+     * @notes 一审状态类型
+     * @param $value
+     * @param $data
+     * @return string|string[]
+     * @author ljj
+     * @date 2022/2/17 2:50 下午
+     */
+    public function getFirstStatusDescAttr($value,$data)
+    {
+        return AssetEnum::getFirstStatusDesc($data['first_status']);
+    }
+
+    /**
+     * @notes 终审
+     * @param $value
+     * @param $data second_status
+     * @return string|string[]
+     * @author ljj
+     * @date 2022/2/17 2:50 下午
+     */
+    public function getSecondStatusDescAttr($value,$data)
+    {
+        return AssetEnum::getSecondStatusDesc($data['second_status']);
+    }
+}