$id], [], $page, $size, function ($q) use ($keyword) { if (!empty($keyword)) { return $q::hasWhere('account', function ($q) use ($keyword) { $q->where('nick_name', 'like', "%" . $keyword . "%")->field("nick_name,avatar_url"); }); } else { return $q->with(["account" => function ($query) { $query->field("nick_name,avatar_url"); }]); } }, ["id" => "desc"]); } /** * 优惠券持有信息列表 * * @param $id * @param $keyword * @param $page * @param $size * @return array * @throws \Exception */ public function getCouponTypeAll() { return CouponType::order(["id" => "desc"])->select(); } /** * 发布优惠券 扣除商家余额 * @param $data * @param $totalMoney */ public function releaseCouponMain($data, $totalMoney) { CouponMain::create($data); Business::where("code", $data["business_code"])->dec("balance", $totalMoney)->update(); } }