animeic 1 年之前
父节点
当前提交
0c2d89ad97
共有 6 个文件被更改,包括 1 次插入197 次删除
  1. 0 25
      pay/app.yaml
  2. 0 65
      pay/assettest.log
  3. 0 27
      pay/conf/app.go
  4. 1 2
      pay/db/model/order.go
  5. 0 68
      pay/pay/pay.go
  6. 0 10
      pay/utils/getPayConfig.go

+ 0 - 25
pay/app.yaml

@@ -53,28 +53,3 @@ single:
       notifyUrl: https://www.3dqueen.cloud/pay/v1/pay/single/wechat/callback
       # notifyUrl:  https://api.afina.studio/pay/single/wechat/callback
 
-multi:
-  - name: sku3d
-    aliPay:
-      appId: 2021003151673020
-      sellerId: 2088441503441284
-      appAuthToken: 202209BB1037f4e0bb70436bb9b31b5d39916X28
-      privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCLIhRJk1CtYC3MUcUZxBa1zayXzPF+1HMKRyYnYuGKNSjU2/xd/mteNyO2ABsRgO2Uy8/sDH5oo0BSogFZmPieQf6QMlI9DkP7iofBDDvUneySylGRvEZUl2aae3eqPTSab/tG/DYGooPwB2+JyPnsWgvwXLt5WhBG8RDXe87qpODJBQYBpop4xo1ZV5BpDZCOktKazd6ni11kVmrxjOWW/Knf2B4BNrMxUhnw6mktRw4Pi1mZB2J/Ebk6tE/OpB/Ni1NSkmauusx9+cVfR9XOswMX4vTDEBwDMsTZZoSoGbUNbOTwYJkpyl+yIZsah0LFQGqnrUOcXZ/sgfE9n09bAgMBAAECggEAIW4v17no4a/BcV2YcWd3WXmw5cydni7n8WlFFqOgs7ewNu0gx2jxXXL8Rqfh2SPUcjNCo2IhIX1QYEqC7odd/ZC33OfqcLczyIXxtoX8/kpv5JluXgkSERNL2QSfrS0FrbIIe3bweEmmUA9JUp8SxiKgycFOXoswbAtSU6RxBFn8u6h7H1mwoo3THihRV/CKXI6ItGiD4t4u6nHEItmikAK5C560+GGaGavREhF5NUsv3xg2YHCI9q3wykI9mIulc3L0auPEUnpIvUWBFtPY6E5tCXAI4K8UUwPYYuotDlgJBVfD0C8kaXnWQnoaTu/70PAMRxEhx6/4okza0Cw1OQKBgQDICwTG7Q84+srvx9r7IxZbetQ4V+MuQZl3cfhwlfuRTUm0R7YUQNAf7gYUbveLV1EUWoKZqhtWObmmh/tOA7Kv5KRbB/ihbDgDNeZ4vMlcrxFsHgvGlX3tlQ9TEl3QMEnJ69FyhW3kQLjbOMMbyexcfc1kSwffyhC2u7dEQp6oVwKBgQCyDVT7VwlpIDy20NmAFg7XF+yfQNUP95+TcrzxOjppiqhb3KTuLZs5W1vYBa/mMhl2P3pc2iWfuA4xfFvKllTRD3lAzOoPjPVYpMDBoaZS0cVNCoC8h4nPEJOHxvW3mOCoRq1DHEwP5CN0DKLQIMnOH1Q/KYb1jYEsEVe0Mrs+nQKBgECK1ZK9P9EZkcqFiBDJRFhlq/011hXBkptoSUlCCvXZovMoxAWK19vFd262UuZBWOahQUwFB2btnwmtDBciuE9qDOFWFBE5EmVuyZqhBrMBxTRGCXScHRI/qr8ZyOz394bPsDcr98XSYBJTIRhhMQKykEdQsgyxbG0Y6ct7VydnAoGABQ8H6RQx+kCmOPN6Gn+F8GqHmIa5BvkcGY5a++eRnUoJOoLsVLALBvgnhd2zf7DQtGFdUqIIC5+pF5LW8MyQoFf2M/ced06j8d7MczPqi9PV7ThtK+4V5kIsTuFCPfMj/uPzLELzjkgHEdcCETO9SBPvytOdOADLOLtNaJtAYqkCgYEAh0cBXQO1T3y3TyQZlqEvD3k1LGL66Mio5xVlFlqLqbnB9XEX0id8+5/K0JMAgCMPdTb8U23iXYtQSRUEJi97IAFGXZH9MWpKfNsrlWQzeQltiJHzXSZH/wBn+64f7ZmNfEElKqYnuOukCuyVz8BuvFYoJ8/5JC6DncxkbhQtkeg=
-      isProd: true
-      returnUrl: https://www.3dqueen.cn/comm/v1/pay/multi/alipay/callback
-      notifyUrl: https://www.3dqueen.cn/comm/v1/pay/multi/alipay/callback
-      # returnUrl: https://api.animeii.tech/pay/multi/alipay/callback
-      # notifyUrl: https://api.animeii.tech/pay/multi/alipay/callback
-      appCertPath: ./crt/multi/alipay/appCertPublicKey.crt
-      aliPayRootCertPath: ./crt/multi/alipay/alipayRootCert.crt
-      aliPayPublicCertPath: ./crt/multi/alipay/alipayCertPublicKey_RSA2.crt
-
-    wechatPay:
-      appId: wxa249dae36c8c9321
-      mchId: 1627685161
-      subMchid: 1627875357
-      serialNo: 42E8289D430D051F2F6608E9480BB7F1BB3DC5F7
-      apiV3Key: BSNDcbbL5r122gEdoCSd9tGNIPNvjSxx
-      privateKey: ./crt/multi/wechat/apiclient_key.pem
-      notifyUrl: https://www.3dqueen.cn/comm/v1/pay/multi/wechat/callback
-      # notifyUrl: https://api.animeii.tech/pay/multi/wechat/callback

