yujian
2019-04-26 553e4585a5ec8e2c22b50e33a27d14ead6fd034d
店铺足迹删除+ 假删除
5个文件已修改
91 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/TaoBaoShopHistoryMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/TaoBaoShopHistory.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/TaoBaoShop.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/TaoBaoShopHistoryMapper.xml 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/TaoBaoShopHistoryServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/TaoBaoShopHistoryMapper.java
@@ -15,7 +15,7 @@
     * @param uid
     * @return
     */
    void deleteByUid(@Param("shopId") Long shopId, @Param("uid") Long uid);
    void updateByUid(@Param("shopId") Long shopId, @Param("uid") Long uid);
    
    /**
     * 根据删除
@@ -23,7 +23,7 @@
     * @param device
     * @return
     */
    void deleteByDevice(@Param("shopId") Long shopId, @Param("device") String device);
    void updateByDevice(@Param("shopId") Long shopId, @Param("device") String device);
    
    
    
fanli/src/main/java/com/yeshi/fanli/entity/brand/TaoBaoShopHistory.java
@@ -27,7 +27,10 @@
    // 设备id
    @Column(name = "tsh_device")
    private String device;
    // 用户是否已删除 : 1已删除 0未删除
    @Column(name = "tsh_state")
    private Integer state;
    @Column(name = "tsh_create_time")
    private Date createTime;
    
@@ -82,4 +85,12 @@
        this.updateTime = updateTime;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/taobao/TaoBaoShop.java
@@ -6,6 +6,8 @@
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
/**
 * 淘宝店铺信息(新版)
 * 
@@ -14,37 +16,61 @@
 */
