'成功', 'data'=>$data]); } /** * 获取app配置 * @param Request $request * @return \think\Response */ public function appConfig(Request $request){ $cacheKey = "caches:config:app"; $data = RedisCache::get($cacheKey); if($data){ return api_succ_return(['msg'=>'成功', 'data'=>$data]); } $time = time(); $webUrl = getWebUrl(); $data = [ // 地址 'privateInfo'=> $webUrl.'/api/privateInfo', 'userAgreementInfo'=> $webUrl.'/api/userAgreementInfo', 'helpCenter'=> $webUrl.'/api/helpCenter', 'aboutUs'=> $webUrl.'/api/aboutUs', 'chat_url'=> env('APP.CHAT_URL_CONFIG'), 'about_us'=> env('APP.ABOUT_US'), //福袋参数 'newhand_url'=> $webUrl.'/api/newhandurl', 'newguide_url'=> $webUrl.'/api/newguideurl', 'aboutbox_url'=> $webUrl.'/api/aboutboxurl', 'one_box_price'=> env('boxsetting.ONE_BOX_PRICE'), 'box_musicurl'=> $webUrl.'/static/resources/'.'box_open.mp3', 'box_desc' => [ ['title'=>'普通','pic'=>$webUrl.'/'.'static/img/box/box_pic10.png', 's_pic'=>$webUrl.'/'.'static/img/box/box_pic10_small.png', 'prob'=>'3.8%', 'box_type'=>10], ['title'=>'稀有','pic'=>$webUrl.'/'.'static/img/box/box_pic20.png', 's_pic'=>$webUrl.'/'.'static/img/box/box_pic20_small.png','prob'=>'30%', 'box_type'=>20], ['title'=>'史诗','pic'=>$webUrl.'/'.'static/img/box/box_pic30.png', 's_pic'=>$webUrl.'/'.'static/img/box/box_pic30_small.png','prob'=>'0.15%', 'box_type'=>30], ['title'=>'传说','pic'=>$webUrl.'/'.'static/img/box/box_pic40.png', 's_pic'=>$webUrl.'/'.'static/img/box/box_pic40_small.png','prob'=>'0.05%', 'box_type'=>40], ], 'services_desc'=> [ '购买一次服务商有效期30天,到期后需再次手动续费。' ], 'bbox_desc'=> [ [ 'title'=>'一袋豪物', 'count'=>1 ], [ 'title'=>'幸运5连', 'count'=>5 ], [ 'title'=>'豪气10连', 'count'=>10 ], [ 'title'=>'超凡二十联', 'count'=>20 ] ], // 广告参数 'adsetting'=> [ 'android'=>[ 'appkey'=>env('LINGYE.ANDROID_APPKEY'), 'jiliid'=>env('LINGYE.ANDROID_JILIID'), 'kaipinid'=>env('LINGYE.ANDROID_KAIPINGID'), 'chapinid'=>env('LINGYE.ANDROID_CHAPINID'), ], 'ios'=>[ 'appkey'=>env('LINGYE.IOS_APPKEY'), 'jiliid'=>env('LINGYE.IOS_JILIID'), 'kaipinid'=>env('LINGYE.IOS_KAIPINGID'), 'chapinid'=>env('LINGYE.IOS_CHAPINID') ] ], // 其他配置参数 'widthdraw'=> [ 'scale'=>env('WITHDRAW.APP_WITHDRAW_SCALE'), 'begin'=>env('WITHDRAW.APP_WITHDRAW_BEGIN'), 'desc'=>[ '本次提现将收取通证'.env('WITHDRAW.APP_WITHDRAW_SCALE').'%+'.env('WITHDRAW.APP_WITHDRAW_BEGIN').'元手续费', '提现到账时间T+1', '提现申请金额必须是10的整数倍', '提现金额单笔不能超过30000,提现大于5千只能使用银行卡', '个人原因导致的提现失败不退还通证', ] ], 'jh_excharge'=> [ 'desc'=>[ '转赠不收取任何手续费', '请确定对方信息后在输入安全密码,由于用户自己原因导致错误转赠,平台概不负责' ] ], 'agent'=> [ 'privince_agent'=>[ 'http://downyjh.meikangjw.com/mlh/agent/p_agent1.png?time='.$time, 'http://downyjh.meikangjw.com/mlh/agent/p_agent2.png?time='.$time, 'http://downyjh.meikangjw.com/mlh/agent/p_agent3.png?time='.$time ], 'city_agent'=>[ 'http://downyjh.meikangjw.com/mlh/agent/c_agent1.png?time='.$time, 'http://downyjh.meikangjw.com/mlh/agent/c_agent2.png?time='.$time, 'http://downyjh.meikangjw.com/mlh/agent/c_agent3.png?time='.$time ], 'p_agent_price'=>'175000|25000', 'c_agent_price'=>'56000|8000', ], 'version'=> env('APP.VERSION') ]; RedisCache::set($cacheKey, $data, rand(5, 10)); return api_succ_return(['msg'=>'成功', 'data'=>$data]); } /** * 获取图形验证码 * @return \think\Response */ public function getVerifyCode() { $captch = new CaptchaBuilder(); $captch->initialize([ 'width' => 100, // 宽度 'height' => 40, // 高度 'line' => true, // 直线 'curve' => false, // 曲线 'fontSize'=>25, // 验证码字体 'noise' => 0, // 噪点背景 'fonts' => [] // 字体 ]); $captch->create(); $uuid = uniqid(); //生成并返回图片流base64编码 ob_start (); $captch->output(1); $captchaCode = $captch->getText(); $image_data = ob_get_contents (); ob_end_clean (); $captchaDataUrl = AESjiami(base64_encode ($image_data)); $array = ['captchaDataUrl' => $captchaDataUrl,'captcha_uuid' => $uuid]; CacheServices::set('catch'.$uuid, $captchaCode, 900); return api_succ_return(['msg'=>'成功', 'data'=>$array]); } /** * 发送短信验证码 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function sendSmsCode(Request $request) { $type = $request->param('type'); $mobile = $request->param('mobile'); $app_sources = $request->param('app_sources'); if (!is_numeric($mobile) || strlen($mobile)!=11){ return api_error_return('手机号码错误'); } if (!$type || !in_array($type, ['register', 'editpass', 'securitypass', 'loingcheck'])){ return api_error_return('类型错误'); } $send_user = UserModel::where(['mobile'=>$mobile])->find(); if (in_array($type, ['editpass', 'securitypass', 'loingcheck']) && !$send_user){ return api_error_return('该手机号码未注册'); } if ($type == 'register' && $send_user){ return api_error_return('该手机号码已注册,请直接登录'); } $m = new NumRecordModel(); if ($send_user){ $user_count = $m->whereDay('create_time', 'today')->where('uid', $send_user['id'])->count(); if ($user_count > 5){ return api_error_return('发送失败,超过单日用户单日最大发送短信'); } } Db::startTrans(); try { $code = rand(100000,999999); $ser_request = new RequestUtilService(); $result = $ser_request->reqeustSmsCode($mobile, $code); if ($result == 0){ $data = [ 'type'=>$type, 'content'=>$code, 'isfrom'=>$app_sources, 'phone'=>$mobile, 'uid'=>$send_user?$send_user['id']:0, 'create_time'=>sr_getcurtime(time()), 'ip'=> get_client_ip() ]; $m->insert($data); }else{ throw new Exception(''); } Db::commit(); return api_succ_return('发送成功'); }catch (\Exception $e){ Db::rollback(); return api_error_return('发送失败'.$e->getMessage()); } } /** * 获取轮播图广告 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getAppBanner(Request $request){ $post = $request->post(); if (!in_array($post['type'], [1,2,3,4,5,6])){ return api_succ_return('成功'); } $cacheKey = "caches:banners:app"; $data = RedisCache::get($cacheKey); if($data){ return api_succ_return(['msg'=>'缓存数据', 'data'=>$data]); } $modelbanner = new SystemBannerModel(); $list = $modelbanner->where('type', intval($post['type'])) ->where('id', 'not in', [55]) ->withAttr('img_pic', function ($val, $data){ return __HTTPIMG($val); })->select()->toArray(); if ($post['type'] == 4){ $list = [ ['id'=>1234,'create_time'=>sr_getcurtime(time()),'type'=>4, 'img_pic'=>getWebUrl().'/static/img/inviteuser/invite18.jpg'.'?time='.time(),'banner_desc'=>'', 'title'=>'邀请好友1','delete_time'=>''], ]; } RedisCache::set($cacheKey, $list, rand(5, 10)); return api_succ_return(['msg'=>'成功', 'data'=>$list]); } /** * 获取文章列表 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function articleList(Request $request){ $post = $request->post(); return api_succ_return(['msg'=>'成功', 'data'=> ArticleService::make()->getListByType(intval($post['type']))]); } /** * 上传文件 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function uploadImg(Request $request) { $file = request() -> file('file'); $type = $request->post('type'); if ($file == null) { return api_error_return('未上传图片'); } $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if(!in_array($extension, array("jpeg","jpg","png"))){ return api_error_return('图片格式错误'); } if (!in_array($type, ['avatar', 'message'])){ return api_error_return('参数错误'); } // 发布消息时 if ($type == 'message'){ $user_info = Db::name('user')->where('id', $request->uid)->find(); if ($user_info['user_type'] != 99){ return api_error_return('没有权限'); } } // 保存处理图片 $saveName = Filesystem::disk('avatar') -> putFile($type, $file, 'md5'); $baseUrl = str_replace('\\', '', 'uploadimg/' . $saveName); return api_succ_return(['msg'=>'成功', 'data'=>['url'=>__HTTPIMG($baseUrl),'base_url'=> $baseUrl]]); } /** * 版本更新 * @param Request $request * @return \think\Response */ public function appVersionCheck(Request $request) { $curandroid = env('app.CUR_ANDROID_VERSION', ''); $curios = env('app.CUR_IOS_VERSION', ''); $curAndroidVersion = str_replace('.', '', $curandroid); $curAndroidVersion = dispRepair($curAndroidVersion, 4, '0', '0'); $curIosVersion = str_replace('.', '', $curios); $curIosVersion = dispRepair($curIosVersion, 4, '0', '0'); $app_sources = $request->param('app_sources'); $app_version = $request->param('app_version'); $app_version = str_replace('.', '', $app_version); $app_version = dispRepair($app_version, 4, '0', '0'); $new_udpate = explode('|', env('app.CUR_ANDROID_VERSION_INFO')); $new_udpate_ios = explode('|', env('app.CUR_IOS_VERSION_INFO')); $androidupdateurl = env('app.API_WEB_URL').'/api/downapp'; $iosupdateurl = env('app.API_WEB_URL').'/api/downapp'; $isandroid_force = 1; $isios_force = 1; if ($app_sources == 'ios'){ if ($curIosVersion > $app_version){ return api_succ_return(['msg'=>'成功', 'data'=>['has_update'=>1, 'cur_version'=>$curios, 'update_msg'=>$new_udpate_ios, 'update_url'=>$iosupdateurl, 'is_force'=>$isios_force, 'type'=>env('APP.DOWN_ANDROID_TYPE')]]); }else{ return api_succ_return(['msg'=>'成功', 'data'=>['has_update'=>0, 'cur_version'=>$curios, 'update_msg'=>[], 'update_url'=>'', 'is_force'=>1, 'type'=>env('APP.DOWN_ANDROID_TYPE')]]); } } if ($app_sources == 'android'){ if ($curAndroidVersion > $app_version){ return api_succ_return(['msg'=>'成功', 'data'=>['has_update'=>1, 'cur_version'=>$curandroid, 'update_msg'=>$new_udpate, 'update_url'=>$androidupdateurl, 'is_force'=>$isandroid_force, 'type'=>env('APP.DOWN_ANDROID_TYPE')]]); }else{ return api_succ_return(['msg'=>'成功', 'data'=>['has_update'=>0, 'cur_version'=>$curandroid, 'update_msg'=>[], 'update_url'=>'', 'is_force'=>1, 'type'=>env('APP.DOWN_ANDROID_TYPE')]]); } } return api_error_return('错误'); } /** * 用户等级信息 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function userLevelDesc(Request $request){ return api_succ_return(['msg'=>"成功", 'data'=> LevelSettingService::make()->getListData()]); } }