|
@@ -28,6 +28,7 @@ import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.exchange.ExchangeCodeService;
|
|
import com.cyksj.service.exchange.ExchangeCodeService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.relation.GroupsRelationExpiryRecordService;
|
|
import com.cyksj.service.relation.GroupsRelationExpiryRecordService;
|
|
|
|
|
+import com.cyksj.service.shop.YhShopFrontService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -82,6 +83,8 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
|
|
|
|
|
private final GroupsRelationExpiryRecordService groupsRelationExpiryRecordService;
|
|
private final GroupsRelationExpiryRecordService groupsRelationExpiryRecordService;
|
|
|
|
|
|
|
|
|
|
+ private final YhShopFrontService yhShopFrontService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public List<ExcelExchangeCodeData> createExchangeCode(ExchangeCodeReq exchangeCodeReq) {
|
|
public List<ExcelExchangeCodeData> createExchangeCode(ExchangeCodeReq exchangeCodeReq) {
|
|
@@ -140,6 +143,9 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
if (exchangeCode.getUseStatus()) {
|
|
if (exchangeCode.getUseStatus()) {
|
|
|
throw BusinessRuntimeException.getInstance("该兑换码已使用");
|
|
throw BusinessRuntimeException.getInstance("该兑换码已使用");
|
|
|
}
|
|
}
|
|
|
|
|
+ //店铺中 进行兑换码 兑换 标记订单 座位
|
|
|
|
|
+ String customId = exchangeCodeTicket.getCustomId();
|
|
|
|
|
+ Long yhsId = yhShopFrontService.checkShopCustomIdAndReturnShopId(customId);
|
|
|
//兑换成功
|
|
//兑换成功
|
|
|
exchangeCode.setUseStatus(true);
|
|
exchangeCode.setUseStatus(true);
|
|
|
exchangeCode.setUserId(userId);
|
|
exchangeCode.setUserId(userId);
|
|
@@ -174,7 +180,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
throw BusinessRuntimeException.getInstance("您的订单已退款,无法使用该兑换码");
|
|
throw BusinessRuntimeException.getInstance("您的订单已退款,无法使用该兑换码");
|
|
|
}
|
|
}
|
|
|
//生成车票订单
|
|
//生成车票订单
|
|
|
- getGroupTripsTicket(goodsDonSkuMapper.selectById(exchangeCode.getSkuId()), userId, orderDon, OrderDon.Type.EX_CODE);
|
|
|
|
|
|
|
+ getGroupTripsTicket(yhsId, goodsDonSkuMapper.selectById(exchangeCode.getSkuId()), userId, orderDon, OrderDon.Type.EX_CODE);
|
|
|
log.info("用户:{}通过兑换码:{}兑换成功", userId, exchangeCodeTicket.getCode());
|
|
log.info("用户:{}通过兑换码:{}兑换成功", userId, exchangeCodeTicket.getCode());
|
|
|
if (exchangeCode.getType() == 1) {
|
|
if (exchangeCode.getType() == 1) {
|
|
|
luckyDrawRecordMapper.updateExCodeStatus(userId, exchangeCode.getCode());
|
|
luckyDrawRecordMapper.updateExCodeStatus(userId, exchangeCode.getCode());
|
|
@@ -232,7 +238,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
* 获取车位
|
|
* 获取车位
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public GroupsRelation getGroupTripsTicket(GoodsDonSku sku, Long userId, OrderDon exCodeOrderDon, OrderDon.Type orderDonTye) {
|
|
|
|
|
|
|
+ public GroupsRelation getGroupTripsTicket(Long yhsId, GoodsDonSku sku, Long userId, OrderDon exCodeOrderDon, OrderDon.Type orderDonTye) {
|
|
|
if (sku == null) {
|
|
if (sku == null) {
|
|
|
throw BusinessRuntimeException.getInstance("规格不存在,请联系客服");
|
|
throw BusinessRuntimeException.getInstance("规格不存在,请联系客服");
|
|
|
}
|
|
}
|
|
@@ -244,7 +250,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
|
throw BusinessRuntimeException.getInstance("用户不存在");
|
|
throw BusinessRuntimeException.getInstance("用户不存在");
|
|
|
}
|
|
}
|
|
|
- GroupsRelation relation = getRelationNoOrder(sku, userId);
|
|
|
|
|
|
|
+ GroupsRelation relation = getRelationNoOrder(sku, userId, yhsId);
|
|
|
|
|
|
|
|
Long relationId = relation.getId();
|
|
Long relationId = relation.getId();
|
|
|
OrderDon orderDon;
|
|
OrderDon orderDon;
|
|
@@ -253,6 +259,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
orderDon.setRelationId(relationId);
|
|
orderDon.setRelationId(relationId);
|
|
|
orderDon.setUserId(userId);
|
|
orderDon.setUserId(userId);
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
|
|
+ orderDon.setYhsId(yhsId);
|
|
|
orderDonMapper.updateById(orderDon);
|
|
orderDonMapper.updateById(orderDon);
|
|
|
if (orderDon.getIsDp()) {
|
|
if (orderDon.getIsDp()) {
|
|
|
//是否已经发送优惠加购车票
|
|
//是否已经发送优惠加购车票
|
|
@@ -272,7 +279,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
log.error("订单id:{}优惠加购规格已被删除 skuId:{},车票未发送", orderDon.getId(), plus_skuId);
|
|
log.error("订单id:{}优惠加购规格已被删除 skuId:{},车票未发送", orderDon.getId(), plus_skuId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- GroupsRelation relationNoOrder = getRelationNoOrder(plus_sku, orderDon.getUserId());
|
|
|
|
|
|
|
+ GroupsRelation relationNoOrder = getRelationNoOrder(plus_sku, orderDon.getUserId(), orderDon.getYhsId());
|
|
|
dis_relation_ids.add(relationNoOrder.getId());
|
|
dis_relation_ids.add(relationNoOrder.getId());
|
|
|
});
|
|
});
|
|
|
//保存订单关联优惠加购车票
|
|
//保存订单关联优惠加购车票
|
|
@@ -294,6 +301,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
orderDon.setMoney(BigDecimal.ZERO);
|
|
orderDon.setMoney(BigDecimal.ZERO);
|
|
|
orderDon.setSkuId(sku.getId());
|
|
orderDon.setSkuId(sku.getId());
|
|
|
orderDon.setRelationId(relationId);
|
|
orderDon.setRelationId(relationId);
|
|
|
|
|
+ orderDon.setYhsId(yhsId);
|
|
|
//默认数量为1
|
|
//默认数量为1
|
|
|
orderDon.setNum(1);
|
|
orderDon.setNum(1);
|
|
|
orderDon.setGoodsId(sku.getGoodsId());
|
|
orderDon.setGoodsId(sku.getGoodsId());
|
|
@@ -351,15 +359,15 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public GroupsRelation getRelationNoOrder(GoodsDonSku sku, Long userId) {
|
|
|
|
|
|
|
+ public GroupsRelation getRelationNoOrder(GoodsDonSku sku, Long userId, Long yhsId) {
|
|
|
GroupsRelation relation = null;
|
|
GroupsRelation relation = null;
|
|
|
Integer retryNum = 1;
|
|
Integer retryNum = 1;
|
|
|
List<Long> errorsRelationIds = new ArrayList<>();
|
|
List<Long> errorsRelationIds = new ArrayList<>();
|
|
|
- relation = getFinalRelation(sku, userId, relation, retryNum, errorsRelationIds);
|
|
|
|
|
|
|
+ relation = getFinalRelation(sku, userId, relation, retryNum, yhsId, errorsRelationIds);
|
|
|
return relation;
|
|
return relation;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public GroupsRelation getFinalRelation(GoodsDonSku sku, Long userId, GroupsRelation relation, Integer retryNum, List<Long> errorsRelationIds) {
|
|
|
|
|
|
|
+ public GroupsRelation getFinalRelation(GoodsDonSku sku, Long userId, GroupsRelation relation, Integer retryNum, Long yhsId, List<Long> errorsRelationIds) {
|
|
|
//寻找差不多过期时间规格的车位
|
|
//寻找差不多过期时间规格的车位
|
|
|
relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getDays(), sku.getMonths(), errorsRelationIds);
|
|
relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getDays(), sku.getMonths(), errorsRelationIds);
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
@@ -428,6 +436,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
if (relation.getStatus() != GroupsRelation.Status.outside) {
|
|
if (relation.getStatus() != GroupsRelation.Status.outside) {
|
|
|
relation.setStatus(GroupsRelation.Status.validity);
|
|
relation.setStatus(GroupsRelation.Status.validity);
|
|
|
}
|
|
}
|
|
|
|
|
+ relation.setYhsId(yhsId);
|
|
|
groupsRelationMapper.updateById(relation);
|
|
groupsRelationMapper.updateById(relation);
|
|
|
redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relation.getId());
|
|
redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relation.getId());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -441,7 +450,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
throw BusinessRuntimeException.getInstance("获取车票异常,请联系客服");
|
|
throw BusinessRuntimeException.getInstance("获取车票异常,请联系客服");
|
|
|
}
|
|
}
|
|
|
//失败重新给他分配车位
|
|
//失败重新给他分配车位
|
|
|
- getFinalRelation(sku, userId, relation, ++retryNum, errorsRelationIds);
|
|
|
|
|
|
|
+ getFinalRelation(sku, userId, relation, ++retryNum, yhsId, errorsRelationIds);
|
|
|
}
|
|
}
|
|
|
return relation;
|
|
return relation;
|
|
|
}
|
|
}
|