@Table("yeshi_ec_taobao_shop_info")
public class TaoBaoShop {
    @Expose
    @Column(name = "tsi_id")
    private Long id;// 卖家ID
    @Expose
    @Column(name = "tsi_user_type")
    private Integer userType;// 用户类型 0-淘宝 1-天猫
    @Expose
    @Column(name = "tsi_shop_id")
    private Long shopId;// 店铺ID
    @Expose
    @Column(name = "tsi_shop_name")
    private String shopName;// 店铺名称
    @Column(name = "tsi_seller_nick")
    private String sellerNick;// 卖家昵称
    private String sellerNick;// 卖家昵
    @Expose
    @Column(name = "tsi_shop_icon")
    private String shopIcon;// 店铺图标
    @Column(name = "tsi_shop_icon_custom")
    private String shopIconCustom;// 自定义店铺图标
    @Expose
    @Column(name = "tsi_score_goods")
    private BigDecimal scoreGoods;// 商品评分
    @Expose
    @Column(name = "tsi_score_seller")
    private BigDecimal scoreSeller;// 卖家评分
    @Expose
    @Column(name = "tsi_score_logistics")
    private BigDecimal scoreLogistics;// 物流评分
    @Expose
    @Column(name = "tsi_score_goods_d")
    private BigDecimal scoreGoodsD;// 与行业平均分的差值
    @Column(name = "tsi_score_seller_d")
    private BigDecimal scoreSellerD;
    @Column(name = "tsi_score_logistics_d")
    private BigDecimal scoreLogisticsD;
    @Expose
    @Column(name = "tsi_good_rate_percentage")
    private BigDecimal goodRatePercentage;// 好评率
    @Column(name = "tsi_update_time")
    private Date updateTime;
    // 店铺链接
    private String shopLink;
    
@@ -54,8 +80,9 @@
    public TaoBaoShop(Long id) {
        this.id = id;
    }
    public Integer getUserType() {
        return userType;
    }
fanli/src/main/java/com/yeshi/fanli/mapping/brand/TaoBaoShopHistoryMapper.xml
@@ -6,24 +6,26 @@
    <id column="tsh_id" property="id" jdbcType="BIGINT"/>
    <result column="tsh_uid" property="uid" jdbcType="BIGINT"/>
    <result column="tsh_device" property="device" jdbcType="VARCHAR"/>
    <result column="tsh_state" property="state" jdbcType="INTEGER"/>
    <result column="tsh_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="tsh_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="tsh_shop_id" property="taoBaoShop" 
        resultMap="com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper.BaseResultMap">
    </association>
  </resultMap>
  <sql id="Base_Column_List">tsh_id,tsh_shop_id,tsh_uid,tsh_device,tsh_create_time,tsh_update_time</sql>
  <sql id="Base_Column_List">tsh_id,tsh_shop_id,tsh_uid,tsh_device,tsh_state,tsh_create_time,tsh_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_taobao_shop_history where tsh_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_taobao_shop_history where tsh_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.TaoBaoShopHistory" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_shop_history (tsh_id,tsh_shop_id,tsh_uid,tsh_device,tsh_create_time,tsh_update_time) values (#{id,jdbcType=BIGINT},#{taoBaoShop.id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{device,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.TaoBaoShopHistory" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_shop_history (tsh_id,tsh_shop_id,tsh_uid,tsh_device,tsh_state,tsh_create_time,tsh_update_time) values (#{id,jdbcType=BIGINT},#{taoBaoShop.id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{device,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.TaoBaoShopHistory" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_shop_history
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">tsh_id,</if>
      <if test="taoBaoShop != null">tsh_shop_id,</if>
      <if test="uid != null">tsh_uid,</if>
      <if test="device != null">tsh_device,</if>
      <if test="state != null">tsh_state,</if>
      <if test="createTime != null">tsh_create_time,</if>
      <if test="updateTime != null">tsh_update_time,</if>
    </trim>values
@@ -32,30 +34,32 @@
      <if test="taoBaoShop != null">#{taoBaoShop.id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="device != null">#{device,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.brand.TaoBaoShopHistory">update yeshi_ec_taobao_shop_history set tsh_shop_id = #{taoBaoShop.id,jdbcType=BIGINT},tsh_uid = #{uid,jdbcType=BIGINT},tsh_device = #{device,jdbcType=VARCHAR},tsh_create_time = #{createTime,jdbcType=TIMESTAMP},tsh_update_time = #{updateTime,jdbcType=TIMESTAMP} where tsh_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.brand.TaoBaoShopHistory">update yeshi_ec_taobao_shop_history set tsh_shop_id = #{taoBaoShop.id,jdbcType=BIGINT},tsh_uid = #{uid,jdbcType=BIGINT},tsh_device = #{device,jdbcType=VARCHAR},tsh_state = #{state,jdbcType=INTEGER},tsh_create_time = #{createTime,jdbcType=TIMESTAMP},tsh_update_time = #{updateTime,jdbcType=TIMESTAMP} where tsh_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.TaoBaoShopHistory">update yeshi_ec_taobao_shop_history
    <set>
      <if test="taoBaoShop != null">tsh_shop_id=#{taoBaoShop.id,jdbcType=BIGINT},</if>
      <if test="uid != null">tsh_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="device != null">tsh_device=#{device,jdbcType=VARCHAR},</if>
      <if test="state != null">tsh_state=#{state,jdbcType=VARCHAR},</if>
      <if test="createTime != null">tsh_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">tsh_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where tsh_id = #{id,jdbcType=BIGINT}
  </update>
  
  <delete id="deleteByUid">
        delete from yeshi_ec_taobao_shop_history
  <update id="updateByUid">
        update yeshi_ec_taobao_shop_history set tsh_state = 1
        where  tsh_uid = #{uid} AND tsh_shop_id = #{shopId}
  </delete>
  </update>
    
  <delete id="deleteByDevice">
        delete from yeshi_ec_taobao_shop_history
  <update id="updateByDevice">
        update yeshi_ec_taobao_shop_history set tsh_state = 1
        where  tsh_device = #{device} AND tsh_shop_id = #{shopId}
  </delete>
  </update>
  
  
  <select id="getByUid" resultMap="BaseResultMap">
@@ -73,32 +77,32 @@
  <select id="listByUid" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_taobao_shop_history h 
    LEFT JOIN `yeshi_ec_taobao_shop_info` p ON h.`tsh_shop_id` = p.`tsi_id`
    WHERE h.tsh_uid = #{uid}
    WHERE h.tsh_uid = #{uid} AND tsh_state = 0
    ORDER BY  h.tsh_update_time DESC
    LIMIT ${start},${count}
  </select>
  
  <select id="countByUid" resultType="Long">
      SELECT IFNULL(COUNT(tsh_id),0) FROM yeshi_ec_taobao_shop_history 
    WHERE tsh_uid = #{uid}
    WHERE tsh_uid = #{uid} AND tsh_state = 0
  </select>
  
   <select id="listByDevice" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_taobao_shop_history h
      LEFT JOIN `yeshi_ec_taobao_shop_info` p ON h.`tsh_shop_id` = p.`tsi_id`
    WHERE h.tsh_device = #{device}
    WHERE h.tsh_device = #{device} AND tsh_state = 0
    ORDER BY h.tsh_update_time DESC
    LIMIT ${start},${count}
  </select>
  
   <select id="countByDevice" resultType="Long">
      SELECT IFNULL(COUNT(tsh_id),0) FROM yeshi_ec_taobao_shop_history 
    WHERE tsh_device = #{device}
    WHERE tsh_device = #{device} AND tsh_state = 0
  </select>
  
  <select id="countByShopId" resultType="Long">
      SELECT IFNULL(COUNT(tsh_id),0) FROM `yeshi_ec_taobao_shop_history`
    WHERE tsh_shop_id = #{shopId}
    WHERE tsh_shop_id = #{shopId}
  </select>
  
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/TaoBaoShopHistoryServiceImpl.java
@@ -37,20 +37,18 @@
        
        if (uid == null || uid == 0) {
            for (String shopId:list) {
                taoBaoShopHistoryMapper.deleteByDevice(Long.parseLong(shopId), device);
                taoBaoShopHistoryMapper.updateByDevice(Long.parseLong(shopId), device);
            }
        } else {
            for (String shopId:list) {
                taoBaoShopHistoryMapper.deleteByUid(Long.parseLong(shopId), uid);
                taoBaoShopHistoryMapper.updateByUid(Long.parseLong(shopId), uid);
            }
        }
    }
    
    
    @Override
    public void addHistory(Long shopId, Long uid, String device) {
        TaoBaoShopHistory record = null;
        if (uid == null || uid == 0) {
            record = taoBaoShopHistoryMapper.getByDevice(shopId, device);
@@ -60,6 +58,7 @@
        
        if (record != null) {
            TaoBaoShopHistory update = new TaoBaoShopHistory();
            update.setState(0);
            update.setId(record.getId());
            update.setUpdateTime(new Date());
            taoBaoShopHistoryMapper.updateByPrimaryKeySelective(update);