| | |
| | | final static String MSG_TYPE_MONEY = "money";
|
| | | final static String MSG_TYPE_ACCOUNT = "account";
|
| | | final static String MSG_TYPE_INVITE = "invite";
|
| | | final static String MSG_TYPE_OTHER = "other";
|
| | |
|
| | | /**
|
| | | * 获取订单消息列表
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.msg; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail; |
| | | |
| | | public interface MsgOtherDetailMapper extends BaseMapper<MsgOtherDetail> { |
| | | |
| | | /** |
| | | * 通过用户ID查询列表 |
| | | * |
| | | * @param uid |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<MsgOtherDetail> listByUid(@Param("uid") Long uid, @Param("start") long start, @Param("count") int count); |
| | | |
| | | /** |
| | | * 查询用户的消息数量 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countByUid(@Param("uid") Long uid); |
| | | |
| | | /** |
| | | * 设置消息已读 |
| | | * |
| | | * @param uid |
| | | */ |
| | | void setMsgReadByUid(Long uid); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dto.msg;
|
| | |
|
| | | /**
|
| | | * 其他消息里面的券相关的内容
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class MsgOtherCouponContentDTO {
|
| | | private String state;
|
| | | private String source;// 来源
|
| | | private String startTime;
|
| | | private String endTime;
|
| | | private Integer leftDay;
|
| | |
|
| | | public String getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(String state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public String getSource() {
|
| | | return source;
|
| | | }
|
| | |
|
| | | public void setSource(String source) {
|
| | | this.source = source;
|
| | | }
|
| | |
|
| | | public String getStartTime() {
|
| | | return startTime;
|
| | | }
|
| | |
|
| | | public void setStartTime(String startTime) {
|
| | | this.startTime = startTime;
|
| | | }
|
| | |
|
| | | public String getEndTime() {
|
| | | return endTime;
|
| | | }
|
| | |
|
| | | public void setEndTime(String endTime) {
|
| | | this.endTime = endTime;
|
| | | }
|
| | |
|
| | | public Integer getLeftDay() {
|
| | | return leftDay;
|
| | | }
|
| | |
|
| | | public void setLeftDay(Integer leftDay) {
|
| | | this.leftDay = leftDay;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public class MsgMoneyDetail {
|
| | | public enum MsgTypeMoneyTypeEnum {
|
| | | share("分享奖金"), invite("邀请奖金"), fanli("返利到账"), extract("提现"), extractValid("提现账号验证"), shareWeiQuan(
|
| | | "分享奖金扣除"), inviteWeiQuan("邀请奖金扣除"), fanliWeiQuan("返利扣除"),orderReward("奖励订单");
|
| | | "分享奖金扣除"), inviteWeiQuan("邀请奖金扣除"), fanliWeiQuan("返利扣除"),orderReward("返利奖励");
|
| | | private final String desc;
|
| | |
|
| | | private MsgTypeMoneyTypeEnum(String desc) {
|
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.msg;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
|
| | | /**
|
| | | * 账号
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_msg_other")
|
| | | public class MsgOtherDetail {
|
| | | public enum MsgTypeOtherTypeEnum {
|
| | | couponMianDan("免单券"), couponWelfareMianDan("福利免单券"), couponReward("奖励券");
|
| | | private final String desc;
|
| | |
|
| | | private MsgTypeOtherTypeEnum(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
| | |
|
| | | @Column(name = "mo_id")
|
| | | private Long id;
|
| | | @Column(name = "mo_uid")
|
| | | private UserInfo user;
|
| | | @Column(name = "mo_type")
|
| | | private MsgTypeOtherTypeEnum type;// 类型
|
| | | @Column(name = "mo_content")
|
| | | private String content;// 状态
|
| | | @Column(name = "mo_beizhu")
|
| | | private String beiZhu;// 备注
|
| | | @Column(name = "mo_read")
|
| | | private Boolean read;
|
| | | @Column(name = "mo_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "mo_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | // 券内容
|
| | | private MsgOtherCouponContentDTO coupnContent;
|
| | |
|
| | | public MsgOtherCouponContentDTO getCoupnContent() {
|
| | | return coupnContent;
|
| | | }
|
| | |
|
| | | public void setCoupnContent(MsgOtherCouponContentDTO coupnContent) {
|
| | | this.coupnContent = coupnContent;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Boolean getRead() {
|
| | | return read;
|
| | | }
|
| | |
|
| | | public void setRead(Boolean read) {
|
| | | this.read = read;
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | public UserInfo getUser() {
|
| | | return user;
|
| | | }
|
| | |
|
| | | public void setUser(UserInfo user) {
|
| | | this.user = user;
|
| | | }
|
| | |
|
| | | public String getContent() {
|
| | | return content;
|
| | | }
|
| | |
|
| | | public void setContent(String content) {
|
| | | this.content = content;
|
| | | }
|
| | |
|
| | | public MsgTypeOtherTypeEnum getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(MsgTypeOtherTypeEnum type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | | }
|
| | |
| | | @Expose
|
| | | @Column(name = "mrs_type_system")
|
| | | private Integer typeSystem;// 系统消息未读数
|
| | | @Expose
|
| | | @Column(name = "mrs_type_other")
|
| | | private Integer typeOther;// 其他消息
|
| | |
|
| | | @Column(name = "mrs_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "mrs_update_time")
|
| | |
| | | this.user = user;
|
| | | }
|
| | |
|
| | | public Integer getTypeOther() {
|
| | | return typeOther;
|
| | | }
|
| | |
|
| | | public void setTypeOther(Integer typeOther) {
|
| | | this.typeOther = typeOther;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.msg; |
| | | |
| | | public class MsgOtherDetailException extends Exception { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public MsgOtherDetailException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public MsgOtherDetailException() { |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return this.msg; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?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.MsgOtherDetailMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.msg.MsgOtherDetail"> |
| | | <id column="mo_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="mo_type" property="type" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.msg.MsgTypeOtherTypeEnumHandler" /> |
| | | <result column="mo_content" property="content" jdbcType="VARCHAR" /> |
| | | <result column="mo_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="mo_read" property="read" jdbcType="BOOLEAN" /> |
| | | <result column="mo_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="mo_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <association property="user" column="mo_uid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="mo_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">mo_id,mo_uid,mo_type,mo_content,mo_beizhu,mo_read,mo_create_time,mo_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_msg_other where mo_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByUid" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_msg_other where mo_uid = #{uid,jdbcType=BIGINT} order by |
| | | mo_create_time desc limit #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="countByUid" resultType="java.lang.Long" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | count(mo_id) |
| | | from yeshi_ec_msg_other where mo_uid = |
| | | #{uid,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_msg_other where mo_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.msg.MsgOtherDetail" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_msg_other |
| | | (mo_id,mo_uid,mo_type,mo_content,mo_beizhu,mo_read,mo_create_time,mo_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{read,jdbcType=BOOLEAN},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgOtherDetail" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_msg_other |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">mo_id,</if> |
| | | <if test="user != null">mo_uid,</if> |
| | | <if test="type != null">mo_type,</if> |
| | | <if test="content != null">mo_content,</if> |
| | | <if test="beiZhu != null">mo_beizhu,</if> |
| | | <if test="read != null">mo_read,</if> |
| | | <if test="createTime != null">mo_create_time,</if> |
| | | <if test="updateTime != null">mo_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="user != null">#{user.id,jdbcType=BIGINT},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="content != null">#{content,jdbcType=VARCHAR},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="read != null">#{read,jdbcType=BOOLEAN},</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.MsgOtherDetail">update |
| | | yeshi_ec_msg_other set mo_uid = #{user.id,jdbcType=BIGINT},mo_type = |
| | | #{type,jdbcType=VARCHAR},mo_content = |
| | | #{content,jdbcType=VARCHAR},mo_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},mo_read = |
| | | #{read,jdbcType=BOOLEAN},mo_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},mo_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where mo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgOtherDetail"> |
| | | update yeshi_ec_msg_other |
| | | <set> |
| | | <if test="user != null">mo_uid=#{user.id,jdbcType=BIGINT},</if> |
| | | <if test="type != null">mo_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="content != null">mo_content=#{content,jdbcType=VARCHAR},</if> |
| | | <if test="beiZhu != null">mo_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="read != null">mo_read=#{read,jdbcType=BOOLEAN},</if> |
| | | <if test="createTime != null">mo_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">mo_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where mo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <update id="setMsgReadByUid" parameterType="java.lang.Long"> |
| | | update |
| | | yeshi_ec_msg_other |
| | | set mo_read=1 |
| | | where mo_uid = #{uid,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | <result column="mrs_type_score" property="typeScore" jdbcType="INTEGER" /> |
| | | <result column="mrs_type_system" property="typeSystem" |
| | | jdbcType="INTEGER" /> |
| | | <result column="mrs_type_other" property="typeOther" jdbcType="INTEGER" /> |
| | | <result column="mrs_create_time" property="createTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="mrs_update_time" property="updateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <association property="user" column="mrs_uid" javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <association property="user" column="mrs_uid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="mrs_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">mrs_id,mrs_uid,mrs_type_order,mrs_type_money,mrs_type_account,mrs_type_invite,mrs_type_score,mrs_type_system,mrs_create_time,mrs_update_time |
| | | <sql id="Base_Column_List">mrs_id,mrs_uid,mrs_type_order,mrs_type_money,mrs_type_account,mrs_type_invite,mrs_type_score,mrs_type_system,mrs_type_other,mrs_create_time,mrs_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.msg.UserMsgUnReadNum" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_msg_read_state |
| | | (mrs_id,mrs_uid,mrs_type_order,mrs_type_money,mrs_type_account,mrs_type_invite,mrs_type_score,mrs_type_system,mrs_create_time,mrs_update_time) |
| | | (mrs_id,mrs_uid,mrs_type_order,mrs_type_money,mrs_type_account,mrs_type_invite,mrs_type_score,mrs_type_system,mrs_type_other,mrs_create_time,mrs_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{typeOrder,jdbcType=INTEGER},#{typeMoney,jdbcType=INTEGER},#{typeAccount,jdbcType=INTEGER},#{typeInvite,jdbcType=INTEGER},#{typeScore,jdbcType=INTEGER},#{typeSystem,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{typeOrder,jdbcType=INTEGER},#{typeMoney,jdbcType=INTEGER},#{typeAccount,jdbcType=INTEGER},#{typeInvite,jdbcType=INTEGER},#{typeScore,jdbcType=INTEGER},#{typeSystem,jdbcType=INTEGER},#{typeOther,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.msg.UserMsgUnReadNum" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | |
| | | <if test="typeInvite != null">mrs_type_invite,</if> |
| | | <if test="typeScore != null">mrs_type_score,</if> |
| | | <if test="typeSystem != null">mrs_type_system,</if> |
| | | <if test="typeOther != null">mrs_type_other,</if> |
| | | <if test="createTime != null">mrs_create_time,</if> |
| | | <if test="updateTime != null">mrs_update_time,</if> |
| | | </trim> |
| | |
| | | <if test="typeInvite != null">#{typeInvite,jdbcType=INTEGER},</if> |
| | | <if test="typeScore != null">#{typeScore,jdbcType=INTEGER},</if> |
| | | <if test="typeSystem != null">#{typeSystem,jdbcType=INTEGER},</if> |
| | | <if test="typeOther != null">#{typeOther,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | |
| | | #{typeAccount,jdbcType=INTEGER},mrs_type_invite = |
| | | #{typeInvite,jdbcType=INTEGER},mrs_type_score = |
| | | #{typeScore,jdbcType=INTEGER},mrs_type_system = |
| | | #{typeSystem,jdbcType=INTEGER},mrs_create_time = |
| | | #{typeSystem,jdbcType=INTEGER},mrs_type_other = |
| | | #{typeOther,jdbcType=INTEGER},mrs_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},mrs_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where mrs_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | <if test="typeInvite != null">mrs_type_invite=#{typeInvite,jdbcType=INTEGER},</if> |
| | | <if test="typeScore != null">mrs_type_score=#{typeScore,jdbcType=INTEGER},</if> |
| | | <if test="typeSystem != null">mrs_type_system=#{typeSystem,jdbcType=INTEGER},</if> |
| | | <if test="typeOther != null">mrs_type_other=#{typeOther,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">mrs_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">mrs_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | |
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.orderReward) {
|
| | | if (detail.getMoney() == null || detail.getOrderId() == null || detail.getBalance() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | }
|
| | |
|
| | | userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.msg;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgOtherDetailMapper;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | | import com.yeshi.fanli.exception.msg.MsgOtherDetailException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgOtherDetailService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class MsgOtherDetailServiceImpl implements MsgOtherDetailService {
|
| | |
|
| | | @Resource
|
| | | private MsgOtherDetailMapper msgOtherDetailMapper;
|
| | |
|
| | | @Override
|
| | | public void addMsgOtherDetail(MsgOtherDetail detail) throws MsgOtherDetailException {
|
| | |
|
| | | if (detail.getType() == MsgTypeOtherTypeEnum.couponMianDan
|
| | | || detail.getType() == MsgTypeOtherTypeEnum.couponReward
|
| | | || detail.getType() == MsgTypeOtherTypeEnum.couponWelfareMianDan) {
|
| | | if (detail.getCoupnContent() == null)
|
| | | throw new MsgOtherDetailException(1, "内容为空");
|
| | | detail.setContent(new Gson().toJson(detail.getCoupnContent()));
|
| | | detail.setCreateTime(new Date());
|
| | | msgOtherDetailMapper.insertSelective(detail);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateMsgOtherDetail(MsgOtherDetail detail) throws MsgOtherDetailException {
|
| | | if (detail.getType() == MsgTypeOtherTypeEnum.couponMianDan
|
| | | || detail.getType() == MsgTypeOtherTypeEnum.couponReward
|
| | | || detail.getType() == MsgTypeOtherTypeEnum.couponWelfareMianDan) {
|
| | | if (detail.getId() == null)
|
| | | throw new MsgOtherDetailException(2, "主键为空");
|
| | | if (detail.getCoupnContent() == null)
|
| | | throw new MsgOtherDetailException(1, "内容为空");
|
| | | detail.setContent(new Gson().toJson(detail.getCoupnContent()));
|
| | | detail.setUpdateTime(new Date());
|
| | | msgOtherDetailMapper.updateByPrimaryKeySelective(detail);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MsgOtherDetail> listMsgOtherDetail(Long uid, int page) {
|
| | | return msgOtherDetailMapper.listByUid(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countMsgOtherDetail(Long uid) {
|
| | | return msgOtherDetailMapper.countByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void readMsgByUid(Long uid) {
|
| | | msgOtherDetailMapper.setMsgReadByUid(uid);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.msg;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
|
| | | import com.yeshi.fanli.exception.msg.MsgOtherDetailException;
|
| | |
|
| | | public interface MsgOtherDetailService {
|
| | | /**
|
| | | * 添加到订单消息
|
| | | * |
| | | * @param detail
|
| | | * @throws MsgOtherDetailException
|
| | | */
|
| | | public void addMsgOtherDetail(MsgOtherDetail detail) throws MsgOtherDetailException;
|
| | |
|
| | | /**
|
| | | * 根据订单号用户ID更新数据
|
| | | * |
| | | * @param detail
|
| | | * @throws MsgOtherDetailException
|
| | | */
|
| | | public void updateMsgOtherDetail(MsgOtherDetail detail) throws MsgOtherDetailException;
|
| | |
|
| | | /**
|
| | | * 订单消息列表
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @return
|
| | | */
|
| | | public List<MsgOtherDetail> listMsgOtherDetail(Long uid, int page);
|
| | |
|
| | | /**
|
| | | * 订单消息数
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countMsgOtherDetail(Long uid);
|
| | |
|
| | | /**
|
| | | * 设置所有消息已读
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void readMsgByUid(Long uid);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory.msg;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | public class MsgOtherCouponContentDTOFactory {
|
| | |
|
| | | private static MsgOtherCouponContentDTO getGeneral(Integer leftDay, String source, Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = new MsgOtherCouponContentDTO();
|
| | | if (endTime != null)
|
| | | dto.setEndTime(TimeUtil.getGernalTime(endTime.getTime(), "yyyy.MM.dd HH:mm"));
|
| | | if (startTime != null)
|
| | | dto.setStartTime(TimeUtil.getGernalTime(startTime.getTime(), "yyyy.MM.dd HH:mm"));
|
| | | dto.setLeftDay(leftDay);
|
| | | dto.setSource(source);
|
| | | return dto;
|
| | | }
|
| | |
|
| | | // 福利奖励券
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponGet(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("成功获得");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponActive(Integer leftDay, Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, "成功邀请1个队员", startTime, endTime);
|
| | | dto.setState("已被激活");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponUsing(Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(null, "成功邀请1个队员", startTime, endTime);
|
| | | dto.setState("使用中,等待系统同步订单");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponUsed(Integer leftDay, Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, "成功邀请1个队员", startTime, endTime);
|
| | | dto.setState("已被使用");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponWillOutOfDate(Integer leftDay, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, "成功邀请1个队员", startTime, endTime);
|
| | | dto.setState("即将过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createWelfareCouponAlreadyOutOfDate(Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(0, "成功邀请1个队员", startTime, endTime);
|
| | | dto.setState("已经过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | // 免单券
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponGet(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("成功获得");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponActive(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("已被激活");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponUsing(String source, Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(null, source, startTime, endTime);
|
| | | dto.setState("使用中,等待系统同步订单");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponUsed(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("已被使用");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponWillOutOfDate(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("即将过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createCouponAlreadyOutOfDate(String source, Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(0, source, startTime, endTime);
|
| | | dto.setState("已经过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | // 奖励券
|
| | |
|
| | | public static MsgOtherCouponContentDTO createRewardCouponGet(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("成功获得");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createRewardCouponActive(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("已被激活");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createRewardCouponUsed(Integer leftDay, String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("已被使用");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createRewardCouponWillOutOfDate(Integer leftDay, String source,
|
| | | Date startTime, Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(leftDay, source, startTime, endTime);
|
| | | dto.setState("即将过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static MsgOtherCouponContentDTO createRewardCouponAlreadyOutOfDate(String source, Date startTime,
|
| | | Date endTime) {
|
| | | MsgOtherCouponContentDTO dto = getGeneral(0, source, startTime, endTime);
|
| | | dto.setState("已经过期");
|
| | | return dto;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory.msg;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
|
| | | public class MsgOtherDetailFactory {
|
| | |
|
| | | /**
|
| | | * 返利订单
|
| | | * |
| | | * @param uid
|
| | | * @param orderId
|
| | | * @param goodsCount
|
| | | * @param orderState
|
| | | * @param payMoney
|
| | | * @param money
|
| | | * @param state
|
| | | * @param beiZhu
|
| | | * @return
|
| | | */
|
| | | public static MsgOtherDetail createFanLiOrder(Long uid, MsgOtherCouponContentDTO content, MsgTypeOtherTypeEnum type,
|
| | | String beiZhu) {
|
| | | if (uid == null)
|
| | | return null;
|
| | | MsgOtherDetail detail = new MsgOtherDetail();
|
| | | detail.setBeiZhu(beiZhu);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | detail.setCoupnContent(content);
|
| | | return detail;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.util.List;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_invite_money.png",
|
| | | msg.getMsgType().getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.orderReward) {//奖励订单
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.orderReward) {// 奖励订单
|
| | | contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("奖励订单", COLOR_TITLE), contentList));
|
| | |
|
| | |
| | | msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 其他消息
|
| | | * |
| | | * @param msg
|
| | | * @return
|
| | | */
|
| | | public static UserMsgVO create(MsgOtherDetail msg) {
|
| | | List<CommonMsgItemVO> items = new ArrayList<>();
|
| | | if (msg.getType() == MsgTypeOtherTypeEnum.couponMianDan
|
| | | || msg.getType() == MsgTypeOtherTypeEnum.couponWelfareMianDan
|
| | | || msg.getType() == MsgTypeOtherTypeEnum.couponReward) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(msg.getContent()))
|
| | | return null;
|
| | | MsgOtherCouponContentDTO dto = new Gson().fromJson(msg.getContent(), MsgOtherCouponContentDTO.class);
|
| | | if (dto == null)
|
| | | return null;
|
| | |
|
| | | List<ClientTextStyleVO> contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getState(), COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(dto.getSource())) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getSource() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("来源", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(dto.getStartTime()) && !StringUtil.isNullOrEmpty(dto.getEndTime())) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getStartTime() + "-" + dto.getEndTime(), COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("有效期", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | if (dto.getLeftDay() != null) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getLeftDay() + "", COLOR_HIGHLIGHT_CONTENT));
|
| | | contentList.add(new ClientTextStyleVO("天", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("剩余天数", COLOR_TITLE), contentList));
|
| | | }
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
|
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_invite.png", msg.getType().getDesc(),
|
| | | msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.mybatishandler.msg;
|
| | |
|
| | | import java.sql.CallableStatement;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import org.apache.ibatis.type.BaseTypeHandler;
|
| | | import org.apache.ibatis.type.JdbcType;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | |
|
| | | public class MsgTypeOtherTypeEnumHandler extends BaseTypeHandler<MsgTypeOtherTypeEnum> {
|
| | |
|
| | | @Override
|
| | | public MsgTypeOtherTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | return MsgTypeOtherTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public MsgTypeOtherTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return MsgTypeOtherTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public MsgTypeOtherTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return MsgTypeOtherTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, MsgTypeOtherTypeEnum arg2, JdbcType arg3)
|
| | | throws SQLException {
|
| | | arg0.setString(arg1, arg2.name());
|
| | | }
|
| | |
|
| | | }
|