| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.encrypt.DESUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dto.taobao.api.TaoKeOfficialActivityConvertResultDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.elme.ElemeConvertInfoResultVO;
|
| | | import com.yeshi.fanli.vo.homemodule.FloatImgDetailVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | } else {// 老人
|
| | | data.put("userTimeType", 1);
|
| | | }
|
| | | data.put("hotFuctionLink",
|
| | | configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform, Integer.parseInt(acceptData.getVersion())));
|
| | | data.put("hotFuctionLink", configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform,
|
| | | Integer.parseInt(acceptData.getVersion())));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
| | | if (uid != null && uid == 0L)
|
| | | uid = null;
|
| | |
|
| | | String platform = acceptData.getPlatform();
|
| | | String version = acceptData.getVersion();
|
| | |
|
| | | // 活动弹框
|
| | | List<FloatAD> listAD = new ArrayList<FloatAD>();
|
| | | List<FloatImgDetailVO> listVO = new ArrayList<FloatImgDetailVO>();
|
| | |
|
| | | List<FloatAD> list = floatADService.getValidByPosition(FloatAD.POSITION_INDEX);
|
| | | List<FloatAD> list = floatADService.getValidFloatADCache(FloatAD.POSITION_INDEX, null, platform,
|
| | | Integer.parseInt(version));
|
| | | if (list != null && !list.isEmpty())
|
| | | listAD.addAll(list);
|
| | |
|
| | | for (int i = 0; i < listAD.size(); i++) {
|
| | | FloatAD floatAD = listAD.get(i);
|
| | | FloatADTypeEnum typeEnum = floatAD.getTypeEnum();
|
| | | if (typeEnum == FloatADTypeEnum.newUserRedPack
|
| | | && (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())
|
| | | || !userTaoLiJinNewbiesService.verifyHasReward(uid, acceptData.getDevice()))) {
|
| | | if (typeEnum == FloatADTypeEnum.newUserRedPack && (!VersionUtil.greaterThan_2_0_5(platform, version)
|
| | | || !userTaoLiJinNewbiesService.verifyHasReward(uid, acceptData.getDevice()))) {
|
| | |
|
| | | listAD.remove(i);
|
| | | i--;
|
| | |
| | | }
|
| | |
|
| | | // 是否显示热门功能按钮
|
| | | String platform = acceptData.getPlatform();
|
| | | data.put("hotFuctionLink",
|
| | | configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform, Integer.parseInt(acceptData.getVersion())));
|
| | | configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform, Integer.parseInt(version)));
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | else
|
| | |
| | | }
|
| | |
|
| | | // 是否需要购物城转链
|
| | | boolean convert = "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoCartConvert.getKey())) ? false : true;
|
| | | boolean convert = "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoCartConvert.getKey())) ? false
|
| | | : true;
|
| | |
|
| | | if (!"cart".equalsIgnoreCase(position) && !convert) {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getUserConfig", method = RequestMethod.POST)
|
| | | public void getUserConfig(AcceptData acceptData, PrintWriter out) {
|
| | | try {
|
| | | // 用户协议链接
|
| | | String serviceProtocol = configService.get(ConfigKeyEnum.serviceProtocolLink.getKey());
|
| | | // 隐私条款链接
|
| | | String privacyProtocol = configService.get(ConfigKeyEnum.privacyProtocolLink.getKey());
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("serviceProtocolLink", serviceProtocol);
|
| | | data.put("privacyProtocolLink", privacyProtocol);
|
| | | // 购物车跳转方式(包含jumpDetail与params)
|
| | | JSONObject source = JSONObject.fromObject(configService.get(ConfigKeyEnum.taobaoCartJumpDetail.getKey()));
|
| | | data.put("taoBaoCart", source);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单解析配置
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderParseConfig", method = RequestMethod.POST)
|
| | | public void getOrderParseConfig(AcceptData acceptData, int type, PrintWriter out) {
|
| | |
|
| | | switch (type) {
|
| | | case Constant.SOURCE_TYPE_TAOBAO:
|
| | | if ("0".equalsIgnoreCase(configService.get(ConfigKeyEnum.autoFindTaobaoOrder.getKey())))
|
| | | out.print(JsonUtil.loadFalseResult(1, "暂不支持"));
|
| | | else {
|
| | | String orderJS = configService.get(ConfigKeyEnum.taobaoOrderParseJS.getKey());
|
| | | JSONObject data = new JSONObject();
|
| | | try {
|
| | | data.put("orderJS", DESUtil.encode(orderJS, StringUtil.getBase64String("YeShiFANLI889*+"),
|
| | | StringUtil.getBase64String("*M#34f?,")));
|
| | | data.put("orderUrl",
|
| | | DESUtil.encode("https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm",
|
| | | StringUtil.getBase64String("YeShiFANLI889*+"),
|
| | | StringUtil.getBase64String("*M#34f?,")));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | break;
|
| | |
|
| | | case Constant.SOURCE_TYPE_JD: {
|
| | |
|
| | | }
|
| | | break;
|
| | |
|
| | | case Constant.SOURCE_TYPE_PDD: {
|
| | |
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取订单配置
|
| | | *
|
| | |
| | | public void getOrderConfig(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | // 测试
|
| | | data.put("showTaoBaoOrder", "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoOrder.getKey()).trim()) ? false : true);
|
| | | data.put("showTaoBaoOrder",
|
| | | "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoOrder.getKey()).trim()) ? false : true);
|
| | | data.put("taoBaoOrderUrl", "https://main.m.taobao.com/olist/index.html");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.elmeLink, uid + "");
|
| | | String elmeLink = redisManager.getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(elmeLink)) {
|
| | | elmeLink = TaoKeApiUtil.officialActivityConvert(TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3],
|
| | | "1571715733668", userInfoExtra.getRelationId());
|
| | | TaoKeOfficialActivityConvertResultDTO dto = TaoKeApiUtil.officialActivityConvert(
|
| | | TaoBaoConstant.TAOBAO_ELEME_PID.split("_")[3], "1571715733668", userInfoExtra.getRelationId());
|
| | | if (dto != null)
|
| | | elmeLink = dto.getShort_click_url();
|
| | | if (!StringUtil.isNullOrEmpty(elmeLink)) {
|
| | | redisManager.cacheCommonString(key, elmeLink, 60 * 60);// 缓存1个小时
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: getElemeLinkNew
|
| | | * @Description: |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param activityId 活动ID
|
| | | * @param share -是否为分享
|
| | | * @param callback |
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "getElemeLinkNew")
|
| | | public void getElemeLinkNew(AcceptData acceptData, Long uid, String activityId, boolean share, boolean shareImg,
|
| | | 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 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());
|
| | | }
|
| | |
|
| | | if (dto != null) {
|
| | | if (share) {// 生成口令
|
| | | String token = TaoKeApiUtil.getTKToken("http://", "饿了么", dto.getShort_click_url());
|
| | | dto.setToken(TaoBaoUtil.filterTaoToken(token));
|
| | | }
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(dto), 60 * 60);// 缓存1个小时
|
| | | }
|
| | | } else {
|
| | | dto = JsonUtil.getSimpleGson().fromJson(elmeResult, TaoKeOfficialActivityConvertResultDTO.class);
|
| | |
|
| | | if (share && StringUtil.isNullOrEmpty(dto.getToken())) {
|
| | | // 保存口令
|
| | | String token = TaoKeApiUtil.getTKToken("http://", "饿了么", dto.getShort_click_url());
|
| | | dto.setToken(TaoBaoUtil.filterTaoToken(token));
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(dto), 60 * 60);// 缓存1个小时
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | ElemeConvertInfoResultVO info = new ElemeConvertInfoResultVO(null, dto.getToken(), dto.getShort_click_url());
|
| | | if (share && shareImg) {
|
| | | InputStream elmeShareImg = ImageUtil.drawSimpleImage(
|
| | | this.getClass().getClassLoader().getResourceAsStream("image/elme_bg.png"), 1080, 1646,
|
| | | HttpUtil.getAsInputStream(dto.getWx_qrcode_url()), 500, 500, 295, 908);
|
| | |
|
| | | if (elmeShareImg != null) {
|
| | | String filePath = FilePathEnum.elmeShare.getPath() + "-" + uid + "-"
|
| | | + UUID.randomUUID().toString().replace("-", "") + ".png";
|
| | | FileUploadResult uploadResult = COSManager.getInstance().uploadFile(elmeShareImg, filePath);
|
| | | if (uploadResult != null)
|
| | | info.setQrCodeImg(uploadResult.getUrl());
|
| | | }
|
| | |
|
| | | if (info.getQrCodeImg() == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("分享图生成失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | 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]);
|
| | | clientTBPid1.setAdZoneId(clientTBPid1.getPid().split("_")[3]);
|
| | | data.put("taoKeParams", clientTBPid1);
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | | |
| | | |
| | | @RequestMapping(value = "getKouBeiLink")
|
| | | public void getKouBeiLink(AcceptData acceptData, Long uid, String activityId, boolean share, boolean shareImg,
|
| | | 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 key = RedisKeyEnum.getRedisKey(RedisKeyEnum.kouBeiLink, 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_KOUBEI_PID.split("_")[3], activityId,
|
| | | userInfoExtra.getRelationId());
|
| | | }
|
| | |
|
| | | if (dto != null) {
|
| | | if (share) {// 生成口令
|
| | | String token = TaoKeApiUtil.getTKToken("http://", "口碑",dto.getClick_url() );
|
| | | dto.setToken(TaoBaoUtil.filterTaoToken(token));
|
| | | }
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(dto), 60 * 60);// 缓存1个小时
|
| | | }
|
| | | } else {
|
| | | dto = JsonUtil.getSimpleGson().fromJson(elmeResult, TaoKeOfficialActivityConvertResultDTO.class);
|
| | |
|
| | | if (share && StringUtil.isNullOrEmpty(dto.getToken())) {
|
| | | // 保存口令
|
| | | String token = TaoKeApiUtil.getTKToken("http://", "口碑", dto.getClick_url());
|
| | | dto.setToken(TaoBaoUtil.filterTaoToken(token));
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(dto), 60 * 60);// 缓存1个小时
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | ElemeConvertInfoResultVO info = new ElemeConvertInfoResultVO(null, dto.getToken(), dto.getClick_url());
|
| | | if (share && shareImg) {
|
| | | InputStream elmeShareImg = ImageUtil.drawSimpleImage(
|
| | | this.getClass().getClassLoader().getResourceAsStream("image/elme_bg.png"), 1080, 1646,
|
| | | HttpUtil.getAsInputStream(dto.getWx_qrcode_url()), 500, 500, 295, 908);
|
| | |
|
| | | if (elmeShareImg != null) {
|
| | | String filePath = FilePathEnum.elmeShare.getPath() + "-" + uid + "-"
|
| | | + UUID.randomUUID().toString().replace("-", "") + ".png";
|
| | | FileUploadResult uploadResult = COSManager.getInstance().uploadFile(elmeShareImg, filePath);
|
| | | if (uploadResult != null)
|
| | | info.setQrCodeImg(uploadResult.getUrl());
|
| | | }
|
| | |
|
| | | if (info.getQrCodeImg() == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("分享图生成失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | data.put("info", info);
|
| | |
|
| | | ClientTBPid clientTBPid1 = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | share ? TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT : TaoBaoConstant.TAOBAO_KOUBEI_PID, null,
|
| | | TaoBaoConstant.TAOBAO_KOUBEI_PID.split("_")[3]);
|
| | | clientTBPid1.setAdZoneId(clientTBPid1.getPid().split("_")[3]);
|
| | | data.put("taoKeParams", clientTBPid1);
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取饿了么的推广链接
|
| | | *
|
| | | * @param acceptData
|
| | |
| | | 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(""));
|
| | | |
| | | |
| | |
|
| | | }
|
| | |
|
| | | }
|