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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.yeshi.fanli.service.impl.user.invite;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.user.invite.ThreeSaleDetailDao;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail;
import com.yeshi.fanli.exception.ParamsException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
 
@Service
public class ThreeSaleDetailSerivceImpl implements ThreeSaleDetailService {
 
    @Resource
    private ThreeSaleDetailDao threeSaleDetailDao;
 
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
 
    @Override
    public void addThreeSaleDetail(ThreeSaleDetail detail) throws ParamsException {
        if (detail.getBossUid() == null || detail.getWorkerUid() == null || detail.getLevel() == null
                || detail.getCreateTime() == null) {
            throw new ParamsException(1, "参数不完整");
        }
        String id = detail.getBossUid() + "#" + detail.getWorkerUid();
        detail.setId(id);
        // 根据主键查询
        ThreeSaleDetail old = threeSaleDetailDao.get(id);
        // if (old == null)
        threeSaleDetailDao.save(detail);
    }
 
    @Override
    public List<ThreeSaleDetail> listByBossUidAndLevel(Long bossUid, int level, int page, int pageSize) {
        return threeSaleDetailDao.listByBossUidAndLevel(bossUid, level, (page - 1) * pageSize, pageSize);
    }
 
    @Override
    public long countByBossUidAndLevel(Long bossUid, int level) {
        return threeSaleDetailDao.countByBossUidAndLevel(bossUid, level);
    }
 
    @Override
    public List<ThreeSaleDetail> listByBossUidAndMinLevel(Long bossUid, int minLevel, int page, int pageSize) {
        return threeSaleDetailDao.listByBossUidAndMinLevel(bossUid, minLevel, (page - 1) * pageSize, pageSize);
    }
 
    @Override
    public long countByBossUidAndMinLevel(Long bossUid, int minLevel) {
        return threeSaleDetailDao.countByBossUidAndMinLevel(bossUid, minLevel);
    }
    
    
    @Override
    public long countByBossUidAndMaxLevel(Long bossUid, int minLevel) {
        return threeSaleDetailDao.countByBossUidAndMaxLevel(bossUid, minLevel);
    }
    
 
    @Override
    public void addByWorkerUid(Long workerUid) {
        List<ThreeSale> list = threeSaleSerivce.getMyBossDeepList(workerUid, 100);
        LogHelper.teamInfo(String.format("邀请详细信息: 用户ID:%s  上级数量:%s", workerUid + "", list.size()));
        int level = 0;
        long createTime = 0L;
        if (list.size() > 0) {
            if (list.get(0).getSucceedTime() != null)
                createTime = list.get(0).getSucceedTime();
            else
                createTime = list.get(0).getCreateTime();
        }
        for (ThreeSale tts : list) {
            level++;
            ThreeSaleDetail detail = new ThreeSaleDetail();
            detail.setBossUid(tts.getBoss().getId());
            detail.setLevel(level);
            detail.setWorkerUid(workerUid);
            detail.setCreateTime(new Date(createTime));
            try {
                if (tts.getState())
                    addThreeSaleDetail(detail);
            } catch (ParamsException e) {
                e.printStackTrace();
            }
        }
    }
 
    @Override
    public List<ThreeSaleDetail> listByWorkerUid(Long uid) {
        return threeSaleDetailDao.listByWorkerUid(uid);
    }
 
    @Override
    public ThreeSaleDetail getByBossUidAndWorkerUid(Long bossUid, Long workerUid) {
        String id = bossUid + "#" + workerUid;
        return threeSaleDetailDao.get(id);
    }
}