hexiaohui
2019-01-29 6a2e44aab53743d1595cdded27d85a8f67f3270c
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
107
108
109
110
111
112
113
package com.yeshi.fanli.service.impl.user;
 
import java.util.Date;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.user.UserExtraTaoBaoInfoMapper;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class UserExtraTaoBaoInfoServiceImpl implements UserExtraTaoBaoInfoService {
 
    @Resource
    private UserExtraTaoBaoInfoMapper userExtraTaoBaoInfoMapper;
 
    @Override
    public void addRelationId(Long uid, String relationId, String taoBaoUid, boolean valid) {
        if (uid == null || relationId == null)
            return;
        UserExtraTaoBaoInfo info = getByUid(uid);
        if (info == null) {
            info = new UserExtraTaoBaoInfo();
            info.setUser(new UserInfo(uid));
            info.setCreateTime(new Date());
            info.setRelationId(relationId);
            info.setRelationUpdateTime(new Date());
            info.setRelationValid(valid);
            info.setTaoBaoUid(taoBaoUid);
            userExtraTaoBaoInfoMapper.insertSelective(info);
        } else {
            UserExtraTaoBaoInfo update = new UserExtraTaoBaoInfo();
            update.setId(info.getId());
            update.setRelationId(relationId);
            update.setRelationValid(valid);
            update.setRelationUpdateTime(new Date());
            update.setTaoBaoUid(taoBaoUid);
            userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(update);
        }
    }
 
    @Override
    public void addSpecialId(Long uid, String specialId, String taoBaoUid, boolean valid) {
        if (uid == null || specialId == null)
            return;
        UserExtraTaoBaoInfo info = getByUid(uid);
        if (info == null) {
            info = new UserExtraTaoBaoInfo();
            info.setUser(new UserInfo(uid));
            info.setCreateTime(new Date());
            info.setSpecialId(specialId);
            info.setSpecialUpdateTime(new Date());
            info.setSpecialValid(valid);
            info.setTaoBaoUid(taoBaoUid);
            userExtraTaoBaoInfoMapper.insertSelective(info);
        } else {
            UserExtraTaoBaoInfo update = new UserExtraTaoBaoInfo();
            update.setId(info.getId());
            update.setSpecialId(specialId);
            update.setSpecialUpdateTime(new Date());
            update.setSpecialValid(valid);
            update.setTaoBaoUid(taoBaoUid);
            userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(update);
        }
    }
 
    @Override
    public UserExtraTaoBaoInfo getByUid(Long uid) {
        return userExtraTaoBaoInfoMapper.selectByUid(uid);
    }
 
    @Override
    public void updateSelective(UserExtraTaoBaoInfo ue) {
        if (ue == null || ue.getId() == null)
            return;
        userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(ue);
    }
 
    @Override
    public void unBindUid(Long uid) {
        userExtraTaoBaoInfoMapper.clearUid(uid);
    }
 
    @Override
    public void bindTaoBaoOrderEnd6Num(String taoBaoUid, String orderId) {
        if (taoBaoUid == null || StringUtil.isNullOrEmpty(orderId))
            return;
        UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoMapper.selectByTaoBaoUid(taoBaoUid);
        if (extraInfo != null) {
            UserExtraTaoBaoInfo update = new UserExtraTaoBaoInfo();
            update.setId(extraInfo.getId());
            update.setTaoBaoOrderEnd6Num(orderId);
            update.setUpdateTime(new Date());
            userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(update);
        }
 
    }
 
    @Override
    public UserExtraTaoBaoInfo getByRelationId(String relationId) {
        return userExtraTaoBaoInfoMapper.selectByRelationIdWithUidNotNull(relationId);
    }
 
    @Override
    public UserExtraTaoBaoInfo getBySpecialId(String specialId) {
        return userExtraTaoBaoInfoMapper.selectBySpecialIdWithUidNotNull(specialId);
    }
 
}