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.yeshi.fanli.dao.mybatis.msg.MsgMoneyDetailMapper;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.exception.msg.MsgMoneyDetailException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgMoneyDetailService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class MsgMoneyDetailServiceImpl implements MsgMoneyDetailService {
|
| | |
|
| | | @Resource
|
| | | private MsgMoneyDetailMapper msgMoneyDetailMapper;
|
| | |
|
| | | @Override
|
| | | public void addMsgMoneyDetail(MsgMoneyDetail detail) throws MsgMoneyDetailException {
|
| | | if (detail == null)
|
| | | throw new MsgMoneyDetailException(1, "消息为空");
|
| | | if (detail.getMsgType() == MsgTypeMoneyTypeEnum.extract) {
|
| | | if (detail.getExtract() == null || detail.getUser() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | MsgMoneyDetail msg = msgMoneyDetailMapper.selectBySourceIdAndMsgType(detail.getExtract().getId(),
|
| | | MsgTypeMoneyTypeEnum.extract);
|
| | | if (msg == null) {
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | } else {
|
| | | MsgMoneyDetail update = new MsgMoneyDetail();
|
| | | update.setId(msg.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setRead(false);
|
| | | update.setStateDesc(detail.getStateDesc());
|
| | | msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.extractValid) {
|
| | | if (detail.getAlipayAccountValid() == null || detail.getUser() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | MsgMoneyDetail msg = msgMoneyDetailMapper.selectBySourceIdAndMsgType(detail.getAlipayAccountValid().getId(),
|
| | | MsgTypeMoneyTypeEnum.extractValid);
|
| | | if (msg == null) {
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | } else {
|
| | | MsgMoneyDetail update = new MsgMoneyDetail();
|
| | | update.setId(msg.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setRead(false);
|
| | | update.setStateDesc(detail.getStateDesc());
|
| | | msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.fanli) {
|
| | | if (detail.getMoney() == null || detail.getGoodsCount() == 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);
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.invite
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.share) {
|
| | | if (detail.getMoney() == null || detail.getGoodsCount() == null || detail.getOrderCount() == null
|
| | | || detail.getBalance() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MsgMoneyDetail> listMsgMoneyDetail(Long uid, int page) {
|
| | | return msgMoneyDetailMapper.listByUid(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countMsgMoneyDetail(Long uid) {
|
| | | return msgMoneyDetailMapper.countByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void readMsgByUid(Long uid) {
|
| | | msgMoneyDetailMapper.setMsgReadByUid(uid);
|
| | | }
|
| | |
|
| | | }
|