| | |
| | | |
| | | 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; |
| | |
| | | @RequestMapping("api/v2/s11") |
| | | public class S11Controller { |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @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; |
| | | } |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | 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; |
| | | } |
| | | /** |
| | | * 获取超级红包分享口令 |
| | | * |
| | | * @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; |
| | | } |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11SuperHongBao, info.getRelationId() + ""); |
| | | String token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = TaoKeApiUtil.officialActivityConvert("19507100253", |
| | | "1574926757600", info.getRelationId()); |
| | | 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); |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"))); |
| | | else |
| | | out.print(JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试")); |
| | | 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 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; |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | } |