| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?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\ConfigService;
- use App\Services\RedisService;
- /**
- * 首页
- * @package App\Http\Controllers\Api
- */
- class IndexController extends webApp
- {
- /**
- * 视频推荐列表
- * @return array
- */
- public function videoList()
- {
- return showJson(1010, true, []);
- }
- /**
- * 配置信息
- * @return array
- */
- public function config()
- {
- try {
- $params = request()->all();
- $system = isset($params['system'])? $params['system'] : [];
- $appSources = isset($system['app_sources']) && $system['app_sources']? $system['app_sources'] : 'ios';
- $cacheKey = "caches:config:app_{$appSources}";
- $config = RedisService::get($cacheKey);
- if (empty($config)) {
- $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"),
- 'custom_phone' => ConfigService::make()->getConfigByCode('custom_phone'),
- 'custom_telegram' => ConfigService::make()->getConfigByCode('custom_telegram'),
- 'custom_email' => ConfigService::make()->getConfigByCode('custom_email'),
- 'open_h5' => ConfigService::make()->getConfigByCode('open_h5',0),
- ];
- 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() : '']);
- }
- }
- /**
- * 物流公司
- * @return array
- */
- public function express()
- {
- return showJson(1010, true, config('express'));
- }
- /**
- * 验证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 liveConfig()
- {
- $userId = request()->post('user_id', 0);
- $roomId = request()->post('room_id', 0);
- $refresh = request()->post('refresh', 0);
- return showJson(1010, true);
- }
- public function noticeCount()
- {
- $noticeUid = request()->post('id',0);
- $userId = request()->post('uid',0);
- $userType = request()->post('type',0);
- return message(1010, true, []);
- }
- /**
- * 验证视频通话剩余时长
- * @return array
- */
- public function checkChat()
- {
- $toUserId = request()->post('to_user_id', 0);
- $fromUserId = request()->post('from_user_id', 0);
- $type = request()->post('type', 2);
- $data = ImChatService::make()->checkChat($fromUserId, $toUserId, $type);
- $config = ConfigService::make()->getConfigByCode('chat_buy_time_money');
- $config = $config ? explode('/', $config) : [];
- $money = isset($config[0]) && $config[0] > 0 ? $config[0] : 10;
- $num = isset($config[1]) && $config[1] > 0 ? $config[1] : 5;
- $tips = "抱歉您的免费时长已经用完,请先余额支付【{$money}元】购买【{$num}分钟】聊天时长再使用视频聊天服务。";
- return message(1010, true, ['time' => $data, 'tips' => $tips]);
- }
- }
|