quanwei
2025-10-29 76ed09d116f484b261d44219de300b79eb2013b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
 
namespace app\common\model\plus\business;
use app\common\model\BaseModel;
 
/**
 * 名片保存(浏览)记录
 */
class Saving extends BaseModel
{
    protected $name='business_card_saving';
    public function user()
    {
        $model=self::getCalledModule()?:'common';
        return $this->hasOne("\\app\\$model\\model\\user\\User",'user_id','user_id');
    }
    public function affiliation()
    {
        $model=self::getCalledModule()?:'common';
        return $this->hasOne("\\app\\$model\\model\\user\\User",'user_id','affiliation_id');
    }
    public function business()
    {
        $model=self::getCalledModule()?:'common';
        return $this->hasOne("\\app\\$model\\model\\plus\\business\\Business",'business_card_id','business_card_id');
    }
 
    public function lists($param=[]){
        $paramL=array_merge(['listRows'=>15],$param);
        $where=[];
        !empty($paramL['user_id'])&&$where['user_id']=$paramL['user_id'];
        !empty($paramL['affiliation_id'])&&$where['affiliation_id']=$paramL['affiliation_id'];
        !empty($paramL['type'])&&$where['type']=$paramL['type'];
        return $this->with(['user'=>['businessCard'=>['image','logoImage']],'affiliation','business'=>['image']])->order('create_time','desc')->where($where)->paginate($paramL);
    }
 
    /**
     * 获取记录数量
     * @param $param
     * @return int|string
     * @throws \think\Exception
     */
    public function getQuantity($paramL=[])
    {
        $where=[];
        !empty($paramL['user_id'])&&$where['user_id']=$paramL['user_id'];
        !empty($paramL['affiliation_id'])&&$where['affiliation_id']=$paramL['affiliation_id'];
        !empty($paramL['today'])&&$this->whereTime('create_time', 'today');
        !empty($paramL['type'])&&$where['type']=$paramL['type'];
        return $this->where($where)->count();
    }
}