| | |
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | 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.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | 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.ClientTBPid;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | 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;
|
| | |
|
| | |
| | | });
|
| | | 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 = jdGoods.getCouponInfo();
|
| | | 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.convertShortLink(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.convert(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;
|
| | | }
|
| | | }
|