| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?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']. '%'];
- }
- }
- if(isset($parms['tenant_mobile'])){
- if(!empty($parms['tenant_mobile'])){
- $where[] = ['tenant_mobile', 'like', '%' . $parms['tenant_mobile']. '%'];
- }
- }
- }
- $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)
- {
- 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' => '新增租赁信息成功!'];
- }
- /**
- * @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();
- }
- }
|