|
@@ -56,7 +56,6 @@ import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -95,49 +94,74 @@ public class CmsAccountController {
|
|
|
|
|
|
|
|
private final AccountDoubleVerifyRecordMapper doubleVerifyRecordMapper;
|
|
private final AccountDoubleVerifyRecordMapper doubleVerifyRecordMapper;
|
|
|
|
|
|
|
|
- @GetMapping("/get")
|
|
|
|
|
- @SaCheckPermission("account:view")
|
|
|
|
|
- public Result<SearchResult<AccountView>> get(Long userId ,String nickName ,String submitAccount ,String expiryStartTime, String expiryEndTime) {
|
|
|
|
|
- MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
|
|
- if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
|
|
- mapBuilder.field(AccountView::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
|
|
|
- .op(Operator.Between);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
|
+ @SaCheckPermission("account:view")
|
|
|
|
|
+ public Result<SearchResult<AccountView>> get(Long userId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday) {
|
|
|
|
|
+ MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
|
|
+ if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
|
|
+ mapBuilder.field(AccountView::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
|
|
|
+ .op(Operator.Between);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if(userId != null || StringUtils.isNotBlank(nickName) || StringUtils.isNotBlank(submitAccount)){
|
|
|
|
|
- List<Long> accountIds = homeGroupMapper.getAccountIdsByUserIdOrNickNameOrSubmitAccount(userId, nickName ,submitAccount);
|
|
|
|
|
- if(accountIds.isEmpty()){
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(new SearchResult<>());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (userId != null || StringUtils.isNotBlank(nickName) || StringUtils.isNotBlank(submitAccount)) {
|
|
|
|
|
+ List<Long> accountIds = homeGroupMapper.getAccountIdsByUserIdOrNickNameOrSubmitAccount(userId, nickName, submitAccount);
|
|
|
|
|
+ if (accountIds.isEmpty()) {
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(new SearchResult<>());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- mapBuilder.field(AccountView::getId, accountIds).op(Operator.InList);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mapBuilder.field(AccountView::getId, accountIds).op(Operator.InList);
|
|
|
|
|
+ }
|
|
|
|
|
+ String extra_sql = StrUtil.EMPTY;
|
|
|
|
|
+ if (expiredAll != null && expiredAll) {
|
|
|
|
|
+ extra_sql += "(if((select count(distinct relation_id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self')>=5,true,false)) = 1";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- SearchResult<AccountView> search = beanSearcher.search(AccountView.class, mapBuilder.build());
|
|
|
|
|
- search.getDataList().forEach((accountView)->{
|
|
|
|
|
- Integer invited = homeGroupMapper.selectCount(Wrappers.lambdaQuery(HomeGroup.class).eq(HomeGroup::getAccountId, accountView.getId()).eq(HomeGroup::getStatus, "invited"));
|
|
|
|
|
- GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, accountView.getId()).last(" limit 1"));
|
|
|
|
|
- int total = groupsTrips == null ? 0 : groupsTrips.getNum() - groupsTrips.getAvailableNum();
|
|
|
|
|
- Integer unInvited = Math.max(total - invited, 0);
|
|
|
|
|
- accountView.setUnInvited(unInvited);
|
|
|
|
|
- accountView.setInvited(invited);
|
|
|
|
|
- accountView.setTotal(total);
|
|
|
|
|
- List<AccountUpdatePasswordRecord> recordList = beanSearcher.searchList(AccountUpdatePasswordRecord.class,
|
|
|
|
|
- MapUtils.builder().field(AccountUpdatePasswordRecord::getAccountId, accountView.getId())
|
|
|
|
|
- .onlySelect(AccountUpdatePasswordRecord::getCreatedTime)
|
|
|
|
|
- .orderBy(AccountUpdatePasswordRecord::getId)
|
|
|
|
|
- .build());
|
|
|
|
|
- accountView.setUpdatePwdNum(recordList.size());
|
|
|
|
|
- if (accountView.getCustomerServiceId() != 0) {
|
|
|
|
|
- CmsUser cmsUser = cmsUserMapper.selectById(accountView.getCustomerServiceId());
|
|
|
|
|
- Optional.ofNullable(cmsUser).ifPresent(customer -> accountView.setCustomerServiceName(cmsUser.getNickname()));
|
|
|
|
|
- }
|
|
|
|
|
- if (recordList.size() > 0) {
|
|
|
|
|
- accountView.setLastUpdatePwdDate(recordList.get(0).getCreatedTime());
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ SearchResult<AccountView> search = beanSearcher.search(AccountView.class, mapBuilder.build());
|
|
|
|
|
+ search.getDataList().forEach((accountView) -> {
|
|
|
|
|
+ Integer invited = homeGroupMapper.selectCount(Wrappers.lambdaQuery(HomeGroup.class).eq(HomeGroup::getAccountId, accountView.getId()).eq(HomeGroup::getStatus, "invited"));
|
|
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, accountView.getId()).last(" limit 1"));
|
|
|
|
|
+ int total = groupsTrips == null ? 0 : groupsTrips.getNum() - groupsTrips.getAvailableNum();
|
|
|
|
|
+ Integer unInvited = Math.max(total - invited, 0);
|
|
|
|
|
+ accountView.setUnInvited(unInvited);
|
|
|
|
|
+ accountView.setInvited(invited);
|
|
|
|
|
+ accountView.setTotal(total);
|
|
|
|
|
+ List<AccountUpdatePasswordRecord> recordList = beanSearcher.searchList(AccountUpdatePasswordRecord.class,
|
|
|
|
|
+ MapUtils.builder().field(AccountUpdatePasswordRecord::getAccountId, accountView.getId())
|
|
|
|
|
+ .onlySelect(AccountUpdatePasswordRecord::getCreatedTime)
|
|
|
|
|
+ .orderBy(AccountUpdatePasswordRecord::getId)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ accountView.setUpdatePwdNum(recordList.size());
|
|
|
|
|
+ if (accountView.getCustomerServiceId() != 0) {
|
|
|
|
|
+ CmsUser cmsUser = cmsUserMapper.selectById(accountView.getCustomerServiceId());
|
|
|
|
|
+ Optional.ofNullable(cmsUser).ifPresent(customer -> accountView.setCustomerServiceName(cmsUser.getNickname()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (recordList.size() > 0) {
|
|
|
|
|
+ accountView.setLastUpdatePwdDate(recordList.get(0).getCreatedTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 导出账号
|
|
* 导出账号
|
|
@@ -145,7 +169,7 @@ public class CmsAccountController {
|
|
|
@GetMapping("/export/account")
|
|
@GetMapping("/export/account")
|
|
|
@SaCheckPermission("account:export")
|
|
@SaCheckPermission("account:export")
|
|
|
@Log(module = "平台管理/导出账号", businessType = BusinessType.EXPORT, isSaveRequestData = true)
|
|
@Log(module = "平台管理/导出账号", businessType = BusinessType.EXPORT, isSaveRequestData = true)
|
|
|
- public void exportAccount(Long userId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, HttpServletResponse response) {
|
|
|
|
|
|
|
+ public void exportAccount(Long userId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, HttpServletResponse response) {
|
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
if (StrUtil.isNotEmpty(expiryStartTime) || StrUtil.isNotEmpty(expiryEndTime)) {
|
|
|
mapBuilder.field(ExcelManageAccountData::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
mapBuilder.field(ExcelManageAccountData::getExpiryTime, expiryStartTime, expiryEndTime)
|
|
@@ -160,9 +184,34 @@ public class CmsAccountController {
|
|
|
|
|
|
|
|
mapBuilder.field(ExcelManageAccountData::getId, accountIds).op(Operator.InList);
|
|
mapBuilder.field(ExcelManageAccountData::getId, accountIds).op(Operator.InList);
|
|
|
}
|
|
}
|
|
|
- List<ExcelManageAccountData> list = beanSearcher.searchAll(ExcelManageAccountData.class, mapBuilder.build());
|
|
|
|
|
|
|
+ String extra_sql = StrUtil.EMPTY;
|
|
|
|
|
+ if (expiredAll != null && expiredAll) {
|
|
|
|
|
+ extra_sql += "(if((select count(distinct relation_id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self')>=5,true,false)) = 1";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
|
|
+ EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelManageAccountData.class, list, "账号列表", "账号列表", ExcelTypeEnum.XLSX, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -591,22 +640,18 @@ public class CmsAccountController {
|
|
|
if (user != null && user.getRoleNames() != null && user.getRoleNames().contains("客服")) {
|
|
if (user != null && user.getRoleNames() != null && user.getRoleNames().contains("客服")) {
|
|
|
builder.field(AccountView::getCustomerServiceId, userId);
|
|
builder.field(AccountView::getCustomerServiceId, userId);
|
|
|
}
|
|
}
|
|
|
- AtomicInteger numOfExpiredAccount = new AtomicInteger(0);
|
|
|
|
|
|
|
+ //需要修改密码
|
|
|
|
|
+ String extra_sql = "(if((select count(distinct relation_id) from user_ticket_cleared_record ur where ur.account_id = a.id and deleted is true and source = 'self')>=5,true,false)) = 1";
|
|
|
|
|
+ builder.put("extra_sql", extra_sql);
|
|
|
|
|
+ Number expireAll = beanSearcher.searchCount(AccountView.class, builder.build());
|
|
|
|
|
+ //存在过期
|
|
|
|
|
+ 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";
|
|
|
|
|
+ builder.put("extra_sql", extra_sql);
|
|
|
|
|
+ Number existsExpired = beanSearcher.searchCount(AccountView.class, builder.build());
|
|
|
|
|
|
|
|
- AtomicInteger numOfExpiredAllAccount = new AtomicInteger(0);
|
|
|
|
|
-
|
|
|
|
|
- List<AccountView> accountViews = beanSearcher.searchAll(AccountView.class, builder.onlySelect(AccountView::getId, AccountView::getExpiryCount, AccountView::getExpiredAll).build());
|
|
|
|
|
- accountViews.forEach(account -> {
|
|
|
|
|
- if (account.getExpiryCount() > 0) {
|
|
|
|
|
- numOfExpiredAccount.getAndAdd(1);
|
|
|
|
|
- }
|
|
|
|
|
- if (account.getExpiredAll()) {
|
|
|
|
|
- numOfExpiredAllAccount.getAndAdd(1);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
CustomerServiceUpdatePwdDetail updatePwdDetail = new CustomerServiceUpdatePwdDetail();
|
|
CustomerServiceUpdatePwdDetail updatePwdDetail = new CustomerServiceUpdatePwdDetail();
|
|
|
- updatePwdDetail.setNumOfExpiredAccount(numOfExpiredAccount.get());
|
|
|
|
|
- updatePwdDetail.setNumOfExpiredAllAccount(numOfExpiredAllAccount.get());
|
|
|
|
|
|
|
+ updatePwdDetail.setNumOfExpiredAllAccount(expireAll.intValue());
|
|
|
|
|
+ updatePwdDetail.setNumOfExpiredAccount(existsExpired.intValue());
|
|
|
|
|
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(updatePwdDetail);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(updatePwdDetail);
|
|
|
}
|
|
}
|