From 055fb8d085efd7e120d69aba6c0fbb8db5867553 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 01 七月 2020 14:37:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java | 56 +++++++++++++++++++++++++-------------------------------
1 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java
index 0d9b693..c2f91b0 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java
@@ -6,15 +6,19 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.msg.MsgOtherDetailMapper;
+import com.yeshi.fanli.entity.bus.msg.MsgExtra;
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.MsgExtraService;
import com.yeshi.fanli.service.inter.msg.MsgOtherDetailService;
import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
@Service
public class MsgOtherDetailServiceImpl implements MsgOtherDetailService {
@@ -25,40 +29,20 @@
@Resource
private UserMsgReadStateService userMsgReadStateService;
+ @Resource
+ private MsgExtraService msgExtraService;
+
+
@Override
+ @Transactional(rollbackFor = Exception.class)
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()));
- if (detail.getCreateTime() == null)
- detail.setCreateTime(new Date());
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.taoLiJin) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.give) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.exchange) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.couponActivate) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.firstOrderReward) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- }else if (detail.getType() == MsgTypeOtherTypeEnum.systemGive) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
- } else if (detail.getType() == MsgTypeOtherTypeEnum.taoLiJinExchange) {
- msgOtherDetailMapper.insertSelective(detail);
- userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
+ if (detail == null || detail.getUser() == null || StringUtil.isNullOrEmpty(detail.getExtraInfo())) {
+ throw new MsgOtherDetailException(1, "娑堟伅鍐呭涓嶅叏");
}
+
+ msgOtherDetailMapper.insertSelective(detail);
+ msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_OTHER);
+ userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
}
@Override
@@ -92,4 +76,14 @@
msgOtherDetailMapper.setMsgReadByUid(uid);
}
+ @Override
+ public MsgOtherDetail selectByPrimaryKey(Long id) {
+ return msgOtherDetailMapper.selectByPrimaryKey(id);
+ }
+
+ @Override
+ public void deleteByPrimaryKey(Long id) {
+ msgOtherDetailMapper.deleteByPrimaryKey(id);
+ msgExtraService.deleteByPidAndType(id, MsgExtra.MSG_TYPE_OTHER);
+ }
}
--
Gitblit v1.8.0