|
|
@@ -11,11 +11,13 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.mapper.*;
|
|
|
+import com.cyksj.mapper.manage.DelGroupsTripsRecordMapper;
|
|
|
import com.cyksj.mapper.manage.GroupsTripsAccountReplaceRecordMapper;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.ReplaceTripsAccountReq;
|
|
|
import com.cyksj.model.views.GroupsAccountView;
|
|
|
+import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
import com.cyksj.service.sms.SmsService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
@@ -60,6 +62,10 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
|
|
|
private final EnvCommonService envCommonService;
|
|
|
|
|
|
+ private final RedisService redisService;
|
|
|
+
|
|
|
+ private final DelGroupsTripsRecordMapper delGroupsTripsRecordMapper;
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
|
|
|
@@ -105,12 +111,37 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
Integer count = relationMapper.selectCount(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
.eq(GroupsRelation::getGroupsId, groupId)
|
|
|
.in(GroupsRelation::getStatus, List.of(GroupsRelation.Status.locking, GroupsRelation.Status.validity)));
|
|
|
+ //可强制删除
|
|
|
+ //后台记录
|
|
|
if (count > 0) {
|
|
|
- throw new BusinessRuntimeException("该车队已有用户购买或锁定.无法删除");
|
|
|
- }else {
|
|
|
- relationMapper.delete(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId,groupId));
|
|
|
- this.removeById(groupId);
|
|
|
+ TASK_EXECUTOR.execute(() -> {
|
|
|
+ if (redisService.setNx(String.format("%s-%s", groupId, groupsTrips.getAccount()), groupId, 10l)) {
|
|
|
+ Account account = accountMapper.selectById(groupsTrips.getAccountId());
|
|
|
+ List<GroupsRelation> groupsRelations = relationMapper.selectList(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getGroupsId, groupId)
|
|
|
+ .in(GroupsRelation::getStatus, List.of(GroupsRelation.Status.locking, GroupsRelation.Status.validity)));
|
|
|
+ groupsRelations.forEach(data -> {
|
|
|
+ DelGroupsTripsRecord delGroupsTripsRecord = new DelGroupsTripsRecord();
|
|
|
+ delGroupsTripsRecord.setGroupsId(groupId);
|
|
|
+ delGroupsTripsRecord.setGroupsStatus(groupsTrips.getStatus().name());
|
|
|
+ if (account != null) {
|
|
|
+ delGroupsTripsRecord.setAccount(account.getAccount());
|
|
|
+ delGroupsTripsRecord.setPassword(account.getPassword());
|
|
|
+ }
|
|
|
+ delGroupsTripsRecord.setRelationId(data.getId());
|
|
|
+ delGroupsTripsRecord.setSkuId(groupsTrips.getSkuId());
|
|
|
+ delGroupsTripsRecord.setUserId(data.getUserId());
|
|
|
+ delGroupsTripsRecord.setStartTime(data.getStartTime());
|
|
|
+ delGroupsTripsRecord.setExpiryTime(data.getExpiryTime());
|
|
|
+ delGroupsTripsRecord.setRelationStatus(data.getStatus().name());
|
|
|
+ delGroupsTripsRecord.setType("delete");
|
|
|
+ delGroupsTripsRecordMapper.insert(delGroupsTripsRecord);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ relationMapper.delete(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId,groupId));
|
|
|
+ this.removeById(groupId);
|
|
|
}
|
|
|
|
|
|
@Override
|