Quellcode durchsuchen

汇付支付服务迁移

weifanli vor 3 Jahren
Ursprung
Commit
ebf3713f41
67 geänderte Dateien mit 1025 neuen und 1979 gelöschten Zeilen
  1. 73 62
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/entity/HttpResponseResult.java
  2. 2 1
      cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UserOrderRefundController.java
  3. 3 8
      cooleshow-user/user-biz/pom.xml
  4. 0 48
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/config/HuifuConfiguration.java
  5. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/OrderPayReq.java
  6. 40 28
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserOrderPayment.java
  7. 0 41
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/PayChannelEnum.java
  8. 0 152
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/HuifuProperties.java
  9. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/IMProperties.java
  10. 25 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/PaymentProperties.java
  11. 0 267
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/PaymentSdk.java
  12. 0 55
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/DivMember.java
  13. 0 73
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/PaymentConfirmParam.java
  14. 0 168
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/PaymentReq.java
  15. 2 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderPaymentService.java
  16. 2 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderRefundService.java
  17. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderService.java
  18. 2 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java
  19. 79 70
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderPaymentServiceImpl.java
  20. 19 14
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderRefundServiceImpl.java
  21. 28 32
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java
  22. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/HttpHelper.java
  23. 23 13
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/UserOrderVo.java
  24. 2 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/res/OrderPayRes.java
  25. 8 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserOrderMapper.xml
  26. 6 2
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/StudentApplication.java
  27. 35 25
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java
  28. 14 12
      pom.xml
  29. 0 1
      toolset/pom.xml
  30. 0 33
      toolset/toolset-payment/payment-adapay/pom.xml
  31. 0 48
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/config/HuifuConfiguration.java
  32. 0 27
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/DeviceInfo.java
  33. 0 55
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/DivMember.java
  34. 0 73
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/PaymentConfirmParam.java
  35. 0 168
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/PaymentReq.java
  36. 0 149
      toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/props/HuifuProperties.java
  37. 0 41
      toolset/toolset-payment/payment-core/pom.xml
  38. 0 44
      toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/PaymentTemplate.java
  39. 0 27
      toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/DeviceInfo.java
  40. 0 21
      toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/ClosePaymentRes.java
  41. 0 36
      toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/PaymentRes.java
  42. 0 20
      toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/RefundBillRes.java
  43. 36 6
      toolset/toolset-payment/pom.xml
  44. 60 39
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java
  45. 35 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/config/AdapayConfiguration.java
  46. 51 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/constant/AdapayConstant.java
  47. 61 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/PaymentTemplate.java
  48. 1 1
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/constant/PaymentConstant.java
  49. 8 6
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/OpenEnum.java
  50. 8 7
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/PayChannelEnum.java
  51. 8 8
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/TradeStatusEnum.java
  52. 65 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Base.java
  53. 13 24
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/ClosePayment.java
  54. 1 1
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/DeviceInfo.java
  55. 1 1
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/DivMember.java
  56. 32 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/OpenAuth.java
  57. 41 26
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Payment.java
  58. 11 21
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/RefundBill.java
  59. 0 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/dao/SysConfigPaymentDao.java
  60. 0 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/entity/SysConfigPayment.java
  61. 60 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/PaymentClient.java
  62. 2 2
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/SysConfigPaymentService.java
  63. 45 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/PaymentClientImpl.java
  64. 1 1
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/SysConfigPaymentServiceImpl.java
  65. 31 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/PaywayUtil.java
  66. 75 0
      toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/util/SpringBeansUtil.java
  67. 12 6
      toolset/utils/src/main/java/com/yonge/toolset/utils/string/StringUtil.java

+ 73 - 62
cooleshow-common/src/main/java/com/yonge/cooleshow/common/entity/HttpResponseResult.java

