Răsfoiți Sursa

Merge branch 'delAccount'

zoujiajian 9 luni în urmă
părinte
comite
9726878231

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/model/request/DelAccountTripsReq.java

@@ -23,4 +23,11 @@ public class DelAccountTripsReq {
 	 * 车队ids
 	 */
 	private List<Long> groupsIds;
+
+	/**
+	 * 账号列表
+	 */
+	private List<String> accounts;
+
+	private Integer goodsId;
 }

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/CmsAccountService.java

@@ -60,4 +60,6 @@ public interface CmsAccountService extends IService<Account> {
 	String getAccountEmailCode(Long accountId) throws Exception;
 
 	void batchDeleteAccountTrips(DelAccountTripsReq delAccountTripsReq, long adminId) throws Exception;
+
+	List<String> batchDelAccountTripsByGoodsAccount(DelAccountTripsReq delAccountTripsReq, long adminId) throws Exception;
 }

+ 47 - 0
netflix-service/src/main/java/com/cyksj/service/mange/account/CmsAccountServiceImpl.java

@@ -558,4 +558,51 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 			}
 		}
 	}
+
+	@Override
+	public List<String> batchDelAccountTripsByGoodsAccount(DelAccountTripsReq delAccountTripsReq, long adminId) throws Exception {
+		CmsUser cmsUser = cmsUserMapper.selectById(adminId);
+		Integer goodsId = delAccountTripsReq.getGoodsId();
+		List<String> accounts = delAccountTripsReq.getAccounts();
+
+		GoodsDon goodsDon = goodsDonMapper.selectById(goodsId);
+		Assert.notNull(goodsDon,"平台不存在");
+
+		List<String> fails = new ArrayList<>();
+
+		if (CollUtil.isNotEmpty(accounts)) {
+			DelAccountRecord delAccountRecord = null;
+			for (String account : accounts) {
+				Account dbAccount = accountMapper.selectOne(Wrappers.lambdaQuery(Account.class).eq(Account::getAccount, account.trim()).eq(Account::getGoodsId, goodsId).last("limit 1"));
+				if (dbAccount == null) {
+					fails.add(account);
+					continue;
+				}
+				GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
+						.eq(GroupsTrips::getAccountId, dbAccount.getId())
+						.last("limit 1"));
+				if (groupsTrips != null) {
+					Integer selectCount = relationMapper.selectCount(Wrappers.lambdaQuery(GroupsRelation.class)
+							.eq(GroupsRelation::getGroupsId, groupsTrips.getId())
+							.ne(GroupsRelation::getUserId, 0));
+					//车队上存在用户不删除 下个循环
+					if (selectCount > 0) {
+						fails.add(account);
+						continue;
+					}
+					groupsMapper.deleteById(groupsTrips.getId());
+					relationMapper.delete(Wrappers.lambdaQuery(GroupsRelation.class)
+							.eq(GroupsRelation::getGroupsId, groupsTrips.getId()));
+				}
+				delAccountRecord = new DelAccountRecord();
+				if (cmsUser != null) {
+					delAccountRecord.setOperator(cmsUser.getNickname());
+				}
+				delAccountRecord.setAccountInfo(Jsons.toJson(account));
+				delAccountRecordMapper.insert(delAccountRecord);
+				accountMapper.deleteById(dbAccount.getId());
+			}
+		}
+		return fails;
+	}
 }

+ 25 - 3
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -124,6 +124,8 @@ public class CmsAccountController {
 
 	private final OrderDonMapper orderDonMapper;
 
+	private final DelAccountRecordMapper delAccountRecordMapper;
+
 	@GetMapping("/get")
 	@SaCheckPermission("account:view")
 	public Result<SearchResult<AccountView>> get(String title, Long userId, String showId, String nickName, String submitAccount, String expiryStartTime, String expiryEndTime, Boolean expiredAll, Boolean existsExpired, Boolean existsExpiredToday, Integer noChangeMonths, Boolean isMjMirror, String orderNo, Boolean isEmpty) {
@@ -775,13 +777,23 @@ public class CmsAccountController {
 	@DeleteMapping("/delete/{id}")
 	@SaCheckPermission("account:delete")
 	@Log(module = "平台管理/删除账号", businessType = BusinessType.DELETE, isSaveRequestData = true)
-	public Result<String> update(@PathVariable Long id){
-	    //是否关联了车队
+	public Result<String> update(@PathVariable Long id) throws Exception {
+		long adminId = StpUtil.getLoginIdAsLong();
+		//是否关联了车队
 	    Integer count = groupsMapper.selectCount(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, id));
 	    if (count > 0) {
 		    throw BusinessRuntimeException.getInstance("已经发布账号,必须先删除车队才可删除账号");
 	    }
-        accountService.removeById(id);
+		Account account = accountService.getById(id);
+		accountService.removeById(id);
+
+		DelAccountRecord delAccountRecord = new DelAccountRecord();
+		CmsUser cmsUser = cmsUserMapper.selectById(adminId);
+		if (cmsUser != null) {
+			delAccountRecord.setOperator(cmsUser.getNickname());
+		}
+		delAccountRecord.setAccountInfo(Jsons.toJson(account));
+		delAccountRecordMapper.insert(delAccountRecord);
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
@@ -795,6 +807,16 @@ public class CmsAccountController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 导入账号 批量删除
+	 */
+	@DeleteMapping("/batch/delete/goods/accountTrips")
+	public Result<List<String>> batchDelAccountTripsByGoodsAccount(@RequestBody DelAccountTripsReq delAccountTripsReq) throws Exception {
+		long adminId = StpUtil.getLoginIdAsLong();
+		List<String> fails = accountService.batchDelAccountTripsByGoodsAccount(delAccountTripsReq, adminId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(fails);
+	}
+
     @PutMapping("/update/expiryTime")
     @SaCheckPermission("account:addExpiryTime")
     public Result<String> updateExpiryTime(@RequestBody ReqAccountIncrExpiryTime incrExpiryTime){