yujian
2019-08-23 4936fa79494c5a2111664b63576340da245e6580
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
package com.yeshi.fanli.service.impl.user;
 
import java.util.Date;
 
import javax.annotation.Resource;
 
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.user.UserInfoModifyRecordMapper;
import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord;
import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.integral.IntegralGetService;
import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class UserInfoModifyRecordServiceImpl implements UserInfoModifyRecordService {
 
    @Resource
    private UserInfoModifyRecordMapper userInfoModifyRecordMapper;
    
    @Resource
    private IntegralGetService integralGetService;
 
    @Async()
    @Override
    public void addModifyRecord(Long uid, ModifyTypeEnum type, String value) {
        try {
            if (uid == null || StringUtil.isNullOrEmpty(value))
                return;
            
            long count = countByUid(uid, type.name());
            if (count == 0) {
                if (type == ModifyTypeEnum.bindPhone) {
                    integralGetService.addBindPhone(uid);
                } else if (type == ModifyTypeEnum.bindAlipay) {
                    integralGetService.addBindAlipay(uid);
                } else if (type == ModifyTypeEnum.bindTaoBao) {
                    integralGetService.addBindTaoBao(uid);
                } else if (type == ModifyTypeEnum.bindWeiXin) {
                    integralGetService.addBindWeiXin(uid);
                } else if (type == ModifyTypeEnum.gender) {
                    integralGetService.addSetGender(uid);
                } else if (type == ModifyTypeEnum.nickName) {
                    integralGetService.addSetNickname(uid);
                } else if (type == ModifyTypeEnum.portrait) {
                    integralGetService.addSetPortrait(uid);
                } else if (type == ModifyTypeEnum.setWeiXinNum) {
                    integralGetService.addSetWeiXinNum(uid);
                }
            }
            
            UserInfoModifyRecord record = new UserInfoModifyRecord();
            record.setUid(uid);
            record.setType(type);
            record.setValue(value);
            record.setCreateTime(new Date());
            userInfoModifyRecordMapper.insertSelective(record);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
 
    @Override
    public long countByUid(Long uid, String type) {
        return userInfoModifyRecordMapper.countByUid(uid, type);
    }
}