+ 0 - 65
pay/assettest.log

@@ -1,65 +0,0 @@
-{"level":"info","timestamp":"2023-07-04 15:11:52","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-04 15:14:01","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-04 16:16:31","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 10:09:06","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 10:10:19","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 10:16:04","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-05 10:16:06","message":"[invalid character 'ï' after object key:value pair]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 10:55:53","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 10:56:10","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 11:00:29","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 11:01:21","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 11:01:57","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 11:02:15","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-05 11:35:31","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 14:58:22","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:09:43","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:15:54","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:44:16","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:47:13","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:48:21","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:49:26","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 15:52:34","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:31:42","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:33:08","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:39:33","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:40:36","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:41:23","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:42:05","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:45:17","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:51:29","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:51:56","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:52:57","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:53:33","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 16:55:24","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 17:05:54","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 17:07:18","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 17:18:02","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-06 17:21:19","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 17:30:09","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-06 17:35:37","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-06 17:48:22","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-07 10:00:12","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-07 14:21:10","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-07 14:36:21","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-07 14:47:56","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-07 15:30:44","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-10 16:41:37","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 10:48:53","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-18 11:01:39","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
-{"level":"debug","timestamp":"2023-07-18 11:20:23","message":"wxRsp: &wechat.Native{CodeUrl:\"weixin://wxpay/bizpayurl?pr=qqN9f8Kzz\"}","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 11:27:59","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 11:30:52","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-18 11:36:19","message":"[amount: 2]","service_name":"assettest"}
-{"level":"debug","timestamp":"2023-07-18 11:36:20","message":"wxRsp: &wechat.Native{CodeUrl:\"weixin://wxpay/bizpayurl?pr=5fEnEK0zz\"}","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-18 14:15:43","message":"[amount: 2]","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-18 14:18:56","message":"[amount: 180]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 14:22:13","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 14:31:53","message":"[amount: 36]","service_name":"assettest"}
-{"level":"debug","timestamp":"2023-07-18 14:31:54","message":"wxRsp: &wechat.Native{CodeUrl:\"weixin://wxpay/bizpayurl?pr=EOlEpMEzz\"}","service_name":"assettest"}
-{"level":"error","timestamp":"2023-07-18 14:33:50","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 15:24:29","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 15:37:03","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 15:43:06","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 16:08:34","message":"[初始化支付客户端]","service_name":"assettest"}
-{"level":"info","timestamp":"2023-07-18 17:22:51","message":"[初始化支付客户端]","service_name":"assettest"}

+ 0 - 27
pay/conf/app.go

@@ -34,32 +34,6 @@ type SinglePayParams struct {
 	}
 }
 
