|
|
@@ -58,11 +58,15 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public GroupsTrips issuance(GroupsTrips groups) {
|
|
|
+ public GroupsTrips issuance(GroupsTrips groups, String verifyCodes) {
|
|
|
GoodsDonSku sku = skuMapper.selectById(groups.getSkuId());
|
|
|
if (sku == null) {
|
|
|
throw new BusinessRuntimeException("该商品规格不存在!");
|
|
|
}
|
|
|
+ String[] verifyCodeArray = null;
|
|
|
+ if (StrUtil.isNotBlank(verifyCodes)) {
|
|
|
+ verifyCodeArray = verifyCodes.split(",");
|
|
|
+ }
|
|
|
groups.setNum(sku.getNum());
|
|
|
groups.setAvailableNum(sku.getNum());
|
|
|
if (groups.getAccountId() == null || accountMapper.selectById(groups.getAccountId()) == null) {
|
|
|
@@ -76,6 +80,9 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
relation.setGroupsId(groups.getId());
|
|
|
relation.setStatus(GroupsRelation.Status.none);
|
|
|
relation.setNum(i);
|
|
|
+ if (verifyCodeArray != null && verifyCodeArray.length > 0 && verifyCodeArray.length >= i) {
|
|
|
+ relation.setVerifyCode(verifyCodeArray[i - 1]);
|
|
|
+ }
|
|
|
relationMapper.insert(relation);
|
|
|
}
|
|
|
return groups;
|
|
|
@@ -112,27 +119,38 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
|
|
|
title = trips.getTitle();
|
|
|
}
|
|
|
String msg = String.format(Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
|
|
|
- groupsRelations.forEach((relation)->{
|
|
|
- if (relation.getExpiryTime() == null) {
|
|
|
- List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, relation.getUserId()).eq(OrderDon::getRelationId, relation.getId()).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
|
|
|
- orderDonList.forEach((orderDon)->{
|
|
|
- //如果续费增加时间,如果首次则设置当前时间为初始时间
|
|
|
- Date expiryTime = Optional.ofNullable(relation.getExpiryTime()).orElse(new Date());
|
|
|
- log.info("设置账号,该用户 {} 初始时间:{} ",orderDon.getUserId(),DateUtil.format(expiryTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
- GoodsDonSku donSku = skuMapper.selectById(orderDon.getSkuId());
|
|
|
-
|
|
|
- Date newDate = DateUtil.offset(expiryTime, DateField.MONTH, donSku.getMonths() * orderDon.getNum());
|
|
|
- relation.setExpiryTime(newDate);
|
|
|
- log.info("设置账号,该用户 {} 过期时间:{} ",orderDon.getUserId(),DateUtil.format(newDate,"yyyy-MM-dd HH:mm:ss"));
|
|
|
- relation.setStartTime(relation.getStartTime() == null ? new Date() : null);
|
|
|
- relationMapper.updateById(relation);
|
|
|
- orderDon.setStatus(OrderDon.Status.complete);
|
|
|
- orderDonMapper.updateById(orderDon);
|
|
|
- });
|
|
|
- }
|
|
|
- //发送短信
|
|
|
- smsService.sendSmsToRelationUser(relation.getUserId(), msg);
|
|
|
- });
|
|
|
+ //配置midJourney安全码
|
|
|
+ String verifyCodes = groupsTrips.getVerifyCodes();
|
|
|
+ String[] verifyCodeArray = null;
|
|
|
+ if (StrUtil.isNotBlank(verifyCodes)) {
|
|
|
+ verifyCodeArray = verifyCodes.split(",");
|
|
|
+ }
|
|
|
+ for (int i = 0; i < groupsRelations.size(); i++) {
|
|
|
+ GroupsRelation relation = groupsRelations.get(i);
|
|
|
+ if (relation.getExpiryTime() == null) {
|
|
|
+ List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, relation.getUserId()).eq(OrderDon::getRelationId, relation.getId()).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
|
|
|
+ orderDonList.forEach((orderDon) -> {
|
|
|
+ //如果续费增加时间,如果首次则设置当前时间为初始时间
|
|
|
+ Date expiryTime = Optional.ofNullable(relation.getExpiryTime()).orElse(new Date());
|
|
|
+ log.info("设置账号,该用户 {} 初始时间:{} ", orderDon.getUserId(), DateUtil.format(expiryTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ GoodsDonSku donSku = skuMapper.selectById(orderDon.getSkuId());
|
|
|
+
|
|
|
+ Date newDate = DateUtil.offset(expiryTime, DateField.MONTH, donSku.getMonths() * orderDon.getNum());
|
|
|
+ relation.setExpiryTime(newDate);
|
|
|
+ log.info("设置账号,该用户 {} 过期时间:{} ", orderDon.getUserId(), DateUtil.format(newDate, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ relation.setStartTime(relation.getStartTime() == null ? new Date() : null);
|
|
|
+ relationMapper.updateById(relation);
|
|
|
+ orderDon.setStatus(OrderDon.Status.complete);
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //发送短信
|
|
|
+ smsService.sendSmsToRelationUser(relation.getUserId(), msg);
|
|
|
+ if (verifyCodeArray != null && verifyCodeArray.length > 0 && i < verifyCodeArray.length) {
|
|
|
+ relation.setVerifyCode(verifyCodeArray[i]);
|
|
|
+ relationMapper.updateById(relation);
|
|
|
+ }
|
|
|
+ }
|
|
|
groupsTrips.setStatus(GroupsTrips.Status.validity);
|
|
|
updateById(groupsTrips);
|
|
|
|