// +---------------------------------------------------------------------- declare(strict_types=1); namespace app\services\user; use app\services\BaseServices; use app\dao\user\UserWechatUserDao; use app\services\crud\SchoolGradeClassServices; //班级 use app\services\crud\SchoolServices; //班级 /** * * Class UserWechatuserServices * @package app\services\user */ class UserWechatuserServices extends BaseServices { /** * UserWechatuserServices constructor. * @param UserWechatUserDao $dao */ public function __construct(UserWechatUserDao $dao) { $this->dao = $dao; } /** * 自定义简单查询总数 * @param array $where * @return int */ public function getCount(array $where): int { return $this->dao->getCount($where); } /** * 复杂条件搜索列表 * @param array $where * @param string $field * @return array */ public function getWhereUserList(array $where, string $field): array { [$page, $limit] = $this->getPageValue(); $order_string = ''; $order_arr = ['asc', 'desc']; if (isset($where['now_money']) && in_array($where['now_money'], $order_arr)) { $order_string = 'now_money ' . $where['now_money']; } $data = $schoolData = []; if (isset($where['class_name']) && !empty($where['class_name'])) { $SchoolGradeClassServices = app()->make(SchoolGradeClassServices::class); $data = $SchoolGradeClassServices->getNameToData($where['class_name']); } if (isset($where['school_name']) && !empty($where['school_name'])) { $SchoolServices = app()->make(SchoolServices::class); $schoolData = $SchoolServices->getNameToData($where['school_name']); } $count = $this->dao->getCountByWhere($where, $data, $schoolData); $list = $this->dao->getListByModel($where, $field, $order_string, $page, $limit, $data, $schoolData); return [$list, $count]; } }