From 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 26 四月 2024 18:02:17 +0800
Subject: [PATCH] 唯品会链接解析升级

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java |  171 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 94 insertions(+), 77 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 a22c6fe..7e2896e 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
@@ -1,77 +1,94 @@
-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.service.inter.msg.UserMsgReadStateService;
-import com.yeshi.fanli.util.Constant;
-
-@Service
-public class MsgOtherDetailServiceImpl implements MsgOtherDetailService {
-
-	@Resource
-	private MsgOtherDetailMapper msgOtherDetailMapper;
-
-	@Resource
-	private UserMsgReadStateService userMsgReadStateService;
-
-	@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()));
-			if (detail.getCreateTime() == null)
-				detail.setCreateTime(new Date());
-			msgOtherDetailMapper.insertSelective(detail);
-			userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
-		} else {
-			msgOtherDetailMapper.insertSelective(detail);
-			userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
-		}
-	}
-
-	@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()));
-			if(detail.getUpdateTime()==null)
-			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);
-	}
-
-}
+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 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 {
+
+	@Resource
+	private MsgOtherDetailMapper msgOtherDetailMapper;
+
+	@Resource
+	private UserMsgReadStateService userMsgReadStateService;
+
+	@Resource
+	private MsgExtraService msgExtraService;
+	
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addMsgOtherDetail(MsgOtherDetail detail) throws MsgOtherDetailException {
+		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
+	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()));
+			if(detail.getUpdateTime()==null)
+			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 List<MsgOtherDetail> listDetail(List<Long> ids) {
+		return msgOtherDetailMapper.listByPrimaryKeys(ids);
+	}
+
+	@Override
+	public long countMsgOtherDetail(Long uid) {
+		return msgOtherDetailMapper.countByUid(uid);
+	}
+
+	@Override
+	public void readMsgByUid(Long uid) {
+		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