| | |
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgOrderDetailMapper;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.exception.msg.MsgOrderDetailException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgOrderDetailService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class MsgOrderDetailServiceImpl implements MsgOrderDetailService {
|
| | |
| | | @Resource
|
| | | private MsgOrderDetailMapper msgOrderDetailMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMsgReadStateService userMsgReadStateService;
|
| | |
|
| | | @Override
|
| | | public void addMsgOrderDetail(MsgOrderDetail detail) throws MsgOrderDetailException {
|
| | | public void addMsgOrderDetail(MsgOrderDetail detail, boolean needNotify) throws MsgOrderDetailException {
|
| | | if (detail == null)
|
| | | throw new MsgOrderDetailException(1, "消息为空");
|
| | | if (detail.getOrderId() == null || detail.getGoodsCount() == null || detail.getType() == null
|
| | | || detail.getState() == null || detail.getPayMoney() == null || detail.getUser() == null)
|
| | | if (detail.getOrderId() == null || detail.getType() == null || detail.getState() == null
|
| | | || detail.getUser() == null)
|
| | | throw new MsgOrderDetailException(2, "消息不完整");
|
| | | MsgOrderDetail old = msgOrderDetailMapper.selectByUidAndOrderId(detail.getUser().getId(), detail.getOrderId());
|
| | | if (old == null) {
|
| | |
| | | update.setBeiZhu(detail.getBeiZhu());
|
| | | msgOrderDetailMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | | if (needNotify)
|
| | | userMsgReadStateService.addOrderMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MsgOrderDetail> listMsgOrderDetail(Long uid, int page) {
|
| | | return null;
|
| | | return msgOrderDetailMapper.listByUid(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countMsgOrderDetail(Long uid) {
|
| | | return 0;
|
| | | return msgOrderDetailMapper.countByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void readMsgByUid(Long uid) {
|
| | | msgOrderDetailMapper.setMsgReadByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateMsgOrderDetail(MsgOrderDetail detail, boolean needNotify) throws MsgOrderDetailException {
|
| | | if (detail == null)
|
| | | throw new MsgOrderDetailException(1, "消息为空");
|
| | | if (detail.getOrderId() == null || detail.getState() == null || detail.getUser() == null)
|
| | | throw new MsgOrderDetailException(2, "消息不完整");
|
| | |
|
| | | MsgOrderDetail msg = msgOrderDetailMapper.selectByUidAndOrderId(detail.getUser().getId(), detail.getOrderId());
|
| | | if (msg == null)
|
| | | return;
|
| | |
|
| | | if (msg.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | |
|
| | | MsgOrderDetail update = new MsgOrderDetail();
|
| | | update.setId(msg.getId());
|
| | | update.setHongBaoMoney(detail.getHongBaoMoney());
|
| | | update.setPayMoney(detail.getPayMoney());
|
| | | if (detail.getState().intValue() != msg.getState()) {
|
| | | update.setState(detail.getState());
|
| | | // update.setUpdateTime(new Date());
|
| | | if (needNotify)
|
| | | userMsgReadStateService.addOrderMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | | msgOrderDetailMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MsgOrderDetail> listMsgOrderByOrderId(String orderId) {
|
| | | return msgOrderDetailMapper.listByOrderId(orderId);
|
| | | }
|
| | |
|
| | | }
|