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 cards = cardUseService.findByModel(moneyCardUse); } @Test @Transactional public void addSettings(){ HashMap columnMap=new HashMap(); columnMap.put("company_id",17); List 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()); } } }