admin
2019-05-06 8f45af9d6cdae97f4f265d2f2a123d990cf1bb1d
设备未读消息处理,分类BUG修改
12个文件已修改
9个文件已添加
908 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java 94 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/TaoBaoClassRelationMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/msg/MsgDeviceReadStateMapper.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgCommonDTO.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgDeviceReadState.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/common/Config.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/ConfigException.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/TaoBaoClassRelationMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/msg/MsgDeviceReadStateMapper.xml 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoClassServiceImpl.java 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgConfigServiceImpl.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserMsgReadStateServiceImpl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/config/ConfigService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/TaoBaoClassService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/MsgConfigService.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/MsgDeviceReadStateService.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/UserMsgReadStateService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
@@ -30,10 +30,12 @@
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
@@ -58,6 +60,8 @@
import com.yeshi.fanli.service.inter.homemodule.SpecialService;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
import com.yeshi.fanli.service.inter.msg.MsgAccountDetailService;
import com.yeshi.fanli.service.inter.msg.MsgConfigService;
import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
import com.yeshi.fanli.service.inter.msg.MsgMoneyDetailService;
import com.yeshi.fanli.service.inter.msg.MsgOrderDetailService;
@@ -140,6 +144,12 @@
    @Resource
    private DeviceActiveService deviceActiveService;
    @Resource
    private MsgConfigService msgConfigService;
    @Resource
    private MsgDeviceReadStateService msgDeviceReadStateService;
    // 消息的类型
    final static String MSG_TYPE_ORDER = "order";
@@ -574,6 +584,50 @@
            }
        }
        long currentTime = System.currentTimeMillis();
        // 返利券小助手
        MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
        if (zhuShouMsg != null) {
            boolean read = false;
            MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
                    UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
                    acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
            if (state != null && state.getReadTime() != null
                    && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
                read = true;
            // 查询是否已读
            if ((zhuShouMsg.getStartTime() != null && currentTime < zhuShouMsg.getStartTime().getTime())
                    || (zhuShouMsg.getEndTime() != null && currentTime > zhuShouMsg.getEndTime().getTime())) {
                // 不显示
            } else
                commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
                        zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
                        zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams()));
        }
        // 官宣任务
        if (uid != null) {
            MsgCommonDTO guanXuanMsg = msgConfigService.getGuanXuanMsg();
            if (guanXuanMsg != null) {
                boolean read = false;
                UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
                if (num != null && (num.getGuanXuanReadTime() != null
                        && guanXuanMsg.getUpdateTime().getTime() < num.getGuanXuanReadTime().getTime()))
                    read = true;
                // 查询是否已读
                if ((guanXuanMsg.getStartTime() != null && currentTime < guanXuanMsg.getStartTime().getTime())
                        || (guanXuanMsg.getEndTime() != null && currentTime > guanXuanMsg.getEndTime().getTime())) {
                    // 不显示
                } else
                    commonMsgList.add(new UserCommonMsgVO(guanXuanMsg.getIcon(), guanXuanMsg.getTitle(),
                            guanXuanMsg.getUpdateTime(), UserCommonMsgVO.TYPE_GUANXUAN, guanXuanMsg.getContent(), read,
                            guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams()));
            }
        }
        //
        // list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
@@ -784,6 +838,16 @@
            return;
        }
        // 初始化读取状态
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_RECOMMEND);
        msgDeviceReadStateService.initReadState(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_ZHUSHOU);
        // 设置设备消息所有已读
        msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
                "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
        int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
