| | |
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.entity.common.Config; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import com.yeshi.fanli.util.email.MailSenderUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import org.yeshi.utils.encrypt.DESUtil; |
| | | import org.yeshi.utils.entity.FileUploadResult; |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | |
| | | 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; |
| | | |
| | | boolean show = false; |
| | | try { |
| | | JSONObject configData = JSONObject.fromObject(value); |
| | | if (configData != null) { |
| | | String channel = acceptData.getChannel().toLowerCase(); |
| | | if (configData.optString(channel) == null) { |
| | | channel = "qq"; |
| | | } |
| | | int version = configData.optInt(channel); |
| | | |
| | | |
| | | if (Integer.parseInt(acceptData.getVersion()) >= version) { |
| | | show = false; |
| | | } else { |
| | | show = true; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | |
| | | 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)); |
| | | } |
| | | |
| | |
| | | data.put("link", configService.getValue(ConfigKeyEnum.accountLogoutProtocolLink.getKey(), acceptData.getSystem())); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 隐私投诉 |
| | | * @date 17:51 2021/10/18 |
| | | * @param: acceptData |
| | | * @param: content |
| | | * @param: images |
| | | * @param: out |
| | | **/ |
| | | @RequestMapping(value = "reportPrivacy") |
| | | public void reportPrivacy(AcceptData acceptData, String content, MultipartFile[] images, PrintWriter out) { |
| | | String urlList = ""; |
| | | if (images != null && images.length > 0) |
| | | for (MultipartFile f : images) { |
| | | try { |
| | | String name = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmssSSS") + "_" + ((int) (Math.random() * 100000)) + ".jpg"; |
| | | FileUploadResult result = COSManager.getInstance().uploadFile(f.getInputStream(), "privacy/report/" + name); |
| | | if (result != null) |
| | | urlList += result.getUrl() + " , "; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | String title = null; |
| | | try { |
| | | title = "隐私投诉:" + URLDecoder.decode(content, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | StringBuffer buffer = new StringBuffer(); |
| | | buffer.append("包名:" + acceptData.getPackages()); |
| | | buffer.append("\n\r"); |
| | | buffer.append("UTDID:" + acceptData.getUtdid()); |
| | | buffer.append("\n\r"); |
| | | buffer.append("DEVICE:" + acceptData.getDevice()); |
| | | buffer.append("\n\r"); |
| | | buffer.append("投诉内容:"); |
| | | buffer.append(content); |
| | | buffer.append("\n\r"); |
| | | buffer.append("提供的截图为:" + urlList); |
| | | |
| | | Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey(), acceptData.getSystem()); |
| | | String[] sts = config.getValue().split(","); |
| | | String account = sts[0]; |
| | | String pwd = sts[1]; |
| | | MailSenderUtil.sendEmail("help@banliapp.com", account, pwd, title, buffer.toString()); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | } |