|  | @@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.app.param.UserRegisterParam;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.model.Channel;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.model.User;
 | 
	
		
			
				|  |  | +import com.yami.shop.bean.po.EnterpriseUserErrExcelInfo;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.po.EnterpriseUserExcelInfo;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.po.EnterpriseUserLogPo;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.po.EnterpriseUserPo;
 | 
	
	
		
			
				|  | @@ -133,13 +134,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public void uploadExcelGoods(MultipartFile file,String username) {
 | 
	
		
			
				|  |  |          List<EnterpriseUserExcelInfo> goodsInfoList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +        String batchNo = String.valueOf(System.currentTimeMillis());
 | 
	
		
			
				|  |  |          EasyExcel.read(file.getInputStream(), EnterpriseUserExcelInfo.class, new PageReadListener<EnterpriseUserExcelInfo>(goodsInfoList::addAll)).sheet().doRead();
 | 
	
		
			
				|  |  |          CullenUtils.validateDataThrowException(goodsInfoList.isEmpty(), "请上传企业用户信息...");
 | 
	
		
			
				|  |  |          goodsInfoList.forEach(c -> {
 | 
	
		
			
				|  |  |              CullenUtils.validateDataThrowException(c.getChannel().contains("必填"), "请删除示例后重试...");
 | 
	
		
			
				|  |  | -            addUser(new EnterpriseUserPo(getChannel(c.getChannel()), c.getRealName(), c.getPhone()));
 | 
	
		
			
				|  |  | +            CullenUtils.validateDataThrowException(c.getPhone()==null,"手机号不能为空...");
 | 
	
		
			
				|  |  | +            CullenUtils.validateDataThrowException(c.getChannel()==null,"渠道不能为空...");
 | 
	
		
			
				|  |  | +            CullenUtils.validateDataThrowException(c.getRealName()==null,"姓名不能为空...");
 | 
	
		
			
				|  |  | +            String phone = c.getPhone().replaceAll("\\s+", "");
 | 
	
		
			
				|  |  | +            if (phone.length()!=11||!CullenUtils.isNumeric(phone)) {
 | 
	
		
			
				|  |  | +                userMapper.addUserLog(username,batchNo,"0",c.getChannel(),c.getRealName(),c.getPhone());
 | 
	
		
			
				|  |  | +            }else {
 | 
	
		
			
				|  |  | +                addUser(new EnterpriseUserPo(getChannel(c.getChannel()), c.getRealName(), c.getPhone()));
 | 
	
		
			
				|  |  | +                userMapper.addUserLog(username,batchNo,"1",c.getChannel(),c.getRealName(),c.getPhone());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        userMapper.addUserLog(username,String.format("共%d条,成功%d条,失败%d条",goodsInfoList.size(),goodsInfoList.size(),0));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -201,6 +211,25 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 | 
	
		
			
				|  |  |          return userMapper.userList(page, user);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void downloadErrorExcel(HttpServletResponse response, String batchNo) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            System.out.println(batchNo);
 | 
	
		
			
				|  |  | +            List<EnterpriseUserLogPo> userLogErrList = userMapper.enterpriseUserLogErrList(batchNo);
 | 
	
		
			
				|  |  | +            CullenUtils.validateDataThrowException(userLogErrList.isEmpty(),"该记录暂无错误日志...");
 | 
	
		
			
				|  |  | +            List<EnterpriseUserErrExcelInfo> list = Lists.newArrayList();
 | 
	
		
			
				|  |  | +            userLogErrList.forEach(c-> list.add(new EnterpriseUserErrExcelInfo("手机号格式错误",c.getChannel(),c.getRealName(),c.getPhone())));
 | 
	
		
			
				|  |  | +            response.setCharacterEncoding("utf-8");
 | 
	
		
			
				|  |  | +            String fileName = URLEncoder.encode("企业员工", "UTF-8").replaceAll("\\+", "%20");
 | 
	
		
			
				|  |  | +            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
 | 
	
		
			
				|  |  | +            EasyExcel.write(response.getOutputStream(), EnterpriseUserErrExcelInfo.class)
 | 
	
		
			
				|  |  | +                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
 | 
	
		
			
				|  |  | +                    .sheet("列表").doWrite(list);
 | 
	
		
			
				|  |  | +        } catch (IOException e) {
 | 
	
		
			
				|  |  | +            throw new GlobalException("文件下载异常");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private Long getChannel(String channel) {
 | 
	
		
			
				|  |  |          List<Channel> channelList = channelMapper.selectList(new LambdaQueryWrapper<Channel>().like(Channel::getChannelName, channel));
 | 
	
		
			
				|  |  |          CullenUtils.validateDataThrowException(channelList.isEmpty(), "没有该渠道,请检查后重试...");
 |