|
|
@@ -9,11 +9,15 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.context.AnalysisContext;
|
|
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
+import com.cyksj.common.util.J11HttpC;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.RedisKey;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
@@ -22,10 +26,7 @@ import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.mapper.sys.SysEmailMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
-import com.cyksj.model.excel.ExcelDoubleVerifyAccountData;
|
|
|
-import com.cyksj.model.excel.ExcelImportAccountData;
|
|
|
-import com.cyksj.model.excel.ExcelImportDoubleVerifyAccountData;
|
|
|
-import com.cyksj.model.excel.ExcelManageAccountData;
|
|
|
+import com.cyksj.model.excel.*;
|
|
|
import com.cyksj.model.manage.request.ReqAccountIncrExpiryTime;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
@@ -33,6 +34,7 @@ import com.cyksj.model.response.ExpiredAccountRep;
|
|
|
import com.cyksj.model.response.OrderDonAccountRep;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
+import com.cyksj.service.mange.AccountCommonService;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
import com.cyksj.service.mange.cms.CmsUserManager;
|
|
|
@@ -57,6 +59,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.http.HttpResponse;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -98,14 +101,20 @@ public class CmsAccountController {
|
|
|
|
|
|
private final AccountUpdatePasswordRecordMapper accountUpdatePasswordRecordMapper;
|
|
|
|
|
|
+ private final AccountCommonService accountCommonService;
|
|
|
+
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
+
|
|
|
private final SysEmailMapper sysEmailMapper;
|
|
|
|
|
|
- private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
+ private final AccountBlockedReplaceRecordMapper accountBlockedReplaceRecordMapper;
|
|
|
+
|
|
|
+ private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
- public Result<SearchResult<AccountView>> get(Long userId, String showId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, Integer noChangeMonths) {
|
|
|
+ public Result<SearchResult<AccountView>> get(Long userId, String showId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, Integer noChangeMonths, Boolean isMjMirror) {
|
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
mapBuilder.field(AccountView::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
|
@@ -151,6 +160,12 @@ public class CmsAccountController {
|
|
|
extra_sql += String.format(" (select min(expiry_time) from (select gt.id from groups_trips where account_id = a.id) gt inner join groups_relation gr on gr.groups_id = gt.id) > '%s'", endOfDay);
|
|
|
}
|
|
|
}
|
|
|
+ if (isMjMirror != null) {
|
|
|
+ if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
+ extra_sql += " and";
|
|
|
+ }
|
|
|
+ extra_sql += String.format(" %s (select 1 from midjourney_account ma where ma.account_id = a.id limit 1)", isMjMirror ? "EXISTS" : "NOT EXISTS");
|
|
|
+ }
|
|
|
if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
mapBuilder.put("extra_sql", extra_sql);
|
|
|
}
|
|
|
@@ -179,76 +194,83 @@ public class CmsAccountController {
|
|
|
}
|
|
|
Integer expiryCount = groupsMapper.countExpiredNum(accountView.getId());
|
|
|
accountView.setExpiryCount(expiryCount);
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(accountView.getAccount())) {
|
|
|
+ Optional.ofNullable(sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
|
|
|
+ .eq(SysEmail::getEmail, accountView.getAccount()).select(SysEmail::getPassword)
|
|
|
+ .last("limit 1")))
|
|
|
+ .ifPresent(email -> accountView.setEmailPassword(email.getPassword()));
|
|
|
+ }
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 导出账号
|
|
|
- */
|
|
|
- @GetMapping("/export/account")
|
|
|
- @Log(module = "平台管理/导出账号", businessType = BusinessType.EXPORT, isSaveRequestData = true)
|
|
|
- public void exportAccount(Long userId, String showId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, Integer noChangeMonths, HttpServletResponse response) {
|
|
|
- MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
- if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
- mapBuilder.field(ExcelManageAccountData::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
|
- .op(Operator.Between);
|
|
|
- }
|
|
|
- if (StrUtil.isNotEmpty(showId)) {
|
|
|
- userId = userMapper.getUserIdByShowId(showId);
|
|
|
- }
|
|
|
-
|
|
|
- if (userId != null || StringUtils.isNotBlank(nickName) || StringUtils.isNotBlank(submitAccount)) {
|
|
|
- List<Long> accountIds = homeGroupMapper.getAccountIdsByUserIdOrNickNameOrSubmitAccount(userId, nickName, submitAccount);
|
|
|
- if (accountIds.isEmpty()) {
|
|
|
- throw BusinessRuntimeException.getInstance("暂无数据!");
|
|
|
- }
|
|
|
-
|
|
|
- mapBuilder.field(ExcelManageAccountData::getId, accountIds).op(Operator.InList);
|
|
|
- }
|
|
|
- String extra_sql = StrUtil.EMPTY;
|
|
|
- if (expiredAll != null && expiredAll) {
|
|
|
- extra_sql += "(if((select count(ur.id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self')>=3,true,false)) = 1";
|
|
|
- }
|
|
|
-
|
|
|
- if (noChangeMonths != null) {
|
|
|
- DateTime pastMonth = DateUtil.offsetMonth(DateTime.now(), -noChangeMonths);
|
|
|
- List<Long> accountIds = accountUpdatePasswordRecordMapper.selectPasswordNotChangedThePastMonthAccountId(pastMonth);
|
|
|
- mapBuilder.field(AccountView::getId, accountIds).op(Operator.InList);
|
|
|
- }
|
|
|
-
|
|
|
- if (existsExpired != null && existsExpired) {
|
|
|
- if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
- extra_sql += " and";
|
|
|
- }
|
|
|
- extra_sql += "(select count(ur.id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self') > 0";
|
|
|
- }
|
|
|
- if (existsExpiredToday != null) {
|
|
|
- DateTime endOfDay = DateUtil.endOfDay(DateTime.now());
|
|
|
- if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
- extra_sql += " and";
|
|
|
- }
|
|
|
- if (existsExpiredToday) {
|
|
|
- extra_sql += String.format(" (select min(expiry_time) from (select gt.id from groups_trips where account_id = a.id) gt inner join groups_relation gr on gr.groups_id = gt.id) <= '%s'", endOfDay);
|
|
|
- } else {
|
|
|
- extra_sql += String.format(" (select min(expiry_time) from (select gt.id from groups_trips where account_id = a.id) gt inner join groups_relation gr on gr.groups_id = gt.id) > '%s'", endOfDay);
|
|
|
- }
|
|
|
- }
|
|
|
- if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
- mapBuilder.put("extra_sql", extra_sql);
|
|
|
- }
|
|
|
- List<ExcelManageAccountData> list = beanSearcher.searchAll(ExcelManageAccountData.class, mapBuilder.build());
|
|
|
-
|
|
|
- EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelManageAccountData.class, list, "账号列表", "账号列表", ExcelTypeEnum.XLSX, null);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 下载批量修改密码模板
|
|
|
- */
|
|
|
- @GetMapping("/get/account/template")
|
|
|
- public void getAccountTemplate(HttpServletResponse response) {
|
|
|
- EasyExcelUtils.createTemplateExcel(response, ExcelImportAccountData.class, "账号批量修改密码模板", "账号批量修改密码模板", ExcelTypeEnum.XLSX, null);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 导出账号
|
|
|
+ */
|
|
|
+ @GetMapping("/export/account")
|
|
|
+ @Log(module = "平台管理/导出账号", businessType = BusinessType.EXPORT, isSaveRequestData = true)
|
|
|
+ public void exportAccount(Long userId, String showId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, Integer noChangeMonths, HttpServletResponse response) {
|
|
|
+ MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
+ mapBuilder.field(ExcelManageAccountData::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
|
+ .op(Operator.Between);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotEmpty(showId)) {
|
|
|
+ userId = userMapper.getUserIdByShowId(showId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userId != null || StringUtils.isNotBlank(nickName) || StringUtils.isNotBlank(submitAccount)) {
|
|
|
+ List<Long> accountIds = homeGroupMapper.getAccountIdsByUserIdOrNickNameOrSubmitAccount(userId, nickName, submitAccount);
|
|
|
+ if (accountIds.isEmpty()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("暂无数据!");
|
|
|
+ }
|
|
|
+
|
|
|
+ mapBuilder.field(ExcelManageAccountData::getId, accountIds).op(Operator.InList);
|
|
|
+ }
|
|
|
+ String extra_sql = StrUtil.EMPTY;
|
|
|
+ if (expiredAll != null && expiredAll) {
|
|
|
+ extra_sql += "(if((select count(ur.id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self')>=3,true,false)) = 1";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (noChangeMonths != null) {
|
|
|
+ DateTime pastMonth = DateUtil.offsetMonth(DateTime.now(), -noChangeMonths);
|
|
|
+ List<Long> accountIds = accountUpdatePasswordRecordMapper.selectPasswordNotChangedThePastMonthAccountId(pastMonth);
|
|
|
+ mapBuilder.field(AccountView::getId, accountIds).op(Operator.InList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (existsExpired != null && existsExpired) {
|
|
|
+ if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
+ extra_sql += " and";
|
|
|
+ }
|
|
|
+ extra_sql += "(select count(ur.id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self') > 0";
|
|
|
+ }
|
|
|
+ if (existsExpiredToday != null) {
|
|
|
+ DateTime endOfDay = DateUtil.endOfDay(DateTime.now());
|
|
|
+ if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
+ extra_sql += " and";
|
|
|
+ }
|
|
|
+ if (existsExpiredToday) {
|
|
|
+ extra_sql += String.format(" (select min(expiry_time) from (select gt.id from groups_trips where account_id = a.id) gt inner join groups_relation gr on gr.groups_id = gt.id) <= '%s'", endOfDay);
|
|
|
+ } else {
|
|
|
+ extra_sql += String.format(" (select min(expiry_time) from (select gt.id from groups_trips where account_id = a.id) gt inner join groups_relation gr on gr.groups_id = gt.id) > '%s'", endOfDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotEmpty(extra_sql)) {
|
|
|
+ mapBuilder.put("extra_sql", extra_sql);
|
|
|
+ }
|
|
|
+ List<ExcelManageAccountData> list = beanSearcher.searchAll(ExcelManageAccountData.class, mapBuilder.build());
|
|
|
+
|
|
|
+ EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelManageAccountData.class, list, "账号列表", "账号列表", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载批量修改密码模板
|
|
|
+ */
|
|
|
+ @GetMapping("/get/account/template")
|
|
|
+ public void getAccountTemplate(HttpServletResponse response) {
|
|
|
+ EasyExcelUtils.createTemplateExcel(response, ExcelImportAccountData.class, "账号批量修改密码模板", "账号批量修改密码模板", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 导入文件,修改密码
|
|
|
@@ -273,7 +295,7 @@ public class CmsAccountController {
|
|
|
}
|
|
|
String oldPwd = account.getPassword();
|
|
|
if (StrUtil.isNotBlank(data.getExpiryTime())) {
|
|
|
- account.setExpiryTime(DateUtil.parse(data.getExpiryTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ account.setExpiryTime(DateUtil.parse(data.getExpiryTime()));
|
|
|
flag = true;
|
|
|
}
|
|
|
String new_pass = data.getPassword();
|
|
|
@@ -338,30 +360,79 @@ public class CmsAccountController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/post")
|
|
|
- @NoSubmit
|
|
|
- @Transactional(rollbackFor = Throwable.class)
|
|
|
- @Log(module = "平台管理/新增账号", businessType = BusinessType.POST, isSaveRequestData = true)
|
|
|
- public Result<String> add(@RequestBody Account account){
|
|
|
+ @GetMapping("/test")
|
|
|
+ public Result<String> stest(MultipartFile file) throws IOException {
|
|
|
+ List<Object> objects = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(0).doReadSync();
|
|
|
+
|
|
|
+ String url = "https://plus1.caifree.com/api?email=%s";
|
|
|
+ objects.forEach(e->{
|
|
|
+ Map<String, Object> map = Jsons.toMap(e);
|
|
|
+ String account = String.valueOf(map.get("0"));
|
|
|
+ if (StrUtil.isNotEmpty(account)) {
|
|
|
+ String formatUrl = String.format(url, account);
|
|
|
+ try {
|
|
|
+ HttpResponse<String> send = J11HttpC.custom()
|
|
|
+ .ofGet()
|
|
|
+ .url(formatUrl)
|
|
|
+ .send(HttpResponse.BodyHandlers.ofString());
|
|
|
+ System.out.println(send.body());
|
|
|
+ } catch (Exception exception) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String url = "https://plus1.caifree.com/api?email=sentzb99@gmail.com";
|
|
|
+ try {
|
|
|
+ HttpResponse<String> send = J11HttpC.custom()
|
|
|
+ .ofGet()
|
|
|
+ .url(url)
|
|
|
+ .send(HttpResponse.BodyHandlers.ofString());
|
|
|
+ System.out.println(send.body());
|
|
|
+ } catch (Exception exception) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/post")
|
|
|
+ @NoSubmit
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ @Log(module = "平台管理/新增账号", businessType = BusinessType.POST, isSaveRequestData = true)
|
|
|
+ public Result<String> add(@RequestBody Account account){
|
|
|
account.setAccount(account.getAccount().trim());
|
|
|
account.setPassword(account.getPassword().trim());
|
|
|
- //账号是否已经添加过
|
|
|
- if (!account.getAccount().contains("客服")) {
|
|
|
- int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
- .eq(Account::getAccount, account.getAccount())
|
|
|
- .eq(Account::getGoodsId, account.getGoodsId()));
|
|
|
- if (count > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
- }
|
|
|
- }
|
|
|
- accountService.save(account);
|
|
|
- //自动配置车队
|
|
|
- GroupsTrips groupsTrips = new GroupsTrips();
|
|
|
- groupsTrips.setSkuId(account.getSkuId());
|
|
|
- groupsTrips.setAccountId(account.getId());
|
|
|
- cmsGroupService.issuance(groupsTrips, account.getVerifyCodes());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
+ //账号是否已经添加过
|
|
|
+ if (!account.getAccount().contains("客服")) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(account.getGoodsId(), account.getAccount())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountService.save(account);
|
|
|
+ if (account.getSkuId() != null) {
|
|
|
+ //自动配置车队
|
|
|
+ GroupsTrips groupsTrips = new GroupsTrips();
|
|
|
+
|
|
|
+ //限制每天新车队前3天 停车数量
|
|
|
+ Integer availableParkingNum = 0;
|
|
|
+ if (account.getSkuId() == 161l) {
|
|
|
+ availableParkingNum = 10;
|
|
|
+ }
|
|
|
+ if (account.getSkuId() == 178l) {
|
|
|
+ availableParkingNum = 4;
|
|
|
+ }
|
|
|
+ groupsTrips.setAvailableParkingNum(availableParkingNum);
|
|
|
+
|
|
|
+ groupsTrips.setSkuId(account.getSkuId());
|
|
|
+ groupsTrips.setAccountId(account.getId());
|
|
|
+ cmsGroupService.issuance(groupsTrips, account.getVerifyCodes());
|
|
|
+ }
|
|
|
+
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取导入账号模板
|
|
|
@@ -388,10 +459,7 @@ public class CmsAccountController {
|
|
|
if (StrUtil.isNotBlank(data.getAccount())) {
|
|
|
//账号是否已经添加过
|
|
|
if (!account.contains("客服")) {
|
|
|
- int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
- .eq(Account::getAccount, account)
|
|
|
- .eq(Account::getGoodsId, goodsId));
|
|
|
- if (count > 0) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(goodsId, account)) {
|
|
|
log.info("该平台下:{}已生成该账号:{}", goodsId, account);
|
|
|
return;
|
|
|
}
|
|
|
@@ -402,18 +470,37 @@ public class CmsAccountController {
|
|
|
at.setGoodsId(goodsId);
|
|
|
at.setSkuId(skuId);
|
|
|
at.setBankCard(bankCard);
|
|
|
+ String isMonth = data.getIsMonth();
|
|
|
+ if (StrUtil.isNotBlank(isMonth)) {
|
|
|
+ at.setIsMonth(true);
|
|
|
+ }
|
|
|
if (StrUtil.isNotBlank(startTime)) {
|
|
|
- at.setStartTime(DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ at.setStartTime(DateUtil.parse(startTime));
|
|
|
+ } else {
|
|
|
+ at.setStartTime(DateTime.now());
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(expiryTime)) {
|
|
|
- at.setExpiryTime(DateUtil.parse(expiryTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ at.setExpiryTime(DateUtil.parse(expiryTime));
|
|
|
+ } else {
|
|
|
+ at.setExpiryTime(DateUtil.offsetMonth(at.getStartTime(), 1));
|
|
|
}
|
|
|
accountService.save(at);
|
|
|
- //自动配置车队
|
|
|
- GroupsTrips groupsTrips = new GroupsTrips();
|
|
|
- groupsTrips.setSkuId(at.getSkuId());
|
|
|
- groupsTrips.setAccountId(at.getId());
|
|
|
- cmsGroupService.issuance(groupsTrips, null);
|
|
|
+ if (at.getSkuId() != null) {
|
|
|
+ //自动配置车队
|
|
|
+ GroupsTrips groupsTrips = new GroupsTrips();
|
|
|
+ //限制每天新车队前3天 停车数量
|
|
|
+ Integer availableParkingNum = 0;
|
|
|
+ if (at.getSkuId() == 161l) {
|
|
|
+ availableParkingNum = 10;
|
|
|
+ }
|
|
|
+ if (at.getSkuId() == 178l) {
|
|
|
+ availableParkingNum = 4;
|
|
|
+ }
|
|
|
+ groupsTrips.setAvailableParkingNum(availableParkingNum);
|
|
|
+ groupsTrips.setSkuId(at.getSkuId());
|
|
|
+ groupsTrips.setAccountId(at.getId());
|
|
|
+ cmsGroupService.issuance(groupsTrips, null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -425,89 +512,86 @@ public class CmsAccountController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("导入账号成功");
|
|
|
}
|
|
|
|
|
|
- @PutMapping("/update")
|
|
|
- @Log(module = "平台管理/编辑账号", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
- public Result<String> update(@RequestBody Account account){
|
|
|
- Account db = accountService.getById(account.getId());
|
|
|
- if (db == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该账号不存在");
|
|
|
- }
|
|
|
- Boolean isClear = false;
|
|
|
- String dbAccount = db.getAccount();
|
|
|
- long userId = StpAbroadUtil.getLoginIdAsLong();
|
|
|
- if (!db.getPassword().equals(account.getPassword())) {
|
|
|
- account.setCustomerServiceId(0l);
|
|
|
- accountService.saveRecord(userId, account.getId(), db.getPassword(), account.getPassword(), "操作编辑");
|
|
|
-
|
|
|
- //清空过期账号 逻辑删除
|
|
|
- userTicketClearedRecordMapper.update(null, Wrappers.lambdaUpdate(UserTicketClearedRecord.class)
|
|
|
- .set(UserTicketClearedRecord::getDeleted, false)
|
|
|
- .eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
- isClear = true;
|
|
|
- }
|
|
|
- if (StrUtil.isNotBlank(account.getAccount())){
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Log(module = "平台管理/编辑账号", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
+ public Result<String> update(@RequestBody Account account) throws Exception {
|
|
|
+ Account db = accountService.getById(account.getId());
|
|
|
+ if (db == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该账号不存在");
|
|
|
+ }
|
|
|
+ Boolean isClear = false;
|
|
|
+ String dbAccount = db.getAccount();
|
|
|
+ long userId = StpAbroadUtil.getLoginIdAsLong();
|
|
|
+ if (!db.getPassword().equals(account.getPassword())) {
|
|
|
+ account.setCustomerServiceId(0l);
|
|
|
+ accountService.saveRecord(userId, account.getId(), db.getPassword(), account.getPassword(), "操作编辑");
|
|
|
+
|
|
|
+ //清空过期账号 逻辑删除
|
|
|
+ userTicketClearedRecordMapper.update(null, Wrappers.lambdaUpdate(UserTicketClearedRecord.class)
|
|
|
+ .set(UserTicketClearedRecord::getDeleted, false)
|
|
|
+ .eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
+ isClear = true;
|
|
|
+ }
|
|
|
+ if (!db.getAccount().equals(account.getAccount())){
|
|
|
account.setAccount(account.getAccount().trim());
|
|
|
//账号是否已经添加过
|
|
|
if (!account.getAccount().contains("客服")) {
|
|
|
- int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
- .ne(Account::getId, account.getId())
|
|
|
- .eq(Account::getAccount, account.getAccount())
|
|
|
- .eq(Account::getGoodsId, account.getGoodsId()));
|
|
|
- if (count > 0) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(account.getGoodsId(), account.getAccount())) {
|
|
|
throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
}
|
|
|
}
|
|
|
- if (!dbAccount.equals(account.getAccount())) {
|
|
|
- isClear = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (StrUtil.isNotBlank(account.getPassword())){
|
|
|
- account.setPassword(account.getPassword().trim());
|
|
|
- }
|
|
|
- String verifyCodes = account.getVerifyCodes();
|
|
|
- if (StrUtil.isNotBlank(verifyCodes) && !StrUtil.equals(verifyCodes, db.getVerifyCodes())) {
|
|
|
- verifyCodes = verifyCodes.replaceAll("\n", "");
|
|
|
- String[] verifyCodesArray = verifyCodes.split("\\*");
|
|
|
- List<String> verifyCodeList = Arrays.stream(verifyCodesArray).filter(str -> StrUtil.isNotBlank(str)).map(str -> str.trim()).collect(Collectors.toList());
|
|
|
- List<GroupsRelationView> relationViews = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
- .field(GroupsRelationView::getAccountId, account.getId())
|
|
|
- .onlySelect(GroupsRelationView::getId)
|
|
|
- .build());
|
|
|
- if (CollUtil.isNotEmpty(relationViews)) {
|
|
|
- for (int i = 0; i < verifyCodeList.size(); i++) {
|
|
|
- if (i < relationViews.size()) {
|
|
|
- GroupsRelationView groupsRelationView = relationViews.get(i);
|
|
|
- groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
- .set(GroupsRelation::getVerifyCode, verifyCodeList.get(i))
|
|
|
- .eq(GroupsRelation::getId, groupsRelationView.getId()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- String apiSecret = account.getApiSecret();
|
|
|
- if (StrUtil.isNotBlank(apiSecret)) {
|
|
|
- doubleVerifyRecordMapper.update(null, Wrappers.lambdaUpdate(AccountDoubleVerifyRecord.class)
|
|
|
- .set(AccountDoubleVerifyRecord::getDeleted, false)
|
|
|
- .set(AccountDoubleVerifyRecord::getApiSecret, apiSecret)
|
|
|
- .eq(AccountDoubleVerifyRecord::getAccountId, account.getId()));
|
|
|
- }
|
|
|
- account.setStartTime(null);
|
|
|
- if (isClear){
|
|
|
- account.setGptRefreshToken(StrUtil.EMPTY);
|
|
|
- //清除gpt token
|
|
|
- redisService.del(RedisKey.CHATGPT_ACCESS_TOKEN + dbAccount);
|
|
|
- redisService.del(RedisService.key.CHAT_GPT_TOKEN_EXCEPTION_KEY.getName() + dbAccount);
|
|
|
- }
|
|
|
- //时间有效
|
|
|
- if (account.getExpiryTime() != null && account.getExpiryTime().after(DateTime.now())) {
|
|
|
- groupsMapper.update(null, Wrappers.lambdaUpdate(GroupsTrips.class)
|
|
|
- .set(GroupsTrips::getStatus, GroupsTrips.Status.validity)
|
|
|
- .eq(GroupsTrips::getAccountId, account.getId())
|
|
|
- .eq(GroupsTrips::getStatus, GroupsTrips.Status.down));
|
|
|
- }
|
|
|
- accountService.updateById(account);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
+ if (!dbAccount.equals(account.getAccount())) {
|
|
|
+ isClear = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(account.getPassword())){
|
|
|
+ account.setPassword(account.getPassword().trim());
|
|
|
+ }
|
|
|
+ String verifyCodes = account.getVerifyCodes();
|
|
|
+ if (StrUtil.isNotBlank(verifyCodes) && !StrUtil.equals(verifyCodes, db.getVerifyCodes())) {
|
|
|
+ verifyCodes = verifyCodes.replaceAll("\n", "");
|
|
|
+ String[] verifyCodesArray = verifyCodes.split("\\*");
|
|
|
+ List<String> verifyCodeList = Arrays.stream(verifyCodesArray).filter(str -> StrUtil.isNotBlank(str)).map(str -> str.trim()).collect(Collectors.toList());
|
|
|
+ List<GroupsRelationView> relationViews = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getAccountId, account.getId())
|
|
|
+ .onlySelect(GroupsRelationView::getId)
|
|
|
+ .build());
|
|
|
+ if (CollUtil.isNotEmpty(relationViews)) {
|
|
|
+ for (int i = 0; i < verifyCodeList.size(); i++) {
|
|
|
+ if (i < relationViews.size()) {
|
|
|
+ GroupsRelationView groupsRelationView = relationViews.get(i);
|
|
|
+ groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getVerifyCode, verifyCodeList.get(i))
|
|
|
+ .eq(GroupsRelation::getId, groupsRelationView.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String apiSecret = account.getApiSecret();
|
|
|
+ if (StrUtil.isNotBlank(apiSecret)) {
|
|
|
+ doubleVerifyRecordMapper.update(null, Wrappers.lambdaUpdate(AccountDoubleVerifyRecord.class)
|
|
|
+ .set(AccountDoubleVerifyRecord::getDeleted, false)
|
|
|
+ .set(AccountDoubleVerifyRecord::getApiSecret, apiSecret)
|
|
|
+ .eq(AccountDoubleVerifyRecord::getAccountId, account.getId()));
|
|
|
+ }
|
|
|
+ account.setStartTime(null);
|
|
|
+ if (isClear){
|
|
|
+ account.setGptRefreshToken(StrUtil.EMPTY);
|
|
|
+ //清除gpt token
|
|
|
+ redisService.del(RedisKey.CHATGPT_ACCESS_TOKEN + dbAccount);
|
|
|
+ redisService.del(RedisService.key.CHAT_GPT_TOKEN_EXCEPTION_KEY.getName() + dbAccount);
|
|
|
+ templateCommonService.sendAccountTemplateMsg(account);
|
|
|
+ }
|
|
|
+ //时间有效
|
|
|
+ if (account.getExpiryTime() != null && account.getExpiryTime().after(DateTime.now())) {
|
|
|
+ groupsMapper.update(null, Wrappers.lambdaUpdate(GroupsTrips.class)
|
|
|
+ .set(GroupsTrips::getStatus, GroupsTrips.Status.validity)
|
|
|
+ .eq(GroupsTrips::getAccountId, account.getId())
|
|
|
+ .eq(GroupsTrips::getStatus, GroupsTrips.Status.down));
|
|
|
+ }
|
|
|
+ accountService.updateById(account);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 修改密码并发送模板消息
|
|
|
@@ -540,6 +624,7 @@ public class CmsAccountController {
|
|
|
.eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
//发放模板消息
|
|
|
try {
|
|
|
+ account.setAccount(db.getAccount());
|
|
|
templateCommonService.sendAccountTemplateMsg(account);
|
|
|
} catch (Exception e) {
|
|
|
log.error("发送账号{}修改密码消息模板错误", account.getId());
|
|
|
@@ -587,24 +672,24 @@ public class CmsAccountController {
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
@Log(module = "平台管理/删除账号", businessType = BusinessType.DELETE, isSaveRequestData = true)
|
|
|
public Result<String> update(@PathVariable Long id){
|
|
|
- //是否关联了车队
|
|
|
- Integer count = groupsMapper.selectCount(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, id));
|
|
|
- if (count > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("已经发布账号,必须先删除车队才可删除账号");
|
|
|
- }
|
|
|
- accountService.removeById(id);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
-
|
|
|
- @PutMapping("/update/expiryTime")
|
|
|
- public Result<String> updateExpiryTime(@RequestBody ReqAccountIncrExpiryTime incrExpiryTime){
|
|
|
- incrExpiryTime.getAccounts().forEach((accountId)->{
|
|
|
- Account account = accountService.getById(accountId);
|
|
|
- DateTime time = DateUtil.offsetDay(account.getExpiryTime(), incrExpiryTime.getDays());
|
|
|
- accountService.update(Wrappers.lambdaUpdate(Account.class).eq(Account::getId,accountId).set(Account::getExpiryTime,time));
|
|
|
- });
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
+ //是否关联了车队
|
|
|
+ Integer count = groupsMapper.selectCount(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, id));
|
|
|
+ if (count > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("已经发布账号,必须先删除车队才可删除账号");
|
|
|
+ }
|
|
|
+ accountService.removeById(id);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update/expiryTime")
|
|
|
+ public Result<String> updateExpiryTime(@RequestBody ReqAccountIncrExpiryTime incrExpiryTime){
|
|
|
+ incrExpiryTime.getAccounts().forEach((accountId)->{
|
|
|
+ Account account = accountService.getById(accountId);
|
|
|
+ DateTime time = DateUtil.offsetDay(account.getExpiryTime(), incrExpiryTime.getDays());
|
|
|
+ accountService.update(Wrappers.lambdaUpdate(Account.class).eq(Account::getId,accountId).set(Account::getExpiryTime,time));
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 需要修改主账号密码的平台
|
|
|
@@ -677,15 +762,6 @@ public class CmsAccountController {
|
|
|
if (account.getGoodsId() != 1l) {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
- //账号是否已经添加过
|
|
|
- if (!account.getAccount().contains("客服")) {
|
|
|
- int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
- .eq(Account::getAccount, account.getAccount())
|
|
|
- .eq(Account::getGoodsId, account.getGoodsId()));
|
|
|
- if (count > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
- }
|
|
|
- }
|
|
|
Boolean flag = false;
|
|
|
String oldPwd = account.getPassword();
|
|
|
if (account != null) {
|
|
|
@@ -792,6 +868,7 @@ public class CmsAccountController {
|
|
|
if (isFlag) {
|
|
|
boolean b = accountService.updateById(db);
|
|
|
if (StrUtil.isNotBlank(newPwd) && !dnPwd.equals(newPwd) && b) {
|
|
|
+ account.setAccount(db.getAccount());
|
|
|
templateCommonService.sendAccountTemplateMsg(account);
|
|
|
}
|
|
|
}
|
|
|
@@ -904,6 +981,185 @@ public class CmsAccountController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑 未续费的账号
|
|
|
+ */
|
|
|
+ @PutMapping("/update/renew/account")
|
|
|
+ public Result<String> updateRenewAccount(@RequestBody Account account) {
|
|
|
+ Long id = account.getId();
|
|
|
+ Date startTime = account.getStartTime();
|
|
|
+ Date expiryTime = account.getExpiryTime();
|
|
|
+ String remark = account.getRemark();
|
|
|
+ Account byId = accountService.getById(id);
|
|
|
+ Assert.notNull(byId, "账号不存在");
|
|
|
+ byId.setStartTime(startTime);
|
|
|
+ byId.setExpiryTime(expiryTime);
|
|
|
+ byId.setRemark(remark);
|
|
|
+ accountService.updateById(byId);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载 替换错误账号模板
|
|
|
+ */
|
|
|
+ @GetMapping("/get/replace/banned/template")
|
|
|
+ public void getReplaceBannedTemplate(HttpServletResponse response) {
|
|
|
+ EasyExcelUtils.createTemplateExcel(response, ExcelBannedAccountData.class, "封禁账号替换模板", "封禁账号替换模板", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 替换封禁账号
|
|
|
+ */
|
|
|
+ @PostMapping("/replace/banned")
|
|
|
+ public Result<List<String>> replaceBannedAccount(Long goodsId, MultipartFile file) throws IOException {
|
|
|
+ List<String> repeat = new ArrayList<>();
|
|
|
+ List<Long> sendMsgList = new ArrayList<>();
|
|
|
+ EasyExcel.read(file.getInputStream(), ExcelBannedAccountData.class, new AnalysisEventListener<ExcelBannedAccountData>() {
|
|
|
+ @Override
|
|
|
+ public void invoke(ExcelBannedAccountData data, AnalysisContext analysisContext) {
|
|
|
+ String oldAccount = data.getOldAccount();
|
|
|
+ String account = data.getAccount();
|
|
|
+ String password = data.getPassword();
|
|
|
+ if (StrUtil.isEmpty(oldAccount) || StrUtil.isEmpty(account) || StrUtil.isEmpty(password)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Account dbAccount = accountService.getOne(Wrappers.lambdaQuery(Account.class)
|
|
|
+ .eq(Account::getGoodsId, goodsId)
|
|
|
+ .eq(Account::getAccount, oldAccount.trim())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (dbAccount == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ account = account.trim();
|
|
|
+ password = password.trim();
|
|
|
+ if (accountCommonService.checkIsDupAccount(goodsId, account)) {
|
|
|
+ repeat.add(oldAccount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dbAccount.setAccount(account);
|
|
|
+ dbAccount.setPassword(password);
|
|
|
+ dbAccount.setStartTime(DateTime.now());
|
|
|
+ dbAccount.setExpiryTime(DateUtil.offsetMonth(DateTime.now(), 1));
|
|
|
+ accountService.updateById(dbAccount);
|
|
|
+
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
+ .eq(GroupsTrips::getAccountId, dbAccount.getId())
|
|
|
+ .eq(GroupsTrips::getStatus, GroupsTrips.Status.down)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (groupsTrips != null) {
|
|
|
+ groupsTrips.setStatus(GroupsTrips.Status.validity);
|
|
|
+ groupsMapper.updateById(groupsTrips);
|
|
|
+ }
|
|
|
+ sendMsgList.add(dbAccount.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).sheet().doRead();
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(sendMsgList)) {
|
|
|
+ TASK_EXECUTOR.execute(() -> {
|
|
|
+ sendMsgList.forEach(accountId -> {
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
+ .eq(GroupsTrips::getAccountId, accountId).last("limit 1"));
|
|
|
+ if (groupsTrips != null) {
|
|
|
+ Account byId = accountService.getById(accountId);
|
|
|
+ cmsGroupService.sendChangeAccountMsg(groupsTrips.getId(), goodsId, byId.getAccount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(repeat);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入备用账号模板
|
|
|
+ */
|
|
|
+ @GetMapping("/export/prepare/template")
|
|
|
+ public void getPrepareTemplate(HttpServletResponse response) {
|
|
|
+ EasyExcelUtils.createTemplateExcel(response, ExcelPrepareAccountData.class, "导入备用账号模板", "导入备用账号模板", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入备用账号
|
|
|
+ */
|
|
|
+ @PostMapping("/batch/import/prepare")
|
|
|
+ public Result<String> batchImportPrepare(Long goodsId, String preSkuIds, MultipartFile file) throws IOException {
|
|
|
+ if (goodsId == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应平台");
|
|
|
+ }
|
|
|
+ if (goodsId == 26) {
|
|
|
+ if (StrUtil.isEmpty(preSkuIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应规格id");
|
|
|
+ }
|
|
|
+ String[] split = preSkuIds.split(",");
|
|
|
+ preSkuIds = Arrays.stream(split).distinct().collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ final String f_skuIds = preSkuIds;
|
|
|
+ EasyExcel.read(file.getInputStream(), ExcelPrepareAccountData.class, new AnalysisEventListener<ExcelPrepareAccountData>() {
|
|
|
+ @Override
|
|
|
+ public void invoke(ExcelPrepareAccountData data, AnalysisContext analysisContext) {
|
|
|
+ String account = data.getAccount();
|
|
|
+ String password = data.getPassword();
|
|
|
+ if (StrUtil.isEmpty(account) || StrUtil.isEmpty(password)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Account insert = new Account();
|
|
|
+ insert.setAccount(account.trim());
|
|
|
+ insert.setPassword(password.trim());
|
|
|
+ insert.setGoodsId(goodsId);
|
|
|
+ insert.setPreSkuIds(f_skuIds);
|
|
|
+ insert.setType(2);
|
|
|
+ insert.setStartTime(DateTime.now());
|
|
|
+ insert.setExpiryTime(DateUtil.offsetMonth(DateTime.now(), 1));
|
|
|
+ insert.setBankCard(data.getBankCard());
|
|
|
+ //账号是否已经添加过
|
|
|
+ if (!insert.getAccount().contains("客服")) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(insert.getGoodsId(), insert.getAccount())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insert.setType(2);
|
|
|
+ accountService.save(insert);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).sheet().doRead();
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增预备账号
|
|
|
+ */
|
|
|
+ @PostMapping("/post/prepare")
|
|
|
+ public Result<String> postPrepare(@RequestBody Account account) {
|
|
|
+ account.setAccount(account.getAccount().trim());
|
|
|
+ account.setPassword(account.getPassword().trim());
|
|
|
+ //账号是否已经添加过
|
|
|
+ if (!account.getAccount().contains("客服")) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(account.getGoodsId(), account.getAccount())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ account.setType(2);
|
|
|
+ if (account.getGoodsId() == 26) {
|
|
|
+ String preSkuIds = account.getPreSkuIds();
|
|
|
+ if (StrUtil.isEmpty(preSkuIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应规格id");
|
|
|
+ }
|
|
|
+ String[] split = preSkuIds.split(",");
|
|
|
+ String skuSetStr = Arrays.stream(split).distinct().collect(Collectors.joining(","));
|
|
|
+ account.setPreSkuIds(skuSetStr);
|
|
|
+ }
|
|
|
+ accountService.save(account);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量导入系统邮箱
|
|
|
*/
|
|
|
@@ -953,4 +1209,59 @@ public class CmsAccountController {
|
|
|
sysEmailMapper.deleteById(id);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入被封禁平台账号
|
|
|
+ */
|
|
|
+ @PostMapping("/batch/import/blocked")
|
|
|
+ public Result<String> batchImportBlockedAccount(MultipartFile file, Long goodsId) throws IOException {
|
|
|
+ Assert.notNull(goodsId, "请选择对应平台");
|
|
|
+ List<Object> accountBlockedList = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(0).doReadSync();
|
|
|
+ accountService.batchImportBlockedAccount(goodsId, accountBlockedList);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除封禁平台账号
|
|
|
+ */
|
|
|
+ @DeleteMapping("/delete/blocked/{id}")
|
|
|
+ public Result<String> deleteBlockedAccount(@PathVariable Long id) throws IOException {
|
|
|
+ accountBlockedReplaceRecordMapper.deleteById(id);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 被封禁账号列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/blocked")
|
|
|
+ public Result<SearchResult<AccountBlockedReplaceRecord>> getBlockedAccount() {
|
|
|
+ SearchResult<AccountBlockedReplaceRecord> search = beanSearcher.search(AccountBlockedReplaceRecord.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .orderBy(AccountBlockedReplaceRecord::getId).desc()
|
|
|
+ .build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 禁用账号
|
|
|
+ */
|
|
|
+ @PutMapping("/update/disable/{accountId}")
|
|
|
+ @Log(module = "平台管理/禁用账号", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
+ public Result<String> updateDisableAccount(@PathVariable Long accountId) {
|
|
|
+ Optional.ofNullable(accountService.getById(accountId))
|
|
|
+ .ifPresent(e -> {
|
|
|
+ e.setIsDisable(!e.getIsDisable());
|
|
|
+ accountService.updateById(e);
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 账号禁用列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/disable/acount")
|
|
|
+ public Result<SearchResult<AccountDisableView>> getDisableAccount() {
|
|
|
+ SearchResult<AccountDisableView> search = beanSearcher.search(AccountDisableView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(AccountDisableView::getIsDisable, 1).build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
}
|