fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java
@@ -14,11 +14,13 @@ import org.yeshi.utils.taobao.TbImgUtil; import com.google.gson.Gson; import com.yeshi.fanli.dto.jd.JDCouponInfo; 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; @@ -46,6 +48,8 @@ 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.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -395,4 +399,83 @@ }); 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(); } String materialId = "https://item.jd.com/" + id + ".html"; String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid); JSONObject data = new JSONObject(); data.put("imgs", imageList); data.put("title", jdGoods.getSkuName()); data.put("zkPrice", jdGoods.getPrice()); 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; } } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/share/UserShareGoodsGroupMapper.java
@@ -56,5 +56,5 @@ * @param auctionId * @return */ UserShareGoodsGroup getNewestRecord (@Param("uid") Long uid, @Param("auctionId") Long auctionId); UserShareGoodsGroup getNewestRecord (@Param("uid") Long uid, @Param("goodsId") Long goodsId, @Param("goodsType") Integer goodsType); } fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml
@@ -154,7 +154,8 @@ SELECT tg.* FROM yeshi_ec_share_goods_group tg RIGHT JOIN `yeshi_ec_share_goods_record` r ON tg.`gu_record_id` = r.`sgr_id` LEFT JOIN `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id` WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{auctionId} AND r.sgr_share_state = 1 WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{goodsId} AND r.sgr_share_state = 1 AND cg.`cg_goods_type` = #{goodsType} ORDER BY tg.gu_updatetime desc LIMIT 1 </select> fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
@@ -17,6 +17,7 @@ import com.yeshi.fanli.service.inter.goods.CommonGoodsService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; @Service @@ -72,8 +73,8 @@ } @Override public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId) { return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId); public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId, Integer goodsType) { return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId, goodsType); } @@ -83,7 +84,7 @@ * @param auctionId */ @Override public void updateOrderRecord (HongBao hongBao) throws UserShareGoodsRecordException{ public void updateOrderRecord (HongBao hongBao, int goodsType) throws UserShareGoodsRecordException{ if (hongBao == null) { throw new UserShareGoodsRecordException(1, "hongBao不能为空"); @@ -102,7 +103,7 @@ throw new UserShareGoodsRecordException(1, "商品ID不能为空"); } UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId()); UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId(), goodsType); if (newestRecord != null) { // 更新订单数量 @@ -144,7 +145,7 @@ throw new UserShareGoodsRecordException(1, "商品Id不能为空"); } UserShareGoodsGroup group = getNewestRecord(uid, auctionId); UserShareGoodsGroup group = getNewestRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); if (group != null) { UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId()); @@ -168,4 +169,40 @@ userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup); } } @Override public void updateBrowseNum(Long uid, Long id, int goodsType) throws UserShareGoodsRecordException{ if (uid == null) { throw new UserShareGoodsRecordException(1, "用户ID不能为空"); } if (id == null) { throw new UserShareGoodsRecordException(1, "商品Id不能为空"); } UserShareGoodsGroup group = getNewestRecord(uid, id, goodsType); if (group != null) { UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId()); // 累计浏览 Integer totalBrowse = group.getTotalBrowse(); if (totalBrowse == null) { totalBrowse = 0; } shareGoodsGroup.setTotalBrowse(totalBrowse + 1); // 今日浏览 Date date = new Date(); Date browseTime = group.getBrowseTime(); if (DateUtil.isSameDay(browseTime, date)) { shareGoodsGroup.setTodayBrowse(group.getTodayBrowse() + 1); } else { shareGoodsGroup.setTodayBrowse(1); } shareGoodsGroup.setBrowseTime(date); userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup); } } } fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsGroupService.java
@@ -45,7 +45,7 @@ * @param auctionId * @return */ public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId); public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId, Integer goodsType); /** @@ -55,7 +55,7 @@ * @param count 订单数量 * @throws UserShareGoodsRecordException */ public void updateOrderRecord(HongBao hongBao) throws UserShareGoodsRecordException; public void updateOrderRecord(HongBao hongBao, int goodsType) throws UserShareGoodsRecordException; /** * 单个商品分享浏览记录 @@ -65,4 +65,13 @@ * @throws UserShareGoodsRecordException */ public void updateBrowseRecord(Long uid, Long auctionId, int count) throws UserShareGoodsRecordException; /** * 记录浏览次数 * @param uid * @param id * @param goodsType * @throws UserShareGoodsRecordException */ public void updateBrowseNum(Long uid, Long id, int goodsType) throws UserShareGoodsRecordException; } fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -151,19 +151,22 @@ * * @return */ public static String convertLink(String materialId, String couponUrl, String pid) { public static String convertLink(String materialId, String couponUrl, String positionId, String ext1) { JSONObject json = new JSONObject(); json.put("materialId", materialId); json.put("siteId", APP_ID); if (couponUrl != null) json.put("positionId", positionId); if (!StringUtil.isNullOrEmpty(couponUrl)) json.put("couponUrl", couponUrl); // json.put("ext1", "437032_12"); json.put("pid", pid); if (!StringUtil.isNullOrEmpty(ext1)) json.put("ext1", ext1); JSONObject root = new JSONObject(); root.put("promotionCodeReq", json); String result = baseRequest("jd.union.open.promotion.common.get", null, json); String result = baseRequest("jd.union.open.promotion.common.get", null, root); JSONObject resultJson = JSONObject.fromObject(result); result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result"); resultJson = JSONObject.fromObject(result);