Jelajahi Sumber

Merge branch 'master' of http://git.dayaedu.com/yonge/cooleshow

liujunchi 3 tahun lalu
induk
melakukan
cb242556eb
19 mengubah file dengan 498 tambahan dan 92 penghapusan
  1. 11 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/VideoLessonGroupSearch.java
  2. 17 11
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderPaymentServiceImpl.java
  3. 1 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java
  4. 3 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/VideoLessonGroupMapper.xml
  5. 15 6
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java
  6. 20 10
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java
  7. 7 3
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/PayChannelEnum.java
  8. 0 14
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/ClosePayment.java
  9. 78 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/OrderDetil.java
  10. 32 18
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Payment.java
  11. 0 14
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/RefundBill.java
  12. 15 2
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/props/PaymentProperties.java
  13. 5 5
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/PaymentClientImpl.java
  14. 13 6
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/PaywayUtil.java
  15. 1 1
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/SpringBeansUtil.java
  16. 134 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/OriginalAliAppTemplate.java
  17. 45 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/config/AlipayConfiguration.java
  18. 52 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/constant/AlipayConstant.java
  19. 49 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/wx/OriginalWxAppTemplate.java

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/VideoLessonGroupSearch.java

@@ -27,6 +27,9 @@ public class VideoLessonGroupSearch extends QueryInfo {
     @ApiModelProperty(value = "老师id")
     private Long teacherId;
 
+    @ApiModelProperty(value = "声部id")
+    private Long lessonSubject;
+
     @ApiModelProperty(value = "是否审核时可见 (0:否  1:是)",hidden = true)
     private YesOrNoEnum auditVersion;
 
@@ -36,6 +39,14 @@ public class VideoLessonGroupSearch extends QueryInfo {
     @ApiModelProperty(value = "平台",required = true)
     private String platform;
 
+    public Long getLessonSubject() {
+        return lessonSubject;
+    }
+
+    public void setLessonSubject(Long lessonSubject) {
+        this.lessonSubject = lessonSubject;
+    }
+
     public YesOrNoEnum getAuditVersion() {
         return auditVersion;
     }

+ 17 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderPaymentServiceImpl.java

@@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
 import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
-import com.yonge.cooleshow.biz.dal.props.PaymentProperties;
 import com.yonge.cooleshow.biz.dal.service.UserOrderService;
+import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.cooleshow.biz.dal.vo.res.OrderPayRes;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -15,10 +15,8 @@ import com.yonge.cooleshow.common.service.IdGeneratorService;
 import com.yonge.toolset.base.result.BaseResult;
 import com.yonge.toolset.payment.base.enums.OpenEnum;
 import com.yonge.toolset.payment.base.enums.PayChannelEnum;
-import com.yonge.toolset.payment.base.model.ClosePayment;
-import com.yonge.toolset.payment.base.model.DeviceInfo;
-import com.yonge.toolset.payment.base.model.DivMember;
-import com.yonge.toolset.payment.base.model.Payment;
+import com.yonge.toolset.payment.base.model.*;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,11 +69,12 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
      * @updateTime 2022/5/11 18:47
      * @return: com.yonge.cooleshow.biz.dal.entity.UserOrderPayment
      */
-    private UserOrderPayment insertOrderPayment(Payment payment, OrderPayReq payReq) {
+    private UserOrderPayment insertOrderPayment(Payment payment) {
         UserOrderPayment orderPayment = new UserOrderPayment();
-        orderPayment.setOrderNo(payReq.getOrderNo());
+        orderPayment.setOpenType(payment.getOpenType());
+        orderPayment.setPayChannel(payment.getPayChannel());
+        orderPayment.setOrderNo(payment.getOrderNo());
         orderPayment.setPaymentNo(payment.getPaymentNo());
-        orderPayment.setPayChannel(payReq.getPayChannel());
         orderPayment.setTransNo(payment.getId());
         orderPayment.setPayAmt(
                 new BigDecimal(payment.getPayAmt()).setScale(2, RoundingMode.HALF_UP)
@@ -84,7 +83,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
         orderPayment.setStatus(TradeStatusEnum.pending);
 
         //查询订单下支付中的付款单,取消支付
-        closePayment(payReq.getOrderNo(), "用户发起了新的付款请求");
+        closePayment(payment.getOrderNo(), "用户发起了新的付款请求");
         //保存新的付款单
         save(orderPayment);
         return orderPayment;
@@ -160,10 +159,17 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
         OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
         Payment payment = new Payment(openType, payReq.getPayChannel());
         payment.setPaymentNo(paymentNo.toString());
+        payment.setOrderNo(payReq.getOrderNo());
         payment.setOrderTitle(detail.getOrderName());
         payment.setOrderDesc(detail.getOrderDesc());
-        payment.setPayAmt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
 
+        //封装订单详情
+        List<OrderDetil> orderDetils = new ArrayList<>();
+        for (UserOrderDetailVo orderDetailVo : detail.getOrderDetailList()) {
+            orderDetils.add(new OrderDetil(orderDetailVo.getId().toString(), orderDetailVo.getGoodName(), 1, orderDetailVo.getActualPrice().toString()));
+        }
+        payment.setOrderDetils(orderDetils);
+        payment.setPayAmt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
         payment.setDescription(payReq.getReason());
 
         if (OpenEnum.ADAPAY.equals(openType)) {
@@ -196,7 +202,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
             orderPayRes.setPayChannel(payReq.getPayChannel());
 
             //入订单付款表
-            insertOrderPayment(paymentResBaseResult.getData(), payReq);
+            insertOrderPayment(paymentResBaseResult.getData());
             //修改订单状态
             userOrderService.updateStatusByOrderNo(payReq.getOrderNo(), OrderStatusEnum.PAYING.getCode());
             return HttpResponseResult.succeed(orderPayRes);

+ 1 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.enums.*;
-import com.yonge.cooleshow.biz.dal.props.PaymentProperties;
 import com.yonge.cooleshow.biz.dal.support.DistributedLock;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
@@ -20,8 +19,8 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.cooleshow.common.service.IdGeneratorService;
 import com.yonge.toolset.base.result.BaseResult;
-import com.yonge.toolset.payment.base.enums.OpenEnum;
 import com.yonge.toolset.payment.base.model.Payment;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.apache.commons.beanutils.BeanUtils;

+ 3 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/VideoLessonGroupMapper.xml

@@ -110,6 +110,9 @@
 			<if test="param.teacherId !=null">
 				AND g.teacher_id_ = #{param.teacherId}
 			</if>
+			<if	test="param.lessonSubject != null">
+				AND g.lesson_subject_ = #{param.lessonSubject}
+			</if>
 		</where>
 	</select>
 	<select id="selectStudentPage" resultType="com.yonge.cooleshow.biz.dal.vo.VideoLessonStudentDetailVo">

+ 15 - 6
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java

@@ -1,6 +1,5 @@
 package com.yonge.cooleshow.student.controller;
 
-import com.alipay.api.response.AlipaySystemOauthTokenResponse;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.huifu.adapay.core.AdapayCore;
 import com.huifu.adapay.core.util.AdapaySign;
@@ -8,7 +7,6 @@ import com.huifu.adapay.core.util.StringUtil;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderPayment;
-import com.yonge.cooleshow.biz.dal.props.PaymentProperties;
 import com.yonge.cooleshow.biz.dal.service.UserOrderPaymentService;
 import com.yonge.cooleshow.biz.dal.service.UserOrderService;
 import com.yonge.cooleshow.common.controller.BaseController;
@@ -17,6 +15,7 @@ import com.yonge.toolset.base.result.BaseResult;
 import com.yonge.toolset.payment.base.enums.OpenEnum;
 import com.yonge.toolset.payment.base.model.OpenAuth;
 import com.yonge.toolset.payment.base.model.Payment;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -27,7 +26,6 @@ import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.sql.Wrapper;
 import java.util.Map;
 
 /**
@@ -79,13 +77,24 @@ public class PaymentController extends BaseController {
     }
 
     /***
-     * 付回调
+     * 付回调
      * @author liweifan
      * @param: request
      * @updateTime 2022/3/11 18:35
      */
-    @PostMapping("/adapayCallback")
-    public void adapayCallback(HttpServletRequest request) {
+    @PostMapping("/callback/{openType}/{payChannel}/{payMethod}")
+    public void callback(
+            @PathVariable("openType") String openType,
+            @PathVariable("payChannel") String payChannel,
+            @PathVariable("payMethod") String payMethod,
+            HttpServletRequest request
+    ) {
+        if(OpenEnum.ADAPAY.getCode().equals(openType)){
+            adapayCallbackHandle(request);
+        }
+    }
+
+    private void adapayCallbackHandle(HttpServletRequest request){
         try {
             //验签传参data
             String data = request.getParameter("data");

+ 20 - 10
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java

@@ -12,6 +12,7 @@ import com.yonge.toolset.payment.base.model.ClosePayment;
 import com.yonge.toolset.payment.base.model.OpenAuth;
 import com.yonge.toolset.payment.base.model.Payment;
 import com.yonge.toolset.payment.base.model.RefundBill;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
 import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.slf4j.Logger;
@@ -28,6 +29,8 @@ public class AdapayTemplate implements PaymentTemplate {
     private final static Logger log = LoggerFactory.getLogger(AdapayTemplate.class);
 
     @Autowired
+    private PaymentProperties paymentProperties;
+    @Autowired
     private SysConfigPaymentService configPaymentService;
 
     @Override
@@ -36,7 +39,7 @@ public class AdapayTemplate implements PaymentTemplate {
     }
 
     @Override
-    public BaseResult<Payment> executePayment(Payment payment){
+    public BaseResult<Payment> executePayment(Payment payment) {
         Map<String, Object> paymentMap = new HashMap<>();
         paymentMap.put("order_no", payment.getPaymentNo());
         paymentMap.put("app_id", configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.APP_ID).getParamValue());
@@ -48,8 +51,11 @@ public class AdapayTemplate implements PaymentTemplate {
         paymentMap.put("description", payment.getDescription());
         paymentMap.put("device_info", payment.getDeviceInfo());
         paymentMap.put("expend", payment.getExpend());
-        paymentMap.put("notify_url",
-                StringUtil.isEmpty(payment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : payment.getNotifyUrl());
+        paymentMap.put("notify_url", paymentProperties.getNotifyUrl()
+                + "/" + payment.getOpenType().getCode()
+                + "/" + payment.getPayChannel().getCode()
+                + "/executePayment"
+        );
 
         log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentMap));
         //调用sdk方法,创建支付,得到支付对象
@@ -103,9 +109,11 @@ public class AdapayTemplate implements PaymentTemplate {
         paymentParams.put("payment_id", closePayment.getId());
         paymentParams.put("reason", closePayment.getReason());
         paymentParams.put("expend", closePayment.getExpend());
-        paymentParams.put("notify_url",
-                StringUtil.isEmpty(closePayment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(closePayment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : closePayment.getNotifyUrl());
-
+        paymentParams.put("notify_url", paymentProperties.getNotifyUrl()
+                + "/" + closePayment.getOpenType().getCode()
+                + "/" + closePayment.getPayChannel().getCode()
+                + "/closePayment"
+        );
         Map<String, Object> res;
         try {
             res = com.huifu.adapay.model.Payment.close(paymentParams);
@@ -126,13 +134,15 @@ public class AdapayTemplate implements PaymentTemplate {
     }
 
     @Override
-    public BaseResult<RefundBill> refundPayment(RefundBill refundBill)  {
+    public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
         Map<String, Object> refundParams = new HashMap<>(10);
         refundParams.put("refund_amt", refundBill.getRefundAmt());
         refundParams.put("refund_order_no", refundBill.getRefundNo());
-        refundParams.put("notify_url",
-                StringUtil.isEmpty(refundBill.getNotifyUrl()) ? configPaymentService.getPaymentConfig(refundBill.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : refundBill.getNotifyUrl());
-
+        refundParams.put("notify_url", paymentProperties.getNotifyUrl()
+                + "/" + refundBill.getOpenType().getCode()
+                + "/" + refundBill.getPayChannel().getCode()
+                + "/refundPayment"
+        );
         Map<String, Object> res;
         try {
             res = Refund.create(refundBill.getId(), refundParams);

+ 7 - 3
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/PayChannelEnum.java

@@ -5,14 +5,18 @@ import com.yonge.toolset.base.enums.BaseEnum;
 
 /**
  * 支付渠道
- *
+ * 汇付支持 alipay、wx_lite
+ * 原生支持 alipay_app、wx_app
  * @author liweifan
  * @updateTime 2022/3/31 11:30
  */
 public enum PayChannelEnum implements BaseEnum<String, PayChannelEnum> {
     alipay("支付宝扫码"),
-    alipay_lite("支付宝小程序支付"),
-    wx_lite("微信小程序支付");
+    alipay_app("支付宝app"),
+
+    wx_app("微信app"),
+    wx_lite("微信小程序支付"),
+    ;
 
     @EnumValue
     private String code;

+ 0 - 14
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/ClosePayment.java

@@ -22,12 +22,6 @@ public class ClosePayment extends Base {
      */
     String reason;
     /***
-     * 回调url
-     * @author liweifan
-     * @updateTime 2022/5/10 15:30
-     */
-    String notifyUrl;
-    /***
      * 扩展域
      * @author liweifan
      * @updateTime 2022/5/10 15:30
@@ -54,14 +48,6 @@ public class ClosePayment extends Base {
         this.reason = reason;
     }
 
-    public String getNotifyUrl() {
-        return notifyUrl;
-    }
-
-    public void setNotifyUrl(String notifyUrl) {
-        this.notifyUrl = notifyUrl;
-    }
-
     public String getExpend() {
         return expend;
     }

+ 78 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/OrderDetil.java

@@ -0,0 +1,78 @@
+package com.yonge.toolset.payment.base.model;
+
+import java.io.Serializable;
+
+/**
+ * 订单详情信息
+ * @Author: liweifan
+ * @Data: 2022/3/31 11:36
+ */
+public class OrderDetil implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /***
+     * 商品编号
+     * @author liweifan
+     * @updateTime 2022/3/31 11:07
+     */
+    private String goodsId;
+    /***
+     * 商品名称
+     * @author liweifan
+     * @updateTime 2022/3/31 11:07
+     */
+    private String goodName;
+    /***
+     * 商品数量
+     * @author liweifan
+     * @updateTime 2022/3/31 11:07
+     */
+    private Integer quantity = 1;
+    /***
+     * 商品价格
+     * @author liweifan
+     * @updateTime 2022/3/31 11:07
+     */
+    private String price;
+
+    public OrderDetil() {
+    }
+
+    public OrderDetil(String goodsId, String goodName, Integer quantity, String price) {
+        this.goodsId = goodsId;
+        this.goodName = goodName;
+        this.quantity = quantity;
+        this.price = price;
+    }
+
+    public String getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(String goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    public String getGoodName() {
+        return goodName;
+    }
+
+    public void setGoodName(String goodName) {
+        this.goodName = goodName;
+    }
+
+    public Integer getQuantity() {
+        return quantity;
+    }
+
+    public void setQuantity(Integer quantity) {
+        this.quantity = quantity;
+    }
+
+    public String getPrice() {
+        return price;
+    }
+
+    public void setPrice(String price) {
+        this.price = price;
+    }
+}

+ 32 - 18
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Payment.java

@@ -26,6 +26,12 @@ public class Payment extends Base {
      */
     private String paymentNo;
     /***
+     * 原始订单号(可选)
+     * @author liweifan
+     * @updateTime 2022/3/31 11:00
+     */
+    private String orderNo;
+    /***
      * 商品标题(必填)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
@@ -38,37 +44,37 @@ public class Payment extends Base {
      */
     private String orderDesc;
     /***
-     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等(必填)
+     * 商品详情(可选)
      * @author liweifan
-     * @updateTime 2022/3/31 11:01
+     * @updateTime 2022/5/12 15:31
      */
-    private String payAmt;
+    private List<OrderDetil> orderDetils;
     /***
-     * 订单附加说明
+     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等(必填)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
-    private String description;
+    private String payAmt;
     /***
-     * 异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
+     * 订单附加说明(可选)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
-    private String notifyUrl;
+    private String description;
     /***
-     * 分账对象信息列表
+     * 分账对象信息列表(可选)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
     private List<DivMember> divMembers;
     /***
-     * 前端设备信息
+     * 前端设备信息(可选)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
     private DeviceInfo deviceInfo;
     /***
-     * 支付渠道额外参数
+     * 支付渠道额外参数(可选)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
@@ -100,6 +106,14 @@ public class Payment extends Base {
         this.paymentNo = paymentNo;
     }
 
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
     public String getOrderTitle() {
         return orderTitle;
     }
@@ -132,14 +146,6 @@ public class Payment extends Base {
         this.description = description;
     }
 
-    public String getNotifyUrl() {
-        return notifyUrl;
-    }
-
-    public void setNotifyUrl(String notifyUrl) {
-        this.notifyUrl = notifyUrl;
-    }
-
     public List<DivMember> getDivMembers() {
         return divMembers;
     }
@@ -171,4 +177,12 @@ public class Payment extends Base {
     public void setPayInfo(String payInfo) {
         this.payInfo = payInfo;
     }
+
+    public List<OrderDetil> getOrderDetils() {
+        return orderDetils;
+    }
+
+    public void setOrderDetils(List<OrderDetil> orderDetils) {
+        this.orderDetils = orderDetils;
+    }
 }

+ 0 - 14
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/RefundBill.java

@@ -29,12 +29,6 @@ public class RefundBill extends Base {
      */
     private BigDecimal refundAmt;
     /***
-     * 异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String notifyUrl;
-    /***
      * 退款描述
      * @author liweifan
      * @updateTime 2022/3/31 11:00
@@ -69,14 +63,6 @@ public class RefundBill extends Base {
         this.refundAmt = refundAmt;
     }
 
-    public String getNotifyUrl() {
-        return notifyUrl;
-    }
-
-    public void setNotifyUrl(String notifyUrl) {
-        this.notifyUrl = notifyUrl;
-    }
-
     public String getReason() {
         return reason;
     }

+ 15 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/PaymentProperties.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/props/PaymentProperties.java

@@ -1,7 +1,6 @@
-package com.yonge.cooleshow.biz.dal.props;
+package com.yonge.toolset.payment.core.props;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -14,6 +13,13 @@ public class PaymentProperties {
      */
     private String openType;
 
+    /***
+     * 支付回调url
+     * @author liweifan
+     * @updateTime 2022/5/11 17:01
+     */
+    private String notifyUrl;
+
     public String getOpenType() {
         return openType;
     }
@@ -22,4 +28,11 @@ public class PaymentProperties {
         this.openType = openType;
     }
 
+    public String getNotifyUrl() {
+        return notifyUrl;
+    }
+
+    public void setNotifyUrl(String notifyUrl) {
+        this.notifyUrl = notifyUrl;
+    }
 }

+ 5 - 5
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/PaymentClientImpl.java

@@ -20,26 +20,26 @@ import java.util.Map;
 public class PaymentClientImpl implements PaymentClient {
     @Override
     public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
-        return PaywayUtil.getRealTemplate(openAuth.getOpenType()).getOpenAuthMsg(openAuth);
+        return PaywayUtil.getRealTemplate(openAuth.getOpenType(), openAuth.getPayChannel()).getOpenAuthMsg(openAuth);
     }
 
     @Override
     public BaseResult<Payment> executePayment(Payment payment) {
-        return PaywayUtil.getRealTemplate(payment.getOpenType()).executePayment(payment);
+        return PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).executePayment(payment);
     }
 
     @Override
     public BaseResult<Payment> queryPayment(Payment payment) {
-        return PaywayUtil.getRealTemplate(payment.getOpenType()).queryPayment(payment);
+        return PaywayUtil.getRealTemplate(payment.getOpenType(), payment.getPayChannel()).queryPayment(payment);
     }
 
     @Override
     public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
-        return PaywayUtil.getRealTemplate(closePayment.getOpenType()).closePayment(closePayment);
+        return PaywayUtil.getRealTemplate(closePayment.getOpenType(), closePayment.getPayChannel()).closePayment(closePayment);
     }
 
     @Override
     public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
-        return PaywayUtil.getRealTemplate(refundBill.getOpenType()).refundPayment(refundBill);
+        return PaywayUtil.getRealTemplate(refundBill.getOpenType(), refundBill.getPayChannel()).refundPayment(refundBill);
     }
 }

+ 13 - 6
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/PaywayUtil.java

@@ -3,7 +3,7 @@ package com.yonge.toolset.payment.core.util;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.payment.base.PaymentTemplate;
 import com.yonge.toolset.payment.base.enums.OpenEnum;
-import com.yonge.toolset.payment.util.SpringBeansUtil;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 
 /***
  *
@@ -18,11 +18,18 @@ public class PaywayUtil {
      * @updateTime 2022/5/11 16:05
      * @return: com.yonge.toolset.payment.base.PaymentTemplate
      */
-    public static PaymentTemplate getRealTemplate(OpenEnum openType) {
-        if(OpenEnum.ORIGINAL.equals(openType)){
-            //原生
-            return (PaymentTemplate) SpringBeansUtil.getBean("");
-        }else if(OpenEnum.ADAPAY.equals(openType)){
+    public static PaymentTemplate getRealTemplate(OpenEnum openType, PayChannelEnum payChannel) {
+        //原生
+        if (OpenEnum.ORIGINAL.equals(openType)) {
+            //支付宝
+            if (PayChannelEnum.alipay_app.equals(payChannel)) {
+                return (PaymentTemplate) SpringBeansUtil.getBean("originalAliAppTemplate");
+            }
+            //微信
+            if (PayChannelEnum.wx_app.equals(payChannel)) {
+                return (PaymentTemplate) SpringBeansUtil.getBean("originalWxAppTemplate");
+            }
+        } else if (OpenEnum.ADAPAY.equals(openType)) {
             //汇付
             return (PaymentTemplate) SpringBeansUtil.getBean("adapayTemplate");
         }

+ 1 - 1
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/util/SpringBeansUtil.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/SpringBeansUtil.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.yonge.toolset.payment.util;
+package com.yonge.toolset.payment.core.util;
 
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;

+ 134 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/OriginalAliAppTemplate.java

@@ -0,0 +1,134 @@
+package com.yonge.toolset.payment.original.ali;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.request.AlipayTradeAppPayRequest;
+import com.alipay.api.request.AlipayTradeQueryRequest;
+import com.alipay.api.response.AlipayTradeAppPayResponse;
+import com.alipay.api.response.AlipayTradeQueryResponse;
+import com.yonge.toolset.base.result.BaseResult;
+import com.yonge.toolset.payment.base.PaymentTemplate;
+import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
+import com.yonge.toolset.payment.base.model.*;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
+import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class OriginalAliAppTemplate implements PaymentTemplate {
+
+    private final static Logger log = LoggerFactory.getLogger(OriginalAliAppTemplate.class);
+
+    @Autowired
+    private PaymentProperties paymentProperties;
+
+    @Autowired
+    private SysConfigPaymentService configPaymentService;
+
+    @Resource(name = "alipayClientApp")
+    private AlipayClient alipayClientApp;
+
+    @Override
+    public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
+        return null;
+    }
+
+    @Override
+    public BaseResult<Payment> executePayment(Payment payment) {
+        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+        request.setNotifyUrl(paymentProperties.getNotifyUrl()
+                + "/" + payment.getOpenType().getCode()
+                + "/" + payment.getPayChannel().getCode()
+                + "/executePayment");
+
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", payment.getPaymentNo());
+        bizContent.put("total_amount", payment.getPayAmt());
+        bizContent.put("subject", payment.getOrderTitle());
+
+        List<Map<String, Object>> orderDetils = new ArrayList<>();
+        for (OrderDetil orderDetil : payment.getOrderDetils()) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("goods_id", orderDetil.getGoodsId());
+            map.put("goods_name", orderDetil.getGoodName());
+            map.put("quantity", orderDetil.getQuantity());
+            map.put("price", orderDetil.getPrice());
+            orderDetils.add(map);
+        }
+        bizContent.put("goods_detail", orderDetils);
+        bizContent.put("merchant_order_no", payment.getOrderNo());
+        request.setBizContent(bizContent.toString());
+        try {
+            AlipayTradeAppPayResponse response = alipayClientApp.sdkExecute(request);
+            if (response.isSuccess()) {
+                payment.setId(response.getTradeNo());
+                payment.setStatus(TradeStatusEnum.pending);
+                return BaseResult.succeed(payment);
+            } else {
+                return BaseResult.failed(response.getMsg());
+            }
+        } catch (AlipayApiException e) {
+            log.error("调用支付宝App支付接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            return BaseResult.failed("交易失败");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return BaseResult.failed("交易失败");
+        }
+    }
+
+    @Override
+    public BaseResult<Payment> queryPayment(Payment payment) {
+        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", payment.getId());
+        request.setBizContent(bizContent.toString());
+        try {
+            AlipayTradeQueryResponse response = alipayClientApp.execute(request);
+
+            if (response.isSuccess()) {
+                payment.setPayAmt(response.getPayAmount());
+                //获取交易状态
+                String tradeStatus = response.getTradeStatus();
+                if("WAIT_BUYER_PAY".equals(tradeStatus)){
+                    payment.setStatus(TradeStatusEnum.pending);
+                }else if("TRADE_CLOSED".equals(tradeStatus)){
+                    payment.setStatus(TradeStatusEnum.succeeded);
+                }else if("TRADE_SUCCESS".equals(tradeStatus)){
+                    payment.setStatus(TradeStatusEnum.succeeded);
+                }else if("TRADE_FINISHED".equals(tradeStatus)){
+                    payment.setStatus(TradeStatusEnum.succeeded);
+                }
+                return BaseResult.succeed(payment);
+            } else {
+                return BaseResult.failed(response.getMsg());
+            }
+        } catch (AlipayApiException e) {
+            log.error("调用支付宝APP查询订单接口失败,err_code={} err_msg={}", e.getErrCode(), e.getErrMsg());
+            return BaseResult.failed("查询失败");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return BaseResult.failed("查询失败");
+        }
+    }
+
+    @Override
+    public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
+        return null;
+    }
+
+    @Override
+    public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
+        return null;
+    }
+}

+ 45 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/config/AlipayConfiguration.java

@@ -0,0 +1,45 @@
+package com.yonge.toolset.payment.original.ali.config;
+
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.huifu.adapay.Adapay;
+import com.huifu.adapay.model.MerConfig;
+import com.yonge.toolset.payment.adapay.constant.AdapayConstant;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
+import com.yonge.toolset.payment.original.ali.constant.AlipayConstant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/12 10:12
+ */
+@Configuration
+public class AlipayConfiguration {
+    @Autowired
+    private SysConfigPaymentService configPaymentService;
+
+    /***
+     * 支付宝APP支付Bean
+     * @author liweifan
+     * @updateTime 2022/5/12 14:16
+     * @return: com.alipay.api.AlipayClient
+     */
+    @Bean(name = "alipayClientApp")
+    public AlipayClient alipayClientApp() {
+        AlipayClient alipayClient = new DefaultAlipayClient(
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_URL).getParamValue(),
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_APPID).getParamValue(),
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_APP_PRIVATE_KEY).getParamValue(),
+                "json", "UTF-8",
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_ALIPAY_PUBLIC_KEY).getParamValue(),
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_SIGN_TYPE).getParamValue(),
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_CONTENT_SIGN_KEY).getParamValue(),
+                configPaymentService.getPaymentConfig(OpenEnum.ORIGINAL, AlipayConstant.ALI_APP_CONTENT_SIGN_TYPE).getParamValue()
+        );
+        return alipayClient;
+    }
+
+}

+ 52 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/constant/AlipayConstant.java

@@ -0,0 +1,52 @@
+package com.yonge.toolset.payment.original.ali.constant;
+
+/**
+ *
+ * @Author: liweifan
+ * @Data: 2022/5/11 16:21
+ */
+public interface AlipayConstant {
+    /***
+     * 支付宝-支付网关
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_URL = "ALI_URL";
+    /***
+     * 支付宝-APP支付-应用ID
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_APPID = "ALI_APP_APPID";
+    /***
+     * 支付宝-APP支付-应用私钥
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_APP_PRIVATE_KEY = "ALI_APP_APP_PRIVATE_KEY";
+    /***
+     * 支付宝-APP支付-应用公钥
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_ALIPAY_PUBLIC_KEY = "ALI_APP_ALIPAY_PUBLIC_KEY";
+    /***
+     * 支付宝-APP支付-验签方式
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_SIGN_TYPE = "ALI_APP_SIGN_TYPE";
+    /***
+     * 支付宝-APP支付-接口内容加密密钥
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_CONTENT_SIGN_KEY = "ALI_APP_CONTENT_SIGN_KEY";
+    /***
+     * 支付宝-APP支付-接口内容加密方式
+     * @author liweifan
+     * @updateTime 2022/5/12 14:12
+     */
+    String ALI_APP_CONTENT_SIGN_TYPE = "ALI_APP_CONTENT_SIGN_TYPE";
+
+}

+ 49 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/wx/OriginalWxAppTemplate.java

@@ -0,0 +1,49 @@
+package com.yonge.toolset.payment.original.wx;
+
+import com.yonge.toolset.base.result.BaseResult;
+import com.yonge.toolset.payment.base.PaymentTemplate;
+import com.yonge.toolset.payment.base.model.ClosePayment;
+import com.yonge.toolset.payment.base.model.OpenAuth;
+import com.yonge.toolset.payment.base.model.Payment;
+import com.yonge.toolset.payment.base.model.RefundBill;
+import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class OriginalWxAppTemplate implements PaymentTemplate {
+
+    private final static Logger log = LoggerFactory.getLogger(OriginalWxAppTemplate.class);
+
+    @Autowired
+    private SysConfigPaymentService configPaymentService;
+
+    @Override
+    public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
+        return null;
+    }
+
+    @Override
+    public BaseResult<Payment> executePayment(Payment payment){
+        return null;
+    }
+
+    @Override
+    public BaseResult<Payment> queryPayment(Payment payment) {
+        return null;
+    }
+
+    @Override
+    public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
+        return null;
+    }
+
+    @Override
+    public BaseResult<RefundBill> refundPayment(RefundBill refundBill)  {
+        return null;
+    }
+}