|
|
@@ -23,8 +23,10 @@ import com.cyksj.model.views.GroupsAccountView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.mange.AccountCommonService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
+import com.cyksj.service.relation.GroupRelationClearService;
|
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
import com.cyksj.service.sms.SmsService;
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserSysMsgNotifyService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
@@ -86,11 +88,17 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
|
|
|
private final UserMapper userMapper;
|
|
|
|
|
|
+ private final NetflixUserAccountSubmitRecoverRecordMapper netflixUserAccountSubmitRecoverRecordMapper;
|
|
|
+
|
|
|
+ private final GroupRelationClearService clearService;
|
|
|
+
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public GroupsTrips issuance(GroupsTrips groups, String verifyCodes) {
|
|
|
+ public GroupsTrips issuance(GroupsTrips groups, String verifyCodes, Boolean isRecover) {
|
|
|
GoodsDonSku sku = skuMapper.selectById(groups.getSkuId());
|
|
|
if (sku == null) {
|
|
|
throw new BusinessRuntimeException("该商品规格不存在!");
|
|
|
@@ -117,7 +125,15 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
if (verifyCodeList != null && verifyCodeList.size() > 0 && verifyCodeList.size() >= i) {
|
|
|
relation.setVerifyCode(verifyCodeList.get(i - 1));
|
|
|
}
|
|
|
+ NetflixUserAccountSubmitRecoverRecord recoverRecord = null;
|
|
|
+ if (sku.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
+ recoverRecord = updateRelationIfRecoverTicket(isRecover, sku, relation);
|
|
|
+ }
|
|
|
relationMapper.insert(relation);
|
|
|
+ if (recoverRecord != null) {
|
|
|
+ recoverRecord.setReplaceRelationId(relation.getId());
|
|
|
+ netflixUserAccountSubmitRecoverRecordMapper.updateById(recoverRecord);
|
|
|
+ }
|
|
|
}
|
|
|
Integer alertCount = alertMapper.selectCount(Wrappers.lambdaQuery(GroupsRelationAlert.class)
|
|
|
.eq(GroupsRelationAlert::getSkuId, sku.getId())
|
|
|
@@ -534,4 +550,36 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 奈飞异常恢复车票
|
|
|
+ */
|
|
|
+ private NetflixUserAccountSubmitRecoverRecord updateRelationIfRecoverTicket(Boolean isRecover, GoodsDonSku sku, GroupsRelation relation) {
|
|
|
+ if (isRecover != null && isRecover) {
|
|
|
+ NetflixUserAccountSubmitRecoverRecord recoverRecord = netflixUserAccountSubmitRecoverRecordMapper.selectOne(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getSkuId, sku.getId())
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getStatus, 0)
|
|
|
+ .orderByAsc(NetflixUserAccountSubmitRecoverRecord::getCreatedTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (recoverRecord != null) {
|
|
|
+ relation.setUserId(recoverRecord.getUserId());
|
|
|
+ relation.setStatus(GroupsRelation.Status.validity);
|
|
|
+ relation.setStartTime(DateTime.now());
|
|
|
+ relation.setExpiryTime(DateUtil.offsetDay(relation.getStartTime(), recoverRecord.getRemainDays().intValue()));
|
|
|
+ //清除车票
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(recoverRecord.getUserId(), null);
|
|
|
+ GroupsRelation clearRelation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getId, recoverRecord.getRelationId())
|
|
|
+ .in(GroupsRelation::getUserId, userIdList)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (clearRelation != null) {
|
|
|
+ clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
|
+ }
|
|
|
+ recoverRecord.setStatus(1);
|
|
|
+ return recoverRecord;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|