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'), ]; RedisService::set($cacheKey, $config, 7200); } 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 data() { $historyGoods = OrderService::make()->getHistoryGoods($this->userId); $proGoodsList = GoodsService::make()->getDataList(['is_discount'=>1,'type'=>2]); $data = [ // 首页轮播 'banners'=> AdService::make()->getListByPosition(1), // 历史购买商品 'historyGoods'=> isset($historyGoods['list'])? $historyGoods['list'] : [], // 促销商品 'proGoodsList'=> isset($proGoodsList['list'])? $proGoodsList['list'] : [], 'userId'=> $this->userId ]; return showJson(1010, true, $data); } /** * 其他广告 * @return array */ public function banner() { $params = request()->all(); $position = isset($params['position'])? intval($params['position']) : 0; $num = isset($params['num']) && $params['num']? intval($params['num']) : 6; $data = AdService::make()->getListByPosition($position,$num); return showJson(1010, true, $data); } /** * 验证更新 * @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]); } } }