@@ -803,20 +867,28 @@
     * @param out
     */
    @RequestMapping(value = "readCommonMsg", method = RequestMethod.POST)
    public void readCommonMsg(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
    public void readCommonMsg(AcceptData acceptData, Long uid, String type, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseResult(2, "请上传type"));
            return;
        }
        if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_GUANXUAN)) {
            if (uid != null) {
        UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
        int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
                + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
        if (totalNum == 0) {
            out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
            return;
        } else
            userMsgReadStateService.setAllMsgRead(uid);
                UserMsgUnReadNum update = new UserMsgUnReadNum();
                update.setId(num.getId());
                update.setGuanXuanReadTime(new Date());
                update.setUpdateTime(new Date());
                userMsgReadStateService.updateSelective(update);
            }
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_RECOMMEND)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_ZHUSHOU)) {
            msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
                    (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/TaoBaoClassRelationMapper.java
@@ -7,11 +7,11 @@
public interface TaoBaoClassRelationMapper extends BaseMapper<TaoBaoClassRelation>{
    List<TaoBaoClassRelation> listByTaoBaoCid(Long taobaoCid);
    
    /**
     * 根据分类id查询
     *
     * @param taobaoCid
     * @return
     */
@@ -24,9 +24,17 @@
     */
    void deleteRelationByLocalCid(Long localCid);
    
    /**
     * 根据分类ID删除
     *
     * @param cid
     * @return
     */
    int deleteByCid(Long cid);
    
    /**
     * 根据子分类ID做删除
     *
     * @param subId
     * @return
     */
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/msg/MsgDeviceReadStateMapper.java
New file
@@ -0,0 +1,28 @@
package com.yeshi.fanli.dao.mybatis.msg;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
public interface MsgDeviceReadStateMapper extends BaseMapper<MsgDeviceReadState> {
    /**
     * 根据设备,设备类型,消息类型获取
     *
     * @param device
     * @param platform
     * @param type
     * @return
     */
    MsgDeviceReadState selectByDeviceAndPlatformAndType(@Param("device") String device, @Param("platform") int platform,
            @Param("type") String type);
    /**
     * 设置所有消息已读
     * @param device
     * @param platform
     */
    void setAllMsgRead(@Param("device") String device, @Param("platform") int platform);
}
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgCommonDTO.java
New file
@@ -0,0 +1,104 @@
package com.yeshi.fanli.dto.msg;
import java.util.Date;
import com.yeshi.fanli.entity.common.JumpDetailV2;
/**
 * 常规消息对象
 *
 * @author Administrator
 *
 */
public class MsgCommonDTO {
    private String contentMd5;// 内容的MD5值
    private String icon;
    private String title;
    private String content;// 内容
    private Boolean show;
    private Date startTime;// 开始时间
    private Date endTime;// 结束时间
    private JumpDetailV2 jumpDetail;// 跳转方式
    private String params;// 跳转参数
    private Date updateTime;
    public String getContentMd5() {
        return contentMd5;
    }
    public void setContentMd5(String contentMd5) {
        this.contentMd5 = contentMd5;
    }
    public String getIcon() {
        return icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Boolean getShow() {
        return show;
    }
    public void setShow(Boolean show) {
        this.show = show;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public JumpDetailV2 getJumpDetail() {
        return jumpDetail;
    }
    public void setJumpDetail(JumpDetailV2 jumpDetail) {
        this.jumpDetail = jumpDetail;
    }
    public String getParams() {
        return params;
    }
    public void setParams(String params) {
        this.params = params;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgDeviceReadState.java
New file
@@ -0,0 +1,96 @@
package com.yeshi.fanli.entity.bus.msg;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/*
 *设备消息状态存储
 */
@Table("yeshi_ec_msg_device_read_state")
public class MsgDeviceReadState {
    public static String TYPE_ZHUSHOU = "zhushou";// 返利券小助手
    public static String TYPE_RECOMMEND = "recommend";// 推荐
    @Column(name = "mdrs_id")
    private Long id;
    @Column(name = "mdrs_device")
    private String device;
    @Column(name = "mdrs_platform")
    private Integer platform;
    @Column(name = "mdrs_type")
    private String type;
    @Column(name = "mdrs_read_time")
    private Date readTime;
    @Column(name = "mdrs_unread_count")
    private Integer unReadCount;
    @Column(name = "mdrs_createtime")
    private Date createTime;
    @Column(name = "mdrs_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getDevice() {
        return device;
    }
    public void setDevice(String device) {
        this.device = device;
    }
    public Integer getPlatform() {
        return platform;
    }
    public void setPlatform(Integer platform) {
        this.platform = platform;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Date getReadTime() {
        return readTime;
    }
    public void setReadTime(Date readTime) {
        this.readTime = readTime;
    }
    public Integer getUnReadCount() {
        return unReadCount;
    }
    public void setUnReadCount(Integer unReadCount) {
        this.unReadCount = unReadCount;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/common/Config.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.entity.common;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -11,7 +13,11 @@
@Entity
@Table(name = "`yeshi_ec_config`")
@org.yeshi.utils.mybatis.Table("yeshi_ec_config")
public class Config {
public class Config implements Serializable{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
fanli/src/main/java/com/yeshi/fanli/exception/ConfigException.java
New file
@@ -0,0 +1,35 @@
package com.yeshi.fanli.exception;
public class ConfigException extends Exception {
    public final static int CODE_VERIFY = 1;
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public ConfigException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ConfigException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/TaoBaoClassRelationMapper.xml
@@ -28,6 +28,10 @@
        yeshi_ec_taobao_class_mapper where tm_system_sub_cid = #{0}
    </delete>
    
    <delete id="deleteByCid" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_class_mapper where tm_system_cid = #{0}
    </delete>
    
    <insert id="insert"
        parameterType="com.yeshi.fanli.entity.bus.clazz.TaoBaoClassRelation"
fanli/src/main/java/com/yeshi/fanli/mapping/msg/MsgDeviceReadStateMapper.xml
New file
@@ -0,0 +1,105 @@
<?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.msg.MsgDeviceReadStateMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState">
        <id column="mdrs_id" property="id" jdbcType="BIGINT" />
        <result column="mdrs_device" property="device" jdbcType="VARCHAR" />
        <result column="mdrs_platform" property="platform" jdbcType="INTEGER" />
        <result column="mdrs_type" property="type" jdbcType="VARCHAR" />
        <result column="mdrs_read_time" property="readTime" jdbcType="TIMESTAMP" />
        <result column="mdrs_unread_count" property="unReadCount"
            jdbcType="INTEGER" />
        <result column="mdrs_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
        <result column="mdrs_update_time" property="updateTime"
            jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">mdrs_id,mdrs_device,mdrs_platform,mdrs_type,mdrs_read_time,mdrs_unread_count,mdrs_create_time,mdrs_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_msg_device_read_state where mdrs_id =
        #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByDeviceAndPlatformAndType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_msg_device_read_state where mdrs_device=#{device} and
        mdrs_platform=#{platform} and mdrs_type=#{type}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_msg_device_read_state where mdrs_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_msg_device_read_state
        (mdrs_id,mdrs_device,mdrs_platform,mdrs_type,mdrs_read_time,mdrs_unread_count,mdrs_create_time,mdrs_update_time)
        values
        (#{id,jdbcType=BIGINT},#{device,jdbcType=VARCHAR},#{platform,jdbcType=INTEGER},#{type,jdbcType=VARCHAR},#{readTime,jdbcType=TIMESTAMP},#{unReadCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_msg_device_read_state
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">mdrs_id,</if>
            <if test="device != null">mdrs_device,</if>
            <if test="platform != null">mdrs_platform,</if>
            <if test="type != null">mdrs_type,</if>
            <if test="readTime != null">mdrs_read_time,</if>
            <if test="unReadCount != null">mdrs_unread_count,</if>
            <if test="createTime != null">mdrs_create_time,</if>
            <if test="updateTime != null">mdrs_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="device != null">#{device,jdbcType=VARCHAR},</if>
            <if test="platform != null">#{platform,jdbcType=INTEGER},</if>
            <if test="type != null">#{type,jdbcType=VARCHAR},</if>
            <if test="readTime != null">#{readTime,jdbcType=TIMESTAMP},</if>
            <if test="unReadCount != null">#{unReadCount,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.bus.msg.MsgDeviceReadState">update
        yeshi_ec_msg_device_read_state set mdrs_device =
        #{device,jdbcType=VARCHAR},mdrs_platform =
        #{platform,jdbcType=INTEGER},mdrs_type =
        #{type,jdbcType=VARCHAR},mdrs_read_time =
        #{readTime,jdbcType=TIMESTAMP},mdrs_unread_count =
        #{unReadCount,jdbcType=INTEGER},mdrs_create_time =
        #{createTime,jdbcType=TIMESTAMP},mdrs_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where mdrs_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState">
        update yeshi_ec_msg_device_read_state
        <set>
            <if test="device != null">mdrs_device=#{device,jdbcType=VARCHAR},</if>
            <if test="platform != null">mdrs_platform=#{platform,jdbcType=INTEGER},</if>
            <if test="type != null">mdrs_type=#{type,jdbcType=VARCHAR},</if>
            <if test="readTime != null">mdrs_read_time=#{readTime,jdbcType=TIMESTAMP},</if>
            <if test="unReadCount != null">mdrs_unread_count=#{unReadCount,jdbcType=INTEGER},</if>
            <if test="createTime != null">mdrs_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">mdrs_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where mdrs_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="setAllMsgRead">
        update yeshi_ec_msg_device_read_state
        mdrs_read_time=now(),mdrs_unread_count=0,mdrs_update_time=now()
        where mdrs_device=#{device} and
        mdrs_platform=#{platform}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java
@@ -184,4 +184,12 @@
        return get("home_float_notify_img");
    }
    @Override
    public void save(Config config) {
        List<Config> list = configMapper.listByKey(config.getKey());
        if (list == null || list.size() == 0) {
            configMapper.insertSelective(config);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java
@@ -209,10 +209,17 @@
        // 保存淘宝商品分类id
        String taobaoCids = record.getTaobaoCids();
        List<Long> tbCidList = new ArrayList<>();
        if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
            taoBaoClassService.save(record.getId(), taobaoCids);
            String[] sts = taobaoCids.split(",");
            for (String st : sts) {
                String cid = st.split("-")[st.split("-").length - 1].trim();
                tbCidList.add(Long.parseLong(cid));
        }
    }
        taoBaoClassService.save(record.getId(), tbCidList);
    }
    /**
     * 上传图片
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
import com.yeshi.fanli.service.inter.lable.LabelClassService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -205,6 +206,7 @@
            if (picture != null && picture.trim().length() > 0) {
                // 删除老图
                if (!Constant.IS_TEST)
                removePicture(resultObj.getPicture());
                // 存储新图
                record.setPicture(picture);
@@ -214,6 +216,7 @@
            if (pictureSecond != null && pictureSecond.trim().length() > 0) {
                // 删除老图
                if (!Constant.IS_TEST)
                removePicture(resultObj.getPictureSecond());
                // 存储新图
                record.setPictureSecond(pictureSecond);
@@ -233,15 +236,16 @@
        // 保存淘宝商品分类id
        String taobaoCids = record.getTaobaoCids();
        if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
            List<Long> tbCidList = new ArrayList<>();
        if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
            String[] sts = taobaoCids.split(",");
            for (String st : sts) {
                String cid = st.split("-")[st.split("-").length - 1];
                tbCidList.add(Long.parseLong(cid));
            }
            taoBaoClassService.saveSub(record.getId(), tbCidList);
        }
        taoBaoClassService.saveSub(record.getId(), tbCidList);
    }
    /**
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoClassServiceImpl.java
@@ -60,90 +60,31 @@
    @Override
    @Transactional
    public void save(Long classId, String taobaoCids) {
        if (StringUtil.isNullOrEmpty(taobaoCids) || "null".equalsIgnoreCase(taobaoCids)) {
    public void save(Long classId, List<Long> taobaoCids) {
        if (taobaoCids == null) {
            return;
        }
        List<Long> listId = new ArrayList<Long>();
        List<TaoBaoClass> listExist = taoBaoClassMapper.listBySystemCid(0, Integer.MAX_VALUE, classId);
        if (listExist != null && listExist.size() > 0) {
            for (TaoBaoClass taoBaoClass : listExist) {
                listId.add(taoBaoClass.getId());
            }
        }
        String[] array = taobaoCids.split(",");
        for (String info : array) {
            if (StringUtil.isNullOrEmpty(info)) {
        // 删除之前的,插入现在的
        taoBaoClassRelationMapper.deleteByCid(classId);
        for (Long categoryId : taobaoCids) {
            TaoBaoClass taoBaoClass = taoBaoClassMapper.getByCategoryId(Integer.parseInt(categoryId + ""));
            if (taoBaoClass == null)
                continue;
            }
            try {
                String[] taobaoArray = info.split("-");
                Integer categoryId = Integer.parseInt(taobaoArray[1]);
                if (listExist != null && listExist.size() > 0) {
                    for (int i = 0; i < listExist.size(); i++) {
                        TaoBaoClass taoBaoClass = listExist.get(i);
                        Integer categoryId2 = taoBaoClass.getCategoryId();
                        if (categoryId == categoryId2 || categoryId.equals(categoryId2)) {
                            if (listId.size() > 0) {
                                listId.remove(taoBaoClass.getId());
                                listExist.remove(i);
                                i--;
                            }
                        }
                    }
                }
                TaoBaoClass tbClass = taoBaoClassMapper.getByCategoryId(Integer.parseInt(taobaoArray[1]));
                if (tbClass == null) {
                    tbClass = new TaoBaoClass();
                    tbClass.setCategoryName(taobaoArray[0].trim());
                    tbClass.setCategoryId(Integer.parseInt(taobaoArray[1].trim()));
                    tbClass.setCreatetime(new Date());
                    tbClass.setUpdatetime(new Date());
                    taoBaoClassMapper.insert(tbClass);
                }
                TaoBaoClassRelation relation = taoBaoClassRelationMapper.getByLocalCid(tbClass.getId());
                if (relation != null) {
                    if (classId.equals(relation.getCid()) || classId == relation.getCid()) {
                        continue;
                    }
                    TaoBaoClassRelation updateRelation = new TaoBaoClassRelation();
                    updateRelation.setId(relation.getId());
                    updateRelation.setCid(classId);
                    updateRelation.setUpdatetime(new Date());
                    taoBaoClassRelationMapper.updateByPrimaryKeySelective(updateRelation);
                } else {
                    relation = new TaoBaoClassRelation();
            TaoBaoClassRelation relation = new TaoBaoClassRelation();
                    relation.setCid(classId);
                    relation.setTaobaoCid(tbClass.getId());
            relation.setTaobaoCid(taoBaoClass.getId());
                    relation.setCreatetime(new Date());
                    relation.setUpdatetime(new Date());
                    relation.setWeight(0.0);
                    taoBaoClassRelationMapper.insertSelective(relation);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (listId.size() > 0) {
            for (Long id : listId) {
                taoBaoClassMapper.deleteByPrimaryKey(id);
                taoBaoClassRelationMapper.deleteRelationByLocalCid(id);
            }
        }
    }
    @Transactional
    @Override
    public void saveSub(Long subClassId, List<Long> taobaoCids) {
        if (taobaoCids == null || taobaoCids.size() == 0) {
        if (taobaoCids == null) {
            return;
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgConfigServiceImpl.java
New file
@@ -0,0 +1,114 @@
package com.yeshi.fanli.service.impl.msg;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.entity.common.Config;
import com.yeshi.fanli.exception.ConfigException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.msg.MsgConfigService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@Service
public class MsgConfigServiceImpl implements MsgConfigService {
    @Resource
    private ConfigService configService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Override
    public void addZhuShouMsg(MsgCommonDTO dto) throws ConfigException {
        Config value = configService.getConfig(KEY_ZHUSHOU);
        if (StringUtil.isNullOrEmpty(dto.getContent()) || StringUtil.isNullOrEmpty(dto.getParams())
                || dto.getShow() == null)
            throw new ConfigException(1, "参数不完整");
        if (value != null) {
            MsgCommonDTO old = new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
            old.setStartTime(dto.getStartTime());
            old.setShow(dto.getShow());
            old.setParams(dto.getParams());
            old.setEndTime(dto.getEndTime());
            old.setContent(dto.getContent());
            if (!StringUtil.Md5(dto.getContent() + "#" + dto.getParams()).equalsIgnoreCase(old.getContentMd5())) {
                old.setUpdateTime(new Date());
            }
            Config cf = new Config();
            cf.setId(value.getId());
            cf.setValue(new Gson().toJson(old));
            configService.update(cf);
        } else {
            dto.setContentMd5(StringUtil.Md5(dto.getContent() + "#" + dto.getParams()));
            dto.setIcon("http://img.flqapp.com/resource/msg/icon_zhushou.png");
            dto.setTitle(Constant.systemCommonConfig.getProjectChineseName() + "小助手");
            dto.setUpdateTime(new Date());
            dto.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
            Config config = new Config();
            config.setCreatetime(System.currentTimeMillis() + "");
            config.setKey(KEY_ZHUSHOU);
            config.setName("消息-返利券小助手");
            config.setValue(new Gson().toJson(dto));
            configService.save(config);
        }
    }
    @Override
    public void addGuanXuanMsg(MsgCommonDTO dto) throws ConfigException {
        Config value = configService.getConfig(KEY_GUANXUAN);
        if (StringUtil.isNullOrEmpty(dto.getContent()) || StringUtil.isNullOrEmpty(dto.getParams())
                || dto.getShow() == null)
            throw new ConfigException(1, "参数不完整");
        if (value != null) {
            MsgCommonDTO old = new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
            old.setStartTime(dto.getStartTime());
            old.setShow(dto.getShow());
            old.setParams(dto.getParams());
            old.setEndTime(dto.getEndTime());
            old.setContent(dto.getContent());
            if (!StringUtil.Md5(dto.getContent() + "#" + dto.getParams()).equalsIgnoreCase(old.getContentMd5())) {
                old.setUpdateTime(new Date());
            }
            Config cf = new Config();
            cf.setId(value.getId());
            cf.setValue(new Gson().toJson(old));
            configService.update(cf);
        } else {
            dto.setContentMd5(StringUtil.Md5(dto.getContent() + "#" + dto.getParams()));
            dto.setIcon("http://img.flqapp.com/resource/msg/icon_guanxuan.png");
            dto.setTitle("官宣任务");
            dto.setUpdateTime(new Date());
            dto.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
            Config config = new Config();
            config.setCreatetime(System.currentTimeMillis() + "");
            config.setKey(KEY_GUANXUAN);
            config.setName("消息-官宣任务");
            config.setValue(new Gson().toJson(dto));
            configService.save(config);
        }
    }
    @Override
    public MsgCommonDTO getZhuShouMsg() {
        Config value = configService.getConfig(KEY_ZHUSHOU);
        if (value == null)
            return null;
        return new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
    }
    @Override
    public MsgCommonDTO getGuanXuanMsg() {
        Config value = configService.getConfig(KEY_GUANXUAN);
        if (value == null)
            return null;
        return new Gson().fromJson(value.getValue(), MsgCommonDTO.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java
New file
@@ -0,0 +1,89 @@
package com.yeshi.fanli.service.impl.msg;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.msg.MsgDeviceReadStateMapper;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
@Service
public class MsgDeviceReadStateServiceImpl implements MsgDeviceReadStateService {
    @Resource
    private MsgDeviceReadStateMapper msgDeviceReadStateMapper;
    @Override
    public void setDeviceMsgRead(String type, String device, int platform) {
        MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
        if (state != null) {
            MsgDeviceReadState update = new MsgDeviceReadState();
            update.setId(state.getId());
            update.setReadTime(new Date());
            update.setUnReadCount(0);
            update.setUpdateTime(new Date());
            msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount) {
        MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
        if (state != null) {
            MsgDeviceReadState update = new MsgDeviceReadState();
            update.setId(state.getId());
            update.setUnReadCount(state.getUnReadCount() + msgCount);
            update.setUpdateTime(new Date());
            msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
        } else {//
            state = new MsgDeviceReadState();
            state.setCreateTime(new Date());
            state.setDevice(device);
            state.setPlatform(platform);
            state.setType(type);
            state.setUnReadCount(msgCount);
            state.setUpdateTime(new Date());
            msgDeviceReadStateMapper.insertSelective(state);
        }
    }
    @Override
    public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform) {
        MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
        if (state == null) {
            state = new MsgDeviceReadState();
            state.setCreateTime(new Date());
            state.setDevice(device);
            state.setPlatform(platform);
            state.setType(type);
            state.setUnReadCount(0);
            state.setUpdateTime(new Date());
            msgDeviceReadStateMapper.insertSelective(state);
        }
        return state;
    }
    @Override
    public void setAllMsgRead(String device, int platform) {
        msgDeviceReadStateMapper.setAllMsgRead(device, platform);
    }
    @Override
    public void initReadState(String device, int platform, String type) {
        MsgDeviceReadState state = getByDeviceAndPlatformAndType(type, device, platform);
        if (state == null) {
            state = new MsgDeviceReadState();
            state.setCreateTime(new Date());
            state.setDevice(device);
            state.setPlatform(platform);
            state.setReadTime(null);
            state.setType(type);
            state.setUnReadCount(0);
            msgDeviceReadStateMapper.insertSelective(state);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserMsgReadStateServiceImpl.java
@@ -194,6 +194,7 @@
        update.setTypeSystem(0);
        update.setTypeOrder(0);
        update.setUpdateTime(new Date());
        update.setGuanXuanReadTime(new Date());
        userMsgUnReadNumMapper.updateByPrimaryKeySelective(update);
        readAccountMsg(uid);
        readOrderMsg(uid);
@@ -214,6 +215,10 @@
        userMsgUnReadNumMapper.updateByPrimaryKeySelective(update);
    }
    @Override
    public void updateSelective(UserMsgUnReadNum num) {
        if (num != null)
            userMsgUnReadNumMapper.updateByPrimaryKeySelective(num);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/config/ConfigService.java
@@ -15,6 +15,8 @@
    void update(List<Config> list);
    void update(Config config);
    void save(Config config);
    String get(String string);
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/TaoBaoClassService.java
@@ -28,7 +28,7 @@
     * @param classId
     * @param taobaoCids
     */
    public void save(Long classId, String taobaoCids);
    public void save(Long classId, List<Long> taobaoCids);
    
    /**
     * 保存二级分类
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/MsgConfigService.java
New file
@@ -0,0 +1,38 @@
package com.yeshi.fanli.service.inter.msg;
import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.exception.ConfigException;
public interface MsgConfigService {
    public String KEY_ZHUSHOU = "msg-config-zhushou";
    public String KEY_GUANXUAN = "msg-config-guanxuan";
    /**
     * 添加小助手消息
     *
     * @param dto
     */
    public void addZhuShouMsg(MsgCommonDTO dto) throws ConfigException;
    /**
     * 添加官宣任务
     *
     * @param dto
     */
    public void addGuanXuanMsg(MsgCommonDTO dto) throws ConfigException;
    /**
     * 获取助手消息
     *
     * @return
     */
    public MsgCommonDTO getZhuShouMsg();
    /**
     * 获取官宣消息
     *
     * @return
     */
    public MsgCommonDTO getGuanXuanMsg();
}
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/MsgDeviceReadStateService.java
New file
@@ -0,0 +1,58 @@
package com.yeshi.fanli.service.inter.msg;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
/**
 * 设备消息阅读状态服务
 *
 * @author Administrator
 *
 */
public interface MsgDeviceReadStateService {
    /**
     * 查询对象
     *
     * @param type
     * @param device
     * @param platform
     * @return
     */
    public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform);
    /**
     * 设置设备消息已读
     *
     * @param type
     * @param device
     * @param platform
     */
    public void setDeviceMsgRead(String type, String device, int platform);
    /**
     * 添加设备未读消息
     *
     * @param type
     * @param device
     * @param platform
     * @param msgCount
     */
    public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount);
    /**
     * 设置所有消息已读
     *
     * @param device
     * @param platform
     */
    public void setAllMsgRead(String device, int platform);
    /**
     * 初始化读取状态
     *
     * @param device
     * @param platform
     */
    public void initReadState(String device, int platform, String type);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/UserMsgReadStateService.java
@@ -52,11 +52,11 @@
    
    /**
     * 增加其他消息未读数
     *
     * @param uid
     * @param count
     */
    public void addOtherMsgUnReadCount(Long uid, int count);
    /**
     * 获取用户所有未读消息数
@@ -110,7 +110,15 @@
    
    /**
     * 读其他消息
     *
     * @param uid
     */
    public void readOtherMsg(Long uid);
    /**
     * 修改
     *
     * @param num
     */
    public void updateSelective(UserMsgUnReadNum num);
}