Files
fdesk/app/crm/service/FollowService.php
T
2025-08-22 14:31:33 +08:00

70 lines
2.0 KiB
PHP

<?php
namespace app\crm\service;
use app\common\service\OssService;
use app\crm\model\Follow;
use app\crm\utils\Util;
use config\constants\Constants;
class FollowService
{
public function list($param, $userId)
{
// $page = $request->input('page', 1);
// $perPage = $request->input('per_page', 10);
//客户id
$customer_id = $param['customer_id'];
$corp_abbr = $param['corp_abbr'];
$where = [];
$where['customer_id'] = $customer_id;
// $where['corp_abbr'] = $corp_abbr;
//用户角色
//跟进id
$id = $param['id'] ?? null;
if (!empty($id)) {
$where['id'] = $id;
}
// 执行分页查询
$data = Follow::where($where)
->orderBy('id', 'desc')->get();
// ->paginate($perPage, ['*'], 'page', $page);
// $host = $request->host();
// $url = 'http:'.$request->url();
foreach ($data as &$value) {
$value = self::getFollow($value);
}
return $data;
}
public static function getFollow($follow)
{
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
$follow['firstFollowtime'] = $follow['follow_time'];
$oss_picture = '';
if (!empty($follow['picture'])) {
$ossservice = new OssService();
$oss_picture = $ossservice->generatePrivateUrl($follow['picture'], 86400);
}
$follow['picture_full'] = $oss_picture;
// $follow = Util::formatDate($follow,['created_at','updated_at','follow_time']);
$follow['follow_time'] = empty($follow['follow_time'])?'':date('Y-m-d H:i:s', $follow['follow_time']);
$follow['created_at'] = empty($follow['created_at'])?'':date('Y-m-d H:i:s', $follow['created_at']);
$follow['updated_at'] = empty($follow['updated_at'])?'':date('Y-m-d H:i:s', $follow['updated_at']);;
// $follow = Util::formatDate($follow);
return $follow;
}
}