package com.yeshi.fanli.service.impl.elme;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.yeshi.fanli.dao.mybatis.elme.ElmeHongBaoOrderMapMapper;
|
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
|
import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
|
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
|
|
/**
|
* 饿了么红包订单映射
|
*
|
* @author Administrator
|
*
|
*/
|
@Service
|
public class ElmeHongBaoOrderMapServiceImpl implements ElmeHongBaoOrderMapService {
|
|
@Resource
|
private ElmeHongBaoOrderMapMapper elmeHongBaoOrderMapMapper;
|
|
@Transactional
|
@Override
|
public void addHongBaoOrderMap(ElmeHongBaoOrderMap map) throws ElmeHongBaoOrderMapException {
|
if (map.getElmeOrder() == null || map.getElmeOrder().getId() == null || map.getHongBao() == null
|
|| map.getHongBao().getId() == null)
|
throw new ElmeHongBaoOrderMapException(1, "信息不完整");
|
ElmeHongBaoOrderMap oldMap = elmeHongBaoOrderMapMapper.selectByOrderId(map.getElmeOrder().getId());
|
if (oldMap != null)
|
throw new ElmeHongBaoOrderMapException(2, "订单ID已经添加过映射");
|
oldMap = elmeHongBaoOrderMapMapper.selectByHongBaoId(map.getHongBao().getId());
|
if (oldMap != null)
|
throw new ElmeHongBaoOrderMapException(3, "红包ID已经添加过映射");
|
elmeHongBaoOrderMapMapper.insertSelective(map);
|
}
|
|
@Override
|
public ElmeHongBaoOrderMap selectByOrderId(Long orderId) {
|
|
return elmeHongBaoOrderMapMapper.selectByOrderId(orderId);
|
}
|
|
@Override
|
public ElmeHongBaoOrderMap selectByHongBaoId(Long hongBaoId) {
|
return elmeHongBaoOrderMapMapper.selectByHongBaoId(hongBaoId);
|
}
|
|
}
|