| | |
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDPingouInfo;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSection;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendSection;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.log.LogManager;
|
| | | import com.yeshi.fanli.log.LogType;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendSectionService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.ScanHistoryService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | 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.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | |
| | | private SuperRecommendBannerService superRecommendBannerService;
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendSectionService superRecommendSectionService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private RecommendSectionGoodsService recommendSectionGoodsService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryService scanHistoryService;
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET)
|
| | | public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) {
|
| | |
|
| | | System system = systemService.getSystem("WEB", Constant.systemCommonConfig.getH5PackageName());
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem("WEB",
|
| | | Constant.systemCommonConfig.getH5PackageName());
|
| | | JSONObject json = new JSONObject();
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NOSYSTEM));
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 处理条件
|
| | | *
|
| | | * 方法说明: 推荐商品列表
|
| | | * |
| | | * @author mawurui createTime 2018年5月11日 上午11:26:03
|
| | | * @param acceptData
|
| | | * @param index
|
| | | * @param uid
|
| | | * @param tid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRecommendSection", method = RequestMethod.GET)
|
| | | public void getRecommendSection(AcceptData acceptData, String callback, PrintWriter out) {
|
| | |
|
| | | System system = systemService.getSystem("WEB", Constant.systemCommonConfig.getH5PackageName());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NOSYSTEM));
|
| | | private void doTaoLiJin(String callback, Long uid, Long tid, PrintWriter out) {
|
| | | // 查询商品淘礼金
|
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.selectByPrimaryKey(tid);
|
| | | if (record == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("商品信息获取失败")));
|
| | | return;
|
| | | }
|
| | | List<SuperRecommendSection> superRecommendSectionList = superRecommendSectionService
|
| | | .getSuperRecommendSectionBySystemId(system.getId());
|
| | | List<RecommendSection> recommendSectionList = null;
|
| | | for (SuperRecommendSection superRecommendSection : superRecommendSectionList) {
|
| | | if (recommendSectionList == null) {
|
| | | recommendSectionList = new ArrayList<RecommendSection>();
|
| | | }
|
| | | RecommendSection recommendSection = superRecommendSection.getRecommendSection();
|
| | |
|
| | | // 暂时改变淘特价的跳转地址
|
| | | if (system.getId() == 7) {
|
| | | recommendSection.setJumpUrl(recommendSection.getJumpUrl().replace("column.html", "column_ttj.html"));
|
| | | }
|
| | | Long auctionId = record.getGoodsId();
|
| | | String tljLink = record.getSendUrl();
|
| | | BigDecimal tljMoney = record.getPerFace();
|
| | |
|
| | | recommendSectionList.add(recommendSection);
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | }
|
| | | if (recommendSectionList == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NODATA));
|
| | |
|
| | | if (goods == null) {// 已经下线
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("商品信息获取失败")));
|
| | | return;
|
| | | }
|
| | | Utils.sort(recommendSectionList);
|
| | | int size = recommendSectionList.size();
|
| | |
|
| | | List<RecommendSectionGoods> recommendSectionGoodsList = null;
|
| | | String token = redisManager.getTLJToken(tljLink);
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tljLink);
|
| | | }
|
| | |
|
| | | // 券后价
|
| | | BigDecimal afterCouponPrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | TaoBaoLink link = new TaoBaoLink();
|
| | | link.setTaoToken(token);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", size);
|
| | | JSONArray dataArr = new JSONArray();
|
| | | JSONObject validData = null;
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | Map<String, String> convertMap = hongBaoManageService.convertMap();
|
| | | String proportion = convertMap.get("hongbao_goods_proportion");
|
| | | String fcRate = convertMap.get("hongbao_fc_ratio");
|
| | |
|
| | | Map<Long, List<RecommendSectionGoods>> map = recommendSectionGoodsService.getAllSectionGoodsMap();
|
| | | for (int i = 0; i < size; i++) {
|
| | | validData = new JSONObject();
|
| | | RecommendSection recommendSection = recommendSectionList.get(i);
|
| | | recommendSectionGoodsList = map.get(recommendSection.getId());
|
| | | if (recommendSectionGoodsList == null) {
|
| | | continue;
|
| | | }
|
| | | Utils.sort(recommendSectionGoodsList);
|
| | | if (recommendSection.getCounts() < recommendSectionGoodsList.size()) {
|
| | | recommendSectionGoodsList = recommendSectionGoodsList.subList(0, recommendSection.getCounts());
|
| | | }
|
| | | validData.put("count", recommendSectionGoodsList.size());
|
| | | validData.put("recommendSection", gson.toJson(recommendSection));
|
| | |
|
| | | // 替换TaoBaoGoodsBrief
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson2 = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
| | | for (RecommendSectionGoods rss : recommendSectionGoodsList) {
|
| | | JSONObject obj = JSONObject.fromObject(gson2.toJson(rss));
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(
|
| | | gson2.fromJson(obj.optJSONObject("taoBaoGoodsBrief").toString(), TaoBaoGoodsBrief.class),
|
| | | proportion, fcRate, ""));
|
| | | obj.put("taoBaoGoodsBrief", json);
|
| | | array.add(obj);
|
| | | }
|
| | |
|
| | | validData.put("recommendSectionGoodsList", array);
|
| | | dataArr.add(validData);
|
| | | data.put("title", goods.getTitle());
|
| | | if (goods.getImgList() == null)
|
| | | goods.setImgList(new ArrayList<>());
|
| | | goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300));
|
| | | data.put("imgs", goods.getImgList());
|
| | | data.put("couponPrice", afterCouponPrice);
|
| | | // 老版本兼容
|
| | | data.put("quanPrice", afterCouponPrice);
|
| | | data.put("zkPrice", goods.getZkPrice());
|
| | | data.put("shareContent", "长按复制本段文字,打开【手机淘宝】即可领取【特别优惠券】购买下单,");
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken()));
|
| | | data.put("reservePrice", goods.getReservePrice());
|
| | | data.put("shopType", goods.getUserType() == 1 ? 2 : 1);
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"无".equalsIgnoreCase(goods.getCouponInfo())) {
|
| | | data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()));
|
| | | data.put("coupon", true);
|
| | | } else {
|
| | | data.put("coupon", false);
|
| | | }
|
| | | data.put("data", dataArr);
|
| | |
|
| | | String result = JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data));
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.cacheCommonString("client-api-getRecommendSection", result, 3 * 60);
|
| | | data.put("tljMoney", tljMoney);
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(result)));
|
| | | return;
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | @SuppressWarnings("unused")
|
| | | @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET)
|
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, String uid, String callback,
|
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, String tid, String uid, String callback,
|
| | | PrintWriter out) {
|
| | | if (!StringUtil.isNullOrEmpty(uid))
|
| | | uid = uid.replace(" ", "+");
|
| | |
|
| | | LogManager.getLogger(LogType.taobaoTrade)
|
| | | .info(String.format("淘宝分享商品H5访问:\n 商品ID:%s \n 原始用户ID:%s \n", id, uid));
|
| | | |
| | | long begin = java.lang.System.currentTimeMillis();
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS);
|
| | | UserShareGoodsHistory shareHistory = null;
|
| | | String pid = configList.get(0).getDefaultPid();
|
| | | if (!StringUtil.isNullOrEmpty(uid)) {
|
| | | try {
|
| | | uid = AESUtil.decrypt(uid, Constant.UIDAESKEY);
|
| | | TBPid tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_SHARE_GOODS);
|
| | | if (tbPid != null)
|
| | | pid = tbPid.getPid();
|
| | | uid = AESUtil.decrypt(uid, Constant.UIDAESKEY);
|
| | | }
|
| | |
|
| | | // 查询该PID,UID,商品ID下是否有这个商品的信息
|
| | | // 判断这个产品是否从APP中分享而来
|
| | | try {
|
| | | shareHistory = shareGoodsService.getShareGoodsHistoryDetail(Long.parseLong(uid),
|
| | | Long.parseLong(id));
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(tid)) {
|
| | | tid = AESUtil.decrypt(tid, Constant.UIDAESKEY);
|
| | | doTaoLiJin(callback, StringUtil.isNullOrEmpty(uid) || Long.parseLong(uid) == 0 ? null : Long.parseLong(uid),
|
| | | Long.parseLong(tid), out);
|
| | | return;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | String token = null;
|
| | | if (!StringUtil.isNullOrEmpty(uid)) {
|
| | | // 查询是否有分享记录
|
| | | UserShareGoodsHistory shareHistory = null;
|
| | | try {
|
| | | shareHistory = shareGoodsService.getShareGoodsHistoryDetail(Long.parseLong(uid), Long.parseLong(id));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ShareGoodsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (shareHistory != null) {// 有分享记录
|
| | | token = shareHistory.getTkCode();
|
| | | goods = redisManager.getTaoBaoGoodsTemp(Long.parseLong(id));
|
| | | if (goods == null)
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | } else {// 没有分享记录,需要直接分享
|
| | | LogHelper.test("没有分享记录:uid:" + uid + " actionid:" + id);
|
| | | // 获取
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
|
| | | app.setAdzoneId(app.getPid().split("_")[3]);
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | |
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goods != null) {
|
| | | String url = goods.getAuctionUrl();
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {
|
| | | url = goods.getCouponLink();
|
| | | }
|
| | | String relationId = userExtraTaoBaoInfoService.getRelationIdByUid(Long.parseLong(uid));
|
| | | if (!StringUtil.isNullOrEmpty(relationId))
|
| | | url += "&relationId=" + relationId;
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url);
|
| | | }
|
| | | }
|
| | |
|
| | | } else {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS);
|
| | | String pid = tbPidService.getSharePid().getPid();
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAdzoneId(pid.split("_")[3]);
|
| | | app.setAppKey(configList.get(0).getAppKey());
|
| | | app.setAppSecret(configList.get(0).getAppSecret());
|
| | | app.setPid(pid);
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goods != null) {
|
| | | String url = goods.getAuctionUrl();
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {
|
| | | url = goods.getCouponLink();
|
| | | }
|
| | | if (!url.contains("uland.taobao.com") && !url.contains("s.click.taobao.com")) {
|
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(Long.parseLong(id), app);
|
| | | url = linkInfo.getCouponLink();
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | url = linkInfo.getAuctionUrl();
|
| | | }
|
| | |
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url);
|
| | | }
|
| | | }
|
| | |
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("商品信息获取失败")));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 券后价
|
| | | BigDecimal afterCouponPrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | TaoBaoLink link = null;
|
| | |
|
| | | if (shareHistory != null) {
|
| | | link = new TaoBaoLink();
|
| | | link.setTaoToken(shareHistory.getTkCode());
|
| | | } else {
|
| | | link = new TaoBaoLink();
|
| | | try {
|
| | | String url = goods.getCouponLink();
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | url = goods.getAuctionUrl();
|
| | | String tbk = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url);
|
| | | link.setTaoToken(tbk);
|
| | | } catch (Exception e) {
|
| | | link = null;
|
| | | }
|
| | | }
|
| | | if (link == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("淘口令生成失败")));
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("口令生成失败")));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 券后价
|
| | | BigDecimal afterCouponPrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | TaoBaoLink link = new TaoBaoLink();
|
| | | link.setTaoToken(token);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", goods.getTitle());
|
| | | if (goods.getImgList() == null)
|
| | | goods.setImgList(new ArrayList<>());
|
| | | goods.getImgList().add(0, goods.getPictUrl());
|
| | | goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300));
|
| | | data.put("imgs", goods.getImgList());
|
| | | data.put("couponPrice", afterCouponPrice);
|
| | | // 老版本兼容
|
| | | data.put("quanPrice", afterCouponPrice);
|
| | | data.put("zkPrice", goods.getZkPrice());
|
| | | data.put("shareContent", "长按复制本段文字,打开【手机淘宝】即可领取【特别优惠券】购买下单,");
|
| | | data.put("token", link.getTaoToken());
|
| | | data.put("quan", !StringUtil.isNullOrEmpty(goods.getCouponInfo()));
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken()));
|
| | | data.put("reservePrice", goods.getReservePrice());
|
| | | data.put("shopType", goods.getUserType() == 1 ? 2 : 1);
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"无".equalsIgnoreCase(goods.getCouponInfo())) {
|
| | | data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()));
|
| | | data.put("coupon", true);
|
| | | // 老版本兼容
|
| | | data.put("quan", true);
|
| | | } else {
|
| | | data.put("coupon", false);
|
| | | // 老版本兼容
|
| | | data.put("quan", true);
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | |
|
| | | final String tempUid = uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(tempUid))
|
| | | userShareGoodsGroupService.updateBrowseRecord(Long.parseLong(tempUid), Long.parseLong(id), 1);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东分享商品信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getJDGoodsDetail")
|
| | | public void getJDGoodsDetail(final AcceptData acceptData, final Long id, String uid, String callback,
|
| | | PrintWriter out) {
|
| | | if (id == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(uid)) {
|
| | | uid = AESUtil.decrypt(uid, Constant.UIDAESKEY);
|
| | | }
|
| | |
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id);
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDApiUtil.getGoodsDetail(id);
|
| | | }
|
| | |
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("商品信息获取失败")));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> imageList = jdGoods.getImageList();
|
| | | if (imageList == null) {
|
| | | imageList = new ArrayList<>();
|
| | | imageList.add(jdGoods.getPicUrl());
|
| | | }
|
| | |
|
| | | boolean hasCoupon = false;
|
| | | String couponUrl = null;
|
| | | BigDecimal discount = new BigDecimal(0);
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
|
| | | if (couponInfo != null) {
|
| | | hasCoupon = true;
|
| | | discount = couponInfo.getDiscount();
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | |
|
| | | boolean jdzy = false;
|
| | | String owner = jdGoods.getOwner();
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | jdzy = true;
|
| | | }
|
| | |
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | uid);
|
| | |
|
| | | int priceType = 1;
|
| | | BigDecimal price = jdGoods.getPrice();
|
| | | ;
|
| | | JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
|
| | | if (pinGouInfo != null) {
|
| | | priceType = 2; // 拼购价
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("jdzy", jdzy);
|
| | | data.put("imgs", imageList);
|
| | | data.put("title", jdGoods.getSkuName());
|
| | | data.put("zkPrice", price);
|
| | | data.put("priceType", priceType);
|
| | | data.put("coupon", hasCoupon);
|
| | | data.put("couponAmount", discount);
|
| | | data.put("couponPrice", JDUtil.getQuanPrice(jdGoods));
|
| | | data.put("helpLink", configService.get("jd_share_h5_help_link"));
|
| | | data.put("jumpLink", jumpLink);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final String tempUid = uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(tempUid))
|
| | | userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多分享商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getPDDGoodsDetail")
|
| | | public void getPDDGoodsDetail(final AcceptData acceptData, final Long id, String uid, String callback,
|
| | | PrintWriter out) {
|
| | | if (id == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(uid)) {
|
| | | uid = AESUtil.decrypt(uid, Constant.UIDAESKEY);
|
| | | }
|
| | |
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("商品信息获取失败")));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> imageList = null;
|
| | | String[] goodsGalleryUrls = pddGoods.getGoodsGalleryUrls();
|
| | | if (goodsGalleryUrls != null) {
|
| | | imageList = Arrays.asList(goodsGalleryUrls);
|
| | | }
|
| | | if (imageList == null) {
|
| | | imageList = new ArrayList<>();
|
| | | String goodsImageUrl = pddGoods.getGoodsImageUrl();
|
| | | if (!StringUtil.isNullOrEmpty(goodsImageUrl)) {
|
| | | imageList.add(goodsImageUrl);
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal hundred = new BigDecimal(100);
|
| | | Boolean hasCoupon = pddGoods.getHasCoupon();
|
| | | BigDecimal amount = new BigDecimal(0);
|
| | | if (hasCoupon != null && hasCoupon) {
|
| | | amount = MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getCouponDiscount()), hundred).setScale(2);
|
| | | } else {
|
| | | hasCoupon = false;
|
| | | }
|
| | |
|
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(id, PinDuoDuoApiUtil.PID_SHARE + "", uid);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("imgs", imageList);
|
| | | data.put("title", pddGoods.getGoodsName());
|
| | | data.put("zkPrice", MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getMinGroupPrice()), hundred).setScale(2));
|
| | | data.put("coupon", hasCoupon);
|
| | | data.put("couponAmount", amount);
|
| | | data.put("couponPrice", PinDuoDuoUtil.getQuanPrice(pddGoods));
|
| | | data.put("helpLink", configService.get("pdd_share_h5_help_link"));
|
| | | data.put("jumpLink", jumpLink);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final String tempUid = uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(tempUid))
|
| | | userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id,
|
| | | Constant.SOURCE_TYPE_PDD);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | }
|