Files
huangjingfen/pro_v3.5.1/app/services/user/UserStoreOrderServices.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

66 lines
2.0 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\services\user;
use app\services\BaseServices;
use app\dao\user\UserStoreOrderDao;
use think\annotation\Inject;
/**
*
* Class UserStoreOrderServices
* @package app\services\user
* @mixin UserStoreOrderDao
*/
class UserStoreOrderServices extends BaseServices
{
/**
* @var UserStoreOrderDao
*/
#[Inject]
protected UserStoreOrderDao $dao;
/**
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/18
* @param $uid
* @param string $orderBy
* @param string $keyword
* @param array $time
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getUserSpreadCountList($uid, $orderBy = '', $keyword = '', $time = [])
{
if ($orderBy === '') {
$orderBy = 'u.add_time desc';
}
$where = [];
$where[] = ['u.uid', 'IN', $uid];
if (strlen(trim($keyword))) {
$where[] = ['u.nickname|u.phone', 'LIKE', "%$keyword%"];
}
if ($time[0] || $time[1]) {
$where[] = ['spread_time', 'between', $time];
}
[$page, $limit] = $this->getPageValue();
$field = "u.uid,u.nickname,u.avatar,from_unixtime(u.add_time,'%Y/%m/%d') as time,u.spread_time,u.spread_count as childCount,p.orderCount,p.numberCount";
$list = $this->dao->getUserSpreadCountList($where, $field, $orderBy, $page, $limit);
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
foreach ($list as &$item) {
$item['childCount'] = count($userServices->getUserSpredadUids($item['uid'], 1)) ?? 0;
}
return $list;
}
}