admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java
@@ -16,6 +16,7 @@
import com.yeshi.fanli.service.inter.msg.MsgExtraService;
import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@Service
public class MsgMoneyDetailServiceImpl implements MsgMoneyDetailService {
@@ -31,10 +32,10 @@
   @Override
   public void addMsgMoneyDetail(MsgMoneyDetail detail) throws MsgMoneyDetailException {
      if (detail == null)
         throw new MsgMoneyDetailException(1, "消息为空");
      if (detail == null || detail.getUser() == null || StringUtil.isNullOrEmpty(detail.getExtraInfo()))
         throw new MsgMoneyDetailException(1, "消息信息不全");
      if (detail.getMsgType() == MsgTypeMoneyTypeEnum.extract) {
         if (detail.getExtract() == null || detail.getUser() == null)
         if (detail.getExtract() == null)
            throw new MsgMoneyDetailException(2, "消息信息不全");
         MsgMoneyDetail msg = msgMoneyDetailMapper.selectBySourceIdAndMsgType(detail.getExtract().getId(),
               MsgTypeMoneyTypeEnum.extract);
@@ -51,10 +52,10 @@
            update.setRead(false);
            update.setStateDesc(detail.getStateDesc());
            msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
            msgExtraService.updateMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_MONEY);
            msgExtraService.addMsgExtra(update.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_MONEY);
         }
      } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.extractValid) {
         if (detail.getAlipayAccountValid() == null || detail.getUser() == null)
         if (detail.getAlipayAccountValid() == null)
            throw new MsgMoneyDetailException(2, "消息信息不全");
         MsgMoneyDetail msg = msgMoneyDetailMapper.selectBySourceIdAndMsgType(detail.getAlipayAccountValid().getId(),
               MsgTypeMoneyTypeEnum.extractValid);
@@ -71,15 +72,14 @@
            update.setRead(false);
            update.setStateDesc(detail.getStateDesc());
            msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
            msgExtraService.updateMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_MONEY);
            msgExtraService.addMsgExtra(update.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_MONEY);
         }
      }  else {
         if(detail.getUser() == null)
            throw new MsgMoneyDetailException(2, "消息信息不全");
         detail.setCreateTime(new Date());
         detail.setUpdateTime(new Date());
         detail.setRead(false);
         msgMoneyDetailMapper.insertSelective(detail);
         msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_MONEY);
      }
      userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
   }
@@ -99,4 +99,15 @@
      msgMoneyDetailMapper.setMsgReadByUid(uid);
   }
   @Override
   public MsgMoneyDetail selectByPrimaryKey(Long id) {
      return msgMoneyDetailMapper.selectByPrimaryKey(id);
   }
   @Override
   public void deleteByPrimaryKey(Long id) {
      msgMoneyDetailMapper.deleteByPrimaryKey(id);
      msgExtraService.deleteByPidAndType(id, MsgExtra.MSG_TYPE_MONEY);
   }
}