fix(order): require dropship SKU before submission

This commit is contained in:
2026-09-30 16:51:49 +08:00
parent 94881d23fd
commit babc7de4b6
3 changed files with 78 additions and 2 deletions
@@ -401,6 +401,7 @@ public class OrderApplicationService {
"提交订单前必须完善货物品名、包装类型、箱数、毛重和体积");
}
validatePersistedCargoQuantity(cargo, cargoIndex, true);
requireDropshipSku(order.getFulfillmentType(), cargo.getSkuNo(), cargoIndex);
if (Boolean.TRUE.equals(cargo.getWoodenProduct()) && !Boolean.TRUE.equals(order.getCustomsInspection())) {
throw new BizException(ResultCode.VALIDATION_FAILED, "木制品必须选择商检");
}
@@ -441,7 +442,8 @@ public class OrderApplicationService {
}
validateWoodInspection(request);
validateRequestCargoQuantities(request.cargoes(), true);
for (var cargo : request.cargoes()) {
for (int cargoIndex = 0; cargoIndex < request.cargoes().size(); cargoIndex++) {
var cargo = request.cargoes().get(cargoIndex);
if (!StringUtils.hasText(cargo.cargoName()) || !StringUtils.hasText(cargo.packageType())
|| cargo.packageCount() < 1 || cargo.grossWeightKg() == null
|| cargo.grossWeightKg().signum() <= 0 || cargo.volumeCbm() == null
@@ -449,6 +451,7 @@ public class OrderApplicationService {
throw new BizException(ResultCode.VALIDATION_FAILED,
"提交订单前必须完善货物品名、包装类型、箱数、毛重和体积");
}
requireDropshipSku(request.fulfillmentType(), cargo.skuNo(), cargoIndex);
}
validateMixedCartons(request);
if ("FBA".equals(request.destinationType())) {
@@ -467,6 +470,13 @@ public class OrderApplicationService {
}
}
private static void requireDropshipSku(String fulfillmentType, String skuNo, int cargoIndex) {
if ("ONE_CLICK_DROPSHIP".equals(fulfillmentType) && !StringUtils.hasText(skuNo)) {
throw new BizException(ResultCode.VALIDATION_FAILED,
"第 " + (cargoIndex + 1) + " 条一件代发货物必须填写 SKU NO.");
}
}
private void validateRequestCargoQuantities(List<OrderRequests.Cargo> cargoes, boolean required) {
for (int index = 0; index < cargoes.size(); index++) {
OrderRequests.Cargo cargo = cargoes.get(index);
@@ -1399,7 +1399,7 @@ components:
type: object
required: [packageCount, woodenProduct]
properties:
skuNo: {type: string, maxLength: 64}
skuNo: {type: string, maxLength: 64, description: 草稿可空;FBA 或 ONE_CLICK_DROPSHIP 订单提交及已提交编辑时每条货物必填}
cargoName: {type: string, maxLength: 128}
cargoNameEn: {type: string, maxLength: 128}
productImageFileId: {type: string, pattern: '^[1-9][0-9]*$'}