repository = $repository; $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null; } /** * @Author:Qinii * @Date: 2020/5/27 * @return mixed */ public function lst() { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id','is_trader','merchant_type']); return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo)); } /** * @Author:Qinii * @Date: 2020/5/29 * @param $id * @return mixed */ public function detail($id) { if (!$this->repository->apiGetOne($id)) return app('json')->fail('店铺已打烊'); if ($this->request->isLogin()) { app()->make(UserMerchantRepository::class)->updateLastTime($this->request->uid(), intval($id)); } return app('json')->success($this->repository->detail($id, $this->userInfo)); } public function systemDetail() { $config = systemConfig(['site_logo', 'site_name','login_logo']); return app('json')->success([ 'mer_avatar' => $config['site_logo'], 'mer_name' => $config['site_name'], 'mer_id' => 0, 'postage_score' => '5.0', 'product_score' => '5.0', 'service_score' => '5.0', ]); } /** * @Author:Qinii * @Date: 2020/5/29 * @param $id * @return mixed */ public function productList($id) { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']); if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊'); return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo)); } /** * @Author:Qinii * @Date: 2020/5/29 * @param int $id * @return mixed */ public function categoryList($id) { if(!$this->repository->merExists((int)$id)) return app('json')->fail('店铺已打烊'); return app('json')->success($this->repository->categoryList($id)); } public function qrcode($id) { if(!$this->repository->merExists($id)) return app('json')->fail('店铺已打烊'); $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id)); return app('json')->success(compact('url')); } public function localLst() { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id']); $where['delivery_way'] = 1; return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo)); } /** * Common: 员工推广二维码 * Author: wu-hui * Time: 2024/01/23 11:54 * @return mixed */ public function promoteQrCode(){ // 参数获取 $merId = $this->request->param('mer_id'); if((int)$merId > 0){ // 判断:当前商户是否绑定酒道馆 $bindShopCount = (int)$this->repository->getSearch([]) ->where('shop_mer_id', $merId) ->where('is_del', 0) ->count(); if($bindShopCount <= 0) return app('json')->fail('未关联酒道馆!'); // 生成推广码 $qrcode = $this->repository->createQrCode(['mid'=>$merId,'suid'=>$this->request->uid()]); return app('json')->success(['qr_code' => $qrcode]); } return app('json')->fail('小程序码生成失败!'); } /** * Common: 员工买单二维码 * Author: wu-hui * Time: 2024/01/23 13:56 * @return mixed */ public function onlinePaymentQrCode(){ // 参数获取 $merId = $this->request->param('mer_id'); if((int)$merId > 0){ $qrcode = $this->repository->createQrCode(['mer_id'=>$merId],'online_payment'); return app('json')->success(['qr_code' => $qrcode]); } return app('json')->fail('小程序码生成失败!'); } /** * Common: 商户登录移动端 * Author: wu-hui * Time: 2024/02/28 17:30 * @return mixed */ public function storeLogin(){ // 参数获取 $params = $this->request->params(['account','password']); if(empty($params['account'])) throw new ValidateException('请输入账号'); if(empty($params['password'])) throw new ValidateException('请输入密码'); // 判断登录是否成功 $repository = app()->make(MerchantAdminRepository::class); $adminInfo = $repository->login($params['account'], $params['password']); $tokenInfo = $repository->createToken($adminInfo); $admin = $adminInfo->toArray(); // 判断:这里仅允许酒道馆和普通商户登录 if($admin['merchant_type'] == 2) throw new ValidateException('当前账号禁止登录!'); return app('json')->success([ 'token' => $tokenInfo['token'], 'exp' => $tokenInfo['exp'], 'mer_id' => $admin['mer_id'], 'merchant_type' => $admin['merchant_type'], 'mer_name' => $admin['mer_name'], 'mer_avatar' => $admin['mer_avatar'] ]); } }