Kaynağa Gözat

submit demo

lianshufeng 1 yıl önce
ebeveyn
işleme
c2a54cafac
21 değiştirilmiş dosya ile 313 ekleme ve 0 silme
  1. 14 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/OrderModel.java
  2. 20 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/RequestCreateOrder.java
  3. 23 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/create/BaseCreateOrderModel.java
  4. 19 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/create/UnionFrictionlessPayCreateOrderModel.java
  5. 11 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/BasePayService.java
  6. 20 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/PayService.java
  7. 7 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/DirectPayService.java
  8. 7 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/FrictionlessPay.java
  9. 14 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/WalletPayService.java
  10. 6 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/AliPayDirectPayService.java
  11. 8 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/UnionFrictionlessPayService.java
  12. 6 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/WeChatDirectPayService.java
  13. 6 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/WeChatWalletPayService.java
  14. 11 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PayCallServiceType.java
  15. 36 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PayProductType.java
  16. 26 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PaymentType.java
  17. 17 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/BasePay.java
  18. 4 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/ExtendPay.java
  19. 9 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/UnionPay.java
  20. 33 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/service/PayServiceImpl.java
  21. 16 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/service/UnionFrictionlessPayServiceImpl.java

+ 14 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/OrderModel.java

@@ -0,0 +1,14 @@
+package com.zhongshu.payment.client.pay.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OrderModel {
+    // 订单id
+    private String id;
+
+}

+ 20 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/RequestCreateOrder.java

@@ -0,0 +1,20 @@
+package com.zhongshu.payment.client.pay.model;
+
+import com.zhongshu.payment.client.pay.model.create.BaseCreateOrderModel;
+import com.zhongshu.payment.client.pay.type.PayProductType;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class RequestCreateOrder {
+
+    //支付产品类型
+    private PayProductType payProductType;
+
+    //创建订单的
+    private BaseCreateOrderModel orderModel;
+
+}

+ 23 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/create/BaseCreateOrderModel.java

@@ -0,0 +1,23 @@
+package com.zhongshu.payment.client.pay.model.create;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class BaseCreateOrderModel {
+
+    // 商务类型 project
+    private String businessType;
+
+    //
+    private String businessId;
+
+
+    //商品id
+    private String goodsId;
+
+
+}

+ 19 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/model/create/UnionFrictionlessPayCreateOrderModel.java

@@ -0,0 +1,19 @@
+package com.zhongshu.payment.client.pay.model.create;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class UnionFrictionlessPayCreateOrderModel extends BaseCreateOrderModel {
+
+    // 商户号
+    private String mchntNo;
+
+
+
+
+
+}

+ 11 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/BasePayService.java

@@ -0,0 +1,11 @@
+package com.zhongshu.payment.client.pay.service;
+
+import com.zhongshu.payment.client.pay.model.OrderModel;
+import com.zhongshu.payment.client.pay.model.create.BaseCreateOrderModel;
+
+public interface BasePayService<T extends BaseCreateOrderModel> {
+
+    //创建订单
+    OrderModel createOrder(T createOrderModel);
+
+}

+ 20 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/PayService.java

@@ -0,0 +1,20 @@
+package com.zhongshu.payment.client.pay.service;
+
+import com.zhongshu.payment.client.pay.model.OrderModel;
+import com.zhongshu.payment.client.pay.model.RequestCreateOrder;
+import com.zhongshu.payment.client.pay.type.PayCallServiceType;
+import org.springframework.cloud.openfeign.FeignClient;
+
+import java.util.List;
+
+//@FeignClient
+public interface PayService {
+
+    //创建订单
+    OrderModel createOrder(RequestCreateOrder createOrder);
+
+
+
+
+
+}

+ 7 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/DirectPayService.java

@@ -0,0 +1,7 @@
+package com.zhongshu.payment.client.pay.service.impl;
+
+
+import com.zhongshu.payment.client.pay.service.BasePayService;
+
+public interface DirectPayService extends BasePayService {
+}

+ 7 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/FrictionlessPay.java

@@ -0,0 +1,7 @@
+package com.zhongshu.payment.client.pay.service.impl;
+
+import com.zhongshu.payment.client.pay.model.create.BaseCreateOrderModel;
+import com.zhongshu.payment.client.pay.service.BasePayService;
+
+public interface FrictionlessPay<T extends BaseCreateOrderModel> extends BasePayService<T> {
+}

+ 14 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/WalletPayService.java

@@ -0,0 +1,14 @@
+package com.zhongshu.payment.client.pay.service.impl;
+
+import com.zhongshu.payment.client.pay.service.BasePayService;
+
+public interface WalletPayService extends BasePayService {
+
+    public  void add();
+
+    public void sub();
+
+    void query();
+
+
+}

+ 6 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/AliPayDirectPayService.java

@@ -0,0 +1,6 @@
+package com.zhongshu.payment.client.pay.service.impl.impl;
+
+import com.zhongshu.payment.client.pay.service.impl.DirectPayService;
+
+public interface AliPayDirectPayService extends DirectPayService {
+}

+ 8 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/UnionFrictionlessPayService.java

@@ -0,0 +1,8 @@
+package com.zhongshu.payment.client.pay.service.impl.impl;
+
+import com.zhongshu.payment.client.pay.model.create.BaseCreateOrderModel;
+import com.zhongshu.payment.client.pay.service.impl.FrictionlessPay;
+
+public interface UnionFrictionlessPayService<T extends BaseCreateOrderModel> extends FrictionlessPay<T> {
+
+}

+ 6 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/WeChatDirectPayService.java

