where('token',$token) ->where('status',1) ->find(); if(empty($memData)){ return false; } $this->user = $memData->toArray(); return true; } /** * 获取支付类型数据 */ public function getPayTypeData(){ $data = [ ["code"=>"wxpay","title"=>"微信支付","img"=> env('appinfo.app_api_domain', '')."/resource/icon/"."wxicon.png"], ["code"=>"balance","title"=>"余额支付","img"=>env('appinfo.app_api_domain', '')."/resource/icon/"."balance.png"], ]; return app('json')->success($data); } /** * 获取分享信息 * @return type */ public function getShareInfo(){ $data = (new SysModel)->getDataInfo("share"); return app('json')->success($data); } /** * 获取模板详情 * @param Request $request * @return type */ public function getShowTemplateItem($id){ $data = (new ShowTemplate) ->field("id,title,price,old_price,status,imgs,is_hot,is_recommend,code,look_count,real_sales,unreal_sales") ->where("id",$id) ->find(); if(empty($data)){ return app('json')->fail("模板不存在"); } if($data["is_init"]==0 && $data["status"]!=1){ return app('json')->fail("模板已下架"); } $data = $data->toArray(); $data["is_use"] = 0; $data["imgs"] = getImageAr($data["imgs"]); $data["img"] = empty($data["imgs"]) ? "" : $data["imgs"][0]; $data["sales_count"] = $data["real_sales"] + $data["unreal_sales"]; unset($data["real_sales"]); unset($data["unreal_sales"]); //验证是否购买过并添加浏览记录 $this->checkUser(request()->header("token", "")); if(!empty($this->user)){ $data["is_use"]=(new UserShowTemplate)->where("uid",$this->user["uid"])->where("show_template_id",$data["id"])->count()>0?1:0; (new ShowTemplate)->where('id', $data["id"])->inc('look_count', 1)->update(); } return app('json')->success($data); } /** * 获取皮肤模板列表 * @param Request $request */ public function getShowTemplateList(Request $request){ $post = UtilService::getMore([ ['is_hot', '0'], ['is_recommend', '0'], ['page', 1], ['pageSize', 50], ], $request); $where["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $where["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $where["status"] = 1; if((int)$post["is_hot"]==1){ $where["is_hot"] = 1; } if((int)$post["is_recommend"]==1){ $where["is_recommend"] = 1; } $data = (new ShowTemplate)->getDataList($where, "id,title,price,old_price,status,imgs,is_hot,is_recommend,code,look_count,real_sales,unreal_sales"); return app('json')->success($data); } /** * 获取轮播图 * @param Request $request */ public function getBannerList(Request $request){ $post = UtilService::getMore([ ['type', ''], ['page', 1], ['pageSize', 50], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $where=[]; $where[]=["is_show","=",1]; $where[]=["page_id","=",70]; $totalCount = (new AdvertModel)->where($where)->count(); $data=null; if($totalCount>0){ $data = (new AdvertModel) ->field("id,img,title,url") ->where($where) ->order("sort","desc") ->page($post["page"], $post["pageSize"]) ->select(); } $data = empty($data)?[]:$data; return app('json')->success(["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount]); } /** * 获取服务类型列表 * @param Request $request * @return type */ public function getServiceTypeList(Request $request){ $post = UtilService::getMore([ ['page', 1], ['pageSize', 50], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $post["status"] = 1; $data = (new ServiceType)->getList($post,"id,title,content,img"); return app('json')->success($data); } /** * 获取标签列表 * @param Request $request * @return type */ public function getServiceLabelList(Request $request){ $post = UtilService::getMore([ ['page', 1], ['pageSize', 50], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $post["status"] = 1; $data = (new ServiceLabel)->getList($post,"id,title,type"); return app('json')->success($data); } /** * 获取用户工作服务类型 * @param Request $request */ public function getUserWorkTypeList(Request $request){ $post = UtilService::getMore([ ['page', 1], ['pageSize', 50], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $post["status"] = 1; $data = (new UserWorkType)->getList($post,"id,title,content,img"); return app('json')->success($data); } /** * 获取从业人员列表 * @param Request $request * @return type */ public function getWorkerList(Request $request){ $post = UtilService::getMore([ ['page', 1], ['pageSize', 50], ['work_type_id', ""], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $post["status"] = 1; $data = (new UserModel)->getApiWorkerList($post); foreach ($data['list'] as &$item) { $infoAuditDb = new InfoAudit(); $infoData = $infoAuditDb->getItem(["status"=>1,"uid"=>$item["uid"]]); $item['is_type_audit'] = $item['is_type_audit']==1?1:0; $item['ancestral_place'] = !empty($infoData['ancestral_place']) ? $infoData['ancestral_place'] : ''; } return app('json')->success($data); } /** * 获取服务时长类型 * @param Request $request * @return type */ public function getServiceTimeTypeList(Request $request){ $post = UtilService::getMore([ ['page', 1], ['pageSize', 50], ], $request); $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $post["status"] = 1; $data = (new ServiceTimeType)->getList($post,"title,code"); return app('json')->success($data); } /** * 获取系统信息 * @param Request $request */ public function getSysData(Request $request){ $data = (new Sys)->where("id",1)->find()->toArray(); $data=[]; return app("json")->success($data); } /** * 首页轮播 * @param Request $request */ public function getHomeBanner(Request $request){ $data = (new AdvertModel) ->field("id,img,title,url") ->where("page_id",70) ->where("is_show",1) ->order("sort","desc") ->select() ->toArray(); $data = empty($data)?[]:$data; return app("json")->success($data); } /** * 获取其他用户名片信息 * @param Request $request */ public function getCommonUserCardInfo(Request $request){ [$uid] = UtilService::getMore([ ['uid', '','empty',"用户信息为空"], ], $request,true); $userData = (new UserModel)->where("uid",$uid)->find(); if(empty($userData)){ return app('json')->fail("用户不存在"); } $userData->toArray(); $data = (new InfoAudit)->getItem(["uid"=>$uid,"status"=>1]); if(empty($data)){ return app('json')->fail("当前用户还未通过审核"); } $typeData = (new TypeAudit)->where("uid",$uid)->order("id","desc")->find(); $data["is_type_audit"] = (empty($typeData) || $typeData["status"]!=1)?0:1; //名片浏览次数 (new UserModel)->where('uid', $uid)->inc('card_look_count', 1)->update(); $accessiInfo = [ 'uid' => $uid, 'add_time' => time(), 'url_ip' => $request->ip(), ]; $res = AccessIp::create($accessiInfo); // $add_time = time();//访问时间 // $url_ip = $request->url();//访问IP $data["card_look_count"] = $userData["card_look_count"]+1; return app('json')->success($data); } /** * 名片浏览量排行榜 * @param Request $request */ public function getCardLookCountRank(Request $request) { $time = $request->param(); $users = AccessIp::where('add_time','>=',$time['time']) ->where('add_time','<=',$time['times']) ->field('uid, count(*) as ip_count') ->group('uid') ->order('ip_count', 'desc') ->select(); $rankList = []; foreach ($users as $key => $value) { $userInfo = (new UserModel)->where('uid', $value['uid'])->find(); $auth = (new InfoAudit)->where('uid',$value['uid'])->find(); $template = $this->getShowTemplateItem($value['uid']); $user_work_type_title = (new UserWorkType)->where('id',$auth['user_work_type_id'])->find(); $rankList[] = [ 'rank' => $key + 1, 'uid' => $value['uid'], 'name' => $userInfo['name'], 'avatar' => $userInfo['avatar'], 'card_look_count' => $value['ip_count'], 'template' => $template, 'is_type_audit' => $auth && $auth['status'] == 1 ? 1 : 0, 'ancestral_place' => $auth ? $auth['ancestral_place'] : '', 'auth_info' => $auth ? $auth->toArray() : [], 'user_work_type_id' => $user_work_type_title['title'], ]; } $rankList = array_values(array_filter($rankList, function($item){ return !empty($item['ancestral_place']); })); return app('json')->success($rankList); } //获取文章详情 public function getArtDetail(\think\Request $request) { $id = $request->param('id'); $article = ArticleModel::where('id', $id)->find(); if (!$article) { return app('json')->fail('文章不存在'); } return app('json')->success(['list' => [$article], 'count' => 1]); } /** * bug提交 * @param Request $request */ public function appBugSub(Request $request){ [$error] = UtilService::getMore([ ['error', '','empty',"错误信息为空"], ], $request,true); $deviceId = $request->header("deviceId", ""); $deviceType = $request->header("deviceType", ""); $fromPlat = $request->header("fromPlat", ""); $version = $request->header("version", ""); (new AppBug)->insert([ "device_id" => $deviceId, "device_type" => $deviceType, "from_plat" => $fromPlat, "version" => $version, "error" => $error, "time" => time() ]); return app("json")->success("提交成功"); } /** * 测试 */ public function appTest(Request $request){ $labelData = (new ServiceLabel)->where("status",1)->where("id","in",["",1,2,6,7,8,0])->column('id'); var_dump($labelData);exit; $money = $request->post("money",0); $money = bcadd("0", $money."",2); echo $money;exit; $xml = " 1 "; $wxpay = new wxpayApi(); // $r = $wxpay->notifyCheckSign($xml); $r = $wxpay->searchOrderQuery("A202304201681959554328879382"); var_dump($r); } }