repository = $repository; } /** * @return mixed * @throws DbException * @throws DataNotFoundException * @throws ModelNotFoundException * @author xaboy * @day 2020-05-14 */ public function lst() { $where = $this->request->params(['is_full_give', 'status', 'is_give_subscribe', 'coupon_name', ['mer_id', null],'is_trader']); [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->getList($where['mer_id'], $where, $page, $limit)); } public function detail($id) { if (!$this->repository->exists($id)) return app('json')->fail('数据不存在'); $coupon = $this->repository->get($id)->append(['used_num', 'send_num']); return app('json')->success($coupon->toArray()); } public function product($id) { $merId = $this->request->merId(); if ($merId) { $exists = app()->make(StoreCouponRepository::class)->merExists($merId, $id); } else { $exists = app()->make(StoreCouponRepository::class)->exists($id); } if (!$exists) { return app('json')->fail('优惠券不存在'); } [$page, $limit] = $this->getPage(); return app('json')->success(app()->make(StoreCouponProductRepository::class)->productList((int)$id, $page, $limit)); } /** * @param StoreCouponUserRepository $repository * @author xaboy * @day 2020/6/2 */ public function issue(StoreCouponUserRepository $repository) { [$page, $limit] = $this->getPage(); $where = $this->request->params(['username', 'coupon_id', 'coupon', 'status', 'mer_id']); return app('json')->success($repository->getList($where, $page, $limit)); } }