admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.yeshi.fanli.service.impl.elme;
 
import java.util.List;
 
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(rollbackFor=Exception.class)
    @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);
    }
 
    @Override
    public List<ElmeHongBaoOrderMap> listByHongBaoUid(Long uid, int page, int pageSize) {
        return elmeHongBaoOrderMapMapper.listByHongBaoUid(uid, (page - 1) * pageSize, pageSize);
    }
 
    @Override
    public long countByHongBaoUid(Long uid) {
        return elmeHongBaoOrderMapMapper.countByHongBaoUid(uid);
    }
 
}