Authored by csgyoho

新用户引导消息

package com.yohoufo.common.enums;
/**
* Created by shengguo.cai on 2018/9/12.
*/
public enum InboxBusinessTypeEnum {
PURCHASE_UNPAID(0,0, "未付款提醒", "您的订单{}尚未支付,请尽快完成订单支付"),
PURCHASE_NOTIFIED_SELLER(0,1, "已通知卖家发货", "您的订单{},卖家将在48小时内发货,请耐心等待"),
PURCHASE_SENDED(0,2, "平台已发货", "您的订单{},平台已发货,请关注物流详情"),
PURCHASE_CLOSED_SELLER(0,3, "交易关闭", "您的订单{},卖家取消商品出售,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡"),
PURCHASE_CLOSED_BUYER(0,4, "交易关闭", "您已取消订单{}"),
PURCHASE_CLOSED_PLATFORM(0,5, "交易关闭", "您的订单{}包含商品,鉴定不通过:您购买的商品未通过平台鉴定,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡"),
SALE_SHELF(1,0, "上架成功", "您的商品{}上架成功"),
SALE_UNSHELF(1,1, "下架成功", "您的商品{}下架成功,保证金将于1个工作日内退回您的支付账户"),
SALE_SELLED(1,2, "商品售出提醒", "您的商品{}已被下单,请关注发货提醒"),
SALE_SEND(1,3, "发货提醒", "您的商品{}买家已付款,请于48小时内完成发货,否则您支付的保证金将作为补偿赔付给买家"),
SALE_CLOSED_SELLER(1,4, "交易关闭", "您已取消{}出售,您支付的保证金已作为补偿赔付给买家"),
SALE_CLOSED_BUYER(1,5, "交易关闭", "买家取消订单,您的商品{}已重新上架出售"),
SALE_CLOSED_PLATFORM(1,6, "交易关闭", "您出售的商品{}鉴定未通过,商品已寄回您提供的收货地址,您支付的保证金已作为补偿赔付给买家"),
SALE_NOTIFIED_UNSHELF(1,7, "商品下架提醒", "因为特殊原因,商品{}暂停售卖,您支付的保证金将于1个工作日内退回您的支付账户"),
SYSTEM_NEWUSER(2,0, "新用户引导", "欢迎使用UFO,详情使用说明请点击"),
SYSTEM_VERIFED(2,1, "实名认证提醒", "请尽快完成实名认证,详情请点击"),
SYSTEM_BINDBANK(2,2, "绑定银行卡提醒", "请尽快绑定银行卡,详情请点击"),
SMS_SEND(3,0, "平台已发货", "您的订单平台已发货,请进入UFO飞碟好物查看物流详情"),
SMS_CLOSED_SELLER(3,1, "交易关闭", "卖家取消{}出售,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡"),
SMS_CLOSED_PLATFORM(3,2, "交易关闭", "鉴定不通过:您购买的商品{}未通过平台鉴定,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡"),
SMS_NOTIFIED_SEND(3,3, "发货提醒", "您的商品{}买家已付款,请尽快完成发货,否则会扣除部分保证金"),
SMS_NOTIFIED_UNSHELF(3,4, "商品下架提醒", "因为特殊原因,您的商品{}暂停售卖,您支付的保证金将于1个工作日内退回您的支付账户");
private Integer businessType;
private String title;
private String content;
private Integer type;
InboxBusinessTypeEnum(Integer type, Integer businessType, String title, String content) {
this.businessType = businessType;
this.title = title;
this.content = content;
this.type = type;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public static InboxBusinessTypeEnum getByTypeAndBusinessType(Integer type,Integer businessType){
InboxBusinessTypeEnum[] emums = values();
for(InboxBusinessTypeEnum cell : emums){
if(cell.getBusinessType().equals(businessType) && cell.getType().equals(type)) {
return cell;
}
}
return null;
}
public Integer getBusinessType() {
return businessType;
}
public void setBusinessType(Integer businessType) {
this.businessType = businessType;
}
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;
}
}
package com.yohoufo.common.enums;
/**
* Created by shengguo.cai on 2018/9/12.
*/
public enum InboxTypeEnum {
PURCHASE(0,"购买消息","http://img11.static.yhbimg.com/goodsimg/2018/03/20/16/01431f2cdf13d21dfa4a11222b97bfae87.png"),
SALE(1,"出售消息","http://img11.static.yhbimg.com/goodsimg/2018/03/20/16/01b354a22d8cf5227a536096cf86315b90.png"),
SYSTEM(2,"系统消息","http://img11.static.yhbimg.com/goodsimg/2018/03/20/16/013ca7e60c8953782d3b3417f0b9a6a596.png");
private Integer id;
private String description;
private String imgUrl;
private InboxTypeEnum(Integer id, String description, String imgUrl){
this.id = id;
this.description = description;
this.imgUrl = imgUrl;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
}
... ... @@ -23,4 +23,6 @@ public interface IInBoxDao {
void updateReadedByUidAndType(@Param("tableName")String tableName,@Param("uid") int uid, @Param("type")Integer type, @Param("readTime")int readTime);
void insertInbox(@Param("tableName")String tableName, @Param("inBox")InBox inBox);
InBox selectNewUserGuideInBox(@Param("tableName")String tableName, @Param("businessType") Integer businessType, @Param("uid") Integer uid);
}
... ...
... ... @@ -52,4 +52,10 @@
and type=#{type}
</if>
</select>
<select id="selectNewUserGuideInBox" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} where uid = #{uid} and business_type = #{businessType}
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -88,6 +88,12 @@
<artifactId>order-ufo-model</artifactId>
<version>${model.version}</version>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>user-ufo-model</artifactId>
<version>${model.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
... ...
... ... @@ -18,7 +18,10 @@
<groupId>com.yohoufo.fore</groupId>
<artifactId>yohoufo-fore-dal</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>user-ufo-model</artifactId>
</dependency>
<dependency>
<groupId>com.yohoufo.fore</groupId>
<artifactId>yohoufo-fore-common</artifactId>
... ...
... ... @@ -6,8 +6,8 @@ import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.enums.InboxBusinessTypeEnum;
import com.yohoufo.common.enums.InboxTypeEnum;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.enums.InboxTypeEnum;
import com.yohoufo.common.redis.NoSyncGracefulRedisTemplate;
import com.yohoufo.dal.user.IInBoxDao;
import com.yohoufo.dal.user.model.InBox;
... ... @@ -58,9 +58,31 @@ public class InBoxServiceImpl implements IInBoxService {
result.add(obj);
}
setInboxTypeInfoByRedis(uid,result);
//添加新用户引导消息
addNewUserGuideMessage(uid);
return result;
}
private void addNewUserGuideMessage(Integer uid) {
log.info("enter addNewUserGuideMessage. uid is {}",uid);
try{
InBox inbox = inBoxDao.selectNewUserGuideInBox(getTableName(uid),InboxBusinessTypeEnum.SYSTEM_NEWUSER.getBusinessType(),uid);
if(inbox != null){
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
addInbox(uid,InboxBusinessTypeEnum.SYSTEM_NEWUSER.getType(),InboxBusinessTypeEnum.SYSTEM_NEWUSER.getBusinessType(),null);
}
};
Thread thread = new Thread(runnable);
thread.start();
}catch (Exception exp){
log.warn("addNewUserGuideMessage error! uid is {} exp is {}",uid,exp);
}
}
private void setInboxTypeInfoByRedis(Integer uid, JSONArray inboxs) {
for(int i=0;i<inboxs.size();i++){
Integer unReadCount = inboxs.getJSONObject(i).getInteger("unReadCount");
... ...