Jelajahi Sumber

Merge branch 'codex/multi-quantity-orders' into pre

zoujiajian 1 Minggu lalu
induk
melakukan
d0e9f36f44

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/exchange/ExchangeCodeService.java

@@ -3,6 +3,7 @@ package com.cyksj.service.exchange;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.cyksj.dto.Result;
 import com.cyksj.model.entity.ExchangeCode;
+import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.entity.OrderDon;
@@ -48,7 +49,7 @@ public interface ExchangeCodeService extends IService<ExchangeCode> {
 	 * Attempts one ticket allocation without swallowing the failure. Multi-quantity
 	 * fulfillment uses this entry so its per-slot transaction can roll back cleanly.
 	 */
-	GroupsRelation getRelationNoOrderOnce(GoodsDonSku sku, Long userId, Long yhsId);
+	GroupsRelation getRelationNoOrderOnce(GoodsDon goods, GoodsDonSku sku, Long userId, Long yhsId);
 
 	/** Releases only the seat lock owned by the specified user. */
 	void releaseRelationLock(Long relationId, Long userId);

+ 6 - 2
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -510,8 +510,12 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 	}
 
 	@Override
-	public GroupsRelation getRelationNoOrderOnce(GoodsDonSku sku, Long userId, Long yhsId) {
-		return allocateRelation(sku, userId, yhsId);
+	public GroupsRelation getRelationNoOrderOnce(GoodsDon goods, GoodsDonSku sku, Long userId, Long yhsId) {
+		GroupsRelation relation = allocateRelation(sku, userId, yhsId);
+		// Multi-quantity fulfillment bypasses the legacy order-creation method which
+		// normally initializes recharge tickets. Initialize every allocated slot here.
+		setRelationInfoIfRecharge(relation, goods, sku);
+		return relation;
 	}
 
 	@Override

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/MultiQuantityOrderServiceImpl.java

@@ -445,7 +445,7 @@ public class MultiQuantityOrderServiceImpl implements MultiQuantityOrderService
 
         // One slot attempt runs in one transaction; any allocation retry must start from a clean state.
 		Long yhsId = order.getYhsId() == null ? 0L : order.getYhsId();
-		GroupsRelation relation = exchangeCodeService.getRelationNoOrderOnce(sku, order.getUserId(), yhsId);
+		GroupsRelation relation = exchangeCodeService.getRelationNoOrderOnce(goods, sku, order.getUserId(), yhsId);
 		if (relation == null || relation.getId() == null) {
 			throw new IllegalStateException("no available ticket");
 		}

+ 3 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1030,7 +1030,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				|| StrUtil.isNotBlank(request.getPhone())) {
 			throw BusinessRuntimeException.getInstance("多数量下单必须使用已登录账号");
 		}
-		if (giftCardOrder || goods.getSpecialType() != null || Boolean.TRUE.equals(sku.getIsMirror())
+		boolean unsupportedSpecialType = goods.getSpecialType() != null
+				&& goods.getSpecialType() != GoodsDon.SpecialType.recharge;
+		if (giftCardOrder || unsupportedSpecialType || Boolean.TRUE.equals(sku.getIsMirror())
 				|| Boolean.TRUE.equals(sku.getIsDp()) || Boolean.TRUE.equals(request.getIsSpecificPrice())
 				|| Boolean.TRUE.equals(request.getIsAcReduce()) || request.getSubsidyId() != null
 				|| request.getPackageId() != null || request.getOriginalOrderId() != null