| | |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.yeshi.buwan.domain.Config; |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.service.imp.ConfigService; |
| | | import com.yeshi.buwan.domain.system.DetailSystemConfig; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.service.imp.DetailSystemConfigService; |
| | | import com.yeshi.buwan.service.imp.SystemService; |
| | | import com.yeshi.buwan.util.EHCacheManager; |
| | | import net.sf.json.JSONObject; |
| | |
| | | @Component |
| | | public class AdJob { |
| | | @Resource |
| | | private ConfigService configService; |
| | | private DetailSystemConfigService configService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | //打开vivo应用市场广告 |
| | | |
| | | //打开华为应用市场的广告 |
| | | @XxlJob("ad-vivo-check") |
| | | public ReturnT<String> openVIVOAd(String params) throws Exception { |
| | | JSONObject paramsJson = JSONObject.fromObject(params); |
| | | String appId = paramsJson.optString("appId"); |
| | | String systemId = paramsJson.optString("detailSystemId"); |
| | | //应用市场的版本 |
| | | Integer onLineVersion = AppMarketUtil.getVIVOLatestVersionCode(appId); |
| | | if (onLineVersion == null) { |
| | | throw new Exception("应用市场版本获取失败:" + appId); |
| | | } |
| | | |
| | | //获取正在上线的版本 |
| | | DetailSystem detailSystem = systemService.getDetailSystemById(systemId); |
| | | Map<String, String> map = configService.getConfigAsMap(detailSystem, 1); |
| | | //正在上线的版本 |
| | | String onLiningVersionCode = map.get("ad_click_download_version"); |
| | | //是否已经上线完成 |
| | | if (onLineVersion >= Integer.parseInt(onLiningVersionCode)) { |
| | | //已经上线,设置 |
| | | showAd("vivo", detailSystem, onLineVersion + 1); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 打开广告 |
| | | * |
| | |
| | | * @param version |
| | | */ |
| | | public void showAd(String channel, DetailSystem detailSystem, int version) { |
| | | Config config = configService.getConfigByKey("video_detail_full_video_version_channel", detailSystem, version); |
| | | DetailSystemConfig config = configService.getConfigByKey("video_detail_full_video_version_channel", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | config = configService.getConfigByKey("ad_splash_config", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | |
| | | } |
| | | config = configService.getConfigByKey("ad_play_video_pre", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | config = configService.getConfigByKey("ad_exit_app", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | config = configService.getConfigByKey("ad_video_detail_full_video", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | config = configService.getConfigByKey("ad_video_search", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | //热启动开屏 |
| | | config = configService.getConfigByKey("ad_splash_hot_start", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | //PPTV视频免广告权益 |
| | | config = configService.getConfigByKey("pptv_no_ad_reward", detailSystem, version); |
| | | updateVersionConfig(channel, config, version); |
| | | |
| | | //删除缓存 |
| | |
| | | * @return |
| | | */ |
| | | public int getOnliningVersionCode(DetailSystem detailSystem) { |
| | | Config config = configService.getConfigByKey("ad_click_download_version", detailSystem, 1); |
| | | DetailSystemConfig config = configService.getConfigByKey("ad_click_download_version", detailSystem, 1); |
| | | return Integer.parseInt(config.getValue()); |
| | | } |
| | | |
| | | public void setOnliningVersionCode(int versionCode, DetailSystem detailSystem) { |
| | | Config config = configService.getConfigByKey("ad_click_download_version", detailSystem, 1); |
| | | DetailSystemConfig config = configService.getConfigByKey("ad_click_download_version", detailSystem, 1); |
| | | config.setValue(versionCode + ""); |
| | | configService.updateConfig(config); |
| | | } |
| | |
| | | * @param config |
| | | * @param version |
| | | */ |
| | | private void updateVersionConfig(String channel, Config config, int version) { |
| | | private void updateVersionConfig(String channel, DetailSystemConfig config, int version) { |
| | | channel = channel.toLowerCase(); |
| | | if (config == null) |
| | | return; |