@@ -0,0 +1,6 @@
+package com.zhongshu.payment.client.pay.service.impl.impl;
+
+import com.zhongshu.payment.client.pay.service.impl.DirectPayService;
+
+public interface WeChatDirectPayService extends DirectPayService {
+}

+ 6 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/service/impl/impl/WeChatWalletPayService.java

@@ -0,0 +1,6 @@
+package com.zhongshu.payment.client.pay.service.impl.impl;
+
+import com.zhongshu.payment.client.pay.service.impl.WalletPayService;
+
+public interface WeChatWalletPayService extends WalletPayService {
+}

+ 11 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PayCallServiceType.java

@@ -0,0 +1,11 @@
+package com.zhongshu.payment.client.pay.type;
+
+public enum PayCallServiceType {
+
+    Add,
+    Sub,
+    Query,
+    CreateOrder
+
+
+}

+ 36 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PayProductType.java

@@ -0,0 +1,36 @@
+package com.zhongshu.payment.client.pay.type;
+
+import com.zhongshu.payment.client.pay.service.BasePayService;
+import com.zhongshu.payment.client.pay.service.impl.impl.AliPayDirectPayService;
+import com.zhongshu.payment.client.pay.service.impl.impl.UnionFrictionlessPayService;
+import com.zhongshu.payment.client.pay.service.impl.impl.WeChatDirectPayService;
+import com.zhongshu.payment.client.pay.service.impl.impl.WeChatWalletPayService;
+import lombok.Getter;
+
+/**
+ * 支付方式
+ */
+public enum PayProductType {
+    WeChatWalletPay("微信充值钱包", PaymentType.WalletPay, WeChatWalletPayService.class),
+    UnionFrictionlessPay("银联无感支付", PaymentType.Frictionless, UnionFrictionlessPayService.class),
+    WeChatDirectPay("微信直营支付", PaymentType.DirectPay, WeChatDirectPayService.class),
+    ALiPayDirectPay("支付宝直营支付", PaymentType.DirectPay, AliPayDirectPayService.class),
+    ;
+
+    @Getter
+    private String remark;
+
+    // 支付结果是否是异步返回
+    @Getter
+    private PaymentType paymentType;
+
+    @Getter
+    private Class<? extends BasePayService> service;
+
+
+    PayProductType(String remark, PaymentType paymentType, Class<? extends BasePayService> service) {
+        this.remark = remark;
+        this.paymentType = paymentType;
+        this.service = service;
+    }
+}

+ 26 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/pay/type/PaymentType.java

@@ -0,0 +1,26 @@
+package com.zhongshu.payment.client.pay.type;
+
+import lombok.Getter;
+
+/**
+ * 支付方式
+ */
+public enum PaymentType {
+
+    // 无感支付
+    Frictionless,
+
+    //钱包支付
+    WalletPay,
+
+    // 直营支付,游客可以直接用微信支付宝支付
+    DirectPay,
+
+
+    ;
+
+    @Getter
+    private String remark;
+
+
+}

+ 17 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/BasePay.java

@@ -0,0 +1,17 @@
+package com.zhongshu.payment.server.core.pay.domain;
+
+import com.zhongshu.payment.client.pay.type.PaymentType;
+import com.zhongshu.payment.server.core.domain.base.SuperMain;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+@Document
+public class BasePay  extends SuperMain {
+
+
+    private PaymentType paymentType;
+
+    @DBRef(lazy = true)
+    private ExtendPay basePay;
+
+}

+ 4 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/ExtendPay.java

@@ -0,0 +1,4 @@
+package com.zhongshu.payment.server.core.pay.domain;
+
+public class ExtendPay {
+}

+ 9 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/domain/UnionPay.java

@@ -0,0 +1,9 @@
+package com.zhongshu.payment.server.core.pay.domain;
+
+import org.springframework.data.mongodb.core.mapping.DBRef;
+
+public class UnionPay extends ExtendPay {
+
+
+
+}

+ 33 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/service/PayServiceImpl.java

@@ -0,0 +1,33 @@
+package com.zhongshu.payment.server.core.pay.service;
+
+import com.zhongshu.payment.client.pay.model.OrderModel;
+import com.zhongshu.payment.client.pay.model.RequestCreateOrder;
+import com.zhongshu.payment.client.pay.service.BasePayService;
+import com.zhongshu.payment.client.pay.service.PayService;
+import com.zhongshu.payment.client.pay.type.PayCallServiceType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureOrder;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+@Service
+public class PayServiceImpl implements PayService {
+
+    @Autowired
+    private ApplicationContext applicationContext;
+
+    @Override
+    public OrderModel createOrder(RequestCreateOrder createOrder) {
+        final BasePayService basePayService = applicationContext.getBean(createOrder.getPayProductType().getService());
+        Assert.notNull(basePayService, "不支持的支付类型");
+
+        // todo 如果报错,需要进行类型转换
+        OrderModel orderModel = basePayService.createOrder(createOrder.getOrderModel());
+
+
+        return null;
+    }
+
+
+}

+ 16 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/pay/service/UnionFrictionlessPayServiceImpl.java

@@ -0,0 +1,16 @@
+package com.zhongshu.payment.server.core.pay.service;
+
+import com.zhongshu.payment.client.pay.model.OrderModel;
+import com.zhongshu.payment.client.pay.model.create.UnionFrictionlessPayCreateOrderModel;
+import com.zhongshu.payment.client.pay.service.impl.impl.UnionFrictionlessPayService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UnionFrictionlessPayServiceImpl implements UnionFrictionlessPayService<UnionFrictionlessPayCreateOrderModel> {
+
+
+    @Override
+    public OrderModel createOrder(UnionFrictionlessPayCreateOrderModel createOrderModel) {
+        return null;
+    }
+}