| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- use App\Services\Api\GoodsService;
- use App\Services\Api\ImChatService;
- use App\Services\Api\VideoCommentService;
- use App\Services\Api\VideoService;
- use App\Services\ConfigService;
- use App\Services\RedisService;
- /**
- * 首页
- * @package App\Http\Controllers\Api
- */
- class IndexController extends webApp
- {
- /**
- * 视频推荐列表
- * @return array
- */
- public function videos()
- {
- try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 0);
- $params['is_recommend'] = 1;
- $datas = VideoService::make()->getIndexList($params, $pageSize,'', $this->userId);
- return showJson(1010, true, $datas);
- } catch (\Exception $exception){
- RedisService::set("caches:request:error_video_index", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']);
- }
- }
- /**
- * 视频评论
- * @return array
- */
- public function videoComment()
- {
- try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 0);
- $datas = VideoCommentService::make()->getDataList($params, $pageSize,'', $this->userId);
- return showJson(1010, true, $datas);
- } catch (\Exception $exception){
- RedisService::set("caches:request:error_video_comment", ['error'=>$exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']);
- }
- }
- /**
- * 配置信息
- * @return array
- */
- public function config()
- {
- try {
- $params = request()->all();
- $system = isset($params['system'])? json_decode($params['system'], true) : [];
- $appSources = isset($system['app_sources']) && $system['app_sources']? $system['app_sources'] : 'android';
- $cacheKey = "caches:config:app_{$appSources}";
- $config = RedisService::get($cacheKey);
- if (empty($config)) {
- $mealList = ConfigService::make()->getConfigByCode('recharge_xd_meals','');
- $mealList = $mealList? explode('|', $mealList) : [];
- $mealList = $mealList? $mealList : [10,20,50,100,200,500,1000];
- $meals = [];
- $xdPrice = (float)ConfigService::make()->getConfigByCode('xd_price',100);
- foreach($mealList as $item){
- $meals[] = [
- 'money'=> $item,
- 'usdt'=> moneyFormat($item/$xdPrice,2),
- ];
- }
- # 用户充值协议
- $locale = RedisService::get("caches:locale:lang_{$this->userId}");
- $locale = $locale? $locale : session('locale_lang');
- $rechargeAgree = ArticleService::make()->getInfo(3, $this->userId, true);
- $rechargeAgree = isset($rechargeAgree['content'])? $rechargeAgree['content'] : '';
- $withdrawAgree = ArticleService::make()->getInfo(5, $this->userId, true);
- $withdrawAgree = isset($withdrawAgree['content'])? $withdrawAgree['content'] : '';
- $minTransfer = (float)ConfigService::make()->getConfigByCode('min_transfer',0.1);
- $maxTransfer = (float)ConfigService::make()->getConfigByCode('max_transfer',100000);
- $transferFee = (float)ConfigService::make()->getConfigByCode('transfer_fee_rate',5);
- $withdrawFee = (float)ConfigService::make()->getConfigByCode('withdraw_fee_rate',5);
- $config = [
- 'app_name' => ConfigService::make()->getConfigByCode('app_name'),
- 'app_logo' => ConfigService::make()->getConfigByCode('app_logo'),
- 'app_version' => ConfigService::make()->getConfigByCode('app_version'),
- 'h5_url' => ConfigService::make()->getConfigByCode("h5_url"),
- 'chat_url' => ConfigService::make()->getConfigByCode("chat_url"),
- 'custom_phone' => ConfigService::make()->getConfigByCode('custom_phone'),
- 'custom_telegram' => ConfigService::make()->getConfigByCode('custom_telegram'),
- 'custom_email' => ConfigService::make()->getConfigByCode('custom_email'),
- 'open_h5' => (int)ConfigService::make()->getConfigByCode('open_h5',0),
- 'min_recharge' => (float)ConfigService::make()->getConfigByCode('min_recharge',0.1),
- 'min_transfer' => $minTransfer>0.1? moneyFormat($minTransfer,2) : 0.1,
- 'max_transfer' => $maxTransfer>0 && $maxTransfer<=100000? moneyFormat($maxTransfer,2) : 100000,
- 'transfer_fee_rate' => $transferFee>0 && $transferFee<100? moneyFormat($transferFee/100,2) : 0,
- 'withdraw_fee_rate' => $withdrawFee>0 && $withdrawFee<100? moneyFormat($withdrawFee/100,2) : 0,
- 'recharge_agree' => $rechargeAgree,
- 'withdraw_agree' => $withdrawAgree,
- 'xd_price' => $xdPrice,
- 'rechargeMeals'=> $meals,
- 'lang'=> $locale,
- ];
- RedisService::set($cacheKey, $config, 7200);
- }
- $config['app_sources'] = $appSources;
- $config['app_url'] = ConfigService::make()->getConfigByCode("app_{$appSources}_url");
- return showJson(1010, true, $config);
- } catch (\Exception $exception) {
- RedisService::set("caches:request:error_config", ['trace' => $exception->getTrace()], 7200);
- return showJson(1018, false, ['error' => env('APP_DEBUG') ? $exception->getMessage() : '']);
- }
- }
- /**
- * 验证APP更新
- * @return array
- */
- public function versionCheck()
- {
- $system = request()->post('system',[]);
- $version = isset($system['version'])? $system['version'] : '1.3.20';
- $appSources = isset($system['app_sources'])? $system['app_sources'] : 'ios';
- $currentVersion = ConfigService::make()->getConfigByCode('app_version');
- if (getVersion($version) < getVersion($currentVersion)) {
- $data = [
- 'has_update' => true,
- 'app_version' => $currentVersion,
- 'app_name' => ConfigService::make()->getConfigByCode('app_name'),
- 'update_notice' => ConfigService::make()->getConfigByCode('app_update_notice'),
- 'app_url' => ConfigService::make()->getConfigByCode("app_{$appSources}_url"),
- ];
- return showJson(1010, true, $data);
- } else {
- $appUrl = ConfigService::make()->getConfigByCode("app_{$appSources}_url");
- return showJson(1010, false, ['has_update' => false,'app_url'=>$appUrl, 'version' => $version]);
- }
- }
- /**
- * 币种
- * @return array
- */
- public function country()
- {
- $data = [
- ['code'=>'CNY','name'=>'人民币','country'=>'中国','locale'=>'zh-cn','mark'=>'¥','status'=>1],
- ['code'=>'MYR','name'=>'林吉特','country'=>'马来西亚','locale'=>'mal','mark'=>'RM','status'=>1],
- ['code'=>'VND','name'=>'越南盾','country'=>'越南','locale'=>'vie','mark'=>'₫','status'=>1],
- ['code'=>'THB','name'=>'泰铢','country'=>'泰国','locale'=>'tha','mark'=>'฿','status'=>1],
- ['code'=>'IDR','name'=>'卢比','country'=>'印度尼西亚','locale'=>'ind','mark'=>'R','status'=>1],
- ['code'=>'JAY','name'=>'日元','country'=>'日本','locale'=>'jap','mark'=>'¥','status'=>1],
- ['code'=>'KRW','name'=>'韩元','country'=>'韩国','locale'=>'sk','mark'=>'₩','status'=>1],
- ['code'=>'EUR','name'=>'欧元','country'=>'法国','locale'=>'fr','mark'=>'€','status'=>1],
- ['code'=>'USD','name'=>'美元','country'=>'美国','locale'=>'en','mark'=>'$','status'=>1],
- ];
- return showJson(1010, true, $data);
- }
- }
|