-type MultiPayParam struct {
-	Name   string
-	AliPay struct {
-		AppId                string `json:"appId"`
-		SellerId             string `json:"sellerId"`
-		AppAuthToken         string `json:"appAuthToken"`
-		PrivateKey           string `json:"privateKey"`
-		IsProd               bool   `json:"isProd"`
-		ReturnUrl            string `json:"returnUrl"`
-		NotifyUrl            string `json:"notifyUrl"`
-		AppCertPath          string `json:"appCertPath"`
-		AliPayRootCertPath   string `json:"aliPayRootCertPath"`
-		AliPayPublicCertPath string `json:"aliPayPublicCertPath"`
-	}
-
-	WechatPay struct {
-		AppId      string `json:"appId"`
-		MchId      string `json:"mchId"`
-		SubMchId   string `json:"subMchid"`
-		SerialNo   string `json:"serialNo"`
-		ApiV3Key   string `json:"apiV3Key"`
-		PrivateKey string `json:"privateKey"`
-		NotifyUrl  string `json:"notifyUrl"`
-	}
-}
-
 type AppConf struct {
 	Port     int32
 	Name     string
@@ -95,7 +69,6 @@ type AppConf struct {
 	}
 
 	Single []*SinglePayParams //企业收款
-	Multi  []*MultiPayParam   //替其他企业收款
 }
 
 func LoadConfFile(filepath string) (*AppConf, error) {

+ 1 - 2
pay/db/model/order.go

@@ -12,8 +12,7 @@ type OrderMsg struct {
 	Id   string `bson:"_id,omitempty" json:"_id,omitempty"`
 	Name string `bson:"name,omitempty" json:"name,omitempty"`
 	// 金额
-	Amount *int   `bson:"amount,omitempty" json:"amount,omitempty"`
-	SubId  string `bson:"subId,omitempty" json:"subId,omitempty"`
+	Amount *int `bson:"amount,omitempty" json:"amount,omitempty"`
 	// 支付方式 0支付宝 1微信
 	PayMode *int `bson:"payMode,omitempty" json:"payMode,omitempty"`
 	// 订单超时,通知微信支付宝关闭订单

+ 0 - 68
pay/pay/pay.go

@@ -14,21 +14,15 @@ import (
 type Pay struct {
 	SingleAlipayClient    *alipay.Client
 	SingleWechatpayClient *wechat.ClientV3
-	MultiAlipayClient     *alipay.Client
-	MultiWechatpayClient  *wechat.ClientV3
 }
 
 var SingleAlipayClient *alipay.Client
 var SingleWechatpayClient *wechat.ClientV3
-var MultiAlipayClient *alipay.Client
-var MultiWechatpayClient *wechat.ClientV3
 
 func NewPay(conf *conf.AppConf) *Pay {
 	return &Pay{
 		NewSingleAlipay(conf),
 		NewSingleWechatPay(conf),
-		NewMultiAlipay(conf),
-		NewMultiWechatPay(conf),
 	}
 }
 
@@ -97,68 +91,6 @@ func NewSingleWechatPay(conf *conf.AppConf) *wechat.ClientV3 {
 	return SingleWechatpayClient
 }
 
-func NewMultiAlipay(conf *conf.AppConf) *alipay.Client {
-	// 初始化支付宝客户端
-	//    appid:应用ID
-	//    privateKey:应用私钥,支持PKCS1和PKCS8
-	//    isProd:是否是正式环境
-	var err error
-	multiCnf := utils.GetMultiPayConfig(conf)
-	MultiAlipayClient, err = alipay.NewClient(multiCnf.AliPay.AppId, multiCnf.AliPay.PrivateKey, multiCnf.AliPay.IsProd)
-	if err != nil {
-		log.Errorf("支付宝客户端创建失败%v", err)
-	}
-	// 打开Debug开关,输出日志,默认关闭
-	MultiAlipayClient.DebugSwitch = gopay.DebugOn
-
-	// 设置支付宝请求 公共参数
-	//    注意:具体设置哪些参数,根据不同的方法而不同,此处列举出所有设置参数
-	MultiAlipayClient.SetLocation(alipay.LocationShanghai). // 设置时区,不设置或出错均为默认服务器时间
-								SetCharset(alipay.UTF8).                 // 设置字符编码,不设置默认 utf-8
-								SetSignType(alipay.RSA2).                // 设置签名类型,不设置默认 RSA2
-								SetReturnUrl(multiCnf.AliPay.ReturnUrl). // 设置返回URL
-								SetNotifyUrl(multiCnf.AliPay.NotifyUrl)  // 设置异步通知URL
-		// SetAppAuthToken(multiCnf.AliPay.AppAuthToken)
-
-	// 自动同步验签(只支持证书模式)
-	// 传入 alipayCertPublicKey_RSA2.crt 内容
-	fileData, err := ioutil.ReadFile(multiCnf.AliPay.AliPayPublicCertPath)
-	if err != nil {
-		log.Errorf("自动验签错误%v", err)
-	}
-	MultiAlipayClient.AutoVerifySign(fileData)
-	// 公钥证书模式,需要传入证书,以下两种方式二选一
-	// 证书路径
-	err = MultiAlipayClient.SetCertSnByPath(multiCnf.AliPay.AppCertPath, multiCnf.AliPay.AliPayRootCertPath, multiCnf.AliPay.AliPayPublicCertPath)
-	if err != nil {
-		log.Errorf("证书导入错误%v", err)
-	}
-	return MultiAlipayClient
-}
-
-func NewMultiWechatPay(conf *conf.AppConf) *wechat.ClientV3 {
-	multiCnf := utils.GetMultiPayConfig(conf)
-	PrivateKey, _ := ioutil.ReadFile(multiCnf.WechatPay.PrivateKey)
-	var err error
-	MultiWechatpayClient, err = wechat.NewClientV3(multiCnf.WechatPay.MchId, multiCnf.WechatPay.SerialNo, multiCnf.WechatPay.ApiV3Key, string(PrivateKey))
-	if err != nil {
-		log.Error(err)
-	}
-
-	// 设置微信平台API证书和序列号(如开启自动验签,请忽略此步骤)
-	//client.SetPlatformCert([]byte(""), "")
-
-	// 启用自动同步返回验签,并定时更新微信平台API证书(开启自动验签时,无需单独设置微信平台API证书和序列号)
-	err = MultiWechatpayClient.AutoVerifySign()
-	if err != nil {
-		log.Error(err)
-	}
-
-	// 打开Debug开关,输出日志,默认是关闭的
-	MultiWechatpayClient.DebugSwitch = gopay.DebugOn
-	return MultiWechatpayClient
-}
-
 func (*Pay) Connect() {
 	log.Info("初始化支付客户端")
 }

+ 0 - 10
pay/utils/getPayConfig.go

@@ -11,13 +11,3 @@ func GetSinglePayConfig(app *conf.AppConf) (param *conf.SinglePayParams) {
 	}
 	return
 }
-
-func GetMultiPayConfig(app *conf.AppConf) (param *conf.MultiPayParam) {
-	multiConfig := app.Multi
-	for _, mc := range multiConfig {
-		if app.ShopName == mc.Name {
-			return mc
-		}
-	}
-	return
-}