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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package com.matrix;
 
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.authority.DefaultAuthorityManager;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.SysCompanyDao;
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.common.service.SysUsersService;
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.MoneyCardUse;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysBedInfoDao;
import com.matrix.system.hive.dao.SysOrderItemDao;
import com.matrix.system.hive.dao.SysShopInfoDao;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.hive.service.*;
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 javax.annotation.Resource;
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;
 
    @Autowired
    private SysUsersService sysUsersService;
 
    @Autowired
    private DefaultAuthorityManager authorityManager;
 
    @Autowired
    SysShopInfoDao sysShopInfoDao;
 
    @Autowired
    SysCompanyDao sysCompanyDao;
 
    @Autowired
    private SysShopInfoService sysShopInfoService;
 
    @Resource
    private SysOrderService sysOrderService;
 
    @Resource
    private SysBedInfoService bedInfoService;
 
    @Resource
    private SysWorktimeService sysWorkTimeService;
 
 
    @Resource
    private SysUsersService usersService;
 
    @Autowired
    private SysUsersDao sysUsersDao;
 
 
    @Autowired
    private SysBedInfoDao sysBedInfoDao;
    @Resource
    private SysOrderService orderService;
    @Autowired
    private BusParameterSettingsDao busParameterSettingsDao;
    @Autowired
    private SysOrderItemDao orderItemDao;
 
    @Resource
    private MoneyCardUseService cardUseService;
    @Test
    public void findOrderById() {
        Long vipId = 111L;
        MoneyCardUse moneyCardUse = new MoneyCardUse();
        moneyCardUse.setVipId(vipId);
        moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_YX);
        List<MoneyCardUse> cards = cardUseService.findByModel(moneyCardUse);
    }
 
    @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());
        }
    }
 
 
 
 
}