|
|
@@ -2,6 +2,7 @@ package com.cyksj.service.mange.account;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -14,6 +15,7 @@ import com.cyksj.mapper.AccountMapper;
|
|
|
import com.cyksj.mapper.AccountUpdatePasswordRecordMapper;
|
|
|
import com.cyksj.mapper.manage.AutoUpdateAccountPwdLogMapper;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
+import com.cyksj.mapper.sys.SysEmailMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountData;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
@@ -31,7 +33,11 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -58,6 +64,8 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
|
|
|
|
|
|
private final SysConfigService sysConfigService;
|
|
|
|
|
|
+ private final SysEmailMapper sysEmailMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ExpiredAccountDataView> getExpiredAccountView(Boolean isCorpWx, String customerService, Long goodsId, Long skuId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, String startTime, String endTime, String now, Long offset, Long limit) {
|
|
|
return accountMapper.getExpiredAccountView(isCorpWx, customerService, goodsId, skuId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startTime, endTime, now, new Page<>(offset, limit));
|
|
|
@@ -181,6 +189,48 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
|
|
|
insertAccount(goodsId, skuId, accountList);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void readFileAndImportEmail(MultipartFile file) throws Exception {
|
|
|
+ InputStream in = null;
|
|
|
+ BufferedReader br = null;
|
|
|
+ String regex = "----";
|
|
|
+ List<SysEmail> sysEmails = new ArrayList<>();
|
|
|
+ List<String> error = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ in = file.getInputStream();
|
|
|
+ br = new BufferedReader(new InputStreamReader(file.getInputStream()));
|
|
|
+ String content = null;
|
|
|
+ while ((content = br.readLine()) != null) {
|
|
|
+ String[] split = content.split(regex);
|
|
|
+ if (split.length > 1) {
|
|
|
+ String email = split[0];
|
|
|
+ String password = split[1];
|
|
|
+ if (!StrUtil.hasEmpty(email, password)) {
|
|
|
+ SysEmail sysEmail = new SysEmail();
|
|
|
+ sysEmail.setEmail(email);
|
|
|
+ sysEmail.setPassword(password);
|
|
|
+ sysEmails.add(sysEmail);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ error.add(split[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(sysEmails)) {
|
|
|
+ Lists.partition(sysEmails, 1000).forEach(data -> {
|
|
|
+ sysEmailMapper.batchInsert(data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (br != null) {
|
|
|
+ br.close();
|
|
|
+ }
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(Jsons.toJson(error));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param goodsId
|