| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <?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);
- $exchangePrice = (float)ConfigService::make()->getConfigByCode('score_exchange_xd_rate',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',0);
- $withdrawFee = (float)ConfigService::make()->getConfigByCode('withdraw_fee_rate',0);
- $exchangeFee = (float)ConfigService::make()->getConfigByCode('exchange_fee_rate',0);
- $accounts = [];
- $wxpayRealname = ConfigService::make()->getConfigByCode('recharge_wxpay_realname','');
- $wxpayQrcode = ConfigService::make()->getConfigByCode('recharge_wxpay_qrcode', '');
- if($wxpayRealname && $wxpayQrcode){
- $accounts['wxpay'] = [
- 'realname' => $wxpayRealname,
- 'qrcode'=> get_image_url($wxpayQrcode),
- ];
- }
- $alipayRealname = ConfigService::make()->getConfigByCode('recharge_alipay_realname','');
- $alipayQrcode = ConfigService::make()->getConfigByCode('recharge_alipay_qrcode', '');
- if($alipayRealname && $alipayQrcode){
- $accounts['alipay'] = [
- 'realname' => $alipayRealname,
- 'qrcode'=> get_image_url($alipayQrcode),
- ];
- }
- $bankRealname = ConfigService::make()->getConfigByCode('recharge_bank_realname','');
- $bankName = ConfigService::make()->getConfigByCode('recharge_bank_name','');
- $bankCard = ConfigService::make()->getConfigByCode('recharge_bank_card', '');
- $bankBranch = ConfigService::make()->getConfigByCode('recharge_bank_branch', '');
- if($bankRealname && $bankName && $bankCard){
- $accounts['bank_account'] = [
- 'realname' => $bankRealname,
- 'bank_name' => $bankName,
- 'bank_card' => $bankCard,
- 'bank_branch'=> $bankBranch,
- ];
- }
- $usdtPrice = RedisService::get("caches:wallets:usdt_rate");
- if ($usdtPrice <= 0) {
- $usdtCnyPrice = ConfigService::make()->getConfigByCode('usdt_cny_price', 7.2);
- $usdtPrice = $usdtCnyPrice > 0 && $usdtCnyPrice < 100 ? $usdtCnyPrice : 0;
- }
- $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"),
- 'chat_api_url' => ConfigService::make()->getConfigByCode("chat_api_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,
- 'exchange_fee' => $exchangeFee>0 && $exchangeFee<100? moneyFormat($exchangeFee,3) : 0,
- 'recharge_agree' => $rechargeAgree,
- 'withdraw_agree' => $withdrawAgree,
- 'xd_price' => $xdPrice,
- 'usdt_price' => $usdtPrice,
- 'exchange_price' => $exchangePrice,
- 'rechargeMeals'=> $meals,
- 'accounts'=> $accounts,
- 'payments' => [
- [
- 'icon' => get_image_url('/images/pay/icon_usdt.png'),
- 'name' => 'USDT',
- 'status' => ConfigService::make()->getConfigByCode('usdt_open',1),
- 'code' => 20,
- "color"=> '#14ECCC',
- ],
- [
- 'icon' => get_image_url('/images/pay/icon_wxpay.png'),
- 'name' => '微信',
- 'status' => ConfigService::make()->getConfigByCode('wechat_open',1),
- 'code' => 30,
- "color"=> '#666',
- ],
- [
- 'icon' => get_image_url('/images/pay/icon_alipay.png'),
- 'name' => '支付宝',
- 'status' => ConfigService::make()->getConfigByCode('alipay_open',1),
- 'code' => 40,
- "color"=> '#666',
- ],
- [
- 'icon' => get_image_url('/images/pay/icon_bank.png'),
- 'name' => '银行卡',
- 'status' => ConfigService::make()->getConfigByCode('bank_open',1),
- 'code' => 50,
- "color"=> '#666',
- ],
- ],
- 'lang'=> $locale,
- ];
- RedisService::set($cacheKey, $config, 7200);
- }
- $config['app_sources'] = $appSources;
- $config['ios_plist'] = get_image_url('/app/');
- $config['app_logo'] = get_image_url($config['app_logo']);
- $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 appData()
- {
- 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_data_{$appSources}";
- $config = RedisService::get($cacheKey);
- if (empty($config)) {
- $locale = RedisService::get("caches:locale:lang_{$this->userId}");
- $locale = $locale? $locale : session('locale_lang');
- $updateNotice = ConfigService::make()->getConfigByCode('app_update_notice');
- $updateNotice = $updateNotice? str_replace("\n","</br>", $updateNotice):'';
- $config = [
- 'app_name' => ConfigService::make()->getConfigByCode('app_name'),
- 'app_logo' => ConfigService::make()->getConfigByCode('app_logo'),
- 'app_version' => ConfigService::make()->getConfigByCode('app_version'),
- 'app_update_notice' => $updateNotice,
- 'h5_url' => ConfigService::make()->getConfigByCode("h5_url"),
- 'custom_phone' => ConfigService::make()->getConfigByCode('custom_phone'),
- 'custom_telegram' => ConfigService::make()->getConfigByCode('custom_telegram'),
- 'custom_email' => ConfigService::make()->getConfigByCode('custom_email'),
- 'lang'=> $locale,
- ];
- RedisService::set($cacheKey, $config, 7200);
- }
- $config['app_sources'] = $appSources;
- $config['app_logo'] = get_image_url($config['app_logo']);
- $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 = request()->post('version', '1.3.20');
- $appSources = isset($system['app_sources'])? $system['app_sources'] : 'ios';
- $currentVersion = ConfigService::make()->getConfigByCode('app_version');
- // var_dump(getVersion($version),getVersion($currentVersion));
- 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_url"),
- 'is_force' => ConfigService::make()->getConfigByCode("is_force",0),
- 'app_hot_wget_url' => ConfigService::make()->getConfigByCode("app_hot_wget_url"),
- 'app_download_url' => ConfigService::make()->getConfigByCode("app_{$appSources}_url"),
- ];
- return showJson(1010, true, $data);
- } else {
- $wgetUrl = ConfigService::make()->getConfigByCode("app_hot_wget_url");
- $appUrl = ConfigService::make()->getConfigByCode("app_url");
- $isForce = ConfigService::make()->getConfigByCode("is_force",0);
- $appDownloadUrl = ConfigService::make()->getConfigByCode("app_{$appSources}_url");
- return showJson(1010, false, ['has_update' => false,'is_force'=>$isForce,'app_url'=>$appUrl,'app_hot_wget_url'=>$wgetUrl,'app_download_url'=>$appDownloadUrl, '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);
- }
- }
|