yujian
2019-07-22 1d23bb817a5b8d7edcd172f02246ecc95250d63b
京东分享H5接口
6个文件已修改
597 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/share/UserShareGoodsGroupMapper.java 118 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml 323 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsGroupService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
@@ -1,60 +1,60 @@
package com.yeshi.fanli.dao.mybatis.share;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
public interface UserShareGoodsGroupMapper {
    int deleteByPrimaryKey(Long id);
    int insert(UserShareGoodsGroup record);
    int insertSelective(UserShareGoodsGroup record);
    UserShareGoodsGroup selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(UserShareGoodsGroup record);
    int updateByPrimaryKey(UserShareGoodsGroup record);
    /**
     * 批量插入
     * @param list
     * @return
     */
    int insertBatch(List<UserShareGoodsGroup> list);
    /**
     * 批量选择更新
     * @param list
     * @return
     */
    int updateBatchSelective(List<UserShareGoodsGroup> list);
    /**
     * 查询分享商品
     * @param recordId
     * @return
     */
    List<UserShareGoodsGroup> listByRecordId(@Param("recordId") Long recordId);
    /**
     * 查询单个商品 判断是否单个商品分享
     * @param recordId
     * @return
     */
    UserShareGoodsGroup getSingleGoods(@Param("source") ShareSourceTypeEnum source, @Param("cid") Long cid, @Param("uid") Long uid);
    /**
     * 查询最新更新的商品
     * @param cid
     * @param auctionId
     * @return
     */
    UserShareGoodsGroup getNewestRecord (@Param("uid") Long uid, @Param("auctionId") Long auctionId);
package com.yeshi.fanli.dao.mybatis.share;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
public interface UserShareGoodsGroupMapper {
    int deleteByPrimaryKey(Long id);
    int insert(UserShareGoodsGroup record);
    int insertSelective(UserShareGoodsGroup record);
    UserShareGoodsGroup selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(UserShareGoodsGroup record);
    int updateByPrimaryKey(UserShareGoodsGroup record);
    /**
     * 批量插入
     * @param list
     * @return
     */
    int insertBatch(List<UserShareGoodsGroup> list);
    /**
     * 批量选择更新
     * @param list
     * @return
     */
    int updateBatchSelective(List<UserShareGoodsGroup> list);
    /**
     * 查询分享商品
     * @param recordId
     * @return
     */
    List<UserShareGoodsGroup> listByRecordId(@Param("recordId") Long recordId);
    /**
     * 查询单个商品 判断是否单个商品分享
     * @param recordId
     * @return
     */
    UserShareGoodsGroup getSingleGoods(@Param("source") ShareSourceTypeEnum source, @Param("cid") Long cid, @Param("uid") Long uid);
    /**
     * 查询最新更新的商品
     * @param cid
     * @param auctionId
     * @return
     */
    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
@@ -1,161 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">
    <id column="gu_id" property="id" jdbcType="BIGINT"/>
    <result column="gu_record_id" property="recordId" jdbcType="BIGINT"/>
    <result column="gu_today_browse" property="todayBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_browse" property="totalBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_order" property="totalOrder" jdbcType="INTEGER"/>
    <result column="gu_total_money" property="totalMoney" jdbcType="DECIMAL"/>
    <result column="gu_browse_time" property="browseTime" jdbcType="TIMESTAMP"/>
    <result column="gu_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="gu_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
          <!-- 记录组中的总商品数量 -->
    <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/>
    <association property="commonGoods" column="gu_common_goods_id"
        resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
  </resultMap>
  <sql id="Base_Column_List">gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group (gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime) values (#{id,jdbcType=BIGINT},#{recordId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{todayBrowse,jdbcType=INTEGER},#{totalBrowse,jdbcType=INTEGER},#{totalOrder,jdbcType=INTEGER},#{totalMoney,jdbcType=DECIMAL},#{browseTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">gu_id,</if>
      <if test="recordId != null">gu_record_id,</if>
      <if test="commonGoods != null">gu_common_goods_id,</if>
      <if test="todayBrowse != null">gu_today_browse,</if>
      <if test="totalBrowse != null">gu_total_browse,</if>
      <if test="totalOrder != null">gu_total_order,</if>
      <if test="totalMoney != null">gu_total_money,</if>
      <if test="browseTime != null">gu_browse_time,</if>
      <if test="createTime != null">gu_createtime,</if>
      <if test="updateTime != null">gu_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="recordId != null">#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group set gu_record_id = #{recordId,jdbcType=BIGINT},gu_common_goods_id = #{commonGoods.id,jdbcType=BIGINT},gu_today_browse = #{todayBrowse,jdbcType=INTEGER},gu_total_browse = #{totalBrowse,jdbcType=INTEGER},gu_total_order = #{totalOrder,jdbcType=INTEGER},gu_total_money = #{totalMoney,jdbcType=DECIMAL},gu_browse_time = #{browseTime,jdbcType=TIMESTAMP},gu_createtime = #{createTime,jdbcType=TIMESTAMP},gu_updatetime = #{updateTime,jdbcType=TIMESTAMP} where gu_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group
    <set>
      <if test="recordId != null">gu_record_id=#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">gu_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">gu_today_browse=#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">gu_total_browse=#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">gu_total_order=#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">gu_total_money=#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">gu_browse_time=#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">gu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">gu_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where gu_id = #{id,jdbcType=BIGINT}
  </update>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
          insert into yeshi_ec_share_goods_group
         (<include refid="Base_Column_List" />)
        values
          <foreach collection="list" item="item" separator=",">
          (
             #{item.id,jdbcType=BIGINT},
             #{item.recordId,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT},
             #{item.todayBrowse,jdbcType=INTEGER},
             #{item.totalBrowse,jdbcType=INTEGER},
             #{item.totalOrder,jdbcType=INTEGER},
             #{item.totalMoney,jdbcType=DECIMAL},
             #{item.browseTime,jdbcType=TIMESTAMP},
             #{item.createTime,jdbcType=TIMESTAMP},
             #{item.updateTime,jdbcType=TIMESTAMP}
         )
          </foreach>
  </insert>
  <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_share_goods_group
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="gu_today_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.todayBrowse !=null">
                     when gu_id=#{item.id} then #{item.todayBrowse}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_total_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalBrowse !=null">
                     when gu_id=#{item.id} then #{item.totalBrowse}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_order =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalOrder !=null">
                     when gu_id=#{item.id} then #{item.totalOrder}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_money =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalMoney !=null">
                     when gu_id=#{item.id} then #{item.totalMoney}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_browse_time =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.browseTime !=null">
                     when gu_id=#{item.id} then #{item.browseTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where gu_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
     </update>
   <select id="listByRecordId" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_share_goods_group  tg
     LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
     WHERE tg.`gu_record_id` = #{recordId}
     ORDER BY tg.`gu_createtime`
   </select>
  <select id="getSingleGoods" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_share_goods_group g
    LEFT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id`
    WHERE  r.sgr_share_state = 1 AND  r.`sgr_source` = #{source}
           AND  g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid}
    ORDER BY g.gu_updatetime desc LIMIT 1
   </select>
   <select id="getNewestRecord" resultMap="BaseResultMap">
    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
    ORDER BY tg.gu_updatetime desc LIMIT 1
   </select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">
    <id column="gu_id" property="id" jdbcType="BIGINT"/>
    <result column="gu_record_id" property="recordId" jdbcType="BIGINT"/>
    <result column="gu_today_browse" property="todayBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_browse" property="totalBrowse" jdbcType="INTEGER"/>
    <result column="gu_total_order" property="totalOrder" jdbcType="INTEGER"/>
    <result column="gu_total_money" property="totalMoney" jdbcType="DECIMAL"/>
    <result column="gu_browse_time" property="browseTime" jdbcType="TIMESTAMP"/>
    <result column="gu_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="gu_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
          <!-- 记录组中的总商品数量 -->
    <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/>
    <association property="commonGoods" column="gu_common_goods_id"
        resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" />
  </resultMap>
  <sql id="Base_Column_List">gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group (gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime) values (#{id,jdbcType=BIGINT},#{recordId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{todayBrowse,jdbcType=INTEGER},#{totalBrowse,jdbcType=INTEGER},#{totalOrder,jdbcType=INTEGER},#{totalMoney,jdbcType=DECIMAL},#{browseTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">gu_id,</if>
      <if test="recordId != null">gu_record_id,</if>
      <if test="commonGoods != null">gu_common_goods_id,</if>
      <if test="todayBrowse != null">gu_today_browse,</if>
      <if test="totalBrowse != null">gu_total_browse,</if>
      <if test="totalOrder != null">gu_total_order,</if>
      <if test="totalMoney != null">gu_total_money,</if>
      <if test="browseTime != null">gu_browse_time,</if>
      <if test="createTime != null">gu_createtime,</if>
      <if test="updateTime != null">gu_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="recordId != null">#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group set gu_record_id = #{recordId,jdbcType=BIGINT},gu_common_goods_id = #{commonGoods.id,jdbcType=BIGINT},gu_today_browse = #{todayBrowse,jdbcType=INTEGER},gu_total_browse = #{totalBrowse,jdbcType=INTEGER},gu_total_order = #{totalOrder,jdbcType=INTEGER},gu_total_money = #{totalMoney,jdbcType=DECIMAL},gu_browse_time = #{browseTime,jdbcType=TIMESTAMP},gu_createtime = #{createTime,jdbcType=TIMESTAMP},gu_updatetime = #{updateTime,jdbcType=TIMESTAMP} where gu_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group
    <set>
      <if test="recordId != null">gu_record_id=#{recordId,jdbcType=BIGINT},</if>
      <if test="commonGoods != null">gu_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
      <if test="todayBrowse != null">gu_today_browse=#{todayBrowse,jdbcType=INTEGER},</if>
      <if test="totalBrowse != null">gu_total_browse=#{totalBrowse,jdbcType=INTEGER},</if>
      <if test="totalOrder != null">gu_total_order=#{totalOrder,jdbcType=INTEGER},</if>
      <if test="totalMoney != null">gu_total_money=#{totalMoney,jdbcType=DECIMAL},</if>
      <if test="browseTime != null">gu_browse_time=#{browseTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">gu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">gu_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where gu_id = #{id,jdbcType=BIGINT}
  </update>
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
          insert into yeshi_ec_share_goods_group
         (<include refid="Base_Column_List" />)
        values
          <foreach collection="list" item="item" separator=",">
          (
             #{item.id,jdbcType=BIGINT},
             #{item.recordId,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT},
             #{item.todayBrowse,jdbcType=INTEGER},
             #{item.totalBrowse,jdbcType=INTEGER},
             #{item.totalOrder,jdbcType=INTEGER},
             #{item.totalMoney,jdbcType=DECIMAL},
             #{item.browseTime,jdbcType=TIMESTAMP},
             #{item.createTime,jdbcType=TIMESTAMP},
             #{item.updateTime,jdbcType=TIMESTAMP}
         )
          </foreach>
  </insert>
  <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_share_goods_group
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="gu_today_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.todayBrowse !=null">
                     when gu_id=#{item.id} then #{item.todayBrowse}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_total_browse =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalBrowse !=null">
                     when gu_id=#{item.id} then #{item.totalBrowse}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_order =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalOrder !=null">
                     when gu_id=#{item.id} then #{item.totalOrder}
                     </if>
                </foreach>
            </trim>
             <trim prefix="gu_total_money =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.totalMoney !=null">
                     when gu_id=#{item.id} then #{item.totalMoney}
                     </if>
                </foreach>
            </trim>
            <trim prefix="gu_browse_time =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                        <if test="item.browseTime !=null">
                     when gu_id=#{item.id} then #{item.browseTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where gu_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
     </update>
   <select id="listByRecordId" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_share_goods_group  tg
     LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id`
     WHERE tg.`gu_record_id` = #{recordId}
     ORDER BY tg.`gu_createtime`
   </select>
  <select id="getSingleGoods" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_share_goods_group g
    LEFT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id`
    WHERE  r.sgr_share_state = 1 AND  r.`sgr_source` = #{source}
           AND  g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid}
    ORDER BY g.gu_updatetime desc LIMIT 1
   </select>
   <select id="getNewestRecord" resultMap="BaseResultMap">
    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` = #{goodsId}  AND r.sgr_share_state = 1
        AND cg.`cg_goods_type` = #{goodsType}
    ORDER BY tg.gu_updatetime desc LIMIT 1
   </select>
</mapper>
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);