diff --git a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/FreshPartner.java b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/FreshPartner.java index 1d25273..0ba2160 100644 --- a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/FreshPartner.java +++ b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/FreshPartner.java @@ -2,14 +2,14 @@ import io.github.dddplus.annotation.Partner; import io.github.dddplus.ext.IIdentityResolver; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; @Partner(code = FreshPartner.CODE, name = "生鲜业务前台BP") -public class FreshPartner implements IIdentityResolver { +public class FreshPartner implements IIdentityResolver { public static final String CODE = "fresh"; @Override - public boolean match(IOrderModel model) { + public boolean match(IOrderMain model) { return model.getSource().toLowerCase().equals(CODE); } } diff --git a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PostPersitExt.java b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PostPersitExt.java index 59cd406..4b8b6c4 100644 --- a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PostPersitExt.java +++ b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PostPersitExt.java @@ -4,14 +4,14 @@ import lombok.extern.slf4j.Slf4j; import org.example.bp.oms.fresh.FreshPartner; import org.example.cp.oms.spec.ext.IPostPersistExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; @Slf4j @Extension(code = FreshPartner.CODE, value = "freshPostPersistExt") public class PostPersitExt implements IPostPersistExt { @Override - public void afterPersist(IOrderModel model) { + public void afterPersist(IOrderMain model) { log.info("{} 落库了,我要发个MQ通知我的下游!", model); } } diff --git a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PresortExt.java b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PresortExt.java index 554b8b3..82792e2 100644 --- a/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PresortExt.java +++ b/order-center-bp-fresh/src/main/java/org/example/bp/oms/fresh/extension/PresortExt.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.bp.oms.fresh.FreshPartner; import org.example.cp.oms.spec.ext.IPresortExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class PresortExt implements IPresortExt { @Override - public void presort(@NotNull IOrderModel model) { + public void presort(@NotNull IOrderMain model) { log.info("Fresh里预分拣的结果:{}", new MockInnerClass().getResult()); } diff --git a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/IsvPartner.java b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/IsvPartner.java index 8a7924e..874af57 100644 --- a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/IsvPartner.java +++ b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/IsvPartner.java @@ -1,14 +1,14 @@ package org.example.bp.oms.isv; import lombok.extern.slf4j.Slf4j; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.annotation.Partner; import io.github.dddplus.ext.IIdentityResolver; import org.springframework.beans.factory.DisposableBean; @Partner(code = IsvPartner.CODE, name = "ISV业务前台") @Slf4j -public class IsvPartner implements IIdentityResolver, DisposableBean { +public class IsvPartner implements IIdentityResolver, DisposableBean { public static final String CODE = "ISV"; public IsvPartner() { @@ -17,7 +17,7 @@ public IsvPartner() { } @Override - public boolean match(IOrderModel model) { + public boolean match(IOrderMain model) { if (model.getSource() == null) { return false; } diff --git a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/CustomModelExt.java b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/CustomModelExt.java index 583177c..44e8df5 100644 --- a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/CustomModelExt.java +++ b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/CustomModelExt.java @@ -9,19 +9,19 @@ import org.example.bp.oms.isv.aop.AutoLogger; import org.example.cp.oms.spec.exception.OrderErrorReason; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; import java.util.Map; @Slf4j @Extension(code = IsvPartner.CODE, value = "isvCustomModel", name = "ISV前台的订单个性化字段处理逻辑") -public class CustomModelExt implements IModelAttachmentExt { +public class CustomModelExt implements IModelAttachmentExt { private static final String KEY_STATION_NO = "_station_contact_"; @Override @AutoLogger - public void explain(@NotNull RequestProfile source, @NotNull IOrderModel target) { + public void explain(@NotNull RequestProfile source, @NotNull IOrderMain target) { // 入参里预留了扩展属性 Map ext = source.getExt(); // 站点联系人号码,是个性化字段,中台只存储,不负责逻辑:前台来处理逻辑,并告诉中台存储到哪些已预留的字段 @@ -38,10 +38,10 @@ public void explain(@NotNull RequestProfile source, @NotNull IOrderModel target) } @Override - public void explain(@NotNull IOrderModel model) { + public void explain(@NotNull IOrderMain model) { } @Override - public void render(@NotNull IOrderModel source, @NotNull ApiResult target) { + public void render(@NotNull IOrderMain source, @NotNull ApiResult target) { } } diff --git a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/PresortExt.java b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/PresortExt.java index f95423e..6ffc05f 100644 --- a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/PresortExt.java +++ b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/PresortExt.java @@ -8,7 +8,7 @@ import org.example.bp.oms.isv.aop.AutoLogger; import org.example.bp.oms.isv.extension.util.WarehouseUtil; import org.example.cp.oms.spec.ext.IPresortExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; import java.io.IOException; @@ -22,7 +22,7 @@ public class PresortExt implements IPresortExt { @Override @AutoLogger - public void presort(@NotNull IOrderModel model) { + public void presort(@NotNull IOrderMain model) { log.info("ISV里预分拣的结果:{}", new MockInnerClass().getResult()); // 演示第三方包的使用:guava diff --git a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/SerializableIsolationExt.java b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/SerializableIsolationExt.java index 5b288d4..48684ce 100644 --- a/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/SerializableIsolationExt.java +++ b/order-center-bp-isv/src/main/java/org/example/bp/oms/isv/extension/SerializableIsolationExt.java @@ -3,7 +3,7 @@ import io.github.dddplus.annotation.Extension; import org.example.bp.oms.isv.IsvPartner; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class SerializableIsolationExt implements ISerializableIsolationExt { @Override - public LockEntry createLockEntry(@NotNull IOrderModel model) { + public LockEntry createLockEntry(@NotNull IOrderMain model) { return new LockEntry(model.customerProvidedOrderNo(), 50, TimeUnit.MINUTES); } } diff --git a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/KaPartner.java b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/KaPartner.java index f16ee60..e41cccd 100644 --- a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/KaPartner.java +++ b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/KaPartner.java @@ -1,15 +1,15 @@ package org.example.bp.oms.ka; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.annotation.Partner; import io.github.dddplus.ext.IIdentityResolver; @Partner(code = KaPartner.CODE, name = "KA业务前台") -public class KaPartner implements IIdentityResolver { +public class KaPartner implements IIdentityResolver { public static final String CODE = "KA"; @Override - public boolean match(IOrderModel model) { + public boolean match(IOrderMain model) { if (model.getSource() == null) { return false; } diff --git a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/AssignOrderNoExt.java b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/AssignOrderNoExt.java index 129ab96..dbc3c6b 100644 --- a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/AssignOrderNoExt.java +++ b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/AssignOrderNoExt.java @@ -3,7 +3,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.bp.oms.ka.KaPartner; import org.example.cp.oms.spec.ext.IAssignOrderNoExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.annotation.Extension; import org.example.cp.oms.spec.resource.IStockRpc; @@ -19,7 +19,7 @@ public class AssignOrderNoExt implements IAssignOrderNoExt { private IStockRpc stockService; @Override - public void assignOrderNo(@NotNull IOrderModel model) { + public void assignOrderNo(@NotNull IOrderMain model) { log.info("KA 预占库存 GSM098"); if (!stockService.preOccupyStock("GSM098")) { throw new RuntimeException("预占库存失败"); diff --git a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/ReviseStepsExt.java b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/ReviseStepsExt.java index 13401e0..cbf45f2 100644 --- a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/ReviseStepsExt.java +++ b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/ReviseStepsExt.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.bp.oms.ka.KaPartner; import org.example.cp.oms.spec.ext.IReviseStepsExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import java.util.List; @@ -13,7 +13,7 @@ public class ReviseStepsExt implements IReviseStepsExt { @Override - public List reviseSteps(IOrderModel model) { + public List reviseSteps(IOrderMain model) { log.info("KA will not revise subsequent steps"); return null; } diff --git a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/SerializableIsolationExt.java b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/SerializableIsolationExt.java index 3ea9aca..f6220ea 100644 --- a/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/SerializableIsolationExt.java +++ b/order-center-bp-ka/src/main/java/org/example/bp/oms/ka/extension/SerializableIsolationExt.java @@ -3,7 +3,7 @@ import lombok.extern.slf4j.Slf4j; import io.github.dddplus.annotation.Extension; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import org.example.bp.oms.ka.KaPartner; @@ -15,7 +15,7 @@ public class SerializableIsolationExt implements ISerializableIsolationExt { @Override - public LockEntry createLockEntry(@NotNull IOrderModel model) { + public LockEntry createLockEntry(@NotNull IOrderMain model) { log.info("KA的锁TTL大一些"); return new LockEntry(model.customerProvidedOrderNo(), 11, TimeUnit.MINUTES); } diff --git a/order-center-cp/cp-oc-controller/src/main/java/org/example/cp/oms/controller/OrderController.java b/order-center-cp/cp-oc-controller/src/main/java/org/example/cp/oms/controller/OrderController.java index e61b2e6..53e3f8b 100644 --- a/order-center-cp/cp-oc-controller/src/main/java/org/example/cp/oms/controller/OrderController.java +++ b/order-center-cp/cp-oc-controller/src/main/java/org/example/cp/oms/controller/OrderController.java @@ -3,7 +3,7 @@ import lombok.extern.slf4j.Slf4j; import io.github.dddplus.api.RequestProfile; import io.github.dddplus.runtime.registry.Container; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.model.OrderModelCreator; import org.example.cp.oms.domain.service.SubmitOrder; import org.slf4j.MDC; @@ -47,7 +47,7 @@ public String submitOrder(@RequestParam(required = false) String type) { creator.setSource(type); creator.setCustomerNo("goog"); // if 'home', HomeAppliancePattern will match creator.setExternalNo("20200987655"); - OrderModel model = OrderModel.createWith(creator); + OrderMain model = OrderMain.createWith(creator); // 调用domain service完成该use case submitOrder.submit(model); diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/AssignOrderNoAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/AssignOrderNoAbility.java index ac02bda..0749b9e 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/AssignOrderNoAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/AssignOrderNoAbility.java @@ -3,7 +3,7 @@ import org.example.cp.oms.domain.CoreDomain; import org.example.cp.oms.domain.ability.extension.DefaultAssignOrderNoExt; import org.example.cp.oms.spec.ext.IAssignOrderNoExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.annotation.DomainAbility; import io.github.dddplus.runtime.BaseDomainAbility; @@ -11,17 +11,17 @@ import javax.validation.constraints.NotNull; @DomainAbility(domain = CoreDomain.CODE, name = "分配订单号的能力") -public class AssignOrderNoAbility extends BaseDomainAbility { +public class AssignOrderNoAbility extends BaseDomainAbility { @Resource private DefaultAssignOrderNoExt defaultAssignOrderNoExt; - public void assignOrderNo(@NotNull IOrderModel model) { + public void assignOrderNo(@NotNull IOrderMain model) { firstExtension(model).assignOrderNo(model); } @Override - public IAssignOrderNoExt defaultExtension(@NotNull IOrderModel model) { + public IAssignOrderNoExt defaultExtension(@NotNull IOrderMain model) { return defaultAssignOrderNoExt; } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/CustomModelAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/CustomModelAbility.java index 8d36073..ae4f47d 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/CustomModelAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/CustomModelAbility.java @@ -4,19 +4,19 @@ import io.github.dddplus.ext.IModelAttachmentExt; import io.github.dddplus.runtime.BaseDomainAbility; import org.example.cp.oms.domain.CoreDomain; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @DomainAbility(domain = CoreDomain.CODE) -public class CustomModelAbility extends BaseDomainAbility { +public class CustomModelAbility extends BaseDomainAbility { - public void explain(@NotNull IOrderModel model) { + public void explain(@NotNull IOrderMain model) { firstExtension(model).explain(model.requestProfile(), model); } @Override - public IModelAttachmentExt defaultExtension(IOrderModel model) { + public IModelAttachmentExt defaultExtension(IOrderMain model) { return null; } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/DecideStepsAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/DecideStepsAbility.java index 224da4e..79ab59e 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/DecideStepsAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/DecideStepsAbility.java @@ -2,7 +2,7 @@ import org.example.cp.oms.domain.CoreDomain; import org.example.cp.oms.spec.DomainAbilities; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.annotation.DomainAbility; import io.github.dddplus.ext.IDecideStepsExt; import io.github.dddplus.runtime.BaseDomainAbility; @@ -11,14 +11,14 @@ import java.util.List; @DomainAbility(domain = CoreDomain.CODE, name = "动态决定领域步骤的能力", tags = DomainAbilities.decideSteps) -public class DecideStepsAbility extends BaseDomainAbility { +public class DecideStepsAbility extends BaseDomainAbility { - public List decideSteps(@NotNull IOrderModel model, String activityCode) { + public List decideSteps(@NotNull IOrderMain model, String activityCode) { return firstExtension(model).decideSteps(model, activityCode); } @Override - public IDecideStepsExt defaultExtension(@NotNull IOrderModel model) { + public IDecideStepsExt defaultExtension(@NotNull IOrderMain model) { // 没有默认的扩展点实现 return null; } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PostPersistAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PostPersistAbility.java index b17cf40..c8cfc79 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PostPersistAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PostPersistAbility.java @@ -4,20 +4,19 @@ import io.github.dddplus.runtime.BaseDomainAbility; import org.example.cp.oms.domain.CoreDomain; import org.example.cp.oms.spec.ext.IPostPersistExt; -import org.example.cp.oms.spec.ext.IPresortExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @DomainAbility(domain = CoreDomain.CODE, name = "落库后的扩展能力") -public class PostPersistAbility extends BaseDomainAbility { +public class PostPersistAbility extends BaseDomainAbility { - public void afterPersist(@NotNull IOrderModel model) { + public void afterPersist(@NotNull IOrderMain model) { firstExtension(model).afterPersist(model); } @Override - public IPostPersistExt defaultExtension(@NotNull IOrderModel model) { + public IPostPersistExt defaultExtension(@NotNull IOrderMain model) { return null; } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PresortAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PresortAbility.java index bfa7294..f1ad9df 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PresortAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/PresortAbility.java @@ -4,19 +4,19 @@ import io.github.dddplus.runtime.BaseDomainAbility; import org.example.cp.oms.domain.CoreDomain; import org.example.cp.oms.spec.ext.IPresortExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @DomainAbility(domain = CoreDomain.CODE, name = "预分拣的能力") -public class PresortAbility extends BaseDomainAbility { +public class PresortAbility extends BaseDomainAbility { - public void presort(@NotNull IOrderModel model) { + public void presort(@NotNull IOrderMain model) { firstExtension(model).presort(model); } @Override - public IPresortExt defaultExtension(@NotNull IOrderModel model) { + public IPresortExt defaultExtension(@NotNull IOrderMain model) { return null; } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/ReviseStepsAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/ReviseStepsAbility.java index 35ed8c5..1d98252 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/ReviseStepsAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/ReviseStepsAbility.java @@ -3,22 +3,22 @@ import io.github.dddplus.annotation.DomainAbility; import io.github.dddplus.runtime.BaseDomainAbility; import org.example.cp.oms.domain.CoreDomain; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.spec.ext.IReviseStepsExt; import javax.validation.constraints.NotNull; import java.util.List; @DomainAbility(domain = CoreDomain.CODE) -public class ReviseStepsAbility extends BaseDomainAbility { +public class ReviseStepsAbility extends BaseDomainAbility { - public List revisedSteps(@NotNull OrderModel model) { + public List revisedSteps(@NotNull OrderMain model) { // execute ext with timeout 300ms return firstExtension(model, 300).reviseSteps(model); } @Override - public IReviseStepsExt defaultExtension(@NotNull OrderModel model) { + public IReviseStepsExt defaultExtension(@NotNull OrderMain model) { return null; } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/SerializableIsolationAbility.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/SerializableIsolationAbility.java index 24aa2f0..bf4da14 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/SerializableIsolationAbility.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/ability/SerializableIsolationAbility.java @@ -5,7 +5,7 @@ import org.example.cp.oms.domain.facade.cache.IRedisClient; import org.example.cp.oms.domain.facade.lock.IRedisLockFactory; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import io.github.dddplus.annotation.DomainAbility; import io.github.dddplus.runtime.BaseDomainAbility; @@ -16,7 +16,7 @@ @DomainAbility(domain = CoreDomain.CODE, name = "订单串行化隔离的能力") @Slf4j -public class SerializableIsolationAbility extends BaseDomainAbility { +public class SerializableIsolationAbility extends BaseDomainAbility { private static final Lock withoutLock = null; @Resource @@ -25,7 +25,7 @@ public class SerializableIsolationAbility extends BaseDomainAbility注意,它没有实现Serializable,因为它不会网络传递,也不会本地文件存储.

+ */ +@Getter // 注意:它没有@Setter,是为了封装,包含订单一致性 @Slf4j -public class OrderModel implements IOrderModel { +public class OrderMain implements IOrderMain { private String source; private String customerNo; @@ -35,12 +40,12 @@ public class OrderModel implements IOrderModel { @Getter private String x1, x2; - public static OrderModel createWith(@NotNull OrderModelCreator creator) throws OrderException { + public static OrderMain createWith(@NotNull OrderModelCreator creator) throws OrderException { log.debug("creating with {}", creator); - return new OrderModel(creator).validate(); + return new OrderMain(creator).validate(); } - private OrderModel(OrderModelCreator creator) { + private OrderMain(OrderModelCreator creator) { this.source = creator.getSource(); this.customerNo = creator.getCustomerNo(); this.externalNo = creator.getExternalNo(); @@ -49,7 +54,7 @@ private OrderModel(OrderModelCreator creator) { this.productDelegate = ProductDelegate.createWith(creator); } - private OrderModel validate() throws OrderException { + private OrderMain validate() throws OrderException { // 模型本身的基础校验 return this; } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java new file mode 100644 index 0000000..f1270a4 --- /dev/null +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java @@ -0,0 +1,6 @@ +package org.example.cp.oms.domain.model.vo; + +import org.example.cp.oms.spec.model.vo.IOrderItem; + +public class OrderItem implements IOrderItem { +} diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/CancelOrder.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/CancelOrder.java index fdbb58f..4375ba7 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/CancelOrder.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/CancelOrder.java @@ -5,7 +5,7 @@ import org.example.cp.oms.domain.ability.SerializableIsolationAbility; import org.example.cp.oms.spec.exception.OrderErrorReason; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.CancelOrderStepsExec; import io.github.dddplus.annotation.DomainService; import io.github.dddplus.model.IDomainService; @@ -25,7 +25,7 @@ public class CancelOrder implements IDomainService { @Resource private CancelOrderStepsExec cancelOrderStepsExec; - public void submit(@NotNull OrderModel orderModel) throws OrderException { + public void submit(@NotNull OrderMain orderModel) throws OrderException { Lock lock = DDD.findAbility(SerializableIsolationAbility.class).acquireLock(orderModel); if (SerializableIsolationAbility.useLock(lock) && !lock.tryLock()) { // 存在并发 diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/SubmitOrder.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/SubmitOrder.java index 71508b3..414f0f7 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/SubmitOrder.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/service/SubmitOrder.java @@ -11,7 +11,7 @@ import org.example.cp.oms.domain.ability.DecideStepsAbility; import org.example.cp.oms.spec.exception.OrderErrorReason; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.spec.Steps; import javax.annotation.Resource; @@ -26,7 +26,7 @@ public class SubmitOrder implements IDomainService { @Resource private SubmitOrderStepsExec submitOrderStepsExec; - public void submit(@NotNull OrderModel orderModel) throws OrderException { + public void submit(@NotNull OrderMain orderModel) throws OrderException { // 先通过防并发扩展点防止一个订单多次处理:但防并发逻辑在不同场景下不同 // 同时,也希望研发清楚:扩展点不是绑定到领域步骤的,它可以在任何地方使用! Lock lock = DDD.findAbility(SerializableIsolationAbility.class).acquireLock(orderModel); diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStep.java index 6113e17..01f5a95 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStep.java @@ -1,11 +1,11 @@ package org.example.cp.oms.domain.step; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import io.github.dddplus.step.IDomainStep; import org.example.cp.oms.spec.Steps; -public abstract class CancelOrderStep implements IDomainStep { +public abstract class CancelOrderStep implements IDomainStep { @Override public String activityCode() { diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStepsExec.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStepsExec.java index 5b6ad18..d8d273b 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStepsExec.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/CancelOrderStepsExec.java @@ -2,19 +2,19 @@ import io.github.dddplus.runtime.StepsExecTemplate; import lombok.extern.slf4j.Slf4j; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.springframework.stereotype.Component; @Component @Slf4j -public class CancelOrderStepsExec extends StepsExecTemplate { +public class CancelOrderStepsExec extends StepsExecTemplate { @Override - protected void beforeStep(CancelOrderStep step, OrderModel model) { + protected void beforeStep(CancelOrderStep step, OrderMain model) { log.info("step:{}.{} before:{}", step.activityCode(), step.stepCode(), model.label()); } @Override - protected void afterStep(CancelOrderStep step, OrderModel model) { + protected void afterStep(CancelOrderStep step, OrderMain model) { } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStep.java index b0a063b..848aef3 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStep.java @@ -1,13 +1,13 @@ package org.example.cp.oms.domain.step; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import io.github.dddplus.step.IRevokableDomainStep; import org.example.cp.oms.spec.exception.OrderException; import org.example.cp.oms.spec.Steps; import javax.validation.constraints.NotNull; -public abstract class SubmitOrderStep implements IRevokableDomainStep { +public abstract class SubmitOrderStep implements IRevokableDomainStep { @Override public String activityCode() { @@ -15,7 +15,7 @@ public String activityCode() { } @Override - public void rollback(@NotNull OrderModel model, @NotNull OrderException cause) { + public void rollback(@NotNull OrderMain model, @NotNull OrderException cause) { // 默认不回滚,子类可以通过覆盖实现对应步骤的回滚逻辑 } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStepsExec.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStepsExec.java index ac87d1d..16089b0 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStepsExec.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/SubmitOrderStepsExec.java @@ -2,19 +2,19 @@ import io.github.dddplus.runtime.StepsExecTemplate; import lombok.extern.slf4j.Slf4j; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.springframework.stereotype.Component; @Component @Slf4j -public class SubmitOrderStepsExec extends StepsExecTemplate { +public class SubmitOrderStepsExec extends StepsExecTemplate { @Override - protected void beforeStep(SubmitOrderStep step, OrderModel model) { + protected void beforeStep(SubmitOrderStep step, OrderMain model) { log.info("step:{}.{} before:{}", step.activityCode(), step.stepCode(), model.label()); } @Override - protected void afterStep(SubmitOrderStep step, OrderModel model) { + protected void afterStep(SubmitOrderStep step, OrderMain model) { } } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/BasicStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/BasicStep.java index 5195e6a..ac1d4d4 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/BasicStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/BasicStep.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.CancelOrderStep; import org.example.cp.oms.spec.Steps; import io.github.dddplus.annotation.Step; @@ -14,7 +14,7 @@ public class BasicStep extends CancelOrderStep { @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/StateStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/StateStep.java index 619d112..0a17af9 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/StateStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/cancelorder/StateStep.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.CancelOrderStep; import org.example.cp.oms.spec.Steps; import io.github.dddplus.annotation.Step; @@ -14,7 +14,7 @@ public class StateStep extends CancelOrderStep { @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BasicStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BasicStep.java index a29f1f4..04d90ff 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BasicStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BasicStep.java @@ -6,7 +6,7 @@ import io.github.dddplus.step.ReviseStepsException; import org.example.cp.oms.domain.ability.PresortAbility; import org.example.cp.oms.domain.ability.ReviseStepsAbility; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.SubmitOrderStep; import org.example.cp.oms.spec.Steps; import org.example.cp.oms.spec.exception.OrderException; @@ -19,7 +19,7 @@ public class BasicStep extends SubmitOrderStep { @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { model.setStep(this.stepCode()); // 动态决定后续步骤:决定后续步骤这个行为,也抽象为扩展点,不同场景进行实现,以实现动态步骤编排的业务多态性 @@ -36,7 +36,7 @@ public void execute(@NotNull OrderModel model) throws OrderException { } @Override - public void rollback(@NotNull OrderModel model, @NotNull OrderException cause) { + public void rollback(@NotNull OrderMain model, @NotNull OrderException cause) { log.info("will rollback now..."); } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BroadcastStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BroadcastStep.java index d68f70b..f70ba68 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BroadcastStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/BroadcastStep.java @@ -2,7 +2,7 @@ import org.example.cp.oms.spec.exception.OrderException; import org.example.cp.oms.domain.facade.mq.IMessageProducer; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.SubmitOrderStep; import org.example.cp.oms.spec.Steps; import io.github.dddplus.annotation.Step; @@ -17,7 +17,7 @@ public class BroadcastStep extends SubmitOrderStep { private IMessageProducer messageProducer; @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { messageProducer.produce(model); } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PersistStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PersistStep.java index 7c10f79..f88afc2 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PersistStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PersistStep.java @@ -4,7 +4,7 @@ import org.example.cp.oms.domain.ability.CustomModelAbility; import org.example.cp.oms.spec.exception.OrderException; import org.example.cp.oms.domain.facade.repository.IOrderRepository; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.SubmitOrderStep; import org.example.cp.oms.spec.Steps; import io.github.dddplus.annotation.Step; @@ -20,7 +20,7 @@ public class PersistStep extends SubmitOrderStep { private IOrderRepository orderRepository; @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { // 分配订单号:不同场景下,订单号规则不同 DDD.findAbility(AssignOrderNoAbility.class).assignOrderNo(model); diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PresortStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PresortStep.java index aa084e0..32a56d5 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PresortStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/PresortStep.java @@ -1,23 +1,18 @@ package org.example.cp.oms.domain.step.submitorder; import io.github.dddplus.annotation.Step; -import io.github.dddplus.runtime.DDD; -import org.example.cp.oms.domain.ability.AssignOrderNoAbility; -import org.example.cp.oms.domain.ability.CustomModelAbility; -import org.example.cp.oms.domain.facade.repository.IOrderRepository; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.SubmitOrderStep; import org.example.cp.oms.spec.Steps; import org.example.cp.oms.spec.exception.OrderException; -import javax.annotation.Resource; import javax.validation.constraints.NotNull; @Step(value = "submitPresortStep", name = "预分拣步骤") public class PresortStep extends SubmitOrderStep { @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { // TODO 把预分拣扩展点从BasicStep移动到这里 } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/ProductStep.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/ProductStep.java index 9822ab9..7c9e7b9 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/ProductStep.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/step/submitorder/ProductStep.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.step.SubmitOrderStep; import org.example.cp.oms.spec.Steps; import io.github.dddplus.annotation.Step; @@ -14,7 +14,7 @@ public class ProductStep extends SubmitOrderStep { @Override - public void execute(@NotNull OrderModel model) throws OrderException { + public void execute(@NotNull OrderMain model) throws OrderException { } @Override diff --git a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/mq/MessageProducer.java b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/mq/MessageProducer.java index 8a485c8..efccc19 100644 --- a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/mq/MessageProducer.java +++ b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/mq/MessageProducer.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.cp.oms.domain.facade.mq.IMessageProducer; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.springframework.stereotype.Component; import javax.validation.constraints.NotNull; @@ -12,7 +12,7 @@ public class MessageProducer implements IMessageProducer { @Override - public void produce(@NotNull OrderModel orderModel) { + public void produce(@NotNull OrderMain orderModel) { log.info("已经发送给MQ:{}", orderModel); } } diff --git a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/repository/OrderRepository.java b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/repository/OrderRepository.java index b461bb6..1af23cb 100644 --- a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/repository/OrderRepository.java +++ b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/repository/OrderRepository.java @@ -2,7 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.example.cp.oms.domain.facade.repository.IOrderRepository; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.infra.manager.IOrderManager; import org.example.cp.oms.infra.po.OrderMainData; import org.example.cp.oms.infra.translator.OrderTranslator; @@ -19,7 +19,7 @@ public class OrderRepository implements IOrderRepository { private IOrderManager orderManager; @Override - public void persist(@NotNull OrderModel orderModel) { + public void persist(@NotNull OrderMain orderModel) { log.info("落库:{}", orderModel); if (true) { diff --git a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/translator/OrderTranslator.java b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/translator/OrderTranslator.java index 0518b54..94f5d60 100644 --- a/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/translator/OrderTranslator.java +++ b/order-center-cp/cp-oc-infrastructure/src/main/java/org/example/cp/oms/infra/translator/OrderTranslator.java @@ -2,7 +2,7 @@ import org.example.cp.oms.infra.po.OrderMainData; import io.github.dddplus.IBaseTranslator; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; @@ -12,10 +12,10 @@ unmappedTargetPolicy = ReportingPolicy.WARN, typeConversionPolicy = ReportingPolicy.ERROR ) -public interface OrderTranslator extends IBaseTranslator { +public interface OrderTranslator extends IBaseTranslator { OrderTranslator instance = Mappers.getMapper(OrderTranslator.class); @Override - OrderMainData translate(OrderModel orderModel); + OrderMainData translate(OrderMain orderModel); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IAssignOrderNoExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IAssignOrderNoExt.java index a810b65..efe55c0 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IAssignOrderNoExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IAssignOrderNoExt.java @@ -1,6 +1,6 @@ package org.example.cp.oms.spec.ext; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.ext.IDomainExtension; import javax.validation.constraints.NotNull; @@ -10,6 +10,6 @@ */ public interface IAssignOrderNoExt extends IDomainExtension { - void assignOrderNo(@NotNull IOrderModel model); + void assignOrderNo(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPostPersistExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPostPersistExt.java index 976023a..f72ad10 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPostPersistExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPostPersistExt.java @@ -1,7 +1,7 @@ package org.example.cp.oms.spec.ext; import io.github.dddplus.ext.IDomainExtension; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -10,5 +10,5 @@ */ public interface IPostPersistExt extends IDomainExtension { - void afterPersist(@NotNull IOrderModel model); + void afterPersist(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPresortExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPresortExt.java index 4ad9815..207f448 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPresortExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IPresortExt.java @@ -1,7 +1,7 @@ package org.example.cp.oms.spec.ext; import io.github.dddplus.ext.IDomainExtension; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -12,5 +12,5 @@ */ public interface IPresortExt extends IDomainExtension { - void presort(@NotNull IOrderModel model); + void presort(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IReviseStepsExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IReviseStepsExt.java index ef336d8..c3264e7 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IReviseStepsExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/IReviseStepsExt.java @@ -1,6 +1,6 @@ package org.example.cp.oms.spec.ext; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.ext.IDomainExtension; import javax.validation.constraints.NotNull; @@ -8,6 +8,6 @@ public interface IReviseStepsExt extends IDomainExtension { - List reviseSteps(@NotNull IOrderModel model); + List reviseSteps(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISensitiveWordsExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISensitiveWordsExt.java index d0454d3..6f12b32 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISensitiveWordsExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISensitiveWordsExt.java @@ -1,7 +1,7 @@ package org.example.cp.oms.spec.ext; import io.github.dddplus.ext.IDomainExtension; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -10,5 +10,5 @@ */ public interface ISensitiveWordsExt extends IDomainExtension { - String[] extract(@NotNull IOrderModel model); + String[] extract(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISerializableIsolationExt.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISerializableIsolationExt.java index 05346ad..c3bb27a 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISerializableIsolationExt.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/ext/ISerializableIsolationExt.java @@ -1,6 +1,6 @@ package org.example.cp.oms.spec.ext; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import io.github.dddplus.ext.IDomainExtension; @@ -17,6 +17,6 @@ public interface ISerializableIsolationExt extends IDomainExtension { * @param model * @return lock entry object. if null, 不需要防并发 */ - LockEntry createLockEntry(@NotNull IOrderModel model); + LockEntry createLockEntry(@NotNull IOrderMain model); } diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderModel.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderMain.java similarity index 88% rename from order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderModel.java rename to order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderMain.java index 22cda57..1a43e45 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderModel.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/IOrderMain.java @@ -6,9 +6,9 @@ import lombok.NonNull; /** - * 中台为业务前台输出的领域模型:以接口的方式控制visibility. + * 中台为业务前台输出的订单聚合根:以接口的方式控制visibility. */ -public interface IOrderModel extends IDomainModel { +public interface IOrderMain extends IDomainModel { /** * 获取订单里包含的产品信息. diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IOrderItem.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IOrderItem.java new file mode 100644 index 0000000..688e72c --- /dev/null +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IOrderItem.java @@ -0,0 +1,4 @@ +package org.example.cp.oms.spec.model.vo; + +public interface IOrderItem { +} diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProduct.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProduct.java index 9f28bac..d623bca 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProduct.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProduct.java @@ -1,7 +1,9 @@ package org.example.cp.oms.spec.model.vo; /** - * 产品信息. + * 订单包含的服务产品信息. + * + *

例如:仓内加工,货到付款,保价等,都是额外的服务产品.

*/ public interface IProduct { diff --git a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProductDelegate.java b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProductDelegate.java index d96fb56..6979770 100644 --- a/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProductDelegate.java +++ b/order-center-cp/cp-oc-spec/src/main/java/org/example/cp/oms/spec/model/vo/IProductDelegate.java @@ -2,6 +2,12 @@ import java.util.List; +/** + * 订单的服务产品管理器. + * + *

它管理某个订单的服务产品.

+ *

DDD里喜欢使用带有业务属性的VO,而不是直接使用Java primitive types,是很有道理的.

+ */ public interface IProductDelegate { List getProducts(); } diff --git a/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/ExampleTest.java b/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/ExampleTest.java index 5961081..a7ea0b0 100644 --- a/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/ExampleTest.java +++ b/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/ExampleTest.java @@ -2,7 +2,7 @@ import io.github.dddplus.api.RequestProfile; import org.example.cp.oms.spec.exception.OrderException; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.model.OrderModelCreator; import org.example.cp.oms.domain.service.SubmitOrder; import org.junit.Ignore; @@ -38,7 +38,7 @@ public void demoSubmitOrder() throws OrderException { creator.setCustomerNo("home"); // HomeAppliancePattern 会触发家电相关的扩展点 creator.setExternalNo("20200987655"); creator.setRequestProfile(requestProfile); - OrderModel orderModel = OrderModel.createWith(creator); + OrderMain orderModel = OrderMain.createWith(creator); // ISV业务前台的下单执行: // SerializableIsolationExt -> DecideStepsExt -> BasicStep(PresortExt) -> PersistStep(AssignOrderNoExt, CustomModelAbility) -> BroadcastStep @@ -56,7 +56,7 @@ public void failureCase() { creator.setCustomerNo("home"); // HomeAppliancePattern 会触发家电相关的扩展点 creator.setExternalNo("20200987655"); creator.setRequestProfile(requestProfile); - OrderModel orderModel = OrderModel.createWith(creator); + OrderMain orderModel = OrderMain.createWith(creator); try { submitOrder.submit(orderModel); fail(); diff --git a/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/PluginMechanismTest.java b/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/PluginMechanismTest.java index cd2c658..a669a4c 100644 --- a/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/PluginMechanismTest.java +++ b/order-center-cp/cp-oc-test/src/test/java/org/example/cp/oms/PluginMechanismTest.java @@ -5,7 +5,7 @@ import io.github.dddplus.plugin.IPlugin; import io.github.dddplus.runtime.registry.Container; import lombok.extern.slf4j.Slf4j; -import org.example.cp.oms.domain.model.OrderModel; +import org.example.cp.oms.domain.model.OrderMain; import org.example.cp.oms.domain.model.OrderModelCreator; import org.example.cp.oms.domain.service.SubmitOrder; import org.junit.Ignore; @@ -115,7 +115,7 @@ private void submitOrder(ApplicationContext applicationContext, String source) { creator.setSource(source); creator.setCustomerNo("home"); // HomeAppliancePattern creator.setExternalNo("20200987655"); - OrderModel orderModel = OrderModel.createWith(creator); + OrderMain orderModel = OrderMain.createWith(creator); // call the domain service SubmitOrder submitOrder = (SubmitOrder) applicationContext.getBean("submitOrder"); diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/ColdChainB2BPattern.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/ColdChainB2BPattern.java index 250b370..f4ba9c1 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/ColdChainB2BPattern.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/ColdChainB2BPattern.java @@ -3,16 +3,16 @@ import io.github.dddplus.annotation.Pattern; import io.github.dddplus.ext.IIdentityResolver; import org.example.cp.oms.spec.Patterns; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @Pattern(code = ColdChainB2BPattern.CODE, name = "冷链B2B模式", tags = Patterns.Tags.B2B) -public class ColdChainB2BPattern implements IIdentityResolver { +public class ColdChainB2BPattern implements IIdentityResolver { public static final String CODE = Patterns.ColdChainB2B; @Override - public boolean match(@NotNull IOrderModel model) { + public boolean match(@NotNull IOrderMain model) { return model.isB2B() && model.isColdChain(); } } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HairPattern.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HairPattern.java index c732ce3..500eb71 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HairPattern.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HairPattern.java @@ -2,17 +2,17 @@ import io.github.dddplus.annotation.Pattern; import org.example.cp.oms.spec.Patterns; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.ext.IIdentityResolver; import javax.validation.constraints.NotNull; @Pattern(code = HairPattern.CODE, name = "海尔业务模式") -public class HairPattern implements IIdentityResolver { +public class HairPattern implements IIdentityResolver { public static final String CODE = Patterns.Hair; @Override - public boolean match(@NotNull IOrderModel model) { + public boolean match(@NotNull IOrderMain model) { if (model.getCustomerNo() == null) { return false; } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HomeAppliancePattern.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HomeAppliancePattern.java index 51a7d9d..f436be1 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HomeAppliancePattern.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/HomeAppliancePattern.java @@ -2,17 +2,17 @@ import io.github.dddplus.annotation.Pattern; import org.example.cp.oms.spec.Patterns; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import io.github.dddplus.ext.IIdentityResolver; import javax.validation.constraints.NotNull; @Pattern(code = HomeAppliancePattern.CODE, name = "家用电器行业模式") -public class HomeAppliancePattern implements IIdentityResolver { +public class HomeAppliancePattern implements IIdentityResolver { public static final String CODE = Patterns.HomeAppliance; @Override - public boolean match(@NotNull IOrderModel model) { + public boolean match(@NotNull IOrderMain model) { if (model.getCustomerNo() == null) { return false; } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/coldchain_b2b/SerializableIsolationExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/coldchain_b2b/SerializableIsolationExt.java index b5c1f60..9f1fbfa 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/coldchain_b2b/SerializableIsolationExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/coldchain_b2b/SerializableIsolationExt.java @@ -3,7 +3,7 @@ import io.github.dddplus.annotation.Extension; import org.example.cp.oms.pattern.ColdChainB2BPattern; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class SerializableIsolationExt implements ISerializableIsolationExt { @Override - public LockEntry createLockEntry(@NotNull IOrderModel model) { + public LockEntry createLockEntry(@NotNull IOrderMain model) { return new LockEntry(model.customerProvidedOrderNo(), 19, TimeUnit.MINUTES); } } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/ReviseStepsExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/ReviseStepsExt.java index 5f8a3b6..ec4bcbe 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/ReviseStepsExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/ReviseStepsExt.java @@ -4,7 +4,7 @@ import org.example.cp.oms.pattern.HairPattern; import org.example.cp.oms.spec.Steps; import org.example.cp.oms.spec.ext.IReviseStepsExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import java.util.ArrayList; import java.util.List; @@ -13,7 +13,7 @@ public class ReviseStepsExt implements IReviseStepsExt { @Override - public List reviseSteps(IOrderModel model) { + public List reviseSteps(IOrderMain model) { if (Steps.SubmitOrder.Activity.equals(model.currentActivity())) { if (model.currentStep().equals(Steps.SubmitOrder.BasicStep)) { List subsequentSteps = new ArrayList<>(); diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/SerializableIsolationExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/SerializableIsolationExt.java index ee8a856..4c8de1b 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/SerializableIsolationExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/hair/SerializableIsolationExt.java @@ -3,7 +3,7 @@ import io.github.dddplus.annotation.Extension; import org.example.cp.oms.pattern.HairPattern; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class SerializableIsolationExt implements ISerializableIsolationExt { @Override - public LockEntry createLockEntry(@NotNull IOrderModel model) { + public LockEntry createLockEntry(@NotNull IOrderMain model) { return new LockEntry(model.customerProvidedOrderNo(), 1, TimeUnit.HOURS); } } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/AssignOrderNoExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/AssignOrderNoExt.java index b2a02f0..6e588f1 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/AssignOrderNoExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/AssignOrderNoExt.java @@ -3,7 +3,7 @@ import org.example.cp.oms.pattern.HomeAppliancePattern; import io.github.dddplus.annotation.Extension; import org.example.cp.oms.spec.ext.IAssignOrderNoExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -12,7 +12,7 @@ public class AssignOrderNoExt implements IAssignOrderNoExt { public static final String HOME_ORDER_NO = "SO9987012"; @Override - public void assignOrderNo(@NotNull IOrderModel model) { + public void assignOrderNo(@NotNull IOrderMain model) { model.assignOrderNo(this, HOME_ORDER_NO); } } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/PresortExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/PresortExt.java index 91f423c..40225c0 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/PresortExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/PresortExt.java @@ -4,7 +4,7 @@ import io.github.dddplus.annotation.Extension; import org.example.cp.oms.pattern.HomeAppliancePattern; import org.example.cp.oms.spec.ext.IPresortExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class PresortExt implements IPresortExt { @Override - public void presort(@NotNull IOrderModel model) { + public void presort(@NotNull IOrderMain model) { log.info("家电的预分拣执行了"); } } diff --git a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/SerializableIsolationExt.java b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/SerializableIsolationExt.java index ee37f4a..7ae45a5 100644 --- a/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/SerializableIsolationExt.java +++ b/order-center-pattern/src/main/java/org/example/cp/oms/pattern/extension/home_appliance/SerializableIsolationExt.java @@ -3,7 +3,7 @@ import io.github.dddplus.annotation.Extension; import org.example.cp.oms.pattern.HomeAppliancePattern; import org.example.cp.oms.spec.ext.ISerializableIsolationExt; -import org.example.cp.oms.spec.model.IOrderModel; +import org.example.cp.oms.spec.model.IOrderMain; import org.example.cp.oms.spec.model.vo.LockEntry; import javax.validation.constraints.NotNull; @@ -13,7 +13,7 @@ public class SerializableIsolationExt implements ISerializableIsolationExt { @Override - public LockEntry createLockEntry(@NotNull IOrderModel model) { + public LockEntry createLockEntry(@NotNull IOrderMain model) { return new LockEntry(model.customerProvidedOrderNo(), 5, TimeUnit.MINUTES); } }