| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | 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/apph5/v1/s11") |
| | | public class H5S11Controller { |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | /** |
| | | * 获取超级红包分享口令 |
| | | * @param sign |
| | | * @param uid |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSuperHongBaoToken") |
| | | public void getSuperHongBaoToken(String sign, Long uid, String callback, PrintWriter out) { |
| | | if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误"))); |
| | | return; |
| | | } |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录"))); |
| | | return; |
| | | } |
| | | /** |
| | | * 获取超级红包分享口令 |
| | | * |
| | | * @param sign |
| | | * @param uid |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSuperHongBaoToken") |
| | | public void getSuperHongBaoToken(String sign, Long uid, String callback, String sceneId, PrintWriter out) { |
| | | if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误"))); |
| | | return; |
| | | } |
| | | |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号"))); |
| | | return; |
| | | } |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录"))); |
| | | return; |
| | | } |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11SuperHongBao, info.getRelationId() + ""); |
| | | String token = null; |
| | | token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = TaoKeApiUtil.officialActivityConvert("19507100253", |
| | | "20150318020003258", info.getRelationId()); |
| | | String link = dto.getClick_url(); |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号"))); |
| | | return; |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg", "【天猫双12】上亿红包等你来拆!", |
| | | link); |
| | | if (!StringUtil.isNullOrEmpty(token)) |
| | | redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天 |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11SuperHongBao, info.getRelationId() + ""); |
| | | String token = null; |
| | | token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | try { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, "mm_124933865_56750082_19507100253", sceneId, info.getRelationId(), false); |
| | | } catch (ConvertLinkException e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMessage()))); |
| | | return; |
| | | } |
| | | String link = dto.getClick_url(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"))); |
| | | return; |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg", "【年货节】上亿红包等你来拆!", |
| | | link); |
| | | if (!StringUtil.isNullOrEmpty(token)) |
| | | redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天 |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | UserInfo user=userInfoService.selectByPKey(uid); |
| | | String desc = configService.getValue(ConfigKeyEnum.superHongBaoShareDesc.getKey(),user.getSystem()); |
| | | desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token)); |
| | | try { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc)))); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误"))); |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"))); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "getYuShouToken") |
| | | public void getYuShouToken(String sign, Long uid, String callback, PrintWriter out) { |
| | | if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误"))); |
| | | return; |
| | | } |
| | | UserInfo user = userInfoService.selectByPKey(uid); |
| | | String desc = configService.getValue(ConfigKeyEnum.superHongBaoShareDesc.getKey(), user.getSystem()); |
| | | desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token)); |
| | | try { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc)))); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误"))); |
| | | } |
| | | } |
| | | |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录"))); |
| | | return; |
| | | } |
| | | @RequestMapping(value = "getYuShouToken") |
| | | public void getYuShouToken(String sign, Long uid, String callback, String sceneId, PrintWriter out) { |
| | | if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误"))); |
| | | return; |
| | | } |
| | | |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号"))); |
| | | return; |
| | | } |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录"))); |
| | | return; |
| | | } |
| | | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11YuShou, info.getRelationId() + ""); |
| | | String token = null; |
| | | if (Constant.IS_OUTNET) |
| | | token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = TaoKeApiUtil.officialActivityConvert("19507100253", |
| | | "20150318020003258", info.getRelationId()); |
| | | String link = dto.getClick_url(); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg", "预售商品付定金,得奖金!", |
| | | link); |
| | | if (Constant.IS_OUTNET) |
| | | 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) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号"))); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试"))); |
| | | return; |
| | | } |
| | | UserInfo user=userInfoService.selectByPKey(uid); |
| | | String desc = configService.getValue(ConfigKeyEnum.superYuShouShareDesc.getKey(),user.getSystem()); |
| | | desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token)); |
| | | try { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc)))); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误"))); |
| | | } |
| | | } |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.S11YuShou, info.getRelationId() + ""); |
| | | String token = null; |
| | | if (Constant.IS_OUTNET) |
| | | token = redisManager.getCommonString(key); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | try { |
| | | TaoKeOfficialActivityConvertResultDTO dto = null; |
| | | try { |
| | | dto = convertLinkManager.taobaoOfficialActivityConvert(uid, "mm_124933865_56750082_19507100253", |
| | | sceneId, info.getRelationId(), true); |
| | | } catch (ConvertLinkException e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMessage()))); |
| | | return; |
| | | } |
| | | String link = dto.getClick_url(); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg", "预售商品付定金,得奖金!", |
| | | link); |
| | | if (Constant.IS_OUTNET) |
| | | 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, "口令生成失败,请稍后重试"))); |
| | | return; |
| | | } |
| | | UserInfo user = userInfoService.selectByPKey(uid); |
| | | String desc = configService.getValue(ConfigKeyEnum.superYuShouShareDesc.getKey(), user.getSystem()); |
| | | desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token)); |
| | | try { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc)))); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误"))); |
| | | } |
| | | } |
| | | |
| | | } |