post('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' => get_image_url(ConfigService::make()->getConfigByCode('app_logo')), 'app_version' => ConfigService::make()->getConfigByCode('app_version'), 'withdraw_1_desc' => format_content(ConfigService::make()->getConfigByCode('withdraw_1_desc', '')), 'withdraw_2_desc' => format_content(ConfigService::make()->getConfigByCode('withdraw_2_desc', '')), 'transfer_desc' => format_content(ConfigService::make()->getConfigByCode('transfer_desc', '')), 'goods_disclaimer' => format_content(ConfigService::make()->getConfigByCode('goods_disclaimer', '')), 'wxpay_open' => ConfigService::make()->getConfigByCode('wxpay_open', 0), 'show_bd_score' => ConfigService::make()->getConfigByCode('show_bd_score', 0), 'withdraw_1_open' => ConfigService::make()->getConfigByCode('withdraw_1_open', 0), 'withdraw_1_min' => ConfigService::make()->getConfigByCode('withdraw_1_min', 0), 'withdraw_1_fee' => ConfigService::make()->getConfigByCode('withdraw_1_fee', 0), 'withdraw_2_open' => ConfigService::make()->getConfigByCode('withdraw_2_open', 0), 'withdraw_2_fee' => ConfigService::make()->getConfigByCode('withdraw_2_fee', 0), 'withdraw_2_rate' => ConfigService::make()->getConfigByCode('withdraw_2_rate', 0), 'transfer_3_open' => ConfigService::make()->getConfigByCode('transfer_3_open', 0), 'notices' => NoticeService::make()->getRecommandList(), ]; RedisService::set($cacheKey, $config, 3600); } return showJson(1010, true, $config); } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 首页数据 * @return array */ public function data() { $areaId = $this->areaId; $buyType = $this->buyType; if($areaId<=0){ $cacheInfo = RedisService::get("caches:index:area_".get_client_ip()); $areaId = isset($cacheInfo['area_id'])?$cacheInfo['area_id'] : 1; $buyType = isset($cacheInfo['buy_type'])?$cacheInfo['buy_type'] : 1; } try { $data = [ // 轮播 'banners' => AdService::make()->getListByPosition(1), 'goods' => $this->userId?GoodsService::make()->getListByType(2, $buyType, $this->userId):[], 'areaId'=> $areaId, 'buyType'=> $buyType, ]; return showJson(1010, true, $data); } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 验证更新 * @return array */ public function versionCheck() { $version = request()->post('version', ''); $appSources = request()->post('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'), 'app_url' => ConfigService::make()->getConfigByCode("app_{$appSources}_url"), 'is_force' => ConfigService::make()->getConfigByCode("app_force_update"), 'auto_update' => false, // 是否APP内自动更新 ]; return showJson(1010, true, $data); } else { return showJson(1010, false, ['has_update' => false, 'version' => $version]); } } }