admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
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
package com.yeshi.fanli.service.impl.hongbao;
 
import java.util.Date;
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.money.AccountDetailHongBaoMapMapper;
import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.entity.money.AccountDetailHongBaoMap;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
 
@Service
public class AccountDetailsHongBaoMapServiceImpl implements AccountDetailsHongBaoMapService {
 
    @Resource
    private AccountDetailHongBaoMapMapper accountDetailHongBaoMapMapper;
 
    @Transactional
    @Override
    public void saveAccountDetailsHongBaoMap(Long hongBaoId, Long accountDetailsId) {
        if (hongBaoId == null || accountDetailsId == null)
            return;
 
        // 保存账户明细与红包的关系
        AccountDetailHongBaoMap map = new AccountDetailHongBaoMap();
        map.setUserMoneyDetail(new UserMoneyDetail(accountDetailsId));
        map.setCreateTime(new Date());
        map.setHongBao(new HongBao(hongBaoId));
        map.setUpdateTime(new Date());
        AccountDetailHongBaoMap oldMap = accountDetailHongBaoMapMapper.selectByHongBaoId(hongBaoId);
        if (oldMap == null) {
            accountDetailHongBaoMapMapper.insertSelective(map);
        }
 
    }
 
    @Transactional
    @Override
    public void saveAccountDetailsHongBaoMap(List<Long> hongBaoIdList, Long accountDetailsId) {
        if (hongBaoIdList != null)
            for (Long hongBaoId : hongBaoIdList)
                saveAccountDetailsHongBaoMap(hongBaoId, accountDetailsId);
    }
 
}