| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | private TBPidService tbPidService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private FloatADService floatADService; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private MsgDeviceReadStateService msgDeviceReadStateService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinOriginService uerTaoLiJinOriginService; |
| | | |
| | | @Resource |
| | | private UserActiveLogService userActiveLogService; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | /** |
| | | * s 首页配置信息 |
| | |
| | | */ |
| | | @RequestMapping(value = "getElemeLink") |
| | | public void getElemeLink(AcceptData acceptData, Long uid, String callback, PrintWriter out) { |
| | | |
| | | UserExtraTaoBaoInfo userInfoExtra = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getRelationId())) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "请绑定淘宝"))); |
| | | return; |
| | | } |
| | | |
| | | String elmePid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_ELME, SystemPIDInfo.PidType.fanli); |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.elmeLink, uid + ""); |
| | | String elmeLink = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(elmeLink)) { |
| | | TaoKeOfficialActivityConvertResultDTO dto = TaoKeApiUtil.officialActivityConvert( |
| | | TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3], "1571715733668", userInfoExtra.getRelationId()); |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | try { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, elmePid, "1571715733668", userInfoExtra.getRelationId(), false); |
| | | } catch (ConvertLinkException e) { |
| | | e.printStackTrace(); |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadFalseResult(e.getMessage())); |
| | | else |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); |
| | | return; |
| | | } |
| | | if (dto != null) |
| | | elmeLink = dto.getShort_click_url(); |
| | | if (!StringUtil.isNullOrEmpty(elmeLink)) { |
| | |
| | | data.put("hongBao", elmeLink); |
| | | data.put("goods", elmeLink); |
| | | |
| | | ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_ELEME_PID, |
| | | null, TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3]); |
| | | ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, elmePid, |
| | | null, elmePid.split("_")[3]); |
| | | data.put("taoKeParams", clientTBPid1); |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "请绑定淘宝"))); |
| | | return; |
| | | } |
| | | |
| | | String elmePid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_ELME, SystemPIDInfo.PidType.fanli); |
| | | String relationPid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share); |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.elmeLink, uid + "-" + activityId + "-" + share); |
| | | String elmeResult = redisManager.getCommonString(key); |
| | | JSONObject data = new JSONObject(); |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | if (StringUtil.isNullOrEmpty(elmeResult)) { |
| | | if (share) { |
| | | dto = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3], |
| | | activityId, userInfoExtra.getRelationId()); |
| | | } else { |
| | | dto = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3], activityId, |
| | | userInfoExtra.getRelationId()); |
| | | try { |
| | | if (share) { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, relationPid, activityId, userInfoExtra.getRelationId(), true); |
| | | } else { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, elmePid, activityId, |
| | | userInfoExtra.getRelationId(), false); |
| | | } |
| | | } catch (ConvertLinkException e) { |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadFalseResult(e.getMessage())); |
| | | else |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); |
| | | return; |
| | | } |
| | | |
| | | if (dto != null) { |
| | |
| | | data.put("info", info); |
| | | |
| | | ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, |
| | | share ? TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT : TaoBaoConstant.TAOBAO_ELEME_PID, null, |
| | | TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3]); |
| | | share ? relationPid : elmePid, null, |
| | | elmePid.split("_")[3]); |
| | | clientTBPid1.setAdZoneId(clientTBPid1.getPid().split("_")[3]); |
| | | data.put("taoKeParams", clientTBPid1); |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | |
| | | public void getKouBeiLink(AcceptData acceptData, Long uid, String activityId, boolean share, boolean shareImg, |
| | | String callback, PrintWriter out) { |
| | | |
| | | String relationPid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share); |
| | | |
| | | UserExtraTaoBaoInfo userInfoExtra = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getRelationId())) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "请绑定淘宝"))); |
| | |
| | | JSONObject data = new JSONObject(); |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | if (StringUtil.isNullOrEmpty(elmeResult)) { |
| | | if (share) { |
| | | dto = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3], |
| | | activityId, userInfoExtra.getRelationId()); |
| | | } else { |
| | | dto = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_KOUBEI_PID.split("_")[3], activityId, |
| | | userInfoExtra.getRelationId()); |
| | | |
| | | try { |
| | | if (share) { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, relationPid, |
| | | activityId, userInfoExtra.getRelationId(), true); |
| | | } else { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, TaoBaoConstant.TAOBAO_KOUBEI_PID, |
| | | activityId, userInfoExtra.getRelationId(), false); |
| | | } |
| | | } catch (ConvertLinkException e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMessage()))); |
| | | return; |
| | | } |
| | | |
| | | if (dto != null) { |
| | |
| | | data.put("info", info); |
| | | |
| | | ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, |
| | | share ? TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT : TaoBaoConstant.TAOBAO_KOUBEI_PID, null, |
| | | share ? relationPid : TaoBaoConstant.TAOBAO_KOUBEI_PID, null, |
| | | TaoBaoConstant.TAOBAO_KOUBEI_PID.split("_")[3]); |
| | | clientTBPid1.setAdZoneId(clientTBPid1.getPid().split("_")[3]); |
| | | data.put("taoKeParams", clientTBPid1); |
| | |
| | | */ |
| | | @RequestMapping(value = "userProtocolListen") |
| | | public void userProtocolListen(AcceptData acceptData, Long uid, int type, PrintWriter out) { |
| | | LogHelper.userProtocolListen(String.format("%s#%s#%s", acceptData.getDevice(), uid, type)); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "getShowAd") |
| | | public void showAd(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | String value = configService.getValue(ConfigKeyEnum.showSplashAd.getKey(), acceptData.getSystem()); |
| | | boolean huaweiShowAd = true; |
| | | if ("huawei".equalsIgnoreCase(acceptData.getChannel())) { |
| | | String version = configService.getValue(ConfigKeyEnum.huaweiOnLineVersionCode.getKey(), acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(version)) { |
| | | if (Integer.parseInt(version) == Integer.parseInt(acceptData.getVersion())) { |
| | | huaweiShowAd = false; |
| | | } |
| | | } |
| | | JSONObject configData = JSONObject.fromObject(value); |
| | | String channel = acceptData.getChannel().toLowerCase(); |
| | | if (configData.optString(channel) == null) { |
| | | channel = "qq"; |
| | | } |
| | | int version = configData.optInt(channel); |
| | | JSONObject data = new JSONObject(); |
| | | boolean show; |
| | | if (Integer.parseInt(acceptData.getVersion()) >= version) { |
| | | show = false; |
| | | } else { |
| | | show = true; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | if ("0".equalsIgnoreCase(value.trim())) { |
| | | if (show) { |
| | | data.put("show", true); |
| | | //加载广告数据 |
| | | data.put("ad", configService.getValue(ConfigKeyEnum.gdtAdInfo, acceptData.getSystem())); |
| | | } else |
| | | data.put("show", false); |
| | | } else { |
| | | if (huaweiShowAd) { |
| | | data.put("show", true); |
| | | //加载广告数据 |
| | | data.put("ad", configService.getValue(ConfigKeyEnum.gdtAdInfo, acceptData.getSystem())); |
| | | } else |
| | | data.put("show", false); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |