model->alias("a")->field("id")->withJoin(["account" => ["avatar_url", "nick_name"], "business"]); $data = [ 'total' => 0, 'current' => $page, 'size' => $limit, 'list' => new Collection(), ]; if (count($where)) { $q = $q->where($where); } if (count($order)) { $q = $q->order($order); } $data['total'] = $q->count(); if ($data['total']) { if ($limit) { if ($page) { $q = $q->page($page); } $q = $q->limit($limit); } $data['list'] = $q->select(); } return $data; } /** * 优惠券列表 * * @param string $businessCode 商家code * @param int $page 默认第一页 0不限制 * @param int $limit 限制条数 0不限制 * @param array $order * @return array * @throws RepositoryException */ public function businessCouponList($where, int $page = 1, int $limit = 0, array $order = ["create_time" => "desc", "id" => "desc"]) { return CouponMain::findList($where, [], $page, $limit, null, $order); } /** * 扣费记录 * * @param string $businessCode 商家code * @param int $page 默认第一页 0不限制 * @param int $limit 限制条数 0不限制 * @param array $order * @return array * @throws RepositoryException */ public function businessDeductionList($where, int $page = 1, int $limit = 0, array $order = ["create_time" => "desc", "id" => "desc"]) { return Deduction::findList($where, [], $page, $limit, null, $order); } /** * 充值记录 * * @param string $businessCode 商家code * @param int $page 默认第一页 0不限制 * @param int $limit 限制条数 0不限制 * @param array $order * @return array * @throws RepositoryException */ public function businessRechargeList($where, int $page = 1, int $limit = 0, array $order = ["create_time" => "desc", "id" => "desc"]) { return Recharge::findList($where, [], $page, $limit, function ($q){ return $q->withJoin(["business"=>["business_name"]]); }, $order); } /* 获取所有不是代理商的商家*/ public function getBusinessAll(){ return Business:: where("state", Business::state_on)->select(); } }