Commit 9bfde828 authored by wangp's avatar wangp

lakala

parent 1dd7c9e0
......@@ -34,8 +34,8 @@ WORKDIR /go/src/system_pay
COPY --from=0 /go/src/system_pay/server ./
# 拷贝配置文件到当前工作目录
# COPY --from=0 /go/src/system_pay/conf/dev ./conf
COPY --from=0 /go/src/system_pay/conf/prod ./conf
COPY --from=0 /go/src/system_pay/conf/dev ./conf
#COPY --from=0 /go/src/system_pay/conf/prod ./conf
# 拷贝国际化文件夹到当前工作目录
COPY --from=0 /go/src/system_pay/i18n ./i18n
......
......@@ -30,12 +30,12 @@ database:
# dbname: "test_food"
# redis
redis:
host: '39.96.85.45'
port: 6382
password: 'saas123456'
db: 0
pool_size: 200
#redis:
# host: '39.96.85.45'
# port: 6382
# password: 'saas123456'
# db: 0
# pool_size: 200
# mongo
......@@ -59,8 +59,8 @@ log:
# smscontent: '【谛宝医生】登录验证码为:%s'
# 支付
#payurl:
# domainname: 'http://tpay-v2.pet-dbc.cn:14880'
payurl:
domainname: 'http://tpay-v2.pet-dbc.cn:14880'
# checkorder: 'https://tpay.pet-dbc.cn/v1/pay/unified_order'
# orderstate: 'https://tpay.pet-dbc.cn/v1/pay/order_state/'
......
......@@ -32,12 +32,12 @@ database:
# dbname: "test_food"
# redis
redis:
host: '39.97.179.15'
port: 6382
password: 'saas123456'
db: 0
pool_size: 200
#redis:
# host: '39.97.179.15'
# port: 6382
# password: 'saas123456'
# db: 0
# pool_size: 200
# mongo
......@@ -62,8 +62,8 @@ sms:
smscontent: '【谛宝多多】登录验证码为:%s'
# 支付
#payurl:
# domainname: 'http://tpay-v2.pet-dbc.cn:14880'
payurl:
domainname: 'http://tpay-v2.pet-dbc.cn:14880'
# checkorder: 'https://pay.pet-dbc.cn/v1/pay/unified_order'
# orderstate: 'https://pay.pet-dbc.cn/v1/pay/order_state/'
......@@ -74,16 +74,18 @@ lakala:
version: '1.0'
# appid: 'OP00000836' #SAAS
# appid名称: '机构-羿律必康(天津)网络科技有限公司'
# serial_no: '0188b7d3d751'
# serial_no: '1686711293777'
# serial_no: '0188b7d3d751'
appid: 'OP00000859' #谛宝多多自营
appid名称: '商户-谛宝诚网络科技(北京)有限公司'
serial_no: '1689571622248'
# 'APPLET_APPID' =>'wx6ff40a576e2f4ca0', //谛宝多多小程序
# merchant_no=822100058221000599501K999501K9 ?
# appid: '' #必康自营
# appid名称: ''
# serial_no: ''
# serial_no: '1689571807509'
#1.聚合收银台(微信H5、支付宝H5)
merchant_no1: '8222900701107M5'
......@@ -94,8 +96,8 @@ lakala:
#3.聚合主扫(微信JSAPI、微信小程序)
merchant_no3: '8222900581201QB'
term_no3: 'D0027598'
sub_appid3: 'wxc3e4d1682da3053c'
user_id3: 'oLvoQ5deygCMj2WrDjPVPvV1L1t8'
sub_appid3: 'wxc3e4d1682da3053c' #子商户公众账号ID
user_id3: 'oLvoQ5deygCMj2WrDjPVPvV1L1t8' #用户标识(sub_openid)
#4.聚合被扫(扫码枪)
merchant_no4: '822290070111135' #结算商户号
term_no4: '29034705' #结算终端号
......
package pay
import (
"crypto"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"io/ioutil"
"system_pay/controller/base"
"system_pay/models"
"system_pay/repository/pay"
......@@ -108,54 +100,54 @@ func (l *PayController) WxNotice(c *gin.Context) {
// return errors.New("wangpei签名测试中。。。。。")
//}
func verySignByPublicKey(c *gin.Context) (bool, error) {
//publicKey string, data []byte, signData []byte
//String responseStr = IOUtils.toString(response.getEntity().getContent(), ENCODING);
appid := c.GetHeader("Lklapi-Appid")
lklapiSerial := c.GetHeader("Lklapi-Serial")
timestamp := c.GetHeader("Lklapi-Timestamp")
nonce := c.GetHeader("Lklapi-Nonce")
signature := c.GetHeader("Lklapi-Signature")
responseStr := c.GetHeader("")
data := appid + "\n" + lklapiSerial + "\n" + timestamp + "\n" + nonce + "\n" + responseStr + "\n";
fmt.Println("verySignByPublicKey start...")
fmt.Println(data)
fmt.Println("signature="+signature)
// 1、读取公钥文件,获取公钥字节
//path_cert := setting.Conf.Lakala.BkPathCert
publicKey, err := ioutil.ReadFile("./cert/dev/lkl-apigw-v2.cer")
if err != nil {
return false, err
}
// 2、解码私钥字节,生成加密对象
block, _ := pem.Decode(publicKey)
if block == nil {
return false, errors.New("私钥信息错误!")
}
// 3、解析DER编码的私钥,生成私钥对象
pubKey, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
return false, err
}
hashed := sha256.Sum256([]byte(data))
fmt.Println("pubKey.(*rsa.PublicKey): ", pubKey.(*rsa.PublicKey))
pubK := pubKey.(*rsa.PublicKey)
sig, err := base64.StdEncoding.DecodeString(signature)
err = rsa.VerifyPKCS1v15(pubK, crypto.SHA256, hashed[:], sig)
if err != nil {
return false, err
}
return true, nil
}
//func verySignByPublicKey(c *gin.Context) (bool, error) {
//
// //publicKey string, data []byte, signData []byte
// //String responseStr = IOUtils.toString(response.getEntity().getContent(), ENCODING);
// appid := c.GetHeader("Lklapi-Appid")
// lklapiSerial := c.GetHeader("Lklapi-Serial")
// timestamp := c.GetHeader("Lklapi-Timestamp")
// nonce := c.GetHeader("Lklapi-Nonce")
// signature := c.GetHeader("Lklapi-Signature")
// responseStr := c.GetHeader("")
//
// data := appid + "\n" + lklapiSerial + "\n" + timestamp + "\n" + nonce + "\n" + responseStr + "\n";
//fmt.Println("verySignByPublicKey start...")
//fmt.Println(data)
//fmt.Println("signature="+signature)
//
// // 1、读取公钥文件,获取公钥字节
// //path_cert := setting.Conf.Lakala.BkPathCert
// publicKey, err := ioutil.ReadFile("./cert/dev/lkl-apigw-v2.cer")
// if err != nil {
// return false, err
// }
// // 2、解码私钥字节,生成加密对象
// block, _ := pem.Decode(publicKey)
// if block == nil {
// return false, errors.New("私钥信息错误!")
// }
// // 3、解析DER编码的私钥,生成私钥对象
// pubKey, err := x509.ParsePKIXPublicKey(block.Bytes)
// if err != nil {
// return false, err
// }
//
// hashed := sha256.Sum256([]byte(data))
//
// fmt.Println("pubKey.(*rsa.PublicKey): ", pubKey.(*rsa.PublicKey))
//
// pubK := pubKey.(*rsa.PublicKey)
//
// sig, err := base64.StdEncoding.DecodeString(signature)
//
// err = rsa.VerifyPKCS1v15(pubK, crypto.SHA256, hashed[:], sig)
// if err != nil {
// return false, err
// }
//
// return true, nil
//}
//const (
// PEM_BEGIN = "-----BEGIN RSA PRIVATE KEY-----\n"
......
......@@ -9,7 +9,6 @@ import (
"os/exec"
_ "system_pay/docs"
logger "system_pay/pkg/logging"
"system_pay/redis"
routers "system_pay/router"
"system_pay/setting"
)
......@@ -50,13 +49,13 @@ func main() {
}
// redis
if err := redis.Init(setting.Conf.Redis); err != nil {
panic("init redis failed, new_error:"+ err.Error())
//fmt.Printf("init redis failed, new_error:%v\n", new_error)
//return
}
//if err := redis.Init(setting.Conf.Redis); err != nil {
// panic("init redis failed, new_error:"+ err.Error())
// //fmt.Printf("init redis failed, new_error:%v\n", new_error)
// //return
//}
// 关闭项目时候关闭redis连接
defer redis.Close()
//defer redis.Close()
// mongo
//MongoDB, err := mongo.ConnectToMongoDB()
......
package redis
import (
"fmt"
"github.com/go-redis/redis"
"system_pay/setting"
)
var (
Redisclient *redis.Client
Nil = redis.Nil
)
// Init 初始化连接
func Init(cfg *setting.RedisConfig) (err error) {
Redisclient = redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
Password: cfg.Password, // no password set
DB: cfg.DB, // use default DB
PoolSize: cfg.PoolSize,
MinIdleConns: cfg.MinIdleConns,
})
_, err = Redisclient.Ping().Result()
if err != nil {
return err
}
return err
}
func Close() {
_ = Redisclient.Close()
}
//
//import (
// "fmt"
// "github.com/go-redis/redis"
// "system_pay/setting"
//)
//
//var (
// Redisclient *redis.Client
// Nil = redis.Nil
//)
//
//// Init 初始化连接
//func Init(cfg *setting.RedisConfig) (err error) {
//
// Redisclient = redis.NewClient(&redis.Options{
// Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
// Password: cfg.Password, // no password set
// DB: cfg.DB, // use default DB
// PoolSize: cfg.PoolSize,
// MinIdleConns: cfg.MinIdleConns,
// })
//
//
// _, err = Redisclient.Ping().Result()
// if err != nil {
// return err
// }
// return err
//}
//
//func Close() {
// _ = Redisclient.Close()
//}
......@@ -15,7 +15,7 @@ type Config struct {
ServerSetting *Server `mapstructure:"server"`
AppSetting *App `mapstructure:"app"`
DatabaseSetting *Database `mapstructure:"database"`
Redis *RedisConfig `mapstructure:"redis"`
//Redis *RedisConfig `mapstructure:"redis"`
LogSetting *Log `mapstructure:"log"`
Sms *SmsInternationalConfig `mapstructure:"sms"`
UploadImage *UploadImage `mapstructure:"uploadimage"`
......@@ -75,14 +75,14 @@ type Database struct {
}
// RedisConfig redis
type RedisConfig struct {
Host string `mapstructure:"host"`
Password string `mapstructure:"password"`
Port int `mapstructure:"port"`
DB int `mapstructure:"db"`
PoolSize int `mapstructure:"pool_size"`
MinIdleConns int `mapstructure:"min_idle_conns"`
}
//type RedisConfig struct {
// Host string `mapstructure:"host"`
// Password string `mapstructure:"password"`
// Port int `mapstructure:"port"`
// DB int `mapstructure:"db"`
// PoolSize int `mapstructure:"pool_size"`
// MinIdleConns int `mapstructure:"min_idle_conns"`
//}
// MongoConfig mongo设置
//type MongoConfig struct {
......@@ -185,7 +185,7 @@ type Esign struct {
// Init 支持热修改的viper设置
func Init() error {
viper.SetConfigFile("conf/config.yaml") // 指定配置文件路径
viper.SetConfigFile("conf/dev/config.yaml") // 指定配置文件路径
err := viper.ReadInConfig() // 读取配置信息
if err != nil { // 读取配置信息失败
fmt.Printf("viper.ReadInConfig failed, new_error:%v\n", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment