|
|
@@ -17,12 +17,11 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.GroupsMapper;
|
|
|
-import com.cyksj.mapper.HomeGroupMapper;
|
|
|
-import com.cyksj.mapper.UserMapper;
|
|
|
-import com.cyksj.mapper.UserTicketClearedRecordMapper;
|
|
|
+import com.cyksj.mapper.*;
|
|
|
+import com.cyksj.mapper.manage.AccountDeletedRecordMapper;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.excel.ExcelExpiredAccountData;
|
|
|
import com.cyksj.model.excel.ExcelImportAccountData;
|
|
|
import com.cyksj.model.excel.ExcelManageAccountData;
|
|
|
import com.cyksj.model.manage.request.ReqAccountIncrExpiryTime;
|
|
|
@@ -54,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
@@ -92,6 +92,10 @@ public class CmsAccountController {
|
|
|
|
|
|
private final CmsUserManager cmsUserManager;
|
|
|
|
|
|
+ private final AccountDeletedRecordMapper accountDeletedRecordMapper;
|
|
|
+
|
|
|
+ private final GroupsRelationMapper relationMapper;
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
|
@SaCheckPermission("account:view")
|
|
|
public Result<SearchResult<AccountView>> get(Long userId ,String nickName ,String submitAccount ,String expiryStartTime, String expiryEndTime) {
|
|
|
@@ -582,4 +586,85 @@ public class CmsAccountController {
|
|
|
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(updatePwdDetail);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取被封账号excel表格 删除账号以及车队
|
|
|
+ */
|
|
|
+ private final GoodsDonMapper goodsDonMapper;
|
|
|
+ @GetMapping("/read/account/expired")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<String> readAccountExpired(MultipartFile file) throws IOException {
|
|
|
+ EasyExcel.read(file.getInputStream(), ExcelExpiredAccountData.class, new AnalysisEventListener<ExcelExpiredAccountData>() {
|
|
|
+ @Override
|
|
|
+ public void invoke(ExcelExpiredAccountData data, AnalysisContext analysisContext) {
|
|
|
+ String account = data.getAccount();
|
|
|
+ String title = data.getTitle();
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectOne(Wrappers.lambdaQuery(GoodsDon.class)
|
|
|
+ .eq(GoodsDon::getTitle, title).last("limit 1"));
|
|
|
+ if (goodsDon == null) {
|
|
|
+ log.error("账号:{}平台不存在", account);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long goodsId = goodsDon.getId();
|
|
|
+ Account dbAccount = accountService.getOne(Wrappers.lambdaQuery(Account.class)
|
|
|
+ .eq(Account::getAccount, account.trim())
|
|
|
+ .eq(Account::getGoodsId, goodsId).last("limit 1"));
|
|
|
+ if (dbAccount == null) {
|
|
|
+ log.error("账号:{}不存在", account);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //先记录
|
|
|
+ Long accountId = dbAccount.getId();
|
|
|
+ String password = dbAccount.getPassword();
|
|
|
+ Date accountStartTime = dbAccount.getStartTime();
|
|
|
+ Date accountExpiryTime = dbAccount.getExpiryTime();
|
|
|
+ Long groupId = null;
|
|
|
+ List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getAccountId, dbAccount.getId()).build());
|
|
|
+ if (!relationViewList.isEmpty()) {
|
|
|
+ groupId = relationViewList.get(0).getGroupsId();
|
|
|
+ }
|
|
|
+ relationViewList.forEach(view -> {
|
|
|
+ Long relationId = view.getId();
|
|
|
+ Long userId = view.getUserId();
|
|
|
+ Long groupsId = view.getGroupsId();
|
|
|
+ Long skuId = view.getSkuId();
|
|
|
+ Date startTime = view.getStartTime();
|
|
|
+ Date expiryTime = view.getExpiryTime();
|
|
|
+ AccountDeletedRecord accountDeletedRecord = new AccountDeletedRecord();
|
|
|
+ accountDeletedRecord.setAccountId(accountId);
|
|
|
+ accountDeletedRecord.setGoodsId(goodsId);
|
|
|
+ accountDeletedRecord.setAccount(account);
|
|
|
+ accountDeletedRecord.setPassword(password);
|
|
|
+ accountDeletedRecord.setAccountStartTime(accountStartTime);
|
|
|
+ accountDeletedRecord.setAccountExpiryTime(accountExpiryTime);
|
|
|
+
|
|
|
+ accountDeletedRecord.setGroupsId(groupsId);
|
|
|
+ accountDeletedRecord.setSkuId(skuId);
|
|
|
+ accountDeletedRecord.setRelationId(relationId);
|
|
|
+ accountDeletedRecord.setUserId(userId);
|
|
|
+ accountDeletedRecord.setRelationStartTime(startTime);
|
|
|
+ accountDeletedRecord.setRelationExpireTime(expiryTime);
|
|
|
+ accountDeletedRecordMapper.insert(accountDeletedRecord);
|
|
|
+ log.info("记录用户:{}被删除车票入库", view.getUserId());
|
|
|
+ });
|
|
|
+ //后删除
|
|
|
+ //删除账号
|
|
|
+ accountService.removeById(accountId);
|
|
|
+
|
|
|
+ //删除车队
|
|
|
+ groupsMapper.delete(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
+ .eq(GroupsTrips::getId, groupId));
|
|
|
+
|
|
|
+ //删除车位
|
|
|
+ relationMapper.delete(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getGroupsId, groupId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|