| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Controller("s11Controller3")
|
| | | @RequestMapping("api/v2/s11")
|
| | | public class S11Controller {
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | /**
|
| | | * 获取超级红包分享口令
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getSuperHongBaoToken")
|
| | | public void getSuperHongBaoToken(AcceptData acceptData, Long uid, String callback, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录")));
|
| | | else
|
| | | out.print(JsonUtil.loadFalseResult(1, "请登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) {
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号")));
|
| | | else
|
| | | out.print(JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往\"我的->个人信息\"绑定淘宝账号"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String key = "s11-superhongbao-" + info.getRelationId();
|
| | | String token = redisManager.getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | try {
|
| | | String link = TaoKeApiUtil.officialActivityConvert("19507100253", "1539329391766",
|
| | | info.getRelationId());
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg", "【天猫双11】上亿红包等你来拆!---板栗快省", link);
|
| | | if (!StringUtil.isNullOrEmpty(token))
|
| | | redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试")));
|
| | | else
|
| | | out.print(JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String desc = configService.get("super-hongbao-share-desc");
|
| | | desc = desc.replace("[淘口令]", token);
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(desc)));
|
| | | else
|
| | | out.print(JsonUtil.loadTrueResult(desc));
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.yeshi.fanli.dto.taobao.api.TaoKeOfficialActivityConvertResultDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.RedisKeyEnum; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | |
| | | @Controller("s11Controller3") |
| | | @RequestMapping("api/v2/s11") |
| | | public class S11Controller { |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | /** |
| | | * 获取超级红包分享口令 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSuperHongBaoToken") |
| | | public void getSuperHongBaoToken(AcceptData acceptData, Long uid, String callback, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录"))); |
| | | else |
| | | out.print(JsonUtil.loadFalseResult(1, "请登录")); |
| | | return; |
| | | } |
| | | |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号"))); |
| | | else |
| | | out.print(JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往\"我的->个人信息\"绑定淘宝账号")); |
| | | return; |
| | | } |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11SuperHongBao, info.getRelationId() + ""); |
| | | String token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | try { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, "mm_124933865_56750082_19507100253", "1574926757600", info.getRelationId(), true); |
| | | } catch (ConvertLinkException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); |
| | | return; |
| | | } |
| | | |
| | | String link = dto.getShort_click_url(); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s12/banner.jpg", |
| | | "【天猫双12】上亿红包等你来拆!---板栗快省", link); |
| | | if (!StringUtil.isNullOrEmpty(token)) |
| | | redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天 |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"))); |
| | | else |
| | | out.print(JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试")); |
| | | return; |
| | | } |
| | | |
| | | String desc = configService.getValue(ConfigKeyEnum.superHongBaoShareDesc.getKey(), acceptData.getSystem()); |
| | | desc = desc.replace("[淘口令]", token); |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(desc))); |
| | | else |
| | | out.print(JsonUtil.loadTrueResult(desc)); |
| | | return; |
| | | } |
| | | |
| | | } |