<?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();
|
}
|
}
|