shareholderRepository = $shareholderRepository; $this->shareholderLevelRepository = $shareholderLevelRepository; $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : NULL; } /** * Common: 获取商户基本信息 * Author: wu-hui * Time: 2024/06/13 15:12 * @param $merId * @return mixed */ public function merInfo($merId){ // 商户信息 $info = app()->make(MerchantRepository::class) ->getSearch(['mer_id'=>$merId]) ->field('mer_id,mer_name,mer_avatar,merchant_type') ->findOrEmpty() ->toArray(); // 总共创股东 $info['total_shareholder'] = $this->shareholderRepository->getSearchModel([ 'mer_id' => $info['mer_id'] ])->count(); return app('json')->success($info); } /** * Common: 获取等级列表(全部) * Author: wu-hui * Time: 2024/06/13 13:47 * @return mixed */ public function levelList(){ // 参数获取 $merId = (int)$this->request->param('mer_id', 0); $merchantType = $this->request->param('merchant_type'); // 等级列表 $list = $this->shareholderLevelRepository->getSearchModel([ 'merchant_type' => $merchantType ])->append(['coupon_list'])->select()->toArray(); // 循环处理 if($merId > 0){ foreach($list as &$item){ // 获取本商户已邀请名额 $item['quota_used'] = $this->shareholderRepository->getSearchModel(['mer_id'=>$merId,'level_id'=>$item['id']])->count(); // 获取本商户剩余可用名额 $item['quota_surplus'] = (int)sprintf("%.2f",$item['mer_quota'] - $item['quota_used']); } } return app('json')->success($list); } /** * Common: 获取等级信息 * Author: wu-hui * Time: 2024/06/14 11:11 * @param $id * @return mixed */ public function levelInfo($id){ // 等级信息获取 $info = $this->shareholderLevelRepository->getSearchModel([ 'id' => $id ]) ->append(['coupon_list']) ->findOrEmpty() ->toArray(); return app('json')->success($info); } /** * Common: 申请加入成为共创股东 * Author: wu-hui * Time: 2024/06/14 15:22 * @return mixed */ public function applyJoin(){ // 参数获取 $params = $this->request->params([ ['mer_id', 0], ['level_id', 0], // 支付相关 'pay_type', 'return_url' ]); $params['uid'] = $this->request->uid(); $params['user_info'] = $this->request->userInfo(); $params['is_app'] = $this->request->isApp(); $res = $this->shareholderRepository->handleJoinInfo($params); if($res) return $res; else return app('json')->success("操作成功"); } /** * Common: 获取加入信息 * Author: wu-hui * Time: 2024/06/14 15:27 * @return mixed */ public function applyJoinInfo(){ // 参数获取 $uid = $this->request->uid(); $merId = $this->request->param('mer_id',0); $levelId = $this->request->param('level_id',0); $info = $this->shareholderRepository->getSearchModel([ 'mer_id' => $merId, 'uid' => $uid, ])->findOrEmpty()->toArray(); return app('json')->success($info); } /** * Common: 获取股东列表 * Author: wu-hui * Time: 2024/06/14 16:00 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getList(){ // 参数处理 [$page, $limit] = $this->getPage(); $params = $this->request->params(['level_id','mer_id','uid','search_text']); // 信息列表获取 $data = $this->shareholderRepository->getList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); } /** * Common: 用户餐费积分记录获取 * Author: wu-hui * Time: 2024/06/20 16:45 * @return mixed */ public function integralRecord(){ // 参数获取 [$page, $limit] = $this->getPage(); $params = $this->request->params([ ['mer_id',0] ]); $params['uid'] = $this->request->uid(); // 列表获取 $data = app()->make(MerchantShareholderIntegralRepository::class)->getList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); } /** * Common: 用户餐费积分统计信息 * Author: wu-hui * Time: 2024/06/20 16:51 * @return mixed */ public function integralStatistic(){ // 参数获取 $params = $this->request->params([ ['mer_id', ''] ]); $params['uid'] = $this->request->uid(); // 列表获取 $statistics = app()->make(MerchantShareholderIntegralRepository::class)->getStatistics((array)$params); return app('json')->success($statistics); } /** * Common: 获取当前共创股东绑定的商户列表 * Author: wu-hui * Time: 2024/06/21 10:22 * @return mixed */ public function merList(){ // 参数获取 $params['uid'] = $this->request->uid(); [$page, $limit] = $this->getPage(); // 列表获取 $data = app()->make(MerchantShareholderIntegralRepository::class)->getMerList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); } }