@@ -10,67 +10,78 @@ import org.springframework.http.HttpStatus;
  */
 public class HttpResponseResult<T> extends BaseResult<T> {
 
-	public HttpResponseResult(boolean status, int code, T data, String message) {
-		super(status,code,data,message);
-	}
-
-	public HttpResponseResult(boolean status, HttpStatus resultCode, T data, String message) {
-		super(status,resultCode,data,message);
-
-	}
-	public HttpResponseResult() {
-	}
-
-	public static <T> HttpResponseResult<T> succeed(T object) {
-		return getResponseData(true, HttpStatus.OK, object, "");
-	}
-
-	public static <T> HttpResponseResult<T> succeed() {
-		return getResponseData(true, HttpStatus.OK, null, "");
-	}
-
-	public static <T> HttpResponseResult<T> succeedData(T obj) {
-		return getResponseData(true, HttpStatus.OK, obj, "操作成功");
-	}
-
-	public static <T> HttpResponseResult<T> warned(String message) {
-		return failed(HttpStatus.MULTI_STATUS, message);
-	}
-
-	public static <T> HttpResponseResult<T> failed() {
-		return failed("");
-	}
-
-	public static <T> HttpResponseResult<T> failed(String msg) {
-		return failed(HttpStatus.INTERNAL_SERVER_ERROR, msg);
-	}
-
-	public static <T> HttpResponseResult<T> failed(HttpStatus statusCode, String msg) {
-		return getResponseData(false, statusCode, null, msg);
-	}
-
-	public static <T> HttpResponseResult<T> status(boolean flag) {
-		return flag ? succeed() : failed("操作失败");
-	}
-
-	public static <T> HttpResponseResult<T> failed(HttpStatus statusCode, T data, String msg) {
-		return getResponseData(false, statusCode, data, msg);
-	}
-	public static <T> HttpResponseResult<T> failed(int code, T data, String msg) {
-		return new HttpResponseResult<>(false, code, data, msg);
-	}
-
-	private static <T> HttpResponseResult<T> getResponseData(boolean status, HttpStatus statusCode, T data, String message) {
-		HttpResponseResult<T> obj = new HttpResponseResult<T>();
-		obj.setStatus(status);
-		obj.setCode(statusCode.value());
-		obj.setData(data);
-		obj.setMsg(message);
-		return obj;
-	}
-
-	@Override
-	public String toString(){
-	    return JsonUtil.toJSONString(this, SerializerFeature.PrettyFormat);
+    public HttpResponseResult(boolean status, int code, T data, String message) {
+        super(status, code, data, message);
+    }
+
+    public HttpResponseResult(boolean status, HttpStatus resultCode, T data, String message) {
+        super(status, resultCode, data, message);
+
+    }
+
+    public HttpResponseResult() {
+    }
+
+    public static <T> HttpResponseResult<T> succeed(T object) {
+        return getResponseData(true, HttpStatus.OK, object, "");
+    }
+
+    public static <T> HttpResponseResult<T> succeed() {
+        return getResponseData(true, HttpStatus.OK, null, "");
+    }
+
+    public static <T> HttpResponseResult<T> succeedData(T obj) {
+        return getResponseData(true, HttpStatus.OK, obj, "操作成功");
+    }
+
+    public static <T> HttpResponseResult<T> warned(String message) {
+        return failed(HttpStatus.MULTI_STATUS, message);
+    }
+
+    public static <T> HttpResponseResult<T> failed() {
+        return failed("");
+    }
+
+    public static <T> HttpResponseResult<T> failed(String msg) {
+        return failed(HttpStatus.INTERNAL_SERVER_ERROR, msg);
+    }
+
+    public static <T> HttpResponseResult<T> failed(HttpStatus statusCode, String msg) {
+        return getResponseData(false, statusCode, null, msg);
+    }
+
+    public static <T> HttpResponseResult<T> status(boolean flag) {
+        return flag ? succeed() : failed("操作失败");
+    }
+
+    public static <T> HttpResponseResult<T> status(BaseResult<T> baseResult) {
+        HttpResponseResult<T> obj = new HttpResponseResult<T>();
+        obj.setStatus(baseResult.getStatus());
+        obj.setCode(baseResult.getCode());
+        obj.setData(baseResult.getData());
+        obj.setMsg(baseResult.getMsg());
+        return obj;
+    }
+
+    public static <T> HttpResponseResult<T> failed(HttpStatus statusCode, T data, String msg) {
+        return getResponseData(false, statusCode, data, msg);
+    }
+
+    public static <T> HttpResponseResult<T> failed(int code, T data, String msg) {
+        return new HttpResponseResult<>(false, code, data, msg);
+    }
+
+    private static <T> HttpResponseResult<T> getResponseData(boolean status, HttpStatus statusCode, T data, String message) {
+        HttpResponseResult<T> obj = new HttpResponseResult<T>();
+        obj.setStatus(status);
+        obj.setCode(statusCode.value());
+        obj.setData(data);
+        obj.setMsg(message);
+        return obj;
+    }
+
+    @Override
+    public String toString() {
+        return JsonUtil.toJSONString(this, SerializerFeature.PrettyFormat);
     }
 }

+ 2 - 1
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UserOrderRefundController.java

@@ -11,6 +11,7 @@ import com.yonge.cooleshow.biz.dal.vo.UserOrderRefundVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.payment.base.model.RefundBill;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -53,7 +54,7 @@ public class UserOrderRefundController extends BaseController {
 	@PostMapping("/doAuth")
 	@ApiOperation(value = "审核", notes = "传入authOperaReq")
 	@PreAuthorize("@pcs.hasPermissions('userOrderRefunds/doAuth')")
-	public HttpResponseResult<Boolean> doAuth(@Valid @RequestBody AuthOperaReq authOperaReq) throws Exception {
+	public HttpResponseResult<RefundBill> doAuth(@Valid @RequestBody AuthOperaReq authOperaReq) throws Exception {
 		SysUser user = sysUserFeignService.queryUserInfo();
 		if (user == null || null == user.getId()) {
 			return failed(HttpStatus.FORBIDDEN, "请登录");

+ 3 - 8
cooleshow-user/user-biz/pom.xml

@@ -87,14 +87,9 @@
         </dependency>
 
         <dependency>
-            <groupId>com.huifu.adapay</groupId>
-            <artifactId>adapay-java-sdk</artifactId>
-            <version>1.2.10</version>
-        </dependency>
-        <dependency>
-            <groupId>com.alipay.sdk</groupId>
-            <artifactId>alipay-sdk-java</artifactId>
-            <version>4.23.0.ALL</version>
+            <groupId>com.yonge.toolset</groupId>
+            <artifactId>toolset-payment</artifactId>
+            <version>${project.toolset.version}</version>
         </dependency>
     </dependencies>
 

+ 0 - 48
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/config/HuifuConfiguration.java

@@ -1,48 +0,0 @@
-package com.yonge.cooleshow.biz.dal.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.cooleshow.biz.dal.props.HuifuProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 路由配置信息
- */
-@Configuration
-@EnableConfigurationProperties({HuifuProperties.class})
-public class HuifuConfiguration {
-	private static HuifuProperties huifuProperties;
-	@Bean
-	public MerConfig merConfig(HuifuProperties authProperties) {
-		this.huifuProperties = authProperties;
-
-		MerConfig merConfig = new MerConfig();
-		merConfig.setApiKey(authProperties.getApiKey());
-		merConfig.setApiMockKey(authProperties.getMockApiKey());
-		merConfig.setRSAPrivateKey(authProperties.getRsaPrivateKey());
-		try {
-			Adapay.initWithMerConfig(merConfig);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return merConfig;
-	}
-
-	@Bean
-	public AlipayClient alipayClient(HuifuProperties authProperties){
-		AlipayClient alipayClient = new DefaultAlipayClient(
-				"https://openapi.alipay.com/gateway.do",
-				authProperties.getAliAppid(),
-				authProperties.getAliPrivatekey(),
-				"json","GBK",authProperties.getAliPublickey(),"RSA2");
-		return alipayClient;
-	}
-
-	public static HuifuProperties getHuifuProperties(){
-		return huifuProperties;
-	}
-}

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/OrderPayReq.java

@@ -1,6 +1,6 @@
 package com.yonge.cooleshow.biz.dal.dto.req;
 
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 

+ 40 - 28
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserOrderPayment.java

@@ -4,8 +4,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
 import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -24,6 +25,12 @@ public class UserOrderPayment implements Serializable {
 	private static final long serialVersionUID = 1L;
     @TableId(value = "id_", type = IdType.AUTO)
     private Long id;
+    @ApiModelProperty("服务提供方: ORIGINAL 微信支付宝 ADAPAY 汇付")
+    @TableField(value = "open_type_")
+    private OpenEnum openType;
+    @ApiModelProperty("支付渠道:  alipay 支付宝  wx_lite 微信 ")
+    @TableField(value = "pay_channel_")
+    private PayChannelEnum payChannel;
     @ApiModelProperty("订单号 ")
 	@TableField(value = "order_no_")
     private String orderNo;
@@ -33,9 +40,6 @@ public class UserOrderPayment implements Serializable {
     @ApiModelProperty("交易流水号 ")
 	@TableField(value = "trans_no_")
     private String transNo;
-    @ApiModelProperty("支付渠道:  alipay 支付宝  wx_lite 微信 ")
-	@TableField(value = "pay_channel_")
-    private PayChannelEnum payChannel;
     @ApiModelProperty("交易金额,必须大于0,保留两位小数点,如0.10、100.05等 ")
 	@TableField(value = "pay_amt_")
     private BigDecimal payAmt;
@@ -84,6 +88,22 @@ public class UserOrderPayment implements Serializable {
         this.id = id;
     }
 
+    public OpenEnum getOpenType() {
+        return openType;
+    }
+
+    public void setOpenType(OpenEnum openType) {
+        this.openType = openType;
+    }
+
+    public PayChannelEnum getPayChannel() {
+        return payChannel;
+    }
+
+    public void setPayChannel(PayChannelEnum payChannel) {
+        this.payChannel = payChannel;
+    }
+
     public String getOrderNo() {
         return orderNo;
     }
@@ -92,20 +112,20 @@ public class UserOrderPayment implements Serializable {
         this.orderNo = orderNo;
     }
 
-    public String getTransNo() {
-        return transNo;
+    public String getPaymentNo() {
+        return paymentNo;
     }
 
-    public void setTransNo(String transNo) {
-        this.transNo = transNo;
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
     }
 
-    public PayChannelEnum getPayChannel() {
-        return payChannel;
+    public String getTransNo() {
+        return transNo;
     }
 
-    public void setPayChannel(PayChannelEnum payChannel) {
-        this.payChannel = payChannel;
+    public void setTransNo(String transNo) {
+        this.transNo = transNo;
     }
 
     public BigDecimal getPayAmt() {
@@ -116,6 +136,14 @@ public class UserOrderPayment implements Serializable {
         this.payAmt = payAmt;
     }
 
+    public BigDecimal getBackPayAmt() {
+        return backPayAmt;
+    }
+
+    public void setBackPayAmt(BigDecimal backPayAmt) {
+        this.backPayAmt = backPayAmt;
+    }
+
     public BigDecimal getFeeAmt() {
         return feeAmt;
     }
@@ -187,20 +215,4 @@ public class UserOrderPayment implements Serializable {
     public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
-
-    public BigDecimal getBackPayAmt() {
-        return backPayAmt;
-    }
-
-    public void setBackPayAmt(BigDecimal backPayAmt) {
-        this.backPayAmt = backPayAmt;
-    }
-
-    public String getPaymentNo() {
-        return paymentNo;
-    }
-
-    public void setPaymentNo(String paymentNo) {
-        this.paymentNo = paymentNo;
-    }
 }

+ 0 - 41
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/PayChannelEnum.java

@@ -1,41 +0,0 @@
-package com.yonge.cooleshow.biz.dal.enums;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.yonge.toolset.base.enums.BaseEnum;
-
-/**
- * 支付渠道
- * @author liweifan
- * @updateTime 2022/3/31 11:30
- */
-public enum PayChannelEnum implements BaseEnum<String, PayChannelEnum> {
-    alipay("alipay","支付宝APP支付"),
-    alipay_lite("alipay_lite","支付宝小程序支付"),
-    wx_lite("wx_lite","微信小程序支付")
-    ;
-    @EnumValue
-    private String code;
-    private String msg;
-
-    PayChannelEnum(String code, String msg) {
-        this.code = code;
-        this.msg = msg;
-    }
-
-    public void setCode(String code) {
-        this.code = code;
-    }
-
-    public String getMsg() {
-        return msg;
-    }
-
-    public void setMsg(String msg) {
-        this.msg = msg;
-    }
-
-    @Override
-    public String getCode() {
-        return this.code;
-    }
-}

+ 0 - 152
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/HuifuProperties.java

@@ -1,152 +0,0 @@
-package com.yonge.cooleshow.biz.dal.props;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-
-/**
- * 权限过滤
- */
-@RefreshScope
-@ConfigurationProperties("huifu")
-public class HuifuProperties {
-    /***
-     * 汇付 控制台 主页面应用的app_id
-     * @author liweifan
-     * @updateTime 2022/3/31 11:19
-     */
-    private String appId;
-    /***
-     * 汇付 控制台->商户信息管理->证书管理中的API Key(prod模式的API KEY)
-     * @author liweifan
-     * @updateTime 2022/3/31 11:19
-     */
-    private String apiKey;
-    /***
-     * 汇付 控制台->商户信息管理->证书管理中的API Key(mock模式的API KEY)
-     * @author liweifan
-     * @updateTime 2022/3/31 11:19
-     */
-    private String mockApiKey;
-    /***
-     * 商户发起请求时,用于请求参数加签所需要的RSA私钥
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String rsaPrivateKey;
-    /***
-     * 付款成功回调地址
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String notifyUrl;
-    /***
-     * 微信appid
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String wxAppid;
-    /***
-     * 微信secret
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String wxSecret;
-    /***
-     * 支付宝appid
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String aliAppid;
-    /***
-     * 支付宝开发者私钥(由开发者自己生成)
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String aliPrivatekey;
-    /***
-     * 支付宝公钥(由支付宝生成)
-     * @author liweifan
-     * @updateTime 2022/3/31 11:24
-     */
-    private String aliPublickey;
-
-    public String getApiKey() {
-        return apiKey;
-    }
-
-    public void setApiKey(String apiKey) {
-        this.apiKey = apiKey;
-    }
-
-    public String getMockApiKey() {
-        return mockApiKey;
-    }
-
-    public void setMockApiKey(String mockApiKey) {
-        this.mockApiKey = mockApiKey;
-    }
-
-    public String getRsaPrivateKey() {
-        return rsaPrivateKey;
-    }
-
-    public void setRsaPrivateKey(String rsaPrivateKey) {
-        this.rsaPrivateKey = rsaPrivateKey;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public void setAppId(String appId) {
-        this.appId = appId;
-    }
-
-    public String getWxAppid() {
-        return wxAppid;
-    }
-
-    public void setWxAppid(String wxAppid) {
-        this.wxAppid = wxAppid;
-    }
-
-    public String getWxSecret() {
-        return wxSecret;
-    }
-
-    public void setWxSecret(String wxSecret) {
-        this.wxSecret = wxSecret;
-    }
-
-    public String getNotifyUrl() {
-        return notifyUrl;
-    }
-
-    public void setNotifyUrl(String notifyUrl) {
-        this.notifyUrl = notifyUrl;
-    }
-
-    public String getAliAppid() {
-        return aliAppid;
-    }
-
-    public void setAliAppid(String aliAppid) {
-        this.aliAppid = aliAppid;
-    }
-
-    public String getAliPrivatekey() {
-        return aliPrivatekey;
-    }
-
-    public void setAliPrivatekey(String aliPrivatekey) {
-        this.aliPrivatekey = aliPrivatekey;
-    }
-
-    public String getAliPublickey() {
-        return aliPublickey;
-    }
-
-    public void setAliPublickey(String aliPublickey) {
-        this.aliPublickey = aliPublickey;
-    }
-}

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/config/IMProperties.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/IMProperties.java

@@ -1,4 +1,4 @@
-package com.yonge.cooleshow.biz.dal.config;
+package com.yonge.cooleshow.biz.dal.props;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;

+ 25 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/props/PaymentProperties.java

@@ -0,0 +1,25 @@
+package com.yonge.cooleshow.biz.dal.props;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "payment")
+public class PaymentProperties {
+    /***
+     * 支付服务提供方
+     * @author liweifan
+     * @updateTime 2022/5/11 17:01
+     */
+    private String openType;
+
+    public String getOpenType() {
+        return openType;
+    }
+
+    public void setOpenType(String openType) {
+        this.openType = openType;
+    }
+
+}

+ 0 - 267
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/PaymentSdk.java

@@ -1,267 +0,0 @@
-package com.yonge.cooleshow.biz.dal.sdk;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
-import com.alipay.api.DefaultAlipayClient;
-import com.alipay.api.request.AlipaySystemOauthTokenRequest;
-import com.alipay.api.response.AlipaySystemOauthTokenResponse;
-import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.model.Payment;
-import com.huifu.adapay.model.PaymentConfirm;
-import com.huifu.adapay.model.Refund;
-import com.yonge.cooleshow.biz.dal.config.HuifuConfiguration;
-import com.yonge.cooleshow.biz.dal.entity.UserOrderRefund;
-import com.yonge.cooleshow.biz.dal.sdk.req.PaymentReq;
-import com.yonge.cooleshow.biz.dal.service.impl.ImGroupMemberServiceImpl;
-import com.yonge.cooleshow.common.constant.CommonConstants;
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import com.yonge.toolset.base.exception.BizException;
-import com.yonge.toolset.base.exception.ThirdpartyException;
-import com.yonge.toolset.utils.collection.MapUtil;
-import com.yonge.toolset.utils.http.HttpUtil;
-import com.yonge.toolset.utils.string.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.math.BigDecimal;
-import java.util.*;
-
-@Component
-public class PaymentSdk {
-    private final static Logger log = LoggerFactory.getLogger(PaymentSdk.class);
-    @Autowired
-    private AlipayClient alipayClient;
-
-    /**
-     * 执行一个支付交易
-     *
-     * @return 创建的支付对象
-     * @throws Exception 异常
-     */
-    public HttpResponseResult<Map<String, Object>> executePayment(PaymentReq paymentReq) {
-        paymentReq.setApp_id(HuifuConfiguration.getHuifuProperties().getAppId());
-        //创建分账对象
-        Map<String, String> div_member = new HashMap<>();
-        div_member.put("member_id", "0");
-        div_member.put("amount", paymentReq.getPay_amt());
-        div_member.put("fee_flag", "Y");
-        List<Map<String, String>> div_members = Arrays.asList(div_member);
-        paymentReq.setDiv_members(JSONObject.toJSONString(div_members));
-
-        log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentReq));
-        //调用sdk方法,创建支付,得到支付对象
-        Map<String, Object> paymentParams = MapUtil.populateMap(new HashMap<>(), paymentReq);
-        Map<String, Object> res;
-        try {
-            res = Payment.create(paymentParams);
-        } catch (BaseAdaPayException e) {
-            return HttpResponseResult.failed(e.getMessage());
-        }
-        if (CollectionUtils.isEmpty(res)) {
-            return HttpResponseResult.failed("请求失败");
-        }
-        log.info("汇付[创建支付对象] Resp:{}", res);
-        String errorCode = (String) res.get("error_code");
-        if (null != errorCode) {
-            String errorMsg = (String) res.get("error_msg");
-            return HttpResponseResult.failed(errorMsg);
-        }
-        return HttpResponseResult.succeed(res);
-    }
-
-    /**
-     * 关闭一个支付交易
-     *
-     * @param paymentId 要关闭的支付id
-     * @return 关闭的支付对象
-     * @throws Exception 异常
-     */
-    public HttpResponseResult<Map<String, Object>> closePayment(String paymentId, String reason, String expend) {
-        Map<String, Object> paymentParams = new HashMap<>(10);
-        paymentParams.put("payment_id", paymentId);
-        paymentParams.put("reason", reason);
-        paymentParams.put("expend", expend);
-        paymentParams.put("notify_url", HuifuConfiguration.getHuifuProperties().getNotifyUrl());
-
-        Map<String, Object> res;
-        try {
-            res = Payment.close(paymentParams);
-        } catch (BaseAdaPayException e) {
-            return HttpResponseResult.failed(e.getMessage());
-        }
-        if (CollectionUtils.isEmpty(res)) {
-            return HttpResponseResult.failed("请求失败");
-        }
-        log.info("汇付[创建支付对象] Resp:{}", res);
-        String errorCode = (String) res.get("error_code");
-        if (null != errorCode) {
-            String errorMsg = (String) res.get("error_msg");
-            return HttpResponseResult.failed(errorMsg);
-        }
-        return HttpResponseResult.succeed(res);
-    }
-
-    public HttpResponseResult<Map<String, Object>> refundPayment(String transNo, String refundOrderNo, BigDecimal refundAmt) {
-        Map<String, Object> refundParams = new HashMap<>(10);
-        refundParams.put("refund_amt", refundAmt.toString());
-        refundParams.put("refund_order_no", refundOrderNo);
-        refundParams.put("notify_url", HuifuConfiguration.getHuifuProperties().getNotifyUrl());
-
-        Map<String, Object> res;
-        try {
-            res = Refund.create(transNo,refundParams);
-        } catch (BaseAdaPayException e) {
-            return HttpResponseResult.failed(e.getMessage());
-        }
-        if (CollectionUtils.isEmpty(res)) {
-            return HttpResponseResult.failed("请求失败");
-        }
-        log.info("汇付[创建退款对象] Resp:{}", res);
-        String errorCode = (String) res.get("error_code");
-        if (null != errorCode) {
-            String errorMsg = (String) res.get("error_msg");
-            return HttpResponseResult.failed(errorMsg);
-        }
-        return HttpResponseResult.succeed(res);
-    }
-
-    /**
-     * 查询一个支付交易
-     *
-     * @param paymentId 要查询的支付id
-     * @return 查询的支付对象
-     * @throws Exception 异常
-     */
-    public Map<String, Object> queryPayment(String paymentId) throws Exception {
-        System.out.println("=======query payment begin=======");
-        //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id7
-        //调用sdk方法,查询支付交易,得到支付对象
-        Map<String, Object> payment = new HashMap<>();
-        try {
-            System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
-            payment = com.huifu.adapay.model.Payment.query(paymentId);
-        } catch (ThirdpartyException e) {
-            e.printStackTrace();
-        }
-
-        System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
-
-        String error_code = (String) payment.get("error_code");
-        if (null != error_code) {
-            String error_msg = (String) payment.get("error_msg");
-            System.out.println("error_code:" + error_code + "............." + error_msg);
-        }
-        System.out.println("=======query payment end=======");
-        return payment;
-    }
-
-    /***
-     * 获取openId
-     * @author liweifan
-     * @param: js_code
-     * @updateTime 2022/4/8 15:49
-     * @return: java.lang.Object
-     */
-    public HttpResponseResult<Map<String, String>> getOpenId(String js_code) {
-        log.info("微信[获取用户openId] Req:{}", js_code);
-        Map<String, Object> param = new HashMap<>();
-        param.put("appid", HuifuConfiguration.getHuifuProperties().getWxAppid());
-        param.put("secret", HuifuConfiguration.getHuifuProperties().getWxSecret());
-        param.put("js_code", js_code);
-        param.put("grant_type", CommonConstants.WECHAT_GRANT_TYPE);
-
-        try {
-            String res = HttpUtil.get("https://api.weixin.qq.com/sns/jscode2session", param);
-            JSONObject jsonObject = JSONObject.parseObject(res);
-            log.info("微信[获取用户openId] Res:{}", jsonObject.toJSONString());
-            String errcode = jsonObject.getString("errcode");
-            if (StringUtil.isEmpty(errcode) || "0".equals(errcode)) {
-                Map<String, String> resMap = new HashMap<>();
-                resMap.put("openid", jsonObject.getString("openid"));
-                resMap.put("session_key", jsonObject.getString("session_key"));
-                return HttpResponseResult.succeed(resMap);
-            } else {
-                return HttpResponseResult.failed(jsonObject.getString("errmsg"));
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            return HttpResponseResult.failed("请求失败");
-        }
-    }
-
-    public HttpResponseResult<AlipaySystemOauthTokenResponse> getAliToken(String authorization_code) {
-        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
-        request.setGrantType("authorization_code");
-        request.setCode(authorization_code);
-        AlipaySystemOauthTokenResponse response = null;
-        try {
-            response = alipayClient.execute(request);
-            if (response.isSuccess()) {
-                return HttpResponseResult.succeed(response);
-            } else {
-                return HttpResponseResult.failed(response.getMsg());
-            }
-        } catch (AlipayApiException e) {
-            log.error("请求支付宝获取token异常,参数{},code is {},msg is {}", authorization_code, e.getErrCode(), e.getErrMsg());
-            return HttpResponseResult.failed(e.getErrMsg());
-        }
-    }
-
-
-
-/*
-    public static Map<String, Object> queryList(Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
-        Map<String, Object> paymentParams = new HashMap<>();
-        paymentParams.put("app_id", ConfigInit.appId);
-        paymentParams.put("page_index", pageIndex);
-        paymentParams.put("page_size", "20");
-        paymentParams.put("created_gte", createdGte);
-        paymentParams.put("created_lte", createdLte);
-        Map<String, Object> payment = com.huifu.adapay.model.Payment.queryList(paymentParams);
-        String error_code = (String) payment.get("error_code");
-        if (null != error_code) {
-            String errorMsg = (String) payment.get("error_msg");
-            throw new ThirdpartyException(errorMsg);
-        }
-        return payment;
-    }
-
-    public static Map<String, Object> queryConfirmList(String paymentId) throws Exception {
-        Map<String, Object> paymentParams = new HashMap<>();
-        paymentParams.put("app_id", ConfigInit.appId);
-        paymentParams.put("payment_id", paymentId);
-
-        Map<String, Object> payment = com.huifu.adapay.model.Payment.queryConfirmList(paymentParams);
-        String error_code = (String) payment.get("error_code");
-        if (null != error_code) {
-            String errorMsg = (String) payment.get("error_msg");
-            throw new ThirdpartyException(errorMsg);
-        }
-        return payment;
-    }
-
-
-    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
-        Map<String, Object> paymentParams = new LinkedHashMap<>();
-        paymentParams.put("appId", ConfigInit.appId);
-        paymentParams.put("amount", amount.setScale(2, BigDecimal.ROUND_HALF_UP));
-        paymentParams.put("orderNo", orderNo);
-//        paymentParams.put("notifyUrl", notifyUrl);
-//        paymentParams.put("returnUrl", returnUrl);
-        paymentParams.put("orderSubject", orderSubject);
-        paymentParams.put("orderBody", orderBody);
-        paymentParams.put("wxAppId", ConfigInit.wxAppId);
-
-        String originalStr = JSONObject.toJSONString(paymentParams);
-        String sign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
-
-        paymentParams.put("sign", sign);
-        paymentParams.remove("appId");
-        return paymentParams;
-    }*/
-}

+ 0 - 55
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/DivMember.java

@@ -1,55 +0,0 @@
-package com.yonge.cooleshow.biz.dal.sdk.req;
-
-import java.io.Serializable;
-
-/**
- * 分账对象
- * @Author: liweifan
- * @Data: 2022/3/31 11:26
- */
-public class DivMember implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 分账用户 Member对象 的 id;若是商户本身时,传入0
-     * @author liweifan
-     * @updateTime 2022/3/31 11:27
-     */
-    private String member_id;
-    /**
-     * 分账金额,精确到分,如0.50,1.00等,分账总金额必须等于主交易金额,金额不能为0.00
-     * @author liweifan
-     * @updateTime 2022/3/31 11:28
-     */
-    private String amount;
-    /**
-     * 是否手续费承担方,N-否,Y-是,手续费承担方有且只能有一个
-     * @author liweifan
-     * @updateTime 2022/3/31 11:28
-     */
-    private String fee_flag;
-
-    public String getMember_id() {
-        return member_id;
-    }
-
-    public void setMember_id(String member_id) {
-        this.member_id = member_id;
-    }
-
-    public String getAmount() {
-        return amount;
-    }
-
-    public void setAmount(String amount) {
-        this.amount = amount;
-    }
-
-    public String getFee_flag() {
-        return fee_flag;
-    }
-
-    public void setFee_flag(String fee_flag) {
-        this.fee_flag = fee_flag;
-    }
-}

+ 0 - 73
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/PaymentConfirmParam.java

@@ -1,73 +0,0 @@
-package com.yonge.cooleshow.biz.dal.sdk.req;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * @Author: liweifan
- * @Data: 2022/3/11 17:44
- */
-public class PaymentConfirmParam implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    //Adapay生成的支付对象id
-    private String payment_id;
-    //请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
-    private String order_no;
-    //确认金额,必须大于0,保留两位小数点,如0.10、100.05等。必须小于等于原支付金额-已确认金额-已撤销金额。
-    private String confirm_amt;
-    //附加说明
-    private String description;
-    //分账对象信息列表,一次请求最多仅支持7个分账方
-    private List<DivMember> div_members;
-    //手续费收取模式:O-商户手续费账户扣取手续费,I-交易金额中扣取手续费;值为空时,默认值为I;若为O时,分账对象列表中不支持传入手续费承担方
-    private String fee_mode;
-
-    public String getPayment_id() {
-        return payment_id;
-    }
-
-    public void setPayment_id(String payment_id) {
-        this.payment_id = payment_id;
-    }
-
-    public String getOrder_no() {
-        return order_no;
-    }
-
-    public void setOrder_no(String order_no) {
-        this.order_no = order_no;
-    }
-
-    public String getConfirm_amt() {
-        return confirm_amt;
-    }
-
-    public void setConfirm_amt(String confirm_amt) {
-        this.confirm_amt = confirm_amt;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public List<DivMember> getDiv_members() {
-        return div_members;
-    }
-
-    public void setDiv_members(List<DivMember> div_members) {
-        this.div_members = div_members;
-    }
-
-    public String getFee_mode() {
-        return fee_mode;
-    }
-
-    public void setFee_mode(String fee_mode) {
-        this.fee_mode = fee_mode;
-    }
-}

+ 0 - 168
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/PaymentReq.java

@@ -1,168 +0,0 @@
-package com.yonge.cooleshow.biz.dal.sdk.req;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * 创建支付对象请求参数
- * @Author: liweifan
- * @Data: 2022/3/31 10:58
- */
-public class PaymentReq implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /***
-     * 请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
-     * @author liweifan
-     * @updateTime 2022/3/31 11:00
-     */
-    private String order_no;
-    /***
-     * 控制台 主页面应用的app_id
-     * @author liweifan
-     * @updateTime 2022/3/31 11:00
-     */
-    private String app_id;
-    /***
-     * 支付渠道,参见 支付渠道
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String pay_channel;
-    /***
-     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String pay_amt;
-    /***
-     * 商品标题
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String goods_title;
-    /***
-     * 商品描述信息,微信小程序和微信公众号该字段最大长度42个字符
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String goods_desc;
-    /***
-     * 分账对象信息列表,最多仅支持7个分账方,json 数组形式,详见 分账对象信息列表
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String div_members;
-    /***
-     * 订单附加说明
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String description;
-    /***
-     * 前端设备信息,详见 设备信息
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private DeviceInfo device_info;
-    /***
-     * 支付渠道额外参数,JSON格式,条件可输入,详见 支付渠道 expend参数
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private Map<String,Object> expend;
-    /***
-     * 异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String notify_url;
-
-    public String getOrder_no() {
-        return order_no;
-    }
-
-    public void setOrder_no(String order_no) {
-        this.order_no = order_no;
-    }
-
-    public String getApp_id() {
-        return app_id;
-    }
-
-    public void setApp_id(String app_id) {
-        this.app_id = app_id;
-    }
-
-    public String getPay_amt() {
-        return pay_amt;
-    }
-
-    public void setPay_amt(String pay_amt) {
-        this.pay_amt = pay_amt;
-    }
-
-    public String getGoods_title() {
-        return goods_title;
-    }
-
-    public void setGoods_title(String goods_title) {
-        this.goods_title = goods_title;
-    }
-
-    public String getGoods_desc() {
-        return goods_desc;
-    }
-
-    public void setGoods_desc(String goods_desc) {
-        this.goods_desc = goods_desc;
-    }
-
-    public String getDiv_members() {
-        return div_members;
-    }
-
-    public void setDiv_members(String div_members) {
-        this.div_members = div_members;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public DeviceInfo getDevice_info() {
-        return device_info;
-    }
-
-    public void setDevice_info(DeviceInfo device_info) {
-        this.device_info = device_info;
-    }
-
-    public Map<String, Object> getExpend() {
-        return expend;
-    }
-
-    public void setExpend(Map<String, Object> expend) {
-        this.expend = expend;
-    }
-
-    public String getNotify_url() {
-        return notify_url;
-    }
-
-    public void setNotify_url(String notify_url) {
-        this.notify_url = notify_url;
-    }
-
-    public String getPay_channel() {
-        return pay_channel;
-    }
-
-    public void setPay_channel(String pay_channel) {
-        this.pay_channel = pay_channel;
-    }
-}

+ 2 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderPaymentService.java

@@ -4,13 +4,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderPayment;
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
 import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.cooleshow.biz.dal.vo.res.OrderPayRes;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
-
-import java.util.Map;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 
 /**
  * 平台订单支付表 服务类
@@ -76,6 +74,6 @@ public interface UserOrderPaymentService extends IService<UserOrderPayment> {
      * @param: detail
      * @updateTime 2022/5/7 13:56
      */
-    HttpResponseResult<OrderPayRes> createOrderPayment(OrderPayReq payReq, UserOrderVo detail);
+    HttpResponseResult<OrderPayRes> createOrderPayment(OrderPayReq payReq, UserOrderVo detail) throws Exception;
 
 }

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

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.biz.dal.dto.search.UserOrderRefundSearch;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderRefund;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderRefundVo;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.payment.base.model.RefundBill;
 
 /**
  * 用户退款表 服务类
@@ -45,5 +46,5 @@ public interface UserOrderRefundService extends IService<UserOrderRefund>  {
 	 * @updateTime 2022/5/9 16:25
 	 * @return: com.yonge.cooleshow.common.entity.HttpResponseResult<java.lang.Boolean>
 	 */
-    HttpResponseResult<Boolean> doAuth(AuthOperaReq authOperaReq, SysUser user);
+    HttpResponseResult<RefundBill> doAuth(AuthOperaReq authOperaReq, SysUser user);
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderService.java

@@ -89,7 +89,7 @@ public interface UserOrderService extends IService<UserOrder> {
      * @param: data
      * @updateTime 2022/4/8 18:24
      */
-    void orderCallback(String data, String type);
+    void adapayCallback(String data, String type);
 
     /***
      * 轮询用户订单

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

@@ -150,8 +150,9 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     public HttpResponseResult<Boolean> openLive(Long id) {
         TeacherTotal teacherTotal = (TeacherTotal) redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(id)).get();
         if (null == teacherTotal) {
-            return HttpResponseResult.succeed(false);
+            teacherTotal = new TeacherTotal();
         }
+
         //开通直播需要粉丝数
         Integer fansNum = Integer.parseInt(sysConfigService.findByParamName(SysConfigConstant.OPEN_LIVE_FANS_NUM).getParamValue());
         //开通直播需要已完成课时数

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

@@ -3,19 +3,23 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yonge.cooleshow.biz.dal.config.HuifuConfiguration;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
 import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
 import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
-import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
-import com.yonge.cooleshow.biz.dal.sdk.req.DeviceInfo;
-import com.yonge.cooleshow.biz.dal.sdk.req.PaymentReq;
+import com.yonge.cooleshow.biz.dal.props.PaymentProperties;
 import com.yonge.cooleshow.biz.dal.service.UserOrderService;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.cooleshow.biz.dal.vo.res.OrderPayRes;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 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.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,10 +29,7 @@ import com.yonge.cooleshow.biz.dal.service.UserOrderPaymentService;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Service
@@ -38,7 +39,9 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
     @Autowired
     private IdGeneratorService idGeneratorService;
     @Autowired
-    private PaymentSdk paymentSdk;
+    private PaymentProperties paymentProperties;
+    @Autowired
+    private PaymentClient paymentClient;
 
     @Override
     public UserOrderPayment detailByOrderNo(String orderNo, PayChannelEnum payChannel, TradeStatusEnum status) {
@@ -63,33 +66,26 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
     /***
      * 入订单付款表
      * @author liweifan
-     * @param: responseResult
+     * @param: paymentRes
      * @param: payReq
-     * @param: paymentNo
-     * @updateTime 2022/5/7 14:19
+     * @updateTime 2022/5/11 18:47
      * @return: com.yonge.cooleshow.biz.dal.entity.UserOrderPayment
      */
-    private UserOrderPayment insertOrderPayment(HttpResponseResult<Map<String, Object>> responseResult, OrderPayReq payReq, Long paymentNo) {
+    private UserOrderPayment insertOrderPayment(Payment payment, OrderPayReq payReq) {
         UserOrderPayment orderPayment = new UserOrderPayment();
         orderPayment.setOrderNo(payReq.getOrderNo());
-        orderPayment.setPaymentNo(paymentNo.toString());
+        orderPayment.setPaymentNo(payment.getPaymentNo());
         orderPayment.setPayChannel(payReq.getPayChannel());
-        if (responseResult.getStatus()) {
-            Map<String, Object> res = responseResult.getData();
-            orderPayment.setTransNo(res.get("id").toString());
-            orderPayment.setPayAmt(
-                    new BigDecimal(res.get("pay_amt").toString()).setScale(2, RoundingMode.HALF_UP)
-            );
-            String pay_info = ((JSONObject) res.get("expend")).getString("pay_info");
-            orderPayment.setPayInfo(pay_info);
-            orderPayment.setStatus(TradeStatusEnum.pending);
-
-            //查询订单下支付中的付款单,取消支付
-            closePayment(payReq.getOrderNo(),"用户发起了新的付款请求");
-        } else {
-            orderPayment.setPayFailMsg(responseResult.getMsg());
-            orderPayment.setStatus(TradeStatusEnum.failed);
-        }
+        orderPayment.setTransNo(payment.getId());
+        orderPayment.setPayAmt(
+                new BigDecimal(payment.getPayAmt()).setScale(2, RoundingMode.HALF_UP)
+        );
+        orderPayment.setPayInfo(payment.getPayInfo());
+        orderPayment.setStatus(TradeStatusEnum.pending);
+
+        //查询订单下支付中的付款单,取消支付
+        closePayment(payReq.getOrderNo(), "用户发起了新的付款请求");
+        //保存新的付款单
         save(orderPayment);
         return orderPayment;
     }
@@ -99,7 +95,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
         UserOrderPayment orderPayment = baseMapper.selectOne(Wrappers.<UserOrderPayment>lambdaQuery()
                 .eq(UserOrderPayment::getOrderNo, orderNo)
                 .eq(UserOrderPayment::getStatus, TradeStatusEnum.pending));
-        if(null == orderPayment){
+        if (null == orderPayment) {
             return orderPayment;
         }
 
@@ -110,12 +106,20 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
 
         //发送支付关单请求
         if (!StringUtil.isEmpty(orderPayment.getTransNo())) {
-            HttpResponseResult<Map<String, Object>> responseResult = paymentSdk.closePayment(orderPayment.getTransNo(), reason, "");
-            if (!responseResult.getStatus()) {
-                orderPayment.setCloseStatus(TradeStatusEnum.failed);
-                orderPayment.setCloseFailMsg(responseResult.getMsg());
-            } else {
-                orderPayment.setCloseStatus(TradeStatusEnum.pending);
+            ClosePayment param = new ClosePayment(orderPayment.getOpenType(), orderPayment.getPayChannel());
+            param.setId(orderPayment.getTransNo());
+            param.setReason(reason);
+
+            try {
+                BaseResult<ClosePayment> responseResult = paymentClient.closePayment(param);
+                if (!responseResult.getStatus()) {
+                    orderPayment.setCloseStatus(TradeStatusEnum.failed);
+                    orderPayment.setCloseFailMsg(responseResult.getMsg());
+                } else {
+                    orderPayment.setCloseStatus(TradeStatusEnum.pending);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
             }
         }
         updateById(orderPayment);
@@ -147,54 +151,59 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
     }
 
     @Override
-    public HttpResponseResult<OrderPayRes> createOrderPayment(OrderPayReq payReq, UserOrderVo detail) {
+    public HttpResponseResult<OrderPayRes> createOrderPayment(OrderPayReq payReq, UserOrderVo detail) throws Exception {
         OrderPayRes orderPayRes = new OrderPayRes();
-        //付订单号生成
-        Long adapayNo = idGeneratorService.generatorId("adapayNo");
+        //付订单号生成
+        Long paymentNo = idGeneratorService.generatorId("paymentNo");
 
         //构建汇付统一下单请求
-        PaymentReq paymentReq = new PaymentReq();
-        paymentReq.setOrder_no(adapayNo.toString());
-        paymentReq.setPay_channel(payReq.getPayChannel().getCode());
-        paymentReq.setPay_amt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
-        paymentReq.setGoods_title(detail.getOrderName());
-        paymentReq.setGoods_desc(detail.getOrderDesc());
-
-        DeviceInfo deviceInfo = new DeviceInfo();
-        deviceInfo.setDevice_ip(payReq.getIpAddress());
-
-        paymentReq.setDevice_info(deviceInfo);
-        //异步通知地址
-        paymentReq.setNotify_url(HuifuConfiguration.getHuifuProperties().getNotifyUrl());
-
-        if (PayChannelEnum.alipay_lite.equals(payReq.getPayChannel())) {
-            Map<String, Object> expend = new HashMap<>();
-            expend.put("buyer_id", payReq.getBuyerId());
-            paymentReq.setExpend(expend);
-        }
-        if (PayChannelEnum.wx_lite.equals(payReq.getPayChannel())) {
-            Map<String, Object> expend = new HashMap<>();
-            expend.put("open_id", payReq.getOpenId());
-            paymentReq.setExpend(expend);
+        OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
+        Payment payment = new Payment(openType, payReq.getPayChannel());
+        payment.setPaymentNo(paymentNo.toString());
+        payment.setOrderTitle(detail.getOrderName());
+        payment.setOrderDesc(detail.getOrderDesc());
+        payment.setPayAmt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
+
+        payment.setDescription(payReq.getReason());
+
+        if (OpenEnum.ADAPAY.equals(openType)) {
+            //创建分账对象
+            DivMember div_member = new DivMember();
+            div_member.setMember_id("0");
+            div_member.setAmount(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
+            div_member.setFee_flag("Y");
+            List<DivMember> div_members = Arrays.asList(div_member);
+            payment.setDivMembers(div_members);
+
+            //前端设备信息
+            DeviceInfo deviceInfo = new DeviceInfo();
+            deviceInfo.setDevice_ip(payReq.getIpAddress());
+            payment.setDeviceInfo(deviceInfo);
+
+            if (PayChannelEnum.wx_lite.equals(payReq.getPayChannel())) {
+                Map<String, Object> expend = new HashMap<>();
+                expend.put("open_id", payReq.getOpenId());
+                payment.setExpend(expend);
+            }
         }
 
         //付款请求
-        HttpResponseResult<Map<String, Object>> responseResult = paymentSdk.executePayment(paymentReq);
-        if (responseResult.getStatus()) {
+        BaseResult<Payment> paymentResBaseResult = paymentClient.executePayment(payment);
+        if (paymentResBaseResult.getStatus()) {
             orderPayRes.setPay_amt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
-            String pay_info = ((JSONObject) responseResult.getData().get("expend")).getString("pay_info");
+            String pay_info = paymentResBaseResult.getData().getPayInfo();
             orderPayRes.setPay_info(pay_info);
             orderPayRes.setPayChannel(payReq.getPayChannel());
 
             //入订单付款表
-            insertOrderPayment(responseResult, payReq, adapayNo);
+            insertOrderPayment(paymentResBaseResult.getData(), payReq);
             //修改订单状态
             userOrderService.updateStatusByOrderNo(payReq.getOrderNo(), OrderStatusEnum.PAYING.getCode());
             return HttpResponseResult.succeed(orderPayRes);
         } else {
             //入订单付款表,同时修改订单状态
-            userOrderService.doOrderCancel(detail, OrderStatusEnum.FAIL, responseResult.getMsg());
-            return HttpResponseResult.failed(responseResult.getMsg());
+            userOrderService.doOrderCancel(detail, OrderStatusEnum.FAIL, paymentResBaseResult.getMsg());
+            return HttpResponseResult.failed(paymentResBaseResult.getMsg());
         }
     }
 }

+ 19 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderRefundServiceImpl.java

@@ -16,7 +16,6 @@ import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
-import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderRefundVo;
@@ -24,6 +23,10 @@ import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.cooleshow.biz.dal.vo.res.RefundCreateRes;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.service.IdGeneratorService;
+import com.yonge.toolset.base.result.BaseResult;
+import com.yonge.toolset.payment.base.model.Payment;
+import com.yonge.toolset.payment.base.model.RefundBill;
+import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -36,9 +39,6 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import static java.util.stream.Collectors.joining;
-
-
 @Service
 public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao, UserOrderRefund> implements UserOrderRefundService {
     @Autowired
@@ -50,10 +50,10 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
     @Autowired
     private CourseGroupService courseGroupService;
     @Autowired
-    private PaymentSdk paymentSdk;
-    @Autowired
     private IdGeneratorService idGeneratorService;
     @Autowired
+    private PaymentClient paymentClient;
+    @Autowired
     private UserOrderRefundPaymentService refundPaymentService;
 
     //验证是否可以退款,获取退款金额信息
@@ -156,14 +156,14 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HttpResponseResult<Boolean> doAuth(AuthOperaReq authOperaReq, SysUser user) {
+    public HttpResponseResult<RefundBill> doAuth(AuthOperaReq authOperaReq, SysUser user) {
         UserOrderRefund orderRefund = baseMapper.selectById(authOperaReq.getId());
         if (!AuthStatusEnum.DOING.equals(orderRefund.getStatus())) {
             return HttpResponseResult.failed("退款单已审核");
         }
         String oredrDetilIds = orderRefund.getOredrDetilIds();
         if (StringUtil.isEmpty(oredrDetilIds)) {
-            return HttpResponseResult.succeed(true);
+            return HttpResponseResult.succeed();
         }
 
         orderRefund.setStatus(authOperaReq.getPass() ? AuthStatusEnum.PASS : AuthStatusEnum.UNPASS);
@@ -190,20 +190,25 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
                 }
             }
         }
-        return HttpResponseResult.succeed(true);
+        return HttpResponseResult.succeed();
     }
 
-    private HttpResponseResult<Boolean> doOrderRefund(UserOrderRefund orderRefund) {
-        UserOrderPayment successPayment = orderPaymentService.getOne(Wrappers.<UserOrderPayment>lambdaQuery()
+    private HttpResponseResult<RefundBill> doOrderRefund(UserOrderRefund orderRefund) {
+        UserOrderPayment payment = orderPaymentService.getOne(Wrappers.<UserOrderPayment>lambdaQuery()
                 .eq(UserOrderPayment::getOrderNo, orderRefund.getOrderNo())
                 .eq(UserOrderPayment::getStatus, TradeStatusEnum.succeeded)
         );
 
         //单号生成
-        Long refundOrderNo = idGeneratorService.generatorId("userOrder");
+        Long billNo = idGeneratorService.generatorId("billNo");
 
-        HttpResponseResult<Map<String, Object>> responseResult = paymentSdk.refundPayment(successPayment.getTransNo(), refundOrderNo.toString(), orderRefund.getActualAmount());
+        RefundBill refundBill = new RefundBill(payment.getOpenType(), payment.getPayChannel());
+        refundBill.setId(payment.getTransNo());
+        refundBill.setRefundNo(billNo.toString());
+        refundBill.setRefundAmt(orderRefund.getActualAmount());
+        refundBill.setReason(orderRefund.getReason());
 
-        return HttpResponseResult.succeed(true);
+        BaseResult<RefundBill> refundBillBaseResult = paymentClient.refundPayment(refundBill);
+        return HttpResponseResult.status(refundBillBaseResult);
     }
 }

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

@@ -4,6 +4,7 @@ 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;
@@ -11,7 +12,6 @@ import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
 import com.yonge.cooleshow.biz.dal.entity.UserOrder;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderPayment;
-import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
@@ -19,6 +19,10 @@ import com.yonge.cooleshow.biz.dal.vo.res.OrderPayRes;
 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.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.apache.commons.beanutils.BeanUtils;
 import org.redisson.api.RedissonClient;
@@ -52,9 +56,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
     @Autowired
     private UserOrderPaymentService orderPaymentService;
     @Autowired
-    private UserOrderRefundService orderRefundsService;
-    @Autowired
-    private PaymentSdk paymentSdk;
+    private PaymentClient paymentClient;
     @Autowired
     private IdGeneratorService idGeneratorService;
     @Autowired
@@ -67,6 +69,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
     private MusicSheetService musicSheetService;
     @Autowired
     private RedissonClient redissonClient;
+    @Autowired
+    private PaymentProperties paymentProperties;
 
     //验证订单是否可以下单,获取订单金额信息
     private static final Map<GoodTypeEnum, Function<OrderReq.OrderReqInfo, HttpResponseResult<OrderCreateRes>>> orderCreate = new HashMap<>();
@@ -177,25 +181,20 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         }
 
         if (!StringUtil.isEmpty(detail.getTransNo())) {
-            try {
-                Map<String, Object> resMap = paymentSdk.queryPayment(detail.getTransNo());
-                //支付成功
-                if (TradeStatusEnum.succeeded.getCode().equals(resMap.get("status").toString())) {
-                    orderSuccess(detail);
-                    return HttpResponseResult.failed("订单已经交易完成");
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                log.error("轮询处理支付中订单异常,异常参数: {}", JSONObject.toJSONString(payReq));
-                return HttpResponseResult.failed("取消订单失败");
+            Payment param = new Payment(detail.getOpenType(), detail.getPayChannel());
+            param.setId(detail.getTransNo());
+            BaseResult<Payment> res = paymentClient.queryPayment(param);
+            //支付成功
+            if (res.getStatus() && TradeStatusEnum.succeeded.getCode().equals(res.getData().getStatus())) {
+                orderSuccess(detail);
+                return HttpResponseResult.failed("订单已经交易完成");
             }
+            //关闭订单付款单
+            orderPaymentService.closePayment(payReq.getOrderNo(), StringUtil.isEmpty(payReq.getReason()) ? "用户取消订单" : payReq.getReason());
         }
         //关闭订单
         doOrderCancel(detail, OrderStatusEnum.CLOSE, StringUtil.isEmpty(payReq.getReason()) ? "用户取消订单" : payReq.getReason());
-        //关闭订单付款单
-        orderPaymentService.closePayment(payReq.getOrderNo(), StringUtil.isEmpty(payReq.getReason()) ? "用户取消订单" : payReq.getReason());
         return HttpResponseResult.succeed(true);
-
     }
 
 
@@ -309,7 +308,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 && !OrderStatusEnum.PAYING.equals(detail.getStatus())) {
             return HttpResponseResult.failed("订单状态异常");
         }
-        return doOrderPayWaitPay(payReq, detail);
+        return doOrderPay(payReq, detail);
     }
 
     @Override
@@ -323,7 +322,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void orderCallback(String data, String type) {
+    public void adapayCallback(String data, String type) {
         JSONObject hfRes = JSONObject.parseObject(data);
         if (type.equals("payment.succeeded")) {//支付成功
             paymentSucceededHandle(hfRes);
@@ -420,17 +419,14 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
             return;
         }
         if (!StringUtil.isEmpty(detail.getTransNo())) {
-            try {
-                Map<String, Object> resMap = paymentSdk.queryPayment(detail.getTransNo());
-                //支付成功
-                if (TradeStatusEnum.succeeded.getCode().equals(resMap.get("status").toString())
-                        && (OrderStatusEnum.WAIT_PAY.equals(detail.getStatus())
-                        || OrderStatusEnum.PAYING.equals(detail.getStatus()))) {
-                    orderSuccess(detail);
-                    return;
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
+            Payment param = new Payment(detail.getOpenType(), detail.getPayChannel());
+            param.setId(detail.getTransNo());
+            BaseResult<Payment> res = paymentClient.queryPayment(param);
+            //支付成功
+            if (res.getStatus() && TradeStatusEnum.succeeded.getCode().equals(res.getData().getStatus())
+                    && (OrderStatusEnum.WAIT_PAY.equals(detail.getStatus()) || OrderStatusEnum.PAYING.equals(detail.getStatus()))
+            ) {
+                orderSuccess(detail);
                 return;
             }
         }
@@ -440,7 +436,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         orderPaymentService.closePayment(orderNo, "订单超时");
     }
 
-    private HttpResponseResult<OrderPayRes> doOrderPayWaitPay(OrderPayReq payReq, UserOrderVo detail) {
+    private HttpResponseResult<OrderPayRes> doOrderPay(OrderPayReq payReq, UserOrderVo detail) throws Exception {
         UserOrderPayment orderPayment = orderPaymentService.detailByOrderNo(payReq.getOrderNo(), payReq.getPayChannel(), TradeStatusEnum.pending);
         //当前渠道已经有创建支付请求
         if (null != orderPayment && !StringUtil.isEmpty(orderPayment.getPayInfo())) {

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/HttpHelper.java

@@ -1,6 +1,6 @@
 package com.yonge.cooleshow.biz.dal.support;
 
-import com.yonge.cooleshow.biz.dal.config.IMProperties;
+import com.yonge.cooleshow.biz.dal.props.IMProperties;
 import io.rong.util.CodeUtil;
 import io.rong.util.GsonUtil;
 import org.apache.commons.lang3.StringUtils;

+ 23 - 13
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/UserOrderVo.java

@@ -2,8 +2,8 @@ package com.yonge.cooleshow.biz.dal.vo;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.yonge.cooleshow.biz.dal.entity.UserOrder;
-import com.yonge.cooleshow.biz.dal.entity.UserOrderDetail;
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -19,16 +19,18 @@ public class UserOrderVo extends UserOrder {
 	private static final long serialVersionUID = 1L;
 	@ApiModelProperty("订单详情 ")
 	private List<UserOrderDetailVo> orderDetailList;
+	@ApiModelProperty("服务提供方: ORIGINAL 微信支付宝 ADAPAY 汇付")
+	private OpenEnum openType;
+	@ApiModelProperty("支付渠道:  alipay 支付宝  wx_lite 微信 ")
+	private PayChannelEnum payChannel;
 	@ApiModelProperty("交易流水号 ")
 	private String transNo;
-	@ApiModelProperty("汇付收取的服务费 ")
+	@ApiModelProperty("收取的服务费 ")
 	private BigDecimal feeAmt;
 	@ApiModelProperty("用户昵称")
 	private String username;
 	@ApiModelProperty(value = "手机号")
 	private String phone;
-	@ApiModelProperty("支付渠道:  alipay 支付宝  wx_lite 微信 ")
-	private PayChannelEnum payChannel;
 
 	public List<UserOrderDetailVo> getOrderDetailList() {
 		return orderDetailList;
@@ -38,6 +40,22 @@ public class UserOrderVo extends UserOrder {
 		this.orderDetailList = orderDetailList;
 	}
 
+	public OpenEnum getOpenType() {
+		return openType;
+	}
+
+	public void setOpenType(OpenEnum openType) {
+		this.openType = openType;
+	}
+
+	public PayChannelEnum getPayChannel() {
+		return payChannel;
+	}
+
+	public void setPayChannel(PayChannelEnum payChannel) {
+		this.payChannel = payChannel;
+	}
+
 	public String getTransNo() {
 		return transNo;
 	}
@@ -69,12 +87,4 @@ public class UserOrderVo extends UserOrder {
 	public void setPhone(String phone) {
 		this.phone = phone;
 	}
-
-	public PayChannelEnum getPayChannel() {
-		return payChannel;
-	}
-
-	public void setPayChannel(PayChannelEnum payChannel) {
-		this.payChannel = payChannel;
-	}
 }

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/res/OrderPayRes.java

@@ -1,6 +1,6 @@
 package com.yonge.cooleshow.biz.dal.vo.res;
 
-import com.yonge.cooleshow.biz.dal.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -15,6 +15,7 @@ public class OrderPayRes {
     @ApiModelProperty("pay_info")
     private String pay_info;
 
+
     @ApiModelProperty(value = "支付渠道:  alipay 支付宝  wx_lite 微信 ")
     private PayChannelEnum payChannel;
 

+ 8 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserOrderMapper.xml

@@ -57,6 +57,7 @@
     <select id="detailByOrderNo" resultType="com.yonge.cooleshow.biz.dal.vo.UserOrderVo">
         SELECT
             <include refid="baseColumns"/>,
+            p.open_type_ as openType,
             p.trans_no_ as transNo,
             p.fee_amt_ as feeAmt,
             u.username_ as username,
@@ -73,8 +74,9 @@
     <select id="detailApp" resultType="com.yonge.cooleshow.biz.dal.vo.UserOrderVo">
         SELECT
             <include refid="baseColumns"/>,
-            p.trans_no_ as transNo,
-            p.pay_channel_ as payChannel
+            p.open_type_ as openType,
+            p.pay_channel_ as payChannel,
+            p.trans_no_ as transNo
         FROM user_order t
         left join user_order_payment p on t.order_no_ = p.order_no_ and (p.status_ = 'pending' or p.status_ = 'succeeded')
         where t.user_id_ = #{param.userId}
@@ -86,12 +88,11 @@
         </if>
     </select>
 
-
-
-
     <sql id="selectSql">
         SELECT
             <include refid="baseColumns"/>,
+            p.open_type_ as openType,
+            p.pay_channel_ as payChannel,
             p.trans_no_ as transNo,
             p.fee_amt_ as feeAmt,
             u.username_ as username,
@@ -165,6 +166,8 @@
     <select id="getPendingOrder" resultType="com.yonge.cooleshow.biz.dal.vo.UserOrderVo">
         SELECT
             <include refid="baseColumns"/>,
+            p.open_type_ as openType,
+            p.pay_channel_ as payChannel,
             p.trans_no_ as transNo,
             p.pay_channel_ as payChannel
         FROM user_order t

+ 6 - 2
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/StudentApplication.java

@@ -16,8 +16,12 @@ import org.springframework.context.annotation.Configuration;
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients("com.yonge.cooleshow")
-@MapperScan("com.yonge.cooleshow.biz.dal.dao")
-@ComponentScan(basePackages = { "com.yonge.cooleshow.student", "com.yonge.cooleshow.auth", "com.yonge.cooleshow.biz", "com.yonge.cooleshow.common", "com.yonge.cooleshow.common.security", "com.yonge.toolset.log", "com.yonge.toolset.thirdparty" })
+@MapperScan(basePackages = {"com.yonge.cooleshow.biz.dal.dao", "com.yonge.toolset.payment.core.dao"})
+@ComponentScan(basePackages = {
+        "com.yonge.cooleshow.student", "com.yonge.cooleshow.auth", "com.yonge.cooleshow.biz",
+        "com.yonge.cooleshow.common", "com.yonge.cooleshow.common.security",
+        "com.yonge.toolset.log", "com.yonge.toolset.thirdparty", "com.yonge.toolset.payment"
+})
 @Configuration
 @EnableSwagger2Doc
 public class StudentApplication {

+ 35 - 25
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java

@@ -1,15 +1,23 @@
 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;
 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.sdk.PaymentSdk;
+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;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+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.service.PaymentClient;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
@@ -19,6 +27,7 @@ import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.sql.Wrapper;
 import java.util.Map;
 
 /**
@@ -31,49 +40,52 @@ import java.util.Map;
 public class PaymentController extends BaseController {
     private final static Logger log = LoggerFactory.getLogger(PaymentController.class);
     @Autowired
-    private PaymentSdk paymentSdk;
+    private UserOrderPaymentService paymentService;
     @Autowired
     private UserOrderService userOrderService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private PaymentClient paymentClient;
+    @Autowired
+    private PaymentProperties paymentProperties;
 
     @ApiOperation(value = "查询付款单")
     @GetMapping("/queryPayment")
-    public HttpResponseResult<Map<String, Object>> queryPayment(String paymentId) throws Exception {
-        return HttpResponseResult.succeed(paymentSdk.queryPayment(paymentId));
-    }
-
-    @ApiOperation(value = "微信支付获取openid")
-    @GetMapping("/getOpenId")
-    public HttpResponseResult<Map<String, String>> getOpenId(String js_code) {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if (user == null || null == user.getId()) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
+    public HttpResponseResult<Payment> queryPayment(String transNo) throws Exception {
+        UserOrderPayment userOrderPayment = paymentService.getOne(Wrappers.<UserOrderPayment>lambdaQuery()
+                .eq(UserOrderPayment::getTransNo, transNo)
+        );
+        if (null == userOrderPayment) {
+            return HttpResponseResult.succeed();
         }
-        HttpResponseResult<Map<String, String>> responseResult = paymentSdk.getOpenId(js_code);
-        return responseResult;
+        Payment param = new Payment(userOrderPayment.getOpenType(), userOrderPayment.getPayChannel());
+        param.setId(userOrderPayment.getTransNo());
+        BaseResult<Payment> paymentBaseResult = paymentClient.queryPayment(param);
+        return HttpResponseResult.status(paymentBaseResult);
     }
 
-    @ApiOperation(value = "支付宝支付获取access_token(授权令牌)和user_id(用户支付宝 ID)")
-    @GetMapping("/getAliToken")
-    public HttpResponseResult<AlipaySystemOauthTokenResponse> getAliToken(String authorization_code) {
+    @ApiOperation(value = "通过用户给的授权码获取三方支付授权信息")
+    @GetMapping("/getOpenId")
+    public HttpResponseResult<Map<String, Object>> getOpenId(OpenAuth openAuth) {
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        HttpResponseResult<AlipaySystemOauthTokenResponse> aliToken = paymentSdk.getAliToken(authorization_code);
-        return aliToken;
+        OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
+        openAuth.setOpenType(openType);
+        BaseResult<Map<String, Object>> res = paymentClient.getOpenAuthMsg(openAuth);
+        return HttpResponseResult.status(res);
     }
 
     /***
      * 汇付回调
-     * 问题:1、成功失败需要回执什么信息 2、回调url地址是否需要加入白名单
      * @author liweifan
      * @param: request
      * @updateTime 2022/3/11 18:35
      */
-    @PostMapping("/callback")
-    public void callback(HttpServletRequest request) {
+    @PostMapping("/adapayCallback")
+    public void adapayCallback(HttpServletRequest request) {
         try {
             //验签传参data
             String data = request.getParameter("data");
@@ -92,12 +104,10 @@ public class PaymentController extends BaseController {
             boolean checkSign = AdapaySign.verifySign(data, sign, publicKey);
             if (checkSign) {
                 log.info("验签成功");
-                userOrderService.orderCallback(data, type);
+                userOrderService.adapayCallback(data, type);
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
-    //支付宝授权回调地址
-    //aliCallback
 }

+ 14 - 12
pom.xml

@@ -11,6 +11,8 @@
 	<url>http://maven.apache.org</url>
 
 	<properties>
+		<project.cooleshow.version>1.0</project.cooleshow.version>
+		<project.toolset.version>1.0</project.toolset.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 		<maven.compiler.source>1.8</maven.compiler.source>
@@ -56,72 +58,72 @@
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>auth-api</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>cooleshow-common</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>auth-api</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.toolset</groupId>
 				<artifactId>utils</artifactId>
-				<version>1.0</version>
+				<version>${project.toolset.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.toolset</groupId>
 				<artifactId>thirdparty-component</artifactId>
-				<version>1.0</version>
+				<version>${project.toolset.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.toolset</groupId>
 				<artifactId>mongo-db</artifactId>
-				<version>1.0</version>
+				<version>${project.toolset.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.toolset</groupId>
 				<artifactId>audit-log</artifactId>
-				<version>1.0</version>
+				<version>${project.toolset.version}</version>
 			</dependency>
 
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>user-biz</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 			<!--mall通用模块-->
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>mall-common</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>mall-pay</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 			<!--mall中MBG生成模块-->
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>mall-mbg</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 			<!--mall安全模块-->
 			<dependency>
 				<groupId>com.yonge.cooleshow</groupId>
 				<artifactId>mall-security</artifactId>
-				<version>1.0</version>
+				<version>${project.cooleshow.version}</version>
 			</dependency>
 			<dependency>
 				<groupId>com.alibaba.cloud</groupId>

+ 0 - 1
toolset/pom.xml

@@ -18,7 +18,6 @@
 	<url>http://maven.apache.org</url>
 
 	<properties>
-		<project.toolset.version>1.0</project.toolset.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 	</properties>
 

+ 0 - 33
toolset/toolset-payment/payment-adapay/pom.xml

@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>toolset-payment</artifactId>
-        <groupId>com.yonge.toolset</groupId>
-        <version>1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>payment-adapay</artifactId>
-    <packaging>jar</packaging>
-    <version>${project.toolset.version}</version>
-
-    <dependencies>
-        <dependency>
-            <groupId>com.yonge.toolset</groupId>
-            <artifactId>payment-core</artifactId>
-            <version>1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.huifu.adapay</groupId>
-            <artifactId>adapay-java-sdk</artifactId>
-            <version>1.2.10</version>
-        </dependency>
-        <dependency>
-            <groupId>com.alipay.sdk</groupId>
-            <artifactId>alipay-sdk-java</artifactId>
-            <version>4.23.0.ALL</version>
-        </dependency>
-    </dependencies>
-</project>

+ 0 - 48
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/config/HuifuConfiguration.java

@@ -1,48 +0,0 @@
-package com.yonge.toolset.payment.adapay.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.props.HuifuProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 路由配置信息
- */
-@Configuration
-@EnableConfigurationProperties({HuifuProperties.class})
-public class HuifuConfiguration {
-	private static HuifuProperties huifuProperties;
-	@Bean
-	public MerConfig merConfig(HuifuProperties authProperties) {
-		this.huifuProperties = authProperties;
-
-		MerConfig merConfig = new MerConfig();
-		merConfig.setApiKey(authProperties.getApiKey());
-		merConfig.setApiMockKey(authProperties.getMockApiKey());
-		merConfig.setRSAPrivateKey(authProperties.getRsaPrivateKey());
-		try {
-			Adapay.initWithMerConfig(merConfig);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return merConfig;
-	}
-
-	@Bean
-	public AlipayClient alipayClient(HuifuProperties authProperties){
-		AlipayClient alipayClient = new DefaultAlipayClient(
-				"https://openapi.alipay.com/gateway.do",
-				authProperties.getAliAppid(),
-				authProperties.getAliPrivatekey(),
-				"json","GBK",authProperties.getAliPublickey(),"RSA2");
-		return alipayClient;
-	}
-
-	public static HuifuProperties getHuifuProperties(){
-		return huifuProperties;
-	}
-}

+ 0 - 27
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/DeviceInfo.java

@@ -1,27 +0,0 @@
-package com.yonge.toolset.payment.adapay.model;
-
-import java.io.Serializable;
-
-/**
- * 交易设备信息
- * @Author: liweifan
- * @Data: 2022/3/31 11:36
- */
-public class DeviceInfo implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /***
-     * 交易设备所在的公网 IP
-     * @author liweifan
-     * @updateTime 2022/3/31 11:07
-     */
-    private String device_ip;
-
-    public String getDevice_ip() {
-        return device_ip;
-    }
-
-    public void setDevice_ip(String device_ip) {
-        this.device_ip = device_ip;
-    }
-}

+ 0 - 55
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/DivMember.java

@@ -1,55 +0,0 @@
-package com.yonge.toolset.payment.adapay.model;
-
-import java.io.Serializable;
-
-/**
- * 分账对象
- * @Author: liweifan
- * @Data: 2022/3/31 11:26
- */
-public class DivMember implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 分账用户 Member对象 的 id;若是商户本身时,传入0
-     * @author liweifan
-     * @updateTime 2022/3/31 11:27
-     */
-    private String member_id;
-    /**
-     * 分账金额,精确到分,如0.50,1.00等,分账总金额必须等于主交易金额,金额不能为0.00
-     * @author liweifan
-     * @updateTime 2022/3/31 11:28
-     */
-    private String amount;
-    /**
-     * 是否手续费承担方,N-否,Y-是,手续费承担方有且只能有一个
-     * @author liweifan
-     * @updateTime 2022/3/31 11:28
-     */
-    private String fee_flag;
-
-    public String getMember_id() {
-        return member_id;
-    }
-
-    public void setMember_id(String member_id) {
-        this.member_id = member_id;
-    }
-
-    public String getAmount() {
-        return amount;
-    }
-
-    public void setAmount(String amount) {
-        this.amount = amount;
-    }
-
-    public String getFee_flag() {
-        return fee_flag;
-    }
-
-    public void setFee_flag(String fee_flag) {
-        this.fee_flag = fee_flag;
-    }
-}

+ 0 - 73
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/PaymentConfirmParam.java

@@ -1,73 +0,0 @@
-package com.yonge.toolset.payment.adapay.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * @Author: liweifan
- * @Data: 2022/3/11 17:44
- */
-public class PaymentConfirmParam implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    //Adapay生成的支付对象id
-    private String payment_id;
-    //请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
-    private String order_no;
-    //确认金额,必须大于0,保留两位小数点,如0.10、100.05等。必须小于等于原支付金额-已确认金额-已撤销金额。
-    private String confirm_amt;
-    //附加说明
-    private String description;
-    //分账对象信息列表,一次请求最多仅支持7个分账方
-    private List<DivMember> div_members;
-    //手续费收取模式:O-商户手续费账户扣取手续费,I-交易金额中扣取手续费;值为空时,默认值为I;若为O时,分账对象列表中不支持传入手续费承担方
-    private String fee_mode;
-
-    public String getPayment_id() {
-        return payment_id;
-    }
-
-    public void setPayment_id(String payment_id) {
-        this.payment_id = payment_id;
-    }
-
-    public String getOrder_no() {
-        return order_no;
-    }
-
-    public void setOrder_no(String order_no) {
-        this.order_no = order_no;
-    }
-
-    public String getConfirm_amt() {
-        return confirm_amt;
-    }
-
-    public void setConfirm_amt(String confirm_amt) {
-        this.confirm_amt = confirm_amt;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public List<DivMember> getDiv_members() {
-        return div_members;
-    }
-
-    public void setDiv_members(List<DivMember> div_members) {
-        this.div_members = div_members;
-    }
-
-    public String getFee_mode() {
-        return fee_mode;
-    }
-
-    public void setFee_mode(String fee_mode) {
-        this.fee_mode = fee_mode;
-    }
-}

+ 0 - 168
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/model/PaymentReq.java

@@ -1,168 +0,0 @@
-package com.yonge.toolset.payment.adapay.model;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * 创建支付对象请求参数
- * @Author: liweifan
- * @Data: 2022/3/31 10:58
- */
-public class PaymentReq implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /***
-     * 请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
-     * @author liweifan
-     * @updateTime 2022/3/31 11:00
-     */
-    private String order_no;
-    /***
-     * 控制台 主页面应用的app_id
-     * @author liweifan
-     * @updateTime 2022/3/31 11:00
-     */
-    private String app_id;
-    /***
-     * 支付渠道,参见 支付渠道
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String pay_channel;
-    /***
-     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String pay_amt;
-    /***
-     * 商品标题
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String goods_title;
-    /***
-     * 商品描述信息,微信小程序和微信公众号该字段最大长度42个字符
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String goods_desc;
-    /***
-     * 分账对象信息列表,最多仅支持7个分账方,json 数组形式,详见 分账对象信息列表
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String div_members;
-    /***
-     * 订单附加说明
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String description;
-    /***
-     * 前端设备信息,详见 设备信息
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private DeviceInfo device_info;
-    /***
-     * 支付渠道额外参数,JSON格式,条件可输入,详见 支付渠道 expend参数
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private Map<String,Object> expend;
-    /***
-     * 异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private String notify_url;
-
-    public String getOrder_no() {
-        return order_no;
-    }
-
-    public void setOrder_no(String order_no) {
-        this.order_no = order_no;
-    }
-
-    public String getApp_id() {
-        return app_id;
-    }
-
-    public void setApp_id(String app_id) {
-        this.app_id = app_id;
-    }
-
-    public String getPay_amt() {
-        return pay_amt;
-    }
-
-    public void setPay_amt(String pay_amt) {
-        this.pay_amt = pay_amt;
-    }
-
-    public String getGoods_title() {
-        return goods_title;
-    }
-
-    public void setGoods_title(String goods_title) {
-        this.goods_title = goods_title;
-    }
-
-    public String getGoods_desc() {
-        return goods_desc;
-    }
-
-    public void setGoods_desc(String goods_desc) {
-        this.goods_desc = goods_desc;
-    }
-
-    public String getDiv_members() {
-        return div_members;
-    }
-
-    public void setDiv_members(String div_members) {
-        this.div_members = div_members;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public DeviceInfo getDevice_info() {
-        return device_info;
-    }
-
-    public void setDevice_info(DeviceInfo device_info) {
-        this.device_info = device_info;
-    }
-
-    public Map<String, Object> getExpend() {
-        return expend;
-    }
-
-    public void setExpend(Map<String, Object> expend) {
-        this.expend = expend;
-    }
-
-    public String getNotify_url() {
-        return notify_url;
-    }
-
-    public void setNotify_url(String notify_url) {
-        this.notify_url = notify_url;
-    }
-
-    public String getPay_channel() {
-        return pay_channel;
-    }
-
-    public void setPay_channel(String pay_channel) {
-        this.pay_channel = pay_channel;
-    }
-}

+ 0 - 149
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/props/HuifuProperties.java

@@ -1,149 +0,0 @@
-package com.yonge.toolset.payment.adapay.props;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-
-@RefreshScope
-@ConfigurationProperties("huifu")
-public class HuifuProperties {
-	/***
-	 * 汇付 控制台 主页面应用的app_id
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:19
-	 */
-	private String appId;
-	/***
-	 * 汇付 控制台->商户信息管理->证书管理中的API Key(prod模式的API KEY)
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:19
-	 */
-	private String apiKey;
-	/***
-	 * 汇付 控制台->商户信息管理->证书管理中的API Key(mock模式的API KEY)
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:19
-	 */
-	private String mockApiKey;
-	/***
-	 * 商户发起请求时,用于请求参数加签所需要的RSA私钥
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String rsaPrivateKey;
-	/***
-	 * 付款成功回调地址
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String notifyUrl;
-	/***
-	 * 微信appid
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String wxAppid;
-	/***
-	 * 微信secret
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String wxSecret;
-	/***
-	 * 支付宝appid
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String aliAppid;
-	/***
-	 * 支付宝开发者私钥(由开发者自己生成)
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String aliPrivatekey;
-	/***
-	 * 支付宝公钥(由支付宝生成)
-	 * @author liweifan
-	 * @updateTime 2022/3/31 11:24
-	 */
-	private String aliPublickey;
-
-	public String getApiKey() {
-		return apiKey;
-	}
-
-	public void setApiKey(String apiKey) {
-		this.apiKey = apiKey;
-	}
-
-	public String getMockApiKey() {
-		return mockApiKey;
-	}
-
-	public void setMockApiKey(String mockApiKey) {
-		this.mockApiKey = mockApiKey;
-	}
-
-	public String getRsaPrivateKey() {
-		return rsaPrivateKey;
-	}
-
-	public void setRsaPrivateKey(String rsaPrivateKey) {
-		this.rsaPrivateKey = rsaPrivateKey;
-	}
-
-	public String getAppId() {
-		return appId;
-	}
-
-	public void setAppId(String appId) {
-		this.appId = appId;
-	}
-
-	public String getWxAppid() {
-		return wxAppid;
-	}
-
-	public void setWxAppid(String wxAppid) {
-		this.wxAppid = wxAppid;
-	}
-
-	public String getWxSecret() {
-		return wxSecret;
-	}
-
-	public void setWxSecret(String wxSecret) {
-		this.wxSecret = wxSecret;
-	}
-
-	public String getNotifyUrl() {
-		return notifyUrl;
-	}
-
-	public void setNotifyUrl(String notifyUrl) {
-		this.notifyUrl = notifyUrl;
-	}
-
-	public String getAliAppid() {
-		return aliAppid;
-	}
-
-	public void setAliAppid(String aliAppid) {
-		this.aliAppid = aliAppid;
-	}
-
-	public String getAliPrivatekey() {
-		return aliPrivatekey;
-	}
-
-	public void setAliPrivatekey(String aliPrivatekey) {
-		this.aliPrivatekey = aliPrivatekey;
-	}
-
-	public String getAliPublickey() {
-		return aliPublickey;
-	}
-
-	public void setAliPublickey(String aliPublickey) {
-		this.aliPublickey = aliPublickey;
-	}
-}

+ 0 - 41
toolset/toolset-payment/payment-core/pom.xml

@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>toolset-payment</artifactId>
-        <groupId>com.yonge.toolset</groupId>
-        <version>1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>payment-core</artifactId>
-    <packaging>jar</packaging>
-    <version>${project.toolset.version}</version>
-
-
-    <properties>
-        <redisson.version>3.16.4</redisson.version>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>com.yonge.toolset</groupId>
-            <artifactId>toolset-mybatis</artifactId>
-            <version>${project.toolset.version}</version>
-        </dependency>
-        <!-- mybatis-plus -->
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.0.7.1</version>
-            <scope>provided</scope>
-        </dependency>
-        <!-- redisson -->
-        <dependency>
-            <groupId>org.redisson</groupId>
-            <artifactId>redisson-spring-boot-starter</artifactId>
-            <version>${redisson.version}</version>
-        </dependency>
-    </dependencies>
-</project>

+ 0 - 44
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/PaymentTemplate.java

@@ -1,44 +0,0 @@
-package com.yonge.toolset.payment.core;
-
-import com.yonge.toolset.base.result.BaseResult;
-import com.yonge.toolset.payment.core.model.ClosePayment;
-import com.yonge.toolset.payment.core.model.Payment;
-import com.yonge.toolset.payment.core.model.RefundBill;
-import com.yonge.toolset.payment.core.model.res.ClosePaymentRes;
-import com.yonge.toolset.payment.core.model.res.PaymentRes;
-import com.yonge.toolset.payment.core.model.res.RefundBillRes;
-
-/**
- * @Author: liweifan
- * @Data: 2022/5/10 15:00
- */
-public interface PaymentTemplate {
-    /***
-     * 统一下单接口
-     * @author liweifan
-     * @param: product 订单对象
-     * @updateTime 2022/3/4 15:12
-     * @return: com.daya.payment.model.AbstractRS
-     */
-    BaseResult<PaymentRes> executePayment(Payment payment) throws Exception;
-    /***
-     * 统一关单接口
-     * @author liweifan
-     * @param: closePayment
-     * @updateTime 2022/5/10 15:34
-     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.core.model.res.ClosePaymentRes>
-     */
-    BaseResult<ClosePaymentRes> closePayment(ClosePayment closePayment) throws Exception;
-
-    /***
-     * 统一退款接口
-     * @author liweifan
-     * @param: closePayment
-     * @updateTime 2022/5/10 15:34
-     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.core.model.res.ClosePaymentRes>
-     */
-    BaseResult<RefundBillRes> refundPayment(RefundBill refundBill) throws Exception;
-
-
-
-}

+ 0 - 27
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/DeviceInfo.java

@@ -1,27 +0,0 @@
-package com.yonge.toolset.payment.core.model;
-
-import java.io.Serializable;
-
-/**
- * 交易设备信息
- * @Author: liweifan
- * @Data: 2022/3/31 11:36
- */
-public class DeviceInfo implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /***
-     * 交易设备所在的公网 IP
-     * @author liweifan
-     * @updateTime 2022/3/31 11:07
-     */
-    private String device_ip;
-
-    public String getDevice_ip() {
-        return device_ip;
-    }
-
-    public void setDevice_ip(String device_ip) {
-        this.device_ip = device_ip;
-    }
-}

+ 0 - 21
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/ClosePaymentRes.java

@@ -1,21 +0,0 @@
-package com.yonge.toolset.payment.core.model.res;
-
-import com.yonge.toolset.payment.core.enums.TradeStatusEnum;
-import com.yonge.toolset.payment.core.model.ClosePayment;
-
-/**
- * 支付关单返回对象
- * @Author: liweifan
- * @Data: 2022/5/10 15:34
- */
-public class ClosePaymentRes extends ClosePayment {
-    private TradeStatusEnum status;
-
-    public TradeStatusEnum getStatus() {
-        return status;
-    }
-
-    public void setStatus(TradeStatusEnum status) {
-        this.status = status;
-    }
-}

+ 0 - 36
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/PaymentRes.java

@@ -1,36 +0,0 @@
-package com.yonge.toolset.payment.core.model.res;
-
-import com.yonge.toolset.payment.core.enums.TradeStatusEnum;
-import com.yonge.toolset.payment.core.model.Payment;
-
-/**
- * 支付返回对象
- * @Author: liweifan
- * @Data: 2022/5/10 15:33
- */
-public class PaymentRes extends Payment {
-    /***
-     * 三方支付流水号,创建付款单后才有
-     * @author liweifan
-     * @updateTime 2022/3/31 11:00
-     */
-    private String id;
-
-    private TradeStatusEnum status;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public TradeStatusEnum getStatus() {
-        return status;
-    }
-
-    public void setStatus(TradeStatusEnum status) {
-        this.status = status;
-    }
-}

+ 0 - 20
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/res/RefundBillRes.java

@@ -1,20 +0,0 @@
-package com.yonge.toolset.payment.core.model.res;
-
-import com.yonge.toolset.payment.core.enums.TradeStatusEnum;
-import com.yonge.toolset.payment.core.model.RefundBill;
-
-/**
- * @Author: liweifan
- * @Data: 2022/5/10 15:44
- */
-public class RefundBillRes extends RefundBill {
-    private TradeStatusEnum status;
-
-    public TradeStatusEnum getStatus() {
-        return status;
-    }
-
-    public void setStatus(TradeStatusEnum status) {
-        this.status = status;
-    }
-}

+ 36 - 6
toolset/toolset-payment/pom.xml

@@ -10,19 +10,49 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>toolset-payment</artifactId>
-    <packaging>pom</packaging>
     <version>${project.toolset.version}</version>
+    <name>toolset-payment</name>
 
-    <modules>
-        <module>payment-core</module>
-        <module>payment-adapay</module>
-    </modules>
+    <properties>
+        <redisson.version>3.16.4</redisson.version>
+    </properties>
 
     <dependencies>
         <dependency>
             <groupId>com.yonge.toolset</groupId>
             <artifactId>toolset-base</artifactId>
-            <version>1.0</version>
+            <version>${project.toolset.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.yonge.toolset</groupId>
+            <artifactId>toolset-mybatis</artifactId>
+            <version>${project.toolset.version}</version>
+        </dependency>
+        <!-- mybatis-plus -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.0.7.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- redisson -->
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson-spring-boot-starter</artifactId>
+            <version>${redisson.version}</version>
+        </dependency>
+        <!-- 阿里 -->
+        <dependency>
+            <groupId>com.alipay.sdk</groupId>
+            <artifactId>alipay-sdk-java</artifactId>
+            <version>4.23.0.ALL</version>
+        </dependency>
+        <!-- 汇付 -->
+        <dependency>
+            <groupId>com.huifu.adapay</groupId>
+            <artifactId>adapay-java-sdk</artifactId>
+            <version>1.2.10</version>
         </dependency>
     </dependencies>
 </project>

+ 60 - 39
toolset/toolset-payment/payment-adapay/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/AdapayTemplate.java

@@ -1,24 +1,21 @@
 package com.yonge.toolset.payment.adapay;
 
 import com.alibaba.fastjson.JSONObject;
-import com.alipay.api.AlipayClient;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.core.util.StringUtil;
 import com.huifu.adapay.model.Refund;
 import com.yonge.toolset.base.result.BaseResult;
-import com.yonge.toolset.payment.adapay.config.HuifuConfiguration;
-import com.yonge.toolset.payment.adapay.model.DeviceInfo;
-import com.yonge.toolset.payment.core.PaymentTemplate;
-import com.yonge.toolset.payment.core.enums.TradeStatusEnum;
-import com.yonge.toolset.payment.core.model.ClosePayment;
-import com.yonge.toolset.payment.core.model.Payment;
-import com.yonge.toolset.payment.core.model.RefundBill;
-import com.yonge.toolset.payment.core.model.res.ClosePaymentRes;
-import com.yonge.toolset.payment.core.model.res.PaymentRes;
-import com.yonge.toolset.payment.core.model.res.RefundBillRes;
+import com.yonge.toolset.payment.adapay.constant.AdapayConstant;
+import com.yonge.toolset.payment.base.PaymentTemplate;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
+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 com.yonge.toolset.utils.string.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -29,14 +26,20 @@ import java.util.Map;
 @Component
 public class AdapayTemplate implements PaymentTemplate {
     private final static Logger log = LoggerFactory.getLogger(AdapayTemplate.class);
+
     @Autowired
-    private AlipayClient alipayClient;
+    private SysConfigPaymentService configPaymentService;
+
+    @Override
+    public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
+        return null;
+    }
 
     @Override
-    public BaseResult<PaymentRes> executePayment(Payment payment) throws Exception {
+    public BaseResult<Payment> executePayment(Payment payment){
         Map<String, Object> paymentMap = new HashMap<>();
-        paymentMap.put("order_no", payment.getOrderNo());
-        paymentMap.put("app_id", HuifuConfiguration.getHuifuProperties().getAppId());
+        paymentMap.put("order_no", payment.getPaymentNo());
+        paymentMap.put("app_id", configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.APP_ID).getParamValue());
         paymentMap.put("pay_channel", payment.getPayChannel().getCode());
         paymentMap.put("pay_amt", payment.getPayAmt());
         paymentMap.put("goods_title", payment.getOrderTitle());
@@ -45,7 +48,8 @@ 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()) ? HuifuConfiguration.getHuifuProperties().getNotifyUrl() : payment.getNotifyUrl());
+        paymentMap.put("notify_url",
+                StringUtil.isEmpty(payment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : payment.getNotifyUrl());
 
         log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentMap));
         //调用sdk方法,创建支付,得到支付对象
@@ -64,21 +68,43 @@ public class AdapayTemplate implements PaymentTemplate {
             String errorMsg = (String) res.get("error_msg");
             return BaseResult.failed(errorMsg);
         }
-        PaymentRes paymentRes = new PaymentRes();
-        BeanUtils.copyProperties(payment, paymentRes);
-        paymentRes.setId(res.get("id").toString());
-        paymentRes.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
-        return BaseResult.succeed(paymentRes);
+        payment.setId(res.get("id").toString());
+        payment.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
+
+        String pay_info = ((JSONObject) res.get("expend")).getString("pay_info");
+        payment.setPayInfo(pay_info);
+        return BaseResult.succeed(payment);
     }
 
     @Override
-    public BaseResult<ClosePaymentRes> closePayment(ClosePayment closePayment) throws Exception {
+    public BaseResult<Payment> queryPayment(Payment payment) {
+        try {
+            Map<String, Object> resMap = com.huifu.adapay.model.Payment.query(payment.getId());
+            String error_code = StringUtil.get(resMap.get("error_code"));
+            if (null != error_code) {
+                String error_msg = StringUtil.get(resMap.get("error_msg"));
+                return BaseResult.failed(error_msg);
+            }
+            payment.setStatus(TradeStatusEnum.getByName(StringUtil.get(resMap.get("status"))));
+            payment.setPaymentNo(StringUtil.get(resMap.get("order_no")));
+            payment.setPayAmt(StringUtil.get(resMap.get("pay_amt")));
+            payment.setPayChannel(PayChannelEnum.valueOf(StringUtil.get(resMap.get("status"))));
+            return BaseResult.succeed(payment);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+            return BaseResult.failed("支付订单查询异常");
+        }
+    }
+
+    @Override
+    public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
 
         Map<String, Object> paymentParams = new HashMap<>(10);
-        paymentParams.put("payment_id", closePayment.getPaymentId());
+        paymentParams.put("payment_id", closePayment.getId());
         paymentParams.put("reason", closePayment.getReason());
         paymentParams.put("expend", closePayment.getExpend());
-        paymentParams.put("notify_url", StringUtil.isEmpty(closePayment.getNotifyUrl()) ? HuifuConfiguration.getHuifuProperties().getNotifyUrl() : closePayment.getNotifyUrl());
+        paymentParams.put("notify_url",
+                StringUtil.isEmpty(closePayment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(closePayment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : closePayment.getNotifyUrl());
 
         Map<String, Object> res;
         try {
@@ -95,23 +121,21 @@ public class AdapayTemplate implements PaymentTemplate {
             String errorMsg = (String) res.get("error_msg");
             return BaseResult.failed(errorMsg);
         }
-        ClosePaymentRes paymentRes = new ClosePaymentRes();
-        BeanUtils.copyProperties(closePayment, paymentRes);
-
-        paymentRes.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
-        return BaseResult.succeed(paymentRes);
+        closePayment.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
+        return BaseResult.succeed(closePayment);
     }
 
     @Override
-    public BaseResult<RefundBillRes> refundPayment(RefundBill refundBill) throws Exception {
+    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()) ? HuifuConfiguration.getHuifuProperties().getNotifyUrl() : refundBill.getNotifyUrl());
+        refundParams.put("notify_url",
+                StringUtil.isEmpty(refundBill.getNotifyUrl()) ? configPaymentService.getPaymentConfig(refundBill.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : refundBill.getNotifyUrl());
 
         Map<String, Object> res;
         try {
-            res = Refund.create(refundBill.getPaymentId(), refundParams);
+            res = Refund.create(refundBill.getId(), refundParams);
         } catch (BaseAdaPayException e) {
             return BaseResult.failed(e.getMessage());
         }
@@ -124,10 +148,7 @@ public class AdapayTemplate implements PaymentTemplate {
             String errorMsg = (String) res.get("error_msg");
             return BaseResult.failed(errorMsg);
         }
-
-        RefundBillRes billRes = new RefundBillRes();
-        BeanUtils.copyProperties(refundBill, billRes);
-        billRes.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
-        return BaseResult.succeed(billRes);
+        refundBill.setStatus(TradeStatusEnum.getByName(res.get("status").toString()));
+        return BaseResult.succeed(refundBill);
     }
 }

+ 35 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/config/AdapayConfiguration.java

@@ -0,0 +1,35 @@
+package com.yonge.toolset.payment.adapay.config;
+
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/12 10:12
+ */
+@Configuration
+public class AdapayConfiguration {
+    @Autowired
+    private SysConfigPaymentService configPaymentService;
+
+    @Bean
+    public MerConfig merConfig() {
+        MerConfig merConfig = new MerConfig();
+        merConfig.setApiKey(configPaymentService.getPaymentConfig(OpenEnum.ADAPAY, AdapayConstant.API_KEY).getParamValue());
+        merConfig.setApiMockKey(configPaymentService.getPaymentConfig(OpenEnum.ADAPAY, AdapayConstant.MOCK_API_KEY).getParamValue());
+        merConfig.setRSAPrivateKey(configPaymentService.getPaymentConfig(OpenEnum.ADAPAY, AdapayConstant.RSA_PRIVATE_KEY).getParamValue());
+        try {
+            Adapay.initWithMerConfig(merConfig);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return merConfig;
+    }
+}

+ 51 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/adapay/constant/AdapayConstant.java

@@ -0,0 +1,51 @@
+package com.yonge.toolset.payment.adapay.constant;
+
+/**
+ *
+ * @Author: liweifan
+ * @Data: 2022/5/11 16:21
+ */
+public interface AdapayConstant {
+    /***
+     * 汇付APP_ID
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String APP_ID = "APP_ID";
+    /***
+     * 汇付API_KEY
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String API_KEY = "API_KEY";
+    /***
+     * 汇付MOCK_API_KEY
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String MOCK_API_KEY = "MOCK_API_KEY";
+    /***
+     * 汇付RSA_PRIVATE_KEY
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String RSA_PRIVATE_KEY = "RSA_PRIVATE_KEY";
+    /***
+     * 汇付回调NOTIFY_URL
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String NOTIFY_URL = "NOTIFY_URL";
+    /***
+     * 微信WX_APPID
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String WX_APPID = "WX_APPID";
+    /***
+     * 微信WX_SECRET
+     * @author liweifan
+     * @updateTime 2022/5/11 16:23
+     */
+    String WX_SECRET = "WX_SECRET";
+}

+ 61 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/PaymentTemplate.java

@@ -0,0 +1,61 @@
+package com.yonge.toolset.payment.base;
+
+import com.yonge.toolset.base.result.BaseResult;
+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 java.util.Map;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/10 15:00
+ */
+public interface PaymentTemplate {
+    /***
+     * 统一获取授权
+     * @author liweifan
+     * @param: openAuth
+     * @updateTime 2022/5/12 10:43
+     * @return: com.yonge.toolset.base.result.BaseResult<java.util.Map<java.lang.String,java.lang.Object>>
+     */
+    BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth);
+    /***
+     * 统一下单接口
+     * @author liweifan
+     * @param: product 订单对象
+     * @updateTime 2022/3/4 15:12
+     * @return: com.daya.payment.model.AbstractRS
+     */
+    BaseResult<Payment> executePayment(Payment payment);
+
+    /***
+     * 查询交易订单
+     * @author liweifan
+     * @param: product 订单对象
+     * @updateTime 2022/3/4 15:12
+     * @return: com.daya.payment.model.AbstractRS
+     */
+    BaseResult<Payment> queryPayment(Payment payment);
+
+    /***
+     * 统一关单接口
+     * @author liweifan
+     * @param: closePayment
+     * @updateTime 2022/5/10 15:34
+     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.base.model.res.ClosePaymentRes>
+     */
+    BaseResult<ClosePayment> closePayment(ClosePayment closePayment);
+
+    /***
+     * 统一退款接口
+     * @author liweifan
+     * @param: closePayment
+     * @updateTime 2022/5/10 15:34
+     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.base.model.res.ClosePaymentRes>
+     */
+    BaseResult<RefundBill> refundPayment(RefundBill refundBill);
+
+
+}

+ 1 - 1
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/constant/PaymentConstant.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/constant/PaymentConstant.java

@@ -1,4 +1,4 @@
-package com.yonge.toolset.payment.core.constant;
+package com.yonge.toolset.payment.base.constant;
 
 /**
  * @Author: liweifan

+ 8 - 6
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/enums/OpenEnum.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/OpenEnum.java

@@ -1,21 +1,23 @@
-package com.yonge.toolset.payment.core.enums;
+package com.yonge.toolset.payment.base.enums;
 
 import com.yonge.toolset.base.enums.BaseEnum;
 
 /**
  * 支付服务提供方
+ *
  * @Author: liweifan
  * @Data: 2022/3/31 14:59
  */
 public enum OpenEnum implements BaseEnum<String, OpenEnum> {
-    ORIGINAL("ORIGINAL","微信支付宝"),
-    ADAPAY("ADAPAY","汇付")
-    ;
+
+    ORIGINAL("微信支付宝"),
+    ADAPAY("汇付");
+
     private String code;
     private String msg;
 
-    OpenEnum(String code, String msg) {
-        this.code = code;
+    OpenEnum(String msg) {
+        this.code = this.name();
         this.msg = msg;
     }
 

+ 8 - 7
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/enums/PayChannelEnum.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/PayChannelEnum.java

@@ -1,24 +1,25 @@
-package com.yonge.toolset.payment.core.enums;
+package com.yonge.toolset.payment.base.enums;
 
 import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.yonge.toolset.base.enums.BaseEnum;
 
 /**
  * 支付渠道
+ *
  * @author liweifan
  * @updateTime 2022/3/31 11:30
  */
 public enum PayChannelEnum implements BaseEnum<String, PayChannelEnum> {
-    alipay("alipay","支付宝扫码"),
-    alipay_lite("alipay_lite","支付宝小程序支付"),
-    wx_lite("wx_lite","微信小程序支付")
-    ;
+    alipay("支付宝扫码"),
+    alipay_lite("支付宝小程序支付"),
+    wx_lite("微信小程序支付");
+
     @EnumValue
     private String code;
     private String msg;
 
-    PayChannelEnum(String code, String msg) {
-        this.code = code;
+    PayChannelEnum(String msg) {
+        this.code = this.name();
         this.msg = msg;
     }
 

+ 8 - 8
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/enums/TradeStatusEnum.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/enums/TradeStatusEnum.java

@@ -1,25 +1,25 @@
-package com.yonge.toolset.payment.core.enums;
+package com.yonge.toolset.payment.base.enums;
 
 import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.yonge.toolset.base.enums.BaseEnum;
 
 /**
  * 交易状态 pending 交易处理中 succeeded 交易成功 failed 交易失败
+ *
  * @Author: liweifan
  * @Data: 2022/3/31 14:59
  */
 public enum TradeStatusEnum implements BaseEnum<String, TradeStatusEnum> {
-    pending("pending","交易处理中"),
-    succeeded("succeeded","交易成功"),
-    failed("failed","交易失败"),
-    close("close","交易关闭")
-    ;
+    pending("交易处理中"),
+    succeeded("交易成功"),
+    failed("交易失败"),
+    close("交易关闭");
     @EnumValue
     private String code;
     private String msg;
 
-    TradeStatusEnum(String code, String msg) {
-        this.code = code;
+    TradeStatusEnum(String msg) {
+        this.code = this.name();
         this.msg = msg;
     }
 

+ 65 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Base.java

@@ -0,0 +1,65 @@
+package com.yonge.toolset.payment.base.model;
+
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
+
+import java.io.Serializable;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/11 16:12
+ */
+public class Base implements Serializable {
+    /***
+     * 支付服务提供方
+     * @author liweifan
+     * @updateTime 2022/3/31 11:01
+     */
+    private OpenEnum openType;
+    /***
+     * 支付渠道
+     * @author liweifan
+     * @updateTime 2022/3/31 11:01
+     */
+    private PayChannelEnum payChannel;
+
+    /***
+     * 交易状态(返回)
+     * @author liweifan
+     * @updateTime 2022/3/31 11:01
+     */
+    private TradeStatusEnum status;
+
+    public Base() {
+    }
+
+    public Base(OpenEnum openType, PayChannelEnum payChannel) {
+        this.openType = openType;
+        this.payChannel = payChannel;
+    }
+
+    public OpenEnum getOpenType() {
+        return openType;
+    }
+
+    public void setOpenType(OpenEnum openType) {
+        this.openType = openType;
+    }
+
+    public PayChannelEnum getPayChannel() {
+        return payChannel;
+    }
+
+    public void setPayChannel(PayChannelEnum payChannel) {
+        this.payChannel = payChannel;
+    }
+
+    public TradeStatusEnum getStatus() {
+        return status;
+    }
+
+    public void setStatus(TradeStatusEnum status) {
+        this.status = status;
+    }
+}

+ 13 - 24
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/ClosePayment.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/ClosePayment.java

@@ -1,27 +1,20 @@
-package com.yonge.toolset.payment.core.model;
+package com.yonge.toolset.payment.base.model;
 
-import com.yonge.toolset.payment.core.enums.PayChannelEnum;
-
-import java.io.Serializable;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 
 /**
  * 统一支付对象
  * @Author: liweifan
  * @Data: 2022/5/10 15:06
  */
-public class ClosePayment implements Serializable {
+public class ClosePayment extends Base {
     /***
      * 付款单id
      * @author liweifan
      * @updateTime 2022/5/10 15:30
      */
-    String paymentId;
-    /***
-     * 支付渠道
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private PayChannelEnum payChannel;
+    String id;
     /***
      * 关闭原因
      * @author liweifan
@@ -41,12 +34,16 @@ public class ClosePayment implements Serializable {
      */
     String expend;
 
-    public String getPaymentId() {
-        return paymentId;
+    public ClosePayment(OpenEnum openType, PayChannelEnum payChannel){
+        super(openType,payChannel);
+    }
+
+    public String getId() {
+        return id;
     }
 
-    public void setPaymentId(String paymentId) {
-        this.paymentId = paymentId;
+    public void setId(String id) {
+        this.id = id;
     }
 
     public String getReason() {
@@ -72,12 +69,4 @@ public class ClosePayment implements Serializable {
     public void setExpend(String expend) {
         this.expend = expend;
     }
-
-    public PayChannelEnum getPayChannel() {
-        return payChannel;
-    }
-
-    public void setPayChannel(PayChannelEnum payChannel) {
-        this.payChannel = payChannel;
-    }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/req/DeviceInfo.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/DeviceInfo.java

@@ -1,4 +1,4 @@
-package com.yonge.cooleshow.biz.dal.sdk.req;
+package com.yonge.toolset.payment.base.model;
 
 import java.io.Serializable;
 

+ 1 - 1
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/DivMember.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/DivMember.java

@@ -1,4 +1,4 @@
-package com.yonge.toolset.payment.core.model;
+package com.yonge.toolset.payment.base.model;
 
 import java.io.Serializable;
 

+ 32 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/OpenAuth.java

@@ -0,0 +1,32 @@
+package com.yonge.toolset.payment.base.model;
+
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
+
+/**
+ * 统一支付授权请求对象
+ *
+ * @Author: liweifan
+ * @Data: 2022/5/10 15:06
+ */
+public class OpenAuth extends Base {
+    /***
+     * 用户授权码
+     * @author liweifan
+     * @updateTime 2022/3/31 11:00
+     */
+
+    private String code;
+
+    public OpenAuth(OpenEnum openType, PayChannelEnum payChannel){
+        super(openType,payChannel);
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+}

+ 41 - 26
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/Payment.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/Payment.java

@@ -1,8 +1,8 @@
-package com.yonge.toolset.payment.core.model;
+package com.yonge.toolset.payment.base.model;
 
-import com.yonge.toolset.payment.core.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 
-import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
@@ -12,33 +12,33 @@ import java.util.Map;
  * @Author: liweifan
  * @Data: 2022/5/10 15:06
  */
-public class Payment implements Serializable {
+public class Payment extends Base {
     /***
-     * 请求订单号
+     * 三方支付流水号(请求后才有)
      * @author liweifan
      * @updateTime 2022/3/31 11:00
      */
-    private String orderNo;
+    private String id;
     /***
-     * 支付渠道
+     * 支付订单号(必填)
      * @author liweifan
-     * @updateTime 2022/3/31 11:01
+     * @updateTime 2022/3/31 11:00
      */
-    private PayChannelEnum payChannel;
+    private String paymentNo;
     /***
-     * 商品标题
+     * 商品标题(必填)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
     private String orderTitle;
     /***
-     * 商品描述信息,微信小程序和微信公众号该字段最大长度42个字符
+     * 商品描述信息(必填)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
     private String orderDesc;
     /***
-     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等
+     * 交易金额,必须大于0,保留两位小数点,如0.10、100.05等(必填)
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
@@ -49,14 +49,12 @@ public class Payment implements Serializable {
      * @updateTime 2022/3/31 11:01
      */
     private String description;
-
     /***
      * 异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
      * @author liweifan
      * @updateTime 2022/3/31 11:01
      */
     private String notifyUrl;
-
     /***
      * 分账对象信息列表
      * @author liweifan
@@ -75,14 +73,31 @@ public class Payment implements Serializable {
      * @updateTime 2022/3/31 11:01
      */
     private Map<String,Object> expend;
+    /***
+     * 三方拉起支付字符串(请求后才有)
+     * @author liweifan
+     * @updateTime 2022/5/11 19:27
+     */
+    private String payInfo;
+
+    public Payment(OpenEnum openType,PayChannelEnum payChannel){
+        super(openType,payChannel);
+    }
+
+    public String getId() {
+        return id;
+    }
 
+    public void setId(String id) {
+        this.id = id;
+    }
 
-    public String getOrderNo() {
-        return orderNo;
+    public String getPaymentNo() {
+        return paymentNo;
     }
 
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
     }
 
     public String getOrderTitle() {
@@ -125,14 +140,6 @@ public class Payment implements Serializable {
         this.notifyUrl = notifyUrl;
     }
 
-    public PayChannelEnum getPayChannel() {
-        return payChannel;
-    }
-
-    public void setPayChannel(PayChannelEnum payChannel) {
-        this.payChannel = payChannel;
-    }
-
     public List<DivMember> getDivMembers() {
         return divMembers;
     }
@@ -156,4 +163,12 @@ public class Payment implements Serializable {
     public void setExpend(Map<String, Object> expend) {
         this.expend = expend;
     }
+
+    public String getPayInfo() {
+        return payInfo;
+    }
+
+    public void setPayInfo(String payInfo) {
+        this.payInfo = payInfo;
+    }
 }

+ 11 - 21
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/model/RefundBill.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/base/model/RefundBill.java

@@ -1,27 +1,21 @@
-package com.yonge.toolset.payment.core.model;
+package com.yonge.toolset.payment.base.model;
 
-import com.yonge.toolset.payment.core.enums.PayChannelEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.PayChannelEnum;
 
-import java.io.Serializable;
 import java.math.BigDecimal;
 
 /**
  * @Author: liweifan
  * @Data: 2022/5/10 15:36
  */
-public class RefundBill implements Serializable {
+public class RefundBill extends Base {
     /***
      * 三方支付流水号
      * @author liweifan
      * @updateTime 2022/3/31 11:00
      */
-    private String paymentId;
-    /***
-     * 支付渠道
-     * @author liweifan
-     * @updateTime 2022/3/31 11:01
-     */
-    private PayChannelEnum payChannel;
+    private String id;
     /***
      * 退款订单号
      * @author liweifan
@@ -47,20 +41,16 @@ public class RefundBill implements Serializable {
      */
     private String reason;
 
-    public String getPaymentId() {
-        return paymentId;
-    }
-
-    public void setPaymentId(String paymentId) {
-        this.paymentId = paymentId;
+    public RefundBill(OpenEnum openType, PayChannelEnum payChannel){
+        super(openType,payChannel);
     }
 
-    public PayChannelEnum getPayChannel() {
-        return payChannel;
+    public String getId() {
+        return id;
     }
 
-    public void setPayChannel(PayChannelEnum payChannel) {
-        this.payChannel = payChannel;
+    public void setId(String id) {
+        this.id = id;
     }
 
     public String getRefundNo() {

+ 0 - 0
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/dao/SysConfigPaymentDao.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/dao/SysConfigPaymentDao.java


+ 0 - 0
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/entity/SysConfigPayment.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/entity/SysConfigPayment.java


+ 60 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/PaymentClient.java

@@ -0,0 +1,60 @@
+package com.yonge.toolset.payment.core.service;
+
+import com.yonge.toolset.base.result.BaseResult;
+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 java.util.Map;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/10 15:00
+ */
+public interface PaymentClient {
+    /***
+     * 统一获取授权
+     * @author liweifan
+     * @param: openAuth
+     * @updateTime 2022/5/12 10:42
+     * @return: com.yonge.toolset.base.result.BaseResult<java.util.Map<java.lang.String,java.lang.Object>>
+     */
+    BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth);
+    /***
+     * 统一下单接口
+     * @author liweifan
+     * @param: product 订单对象
+     * @updateTime 2022/3/4 15:12
+     * @return: com.daya.payment.model.AbstractRS
+     */
+    BaseResult<Payment> executePayment(Payment payment);
+
+    /***
+     * 统一下单接口
+     * @author liweifan
+     * @param: product 订单对象
+     * @updateTime 2022/3/4 15:12
+     * @return: com.daya.payment.model.AbstractRS
+     */
+    BaseResult<Payment> queryPayment(Payment payment);
+
+    /***
+     * 统一关单接口
+     * @author liweifan
+     * @param: closePayment
+     * @updateTime 2022/5/10 15:34
+     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.base.model.res.ClosePaymentRes>
+     */
+    BaseResult<ClosePayment> closePayment(ClosePayment closePayment);
+
+    /***
+     * 统一退款接口
+     * @author liweifan
+     * @param: closePayment
+     * @updateTime 2022/5/10 15:34
+     * @return: com.yonge.toolset.base.result.BaseResult<com.yonge.toolset.payment.base.model.res.ClosePaymentRes>
+     */
+    BaseResult<RefundBill> refundPayment(RefundBill refundBill);
+
+}

+ 2 - 2
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/service/SysConfigPaymentService.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/SysConfigPaymentService.java

@@ -2,7 +2,7 @@ package com.yonge.toolset.payment.core.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.toolset.payment.core.entity.SysConfigPayment;
-import com.yonge.toolset.payment.core.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
 
 /**
  * 支付服务配置参数 服务类
@@ -18,5 +18,5 @@ public interface SysConfigPaymentService extends IService<SysConfigPayment>  {
 	 * @updateTime 2022/5/10 22:55
 	 * @return: com.yonge.toolset.payment.core.entity.SysConfigPayment
 	 */
-	SysConfigPayment getPaymentConfig(OpenEnum openType,String paramName);
+	SysConfigPayment getPaymentConfig(OpenEnum openType, String paramName);
 }

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

@@ -0,0 +1,45 @@
+package com.yonge.toolset.payment.core.service.impl;
+
+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.util.PaywayUtil;
+import com.yonge.toolset.payment.core.service.PaymentClient;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/5/11 15:40
+ */
+@Service
+public class PaymentClientImpl implements PaymentClient {
+    @Override
+    public BaseResult<Map<String, Object>> getOpenAuthMsg(OpenAuth openAuth) {
+        return PaywayUtil.getRealTemplate(openAuth.getOpenType()).getOpenAuthMsg(openAuth);
+    }
+
+    @Override
+    public BaseResult<Payment> executePayment(Payment payment) {
+        return PaywayUtil.getRealTemplate(payment.getOpenType()).executePayment(payment);
+    }
+
+    @Override
+    public BaseResult<Payment> queryPayment(Payment payment) {
+        return PaywayUtil.getRealTemplate(payment.getOpenType()).queryPayment(payment);
+    }
+
+    @Override
+    public BaseResult<ClosePayment> closePayment(ClosePayment closePayment) {
+        return PaywayUtil.getRealTemplate(closePayment.getOpenType()).closePayment(closePayment);
+    }
+
+    @Override
+    public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
+        return PaywayUtil.getRealTemplate(refundBill.getOpenType()).refundPayment(refundBill);
+    }
+}

+ 1 - 1
toolset/toolset-payment/payment-core/src/main/java/com/yonge/toolset/payment/core/service/impl/SysConfigPaymentServiceImpl.java → toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/service/impl/SysConfigPaymentServiceImpl.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.toolset.payment.core.dao.SysConfigPaymentDao;
 import com.yonge.toolset.payment.core.entity.SysConfigPayment;
-import com.yonge.toolset.payment.core.enums.OpenEnum;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
 import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.redisson.api.RedissonClient;

+ 31 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/core/util/PaywayUtil.java

@@ -0,0 +1,31 @@
+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;
+
+/***
+ *
+ * @author liweifan
+ * @updateTime 2022/5/11 16:04
+ */
+public class PaywayUtil {
+    /***
+     * 获取真实的支付方式
+     * @author liweifan
+     * @param: openType
+     * @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)){
+            //汇付
+            return (PaymentTemplate) SpringBeansUtil.getBean("adapayTemplate");
+        }
+        throw new BizException("未找到的服务提供方");
+    }
+}

+ 75 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/util/SpringBeansUtil.java

@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
+ * <p>
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.gnu.org/licenses/lgpl.html
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yonge.toolset.payment.util;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * @description: Spring 框架下, 获取Beans静态函数方法。
+ * @Author terrfly
+ * @Date 2019/12/31 13:57
+ */
+@Component
+public class SpringBeansUtil implements ApplicationContextAware {
+
+    private static ApplicationContext applicationContext = null;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        if(SpringBeansUtil.applicationContext == null){
+            SpringBeansUtil.applicationContext  = applicationContext;
+        }
+    }
+
+    /** 获取applicationContext */
+    public static ApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+     /** 通过name获取 Bean. */
+    public static Object getBean(String name){
+        String[] beanDefinitionNames = getApplicationContext().getBeanDefinitionNames();
+        for (String beanDefinitionName : beanDefinitionNames) {
+            System.out.println(beanDefinitionName);
+        }
+        if(!getApplicationContext().containsBean(name)){
+            return null;
+        }
+        return getApplicationContext().getBean(name);
+
+    }
+
+     /** 通过class获取Bean. */
+    public static <T> T getBean(Class<T> clazz){
+        try {
+            return getApplicationContext().getBean(clazz);
+        } catch (BeansException e) {
+            return null;
+        }
+    }
+
+     /** 通过name,以及Clazz返回指定的Bean */
+    public static <T> T getBean(String name, Class<T> clazz){
+        if(!getApplicationContext().containsBean(name)){
+            return null;
+        }
+        return getApplicationContext().getBean(name, clazz);
+    }
+
+}

+ 12 - 6
toolset/utils/src/main/java/com/yonge/toolset/utils/string/StringUtil.java

@@ -14,7 +14,7 @@ import java.util.List;
  */
 public class StringUtil {
     public static boolean isEmpty(@Nullable Object str) {
-        if(null != str){
+        if (null != str) {
             String trim = str.toString().trim();
             return "".equals(trim);
         }
@@ -195,13 +195,11 @@ public class StringUtil {
     }
 
 
-
     public static List<Long> toLongList(String str) {
         return Arrays.asList(toLongArray(str));
     }
 
 
-
     /**
      * 字符串转 long,为空则返回默认值
      *
@@ -246,18 +244,26 @@ public class StringUtil {
         }
     }
 
-    public static String join(Collection<?> coll, String delim){
+    public static String get(Object o) {
+        if (isEmpty(o)) {
+            return StringPool.EMPTY;
+        } else {
+            return o.toString();
+        }
+    }
+
+    public static String join(Collection<?> coll, String delim) {
         return join(coll, delim, "", "");
     }
 
-    public static String join(Collection<?> coll, String delim, String prefix, String suffix){
+    public static String join(Collection<?> coll, String delim, String prefix, String suffix) {
         if (CollectionUtils.isEmpty(coll)) {
             return "";
         } else {
             StringBuilder sb = new StringBuilder();
             Iterator it = coll.iterator();
 
-            while(it.hasNext()) {
+            while (it.hasNext()) {
                 sb.append(prefix).append(it.next()).append(suffix);
                 if (it.hasNext()) {
                     sb.append(delim);