935090232@qq.com
2021-10-30 caa15383382af86c00f7176c1d24280a7da6d9e2
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
package com.matrix;
 
import com.matrix.core.tools.StringUtils;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.fenxiao.dao.BizUserDao;
import com.matrix.system.fenxiao.entity.BizUser;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.hive.service.CodeService;
import com.matrix.system.hive.service.SysVipInfoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.HashMap;
import java.util.List;
 
/**
 * bizuser转到vipinfo表工具类
 * 
 * @author jiangyouyao
 * @email 512061637@qq.com
 * @date 2019年2月25日
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ZqErpApplication.class},webEnvironment =SpringBootTest.WebEnvironment.RANDOM_PORT)
public class BizUserToVipInfoTool {
 
    @Autowired
    BizUserDao bizUserDao;
 
    @Autowired
    SysVipInfoDao sysVipInfoDao;
 
    @Autowired
    CodeService codeService;
 
    @Autowired
    SysVipInfoService sysVipInfoService;
 
    @Test
    @Transactional
    public void addSettings(){
        HashMap columnMap=new HashMap();
        columnMap.put("company_id",17);
        List<BizUser> bizUsers = bizUserDao.selectByMap(columnMap);
        for (BizUser bizUser : bizUsers) {
            SysVipInfo sysVipInfo = sysVipInfoDao.selectByPhone(bizUser.getPhoneNumber(),17L);
            if(sysVipInfo!=null){
                sysVipInfo=sysVipInfoService.findByOpenId(bizUser.getOpenId());
            }
            if(sysVipInfo!=null){
                sysVipInfo.setNickName(bizUser.getNickName());
                sysVipInfo.setAvatarUrl(bizUser.getAvatarUrl());
                sysVipInfo.setOpenId(bizUser.getOpenId());
                sysVipInfo.setSessionKey(bizUser.getSessionKey());
                sysVipInfoDao.update(sysVipInfo);
            }else{
                SysVipInfo    sysVipInfoNew = new SysVipInfo();
                if(bizUser.getGender()!=null){
                    sysVipInfoNew.setSex(bizUser.getGender().equals("1")?"男":"女");
                }
                sysVipInfoNew.setNickName(bizUser.getNickName());
                sysVipInfoNew.setAvatarUrl(bizUser.getAvatarUrl());
                sysVipInfoNew.setIsSales(SysVipInfo.NOT_SALES);
                sysVipInfoNew.setOpenId(bizUser.getOpenId());
                sysVipInfoNew.setSessionKey(bizUser.getSessionKey());
                sysVipInfoNew.setCompanyId(17L);
                sysVipInfoNew.setShopId(13L);
                sysVipInfoNew.setArrivalWay("微商城");
                sysVipInfoNew.setVipName("微信用户");
                sysVipInfoNew.setVipState(Dictionary.VIP_STATE_HY);
                sysVipInfoNew.setVipType(Dictionary.VIP_TYPE_NOCARD);
                sysVipInfoNew.setIsDeal(SysVipInfo.UNDEAL_VIP);
                sysVipInfoNew.setVipNo(StringUtils.getRandomString(10));
                sysVipInfoNew.setCity(bizUser.getCity());
                sysVipInfoNew.setArea(bizUser.getArea());
                sysVipInfoNew.setProvince(bizUser.getProvince());
                sysVipInfoNew.setPhone(bizUser.getPhoneNumber());
                sysVipInfoNew.setPhoto(bizUser.getAvatarUrl());
                sysVipInfoService.add(sysVipInfoNew);
            }
            System.out.println("处理进度"+ bizUsers.indexOf(bizUser)+"/"+bizUsers.size());
        }
    }
 
 
 
 
}