Merge branch 'dev/dev1.0' into feature_413_cjh
This commit is contained in:
		
						commit
						a7cf191437
					
				| 
						 | 
				
			
			@ -5,9 +5,16 @@ import (
 | 
			
		|||
	"PaymentCenter/app/data"
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/ordersmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderthirdpaylogmodel"
 | 
			
		||||
	"PaymentCenter/app/third/paymentService"
 | 
			
		||||
	"PaymentCenter/app/third/paymentService/payCommon"
 | 
			
		||||
	"PaymentCenter/app/utils"
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"github.com/qit-team/snow-core/command"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +32,7 @@ func closeOrder() {
 | 
			
		|||
	repo := data.NewOrderRepo(ordersmodel.GetInstance().GetDb())
 | 
			
		||||
	// 拼接条件
 | 
			
		||||
	cond := builder.NewCond()
 | 
			
		||||
	cond = cond.And(builder.Eq{"status": common.ORDER_STATUS_PAYING}, builder.Lt{"create_time": time.Now().Add(-time.Hour)})
 | 
			
		||||
	cond = cond.And(builder.Eq{"status": common.ORDER_STATUS_PAYING}, builder.Lt{"create_time": time.Now().Add(-time.Second * time.Duration(config.GetConf().CronConfig.CloseOrderTime))})
 | 
			
		||||
 | 
			
		||||
	order := make([]ordersmodel.Orders, 0)
 | 
			
		||||
	total, err := repo.OrderList(cond, entities.PageRequest{}, &order)
 | 
			
		||||
| 
						 | 
				
			
			@ -48,31 +55,119 @@ func closeOrder() {
 | 
			
		|||
	utils.Log(nil, "关闭订单,修改订单状态成功", "count="+strconv.Itoa(len(order)))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 定时查询支付中的订单, 主动查询订单支付状态
 | 
			
		||||
// 主动查询订单支付状态
 | 
			
		||||
func queryOrder() {
 | 
			
		||||
	var now = time.Now().Format(time.DateTime)
 | 
			
		||||
	utils.Log(nil, "主动查询订单支付状态", now)
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	// 查询未支付的订单
 | 
			
		||||
	repo := data.NewOrderRepo(ordersmodel.GetInstance().GetDb())
 | 
			
		||||
	// 拼接条件
 | 
			
		||||
	cond := builder.NewCond()
 | 
			
		||||
	cond = cond.And(builder.Eq{"status": common.ORDER_STATUS_PAYING}, builder.Gt{"create_time": time.Now().Add(-time.Second)})
 | 
			
		||||
	order := make([]ordersmodel.Orders, 0)
 | 
			
		||||
	total, err := repo.OrderList(cond, entities.PageRequest{}, &order)
 | 
			
		||||
	config.GetConf()
 | 
			
		||||
	cond = cond.And(builder.Eq{"status": common.ORDER_STATUS_PAYING}, builder.Gt{"orders.create_time": time.Now().Add(-time.Second * time.Duration(config.GetConf().CronConfig.QueryOrderTime))})
 | 
			
		||||
	order := make([]ordersmodel.OrdersLeftPayChannelList, 0)
 | 
			
		||||
	err := repo.OrdersLeftPayChannelList(cond, entities.PageRequest{}, &order)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		utils.Log(nil, "主动查询订单支付状态,查询未付中订单失败", err)
 | 
			
		||||
		return
 | 
			
		||||
	} else if total > 0 {
 | 
			
		||||
		// 发起查询上游支付
 | 
			
		||||
		for _, v := range order {
 | 
			
		||||
			go func(order ordersmodel.Orders) {
 | 
			
		||||
				// 发起查询
 | 
			
		||||
				utils.Log(nil, "主动查询订单支付状态,发起查询", order.Id)
 | 
			
		||||
				// 解析上游结果
 | 
			
		||||
	} else if len(order) > 0 {
 | 
			
		||||
		ch := make(chan struct{}, config.GetConf().CronConfig.ConcurrentNumber)
 | 
			
		||||
		wg := sync.WaitGroup{}
 | 
			
		||||
 | 
			
		||||
				// 修改订单状态
 | 
			
		||||
			}(v)
 | 
			
		||||
		for index := range order {
 | 
			
		||||
			ch <- struct{}{}
 | 
			
		||||
			wg.Add(1)
 | 
			
		||||
			orderInfo := order[index]
 | 
			
		||||
 | 
			
		||||
			// 发起查询上游支付
 | 
			
		||||
			go func(orderInfo ordersmodel.OrdersLeftPayChannelList) {
 | 
			
		||||
				defer func() {
 | 
			
		||||
					<-ch
 | 
			
		||||
					wg.Done()
 | 
			
		||||
				}()
 | 
			
		||||
 | 
			
		||||
				query := paymentService.PayOrderQueryRequest{
 | 
			
		||||
					OrderId: orderInfo.Id,
 | 
			
		||||
				}
 | 
			
		||||
				switch orderInfo.ChannelType {
 | 
			
		||||
				case common.PAY_CHANNEL_WECHAT_H5, common.PAY_CHANNEL_WECHAT_JSAPI, common.PAY_CHANNEL_WECHAT_NATIVE, common.PAY_CHANNEL_WECHAT_APP, common.PAY_CHANNEL_WECHAT_MINI:
 | 
			
		||||
					_ = json.Unmarshal([]byte(orderInfo.ExtJson), &query.Wx)
 | 
			
		||||
					query.PayChannel = payCommon.PAY_CHANNLE_TYPE_WECHAT
 | 
			
		||||
				case common.PAY_CHANNEL_ALIPAY_JSAPI, common.PAY_CHANNEL_ALIPAY_WEB, common.PAY_CHANNEL_ALIPAY_MINI:
 | 
			
		||||
					query.PayChannel = payCommon.PAY_CHANNLE_TYPE_ZFB
 | 
			
		||||
					_ = json.Unmarshal([]byte(orderInfo.ExtJson), &query.Ali)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// 发起查询
 | 
			
		||||
				result := paymentService.PayOrderQuery(ctx, query)
 | 
			
		||||
				utils.Log(nil, "主动查询订单支付状态,上游返回数据", result)
 | 
			
		||||
				// 查询成功,校验状态
 | 
			
		||||
				var status int
 | 
			
		||||
				if result.Code == payCommon.PAY_SUCCESS_CODE {
 | 
			
		||||
					switch result.Result.TradeState {
 | 
			
		||||
					case "SUCCESS":
 | 
			
		||||
						// 成功
 | 
			
		||||
						status = common.ORDER_STATUS_PAYED
 | 
			
		||||
					case "REFUND":
 | 
			
		||||
						// 退款
 | 
			
		||||
 | 
			
		||||
					case "NOTPAY":
 | 
			
		||||
						// 未支付
 | 
			
		||||
						return
 | 
			
		||||
					case "CLOSED":
 | 
			
		||||
						// 关闭
 | 
			
		||||
						status = common.ORDER_STATUS_CLOSE
 | 
			
		||||
 | 
			
		||||
					}
 | 
			
		||||
					// 回调通知下游	todo
 | 
			
		||||
 | 
			
		||||
					// 更新订单状态 todo
 | 
			
		||||
					orderUpdate := ordersmodel.Orders{
 | 
			
		||||
						Id:     orderInfo.Id,
 | 
			
		||||
						Status: status,
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					session := ordersmodel.GetInstance().GetDb().NewSession()
 | 
			
		||||
					if err = session.Begin(); err != nil {
 | 
			
		||||
						utils.Log(nil, "主动查询订单支付状态,更新订单状态失败", err)
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					defer func() {
 | 
			
		||||
						if err != nil {
 | 
			
		||||
							session.Rollback()
 | 
			
		||||
						} else {
 | 
			
		||||
							err = session.Commit()
 | 
			
		||||
						}
 | 
			
		||||
					}()
 | 
			
		||||
					orderLogRepo := data.NewOrderThirdPayLogRepo(session)
 | 
			
		||||
					orderRepo := data.NewOrderRepo(session)
 | 
			
		||||
 | 
			
		||||
					conn := builder.NewCond()
 | 
			
		||||
					conn = conn.And(builder.Eq{"id": orderInfo.Id})
 | 
			
		||||
					_, err = orderRepo.OrderUpdate(&orderUpdate, conn)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						utils.Log(nil, "主动查询订单支付状态,更新订单状态失败", err)
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					// 写入日志
 | 
			
		||||
					log := orderthirdpaylogmodel.OrderThirdPayLog{
 | 
			
		||||
						OrderId:          orderInfo.Id,
 | 
			
		||||
						PayCallback:      "",
 | 
			
		||||
						Status:           0,
 | 
			
		||||
						MerchantParam:    "",
 | 
			
		||||
						MerchantCallback: "",
 | 
			
		||||
					}
 | 
			
		||||
					_, err = orderLogRepo.OrderThirdPayLogInsertOne(&log)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						utils.Log(nil, "主动查询订单支付状态,写入支付日志失败", err)
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
			}(orderInfo)
 | 
			
		||||
		}
 | 
			
		||||
		wg.Wait()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
package console
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/robfig/cron"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +11,7 @@ import (
 | 
			
		|||
 * @wiki https://godoc.org/github.com/robfig/cron
 | 
			
		||||
 */
 | 
			
		||||
func RegisterSchedule(c *cron.Cron) {
 | 
			
		||||
	fmt.Println(config.GetConf().CronConfig)
 | 
			
		||||
	//c.AddFunc("0 30 * * * *", test)
 | 
			
		||||
	//c.AddFunc("@hourly", test)
 | 
			
		||||
	//c.AddFunc("@every 10s", test)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
package common
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	TOKEN_PRE    = "player_token_"
 | 
			
		||||
	TOKEN_Admin  = "Admin_token_"
 | 
			
		||||
	ADMIN_V1     = "/pay/admin/api/v1"
 | 
			
		||||
	FRONT_API_V1 = "/v1"
 | 
			
		||||
	TOKEN_PRE   = "player_token_"
 | 
			
		||||
	TOKEN_Admin = "Admin_token_"
 | 
			
		||||
	ADMIN_V1    = "/pay/admin/api/v1"
 | 
			
		||||
	FRONT_V1    = "/api/v1"
 | 
			
		||||
 | 
			
		||||
	// 支付渠道枚举,1微信JSAPI,2微信H5,3微信app,4微信Native,5微信小程序,6支付宝网页&移动应用,7支付宝小程序,8支付宝JSAPI
 | 
			
		||||
	PAY_CHANNEL_UNKNOWN       = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ const (
 | 
			
		|||
	ADMIN_USER_NAME         = "User-Name"
 | 
			
		||||
	ADMIN_USER_INCLUDEUSERS = "Include-Users"
 | 
			
		||||
 | 
			
		||||
	// '订单状态,待支付、支付中、支付成功、支付失败、订单关闭',
 | 
			
		||||
	// '订单状态,1待支付、2支付中、3支付成功、4支付失败、5订单关闭',
 | 
			
		||||
	ORDER_STATUS_WAITPAY = 1
 | 
			
		||||
	ORDER_STATUS_PAYING  = 2
 | 
			
		||||
	ORDER_STATUS_PAYED   = 3
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,14 +19,21 @@ const (
 | 
			
		|||
	//系统错误
 | 
			
		||||
	SystemError = 500
 | 
			
		||||
 | 
			
		||||
	//请求超时
 | 
			
		||||
	RequestTimeOut = 600
 | 
			
		||||
 | 
			
		||||
	//未登录
 | 
			
		||||
	NotLogin = 1000
 | 
			
		||||
 | 
			
		||||
	// 商户
 | 
			
		||||
	MerchantNotFound = 1100
 | 
			
		||||
 | 
			
		||||
	AppNotFound = 1200
 | 
			
		||||
	// app
 | 
			
		||||
	AppNotFound   = 1200
 | 
			
		||||
	AppDisabled   = 1201
 | 
			
		||||
	AppIpNotAllow = 1202
 | 
			
		||||
 | 
			
		||||
	//渠道
 | 
			
		||||
	PayChannelNotFound = 1300
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -40,14 +47,16 @@ var MsgEN = map[int]string{
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
var MsgZH = map[int]string{
 | 
			
		||||
	Success:    "请求成功",
 | 
			
		||||
	ParamError: "参数错误",
 | 
			
		||||
	NotFound:   "数据不存在",
 | 
			
		||||
	NotAuth:    "未经授权",
 | 
			
		||||
	NotLogin:   "未登录",
 | 
			
		||||
 | 
			
		||||
	MerchantNotFound:   "商户不存在",
 | 
			
		||||
	AppNotFound:        "应用不存在",
 | 
			
		||||
	Success:          "请求成功",
 | 
			
		||||
	ParamError:       "参数错误",
 | 
			
		||||
	NotFound:         "数据不存在",
 | 
			
		||||
	NotAuth:          "未经授权",
 | 
			
		||||
	NotLogin:         "未登录",
 | 
			
		||||
	RequestTimeOut:   "请求超时",
 | 
			
		||||
	MerchantNotFound: "商户不存在",
 | 
			
		||||
	AppNotFound:      "app_id未找到",
 | 
			
		||||
	AppDisabled:      "app通道关闭",
 | 
			
		||||
	AppIpNotAllow:    "ip不在白名单内",
 | 
			
		||||
	PayChannelNotFound: "支付方式不存在",
 | 
			
		||||
}
 | 
			
		||||
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
package pojo
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	Rsa int32 = iota + 1
 | 
			
		||||
	Sm2
 | 
			
		||||
	Sm4
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
package pojo
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	STATUS_ENABLE   int32 = 1
 | 
			
		||||
	STATUS_DISABLED int32 = 2
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ package data
 | 
			
		|||
import (
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/appmodel"
 | 
			
		||||
	"database/sql"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
	"xorm.io/xorm"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +39,11 @@ func (m *AppRepo) AppUpdate(app *appmodel.App, conn builder.Cond, columns ...str
 | 
			
		|||
	return m.repo.Where(conn).MustCols(columns...).Update(app)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *AppRepo) AppGet(app *appmodel.App, conn builder.Cond) (bool, error) {
 | 
			
		||||
	return m.repo.Where(conn).Get(app)
 | 
			
		||||
func (m *AppRepo) AppFindOne(app *appmodel.App, conn builder.Cond, columns ...string) (*appmodel.App, error) {
 | 
			
		||||
	has, err := m.repo.Where(conn).Get(app)
 | 
			
		||||
	if !has {
 | 
			
		||||
		return nil, sql.ErrNoRows
 | 
			
		||||
	}
 | 
			
		||||
	return app, err
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
package data
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/orderlogmodel"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
	"xorm.io/xorm"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type OrderLogRepo struct {
 | 
			
		||||
	repo xorm.Interface
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewOrderLogRepo(repo xorm.Interface) *OrderLogRepo {
 | 
			
		||||
	return &OrderLogRepo{
 | 
			
		||||
		repo: repo,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderLogRepo) OrderLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderlogmodel.OrderLog) (int64, error) {
 | 
			
		||||
	repo := m.repo.Where(conn)
 | 
			
		||||
	if pageFilter.Page > 0 {
 | 
			
		||||
		repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
 | 
			
		||||
	}
 | 
			
		||||
	return repo.Desc("create_time").FindAndCount(orderLogList)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderLogRepo) OrderLogInsertOne(orderLog *orderlogmodel.OrderLog) (int64, error) {
 | 
			
		||||
	return m.repo.InsertOne(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderLogRepo) OrderLogDelete(orderLog *orderlogmodel.OrderLog, conn builder.Cond) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).Delete(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// columns 参数为要更新的字段
 | 
			
		||||
func (m *OrderLogRepo) OrderLogUpdate(orderLog *orderlogmodel.OrderLog, conn builder.Cond, columns ...string) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
package data
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/orderrequestlogmodel"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
	"xorm.io/xorm"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type OrderRequestLogRepo struct {
 | 
			
		||||
	repo xorm.Interface
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewOrderRequestLogRepo(repo xorm.Interface) *OrderRequestLogRepo {
 | 
			
		||||
	return &OrderRequestLogRepo{
 | 
			
		||||
		repo: repo,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderRequestLogRepo) OrderRequestLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderrequestlogmodel.OrderRequestLog) (int64, error) {
 | 
			
		||||
	repo := m.repo.Where(conn)
 | 
			
		||||
	if pageFilter.Page > 0 {
 | 
			
		||||
		repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
 | 
			
		||||
	}
 | 
			
		||||
	return repo.Desc("create_time").FindAndCount(orderLogList)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderRequestLogRepo) OrderRequestLogInsertOne(orderLog *orderrequestlogmodel.OrderRequestLog) (int64, error) {
 | 
			
		||||
	return m.repo.InsertOne(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderRequestLogRepo) OrderRequestLogDelete(orderLog *orderrequestlogmodel.OrderRequestLog, conn builder.Cond) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).Delete(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// columns 参数为要更新的字段
 | 
			
		||||
func (m *OrderRequestLogRepo) OrderRequestLogUpdate(orderLog *orderrequestlogmodel.OrderRequestLog, conn builder.Cond, columns ...string) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
package data
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/orderthirdpaylogmodel"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
	"xorm.io/xorm"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type OrderThirdPayLogRepo struct {
 | 
			
		||||
	repo xorm.Interface
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewOrderThirdPayLogRepo(repo xorm.Interface) *OrderThirdPayLogRepo {
 | 
			
		||||
	return &OrderThirdPayLogRepo{
 | 
			
		||||
		repo: repo,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderThirdPayLogRepo) OrderThirdPayLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderthirdpaylogmodel.OrderThirdPayLog) (int64, error) {
 | 
			
		||||
	repo := m.repo.Where(conn)
 | 
			
		||||
	if pageFilter.Page > 0 {
 | 
			
		||||
		repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
 | 
			
		||||
	}
 | 
			
		||||
	return repo.Desc("create_time").FindAndCount(orderLogList)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderThirdPayLogRepo) OrderThirdPayLogInsertOne(orderLog *orderthirdpaylogmodel.OrderThirdPayLog) (int64, error) {
 | 
			
		||||
	return m.repo.InsertOne(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderThirdPayLogRepo) OrderThirdPayLogDelete(orderLog *orderthirdpaylogmodel.OrderThirdPayLog, conn builder.Cond) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).Delete(orderLog)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// columns 参数为要更新的字段
 | 
			
		||||
func (m *OrderThirdPayLogRepo) OrderThirdPayLogUpdate(orderLog *orderthirdpaylogmodel.OrderThirdPayLog, conn builder.Cond, columns ...string) (int64, error) {
 | 
			
		||||
	return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -49,3 +49,13 @@ func (m *OrderRepo) OrdersBackendList(conn builder.Cond, pageFilter entities.Pag
 | 
			
		|||
		Join("left", "pay_channel", "pay_channel.id = orders.pay_id")
 | 
			
		||||
	return repo.Desc("create_time").FindAndCount(orderList)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *OrderRepo) OrdersLeftPayChannelList(conn builder.Cond, pageFilter entities.PageRequest, orderList *[]ordersmodel.OrdersLeftPayChannelList) error {
 | 
			
		||||
	repo := m.repo.Select(`orders.*,pay_channel.channel_type,pay_channel.app_id ,pay_channel.ext_json`).
 | 
			
		||||
		Where(conn)
 | 
			
		||||
	if pageFilter.Page > 0 {
 | 
			
		||||
		repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
 | 
			
		||||
	}
 | 
			
		||||
	repo = repo.Join("left", "pay_channel", "pay_channel.id = orders.pay_id")
 | 
			
		||||
	return repo.Find(orderList)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ import (
 | 
			
		|||
	"PaymentCenter/app/http/entities/backend"
 | 
			
		||||
	"PaymentCenter/app/models/appmodel"
 | 
			
		||||
	"PaymentCenter/app/services"
 | 
			
		||||
	"PaymentCenter/app/utils/sm2"
 | 
			
		||||
	"PaymentCenter/app/utils/encrypt/sm2"
 | 
			
		||||
	"github.com/ahmetb/go-linq/v3"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,8 +5,9 @@ import (
 | 
			
		|||
	"PaymentCenter/app/http/controllers"
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/http/entities/backend"
 | 
			
		||||
	"PaymentCenter/app/models/orderlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderrequestlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/ordersmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderthirdpaylogmodel"
 | 
			
		||||
	"PaymentCenter/app/services"
 | 
			
		||||
	"github.com/ahmetb/go-linq/v3"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
| 
						 | 
				
			
			@ -36,16 +37,22 @@ func OrderList(c *gin.Context) {
 | 
			
		|||
func OrderLogsList(c *gin.Context) {
 | 
			
		||||
	req, _ := controllers.GetRequest(c).(*backend.OrderLogsListRequest)
 | 
			
		||||
	req.SetDefault()
 | 
			
		||||
	orderLogList, total, code := services.OrderLogsList(*req)
 | 
			
		||||
	requestLog, thirdLog, code := services.OrderLogsList(*req)
 | 
			
		||||
 | 
			
		||||
	result := make([]backend.OrderLogResponse, 0, len(orderLogList))
 | 
			
		||||
	linq.From(orderLogList).SelectT(func(in orderlogmodel.OrderLog) (out backend.OrderLogResponse) {
 | 
			
		||||
	requestLogList := make([]backend.OrderRequestLogResponse, 0, len(requestLog))
 | 
			
		||||
	linq.From(requestLog).SelectT(func(in orderrequestlogmodel.OrderRequestLog) (out backend.OrderRequestLogResponse) {
 | 
			
		||||
		out.ResponseFromDb(in)
 | 
			
		||||
		return
 | 
			
		||||
	}).ToSlice(&result)
 | 
			
		||||
	data := entities.PageRsp{
 | 
			
		||||
		Total: total,
 | 
			
		||||
		Data:  result,
 | 
			
		||||
	}
 | 
			
		||||
	controllers.HandCodeRes(c, data, code)
 | 
			
		||||
	}).ToSlice(&requestLogList)
 | 
			
		||||
 | 
			
		||||
	thirdLogList := make([]backend.OrderThirdLogResponse, 0, len(thirdLog))
 | 
			
		||||
	linq.From(thirdLog).SelectT(func(in orderthirdpaylogmodel.OrderThirdPayLog) (out backend.OrderThirdLogResponse) {
 | 
			
		||||
		out.ResponseFromDb(in)
 | 
			
		||||
		return
 | 
			
		||||
	}).ToSlice(&thirdLogList)
 | 
			
		||||
 | 
			
		||||
	controllers.HandCodeRes(c, gin.H{
 | 
			
		||||
		"request_log_list": requestLogList,
 | 
			
		||||
		"third_log_list":   thirdLogList,
 | 
			
		||||
	}, code)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -230,3 +230,7 @@ func GetAdminUserIncludeUsers(c *gin.Context) string {
 | 
			
		|||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ErrWithCode(c *gin.Context, code int) {
 | 
			
		||||
	Error(c, code, errorcode.GetMsg(code, c.GetHeader("local")))
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +0,0 @@
 | 
			
		|||
package front
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/controllers"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func HelloHandler(c *gin.Context) {
 | 
			
		||||
	controllers.Success(c, "aaaa")
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -16,8 +16,8 @@ type AppResponse struct {
 | 
			
		|||
	MerchantId        int64  `json:"merchant_id"`
 | 
			
		||||
	AppName           string `json:"app_name"`
 | 
			
		||||
	AppRemark         string `json:"app_remark"`
 | 
			
		||||
	Status            int    `json:"status"`
 | 
			
		||||
	KeyType           int    `json:"key_type"`
 | 
			
		||||
	Status            int32  `json:"status"`
 | 
			
		||||
	KeyType           int32  `json:"key_type"`
 | 
			
		||||
	PublicKey         string `json:"public_key"`
 | 
			
		||||
	PrivateKey        string `json:"private_key"`
 | 
			
		||||
	MerchantPublicKey string `json:"merchant_public_key"`
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +45,8 @@ type AppCreateRequest struct {
 | 
			
		|||
	MerchantId        int64  `json:"merchant_id" validate:"required" label:"商户ID"`
 | 
			
		||||
	AppName           string `json:"app_name" validate:"required" label:"应用名称"`
 | 
			
		||||
	AppRemark         string `json:"app_remark" label:"应用备注"`
 | 
			
		||||
	Status            int    `json:"status" validate:"oneof=0 1 2" label:"应用状态"`
 | 
			
		||||
	KeyType           int    `json:"key_type" validate:"required" label:"应用密钥类型"`
 | 
			
		||||
	Status            int32  `json:"status" validate:"oneof=0 1 2" label:"应用状态"`
 | 
			
		||||
	KeyType           int32  `json:"key_type" validate:"required" label:"应用密钥类型"`
 | 
			
		||||
	PublicKey         string `json:"public_key" validate:"required" label:"应用公钥"`
 | 
			
		||||
	PrivateKey        string `json:"private_key" validate:"required" label:"应用私钥"`
 | 
			
		||||
	MerchantPublicKey string `json:"merchant_public_key"  label:"商户公钥"`
 | 
			
		||||
| 
						 | 
				
			
			@ -72,8 +72,8 @@ type AppUpdateRequest struct {
 | 
			
		|||
	Id                int64  `json:"id" validate:"required" label:"应用ID"`
 | 
			
		||||
	AppName           string `json:"app_name" label:"应用名称"`
 | 
			
		||||
	AppRemark         string `json:"app_remark" label:"应用备注"`
 | 
			
		||||
	Status            int    `json:"status"  label:"应用状态"`
 | 
			
		||||
	KeyType           int    `json:"key_type" label:"应用密钥类型"`
 | 
			
		||||
	Status            int32  `json:"status"  label:"应用状态"`
 | 
			
		||||
	KeyType           int32  `json:"key_type" label:"应用密钥类型"`
 | 
			
		||||
	PublicKey         string `json:"public_key"  label:"应用公钥"`
 | 
			
		||||
	PrivateKey        string `json:"private_key"  label:"应用私钥"`
 | 
			
		||||
	MerchantPublicKey string `json:"merchant_public_key" label:"商户公钥"`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,8 +2,9 @@ package backend
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/models/orderlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderrequestlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/ordersmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderthirdpaylogmodel"
 | 
			
		||||
	"PaymentCenter/app/utils"
 | 
			
		||||
	"github.com/pkg/errors"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,9 +67,9 @@ func (o *OrderListRequest) ValidateRequest() (r OrderList, err error) {
 | 
			
		|||
type OrdersResponse struct {
 | 
			
		||||
	Id               int64  `json:"id"`
 | 
			
		||||
	MerchantId       int64  `json:"merchant_id"`
 | 
			
		||||
	PayId            int64  `json:"pay_id"`
 | 
			
		||||
	PayChannelId     int64  `json:"pay_channel_id"`
 | 
			
		||||
	AppId            int64  `json:"app_id"`
 | 
			
		||||
	MerchantOrderId  string `json:"merchant_order_id"`
 | 
			
		||||
	OutTreadNo       string `json:"out_tread_no"`
 | 
			
		||||
	Status           int    `json:"status"`
 | 
			
		||||
	OrderType        int    `json:"order_type"`
 | 
			
		||||
	Amount           int    `json:"amount"`
 | 
			
		||||
| 
						 | 
				
			
			@ -87,16 +88,12 @@ type OrdersResponse struct {
 | 
			
		|||
func (o *OrdersResponse) ResponseFromDb(db ordersmodel.OrdersBackendList) {
 | 
			
		||||
	o.Id = db.Id
 | 
			
		||||
	o.MerchantId = db.MerchantId
 | 
			
		||||
	o.PayId = db.PayId
 | 
			
		||||
	o.PayChannelId = db.PayChannelId
 | 
			
		||||
	o.AppId = db.AppId
 | 
			
		||||
	o.MerchantOrderId = db.MerchantOrderId
 | 
			
		||||
	o.OutTreadNo = db.OutTreadNo
 | 
			
		||||
	o.Status = db.Status
 | 
			
		||||
	o.OrderType = db.OrderType
 | 
			
		||||
	o.Amount = db.Amount
 | 
			
		||||
	o.IpAddress = db.IpAddress
 | 
			
		||||
	o.MerchantRequest = db.MerchantRequest
 | 
			
		||||
	o.MerchantResponse = db.MerchantResponse
 | 
			
		||||
	o.OrderResponse = db.OrderResponse
 | 
			
		||||
	o.ExtJson = db.ExtJson
 | 
			
		||||
	o.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
 | 
			
		||||
	o.UpdateTime = db.UpdateTime.Format("2006-01-02 15:04:05")
 | 
			
		||||
| 
						 | 
				
			
			@ -110,17 +107,37 @@ type OrderLogsListRequest struct {
 | 
			
		|||
	entities.PageRequest
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type OrderLogResponse struct {
 | 
			
		||||
type OrderRequestLogResponse struct {
 | 
			
		||||
	Id               int64  `json:"id"`
 | 
			
		||||
	IpAddress        string `json:"ip_address"`
 | 
			
		||||
	OrderId          int64  `json:"order_id"`
 | 
			
		||||
	MerchantRequest  string `json:"merchant_request"`
 | 
			
		||||
	MerchantResponse string `json:"merchant_response"`
 | 
			
		||||
	CreateTime       string `json:"create_time"`
 | 
			
		||||
	Status           int    `json:"status"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *OrderRequestLogResponse) ResponseFromDb(db orderrequestlogmodel.OrderRequestLog) {
 | 
			
		||||
	o.Id = db.Id
 | 
			
		||||
	o.OrderId = db.OrderId
 | 
			
		||||
	o.IpAddress = db.IpAddress
 | 
			
		||||
	o.Status = db.Status
 | 
			
		||||
	o.MerchantRequest = db.MerchantRequest
 | 
			
		||||
	o.MerchantResponse = db.MerchantResponse
 | 
			
		||||
	o.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type OrderThirdLogResponse struct {
 | 
			
		||||
	Id               int64  `json:"id"`
 | 
			
		||||
	OrderId          int64  `json:"order_id"`
 | 
			
		||||
	CreateTime       string `json:"create_time"`
 | 
			
		||||
	PayCallback      string `json:"pay_callback"`
 | 
			
		||||
	Status           int    `json:"status"`
 | 
			
		||||
	MerchantParam    string `json:"merchant_param"`
 | 
			
		||||
	MerchantCallback string `json:"merchant_callback"`
 | 
			
		||||
	CreateTime       string `json:"create_time"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *OrderLogResponse) ResponseFromDb(db orderlogmodel.OrderLog) {
 | 
			
		||||
func (o *OrderThirdLogResponse) ResponseFromDb(db orderthirdpaylogmodel.OrderThirdPayLog) {
 | 
			
		||||
	o.Id = db.Id
 | 
			
		||||
	o.OrderId = db.OrderId
 | 
			
		||||
	o.PayCallback = db.PayCallback
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ func (p *PayChannelResponse) ResponseFromDb(db paychannelmodel.PayChannel) {
 | 
			
		|||
	p.ExpireTime = db.ExpireTime.Format("2006-01-02 15:04:05")
 | 
			
		||||
	p.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
 | 
			
		||||
 | 
			
		||||
	switch p.ChannelType {
 | 
			
		||||
	switch db.ChannelType {
 | 
			
		||||
	case common.PAY_CHANNEL_WECHAT_H5, common.PAY_CHANNEL_WECHAT_JSAPI, common.PAY_CHANNEL_WECHAT_NATIVE, common.PAY_CHANNEL_WECHAT_APP, common.PAY_CHANNEL_WECHAT_MINI:
 | 
			
		||||
		_ = json.Unmarshal([]byte(db.ExtJson), &p.WechatPayChannel)
 | 
			
		||||
	case common.PAY_CHANNEL_ALIPAY_JSAPI, common.PAY_CHANNEL_ALIPAY_WEB, common.PAY_CHANNEL_ALIPAY_MINI:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
package front
 | 
			
		||||
 | 
			
		||||
type PayCommonBody struct {
 | 
			
		||||
	AppId     int64 `json:"app_id" validate:"required"`
 | 
			
		||||
	Timestamp int64 `json:"timestamp" validate:"required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PayWeb struct {
 | 
			
		||||
	PayCommonBody
 | 
			
		||||
	PayChannel int64 `json:"private_key_path"`
 | 
			
		||||
	Delay      int64 `json:"delay"` //延时时间
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4,7 +4,10 @@ import (
 | 
			
		|||
	"PaymentCenter/app/constants/common"
 | 
			
		||||
	"PaymentCenter/app/constants/errorcode"
 | 
			
		||||
	"PaymentCenter/app/http/controllers"
 | 
			
		||||
	"PaymentCenter/app/http/entities"
 | 
			
		||||
	"PaymentCenter/app/http/entities/front"
 | 
			
		||||
	"PaymentCenter/app/http/requestmapping"
 | 
			
		||||
	"PaymentCenter/app/services"
 | 
			
		||||
	"PaymentCenter/app/utils"
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
| 
						 | 
				
			
			@ -109,18 +112,52 @@ func ValidateRequest() gin.HandlerFunc {
 | 
			
		|||
		if handler == nil {
 | 
			
		||||
			utils.Log(c, "path", path)
 | 
			
		||||
			controllers.HandCodeRes(c, nil, errorcode.NotFound)
 | 
			
		||||
		} else {
 | 
			
		||||
			v := handler()
 | 
			
		||||
			msg, err := controllers.GenRequest(c, v)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				utils.Log(c, "参数错误", "path=", path, "err=", err.Error(), "msg=", msg)
 | 
			
		||||
				controllers.Error(c, errorcode.ParamError, msg...)
 | 
			
		||||
				c.Abort()
 | 
			
		||||
			} else {
 | 
			
		||||
				c.Set("request", v)
 | 
			
		||||
				c.Next()
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		v := handler()
 | 
			
		||||
		msg, err := controllers.GenRequest(c, v)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			utils.Log(c, "参数错误", "path=", path, "err=", err.Error(), "msg=", msg)
 | 
			
		||||
			controllers.Error(c, errorcode.ParamError, msg...)
 | 
			
		||||
			c.Abort()
 | 
			
		||||
		}
 | 
			
		||||
		c.Set("request", v)
 | 
			
		||||
 | 
			
		||||
		c.Next()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ValidatePayRequest() gin.HandlerFunc {
 | 
			
		||||
	return func(c *gin.Context) {
 | 
			
		||||
		com, err := utils.SonicApiDataToStruct(controllers.GetRequest(c), &front.PayCommonBody{})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			controllers.ErrWithCode(c, errorcode.ParamError)
 | 
			
		||||
		}
 | 
			
		||||
		comStruct := com.(*front.PayCommonBody)
 | 
			
		||||
		//判断时间
 | 
			
		||||
		//now := time.Now().UnixNano() / 1000000
 | 
			
		||||
		//if comStruct.Timestamp > now || (config.GetConf().TimeOut != 0 && (now-comStruct.Timestamp) > config.GetConf().TimeOut) {
 | 
			
		||||
		//	controllers.ErrWithCode(c, errorcode.RequestTimeOut)
 | 
			
		||||
		//	return
 | 
			
		||||
		//}
 | 
			
		||||
		//获取app信息
 | 
			
		||||
		app, errCode := services.AppFindOne(entities.IdRequest{Id: comStruct.AppId})
 | 
			
		||||
		if errCode != errorcode.Success {
 | 
			
		||||
			controllers.ErrWithCode(c, errCode)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		//检查app可用性
 | 
			
		||||
		appCheck := services.NewAppCheck(app).Check()
 | 
			
		||||
		if appCheck.GetCode() != errorcode.Success {
 | 
			
		||||
			controllers.ErrWithCode(c, appCheck.GetCode())
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		//检查白名单
 | 
			
		||||
		if !appCheck.IpCheck(c.ClientIP()) {
 | 
			
		||||
			controllers.ErrWithCode(c, appCheck.GetCode())
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		c.Next()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,10 @@
 | 
			
		|||
package requestmapping
 | 
			
		||||
 | 
			
		||||
var FrontRequestMap = map[string]func() interface{}{}
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/constants/common"
 | 
			
		||||
	"PaymentCenter/app/http/entities/front"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var FrontRequestMap = map[string]func() interface{}{
 | 
			
		||||
	common.FRONT_V1 + "/pay/web": func() interface{} { return new(front.PayWeb) },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,17 +5,18 @@ package routes
 | 
			
		|||
 */
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/http/controllers"
 | 
			
		||||
	"PaymentCenter/app/http/controllers/backend"
 | 
			
		||||
	"PaymentCenter/app/http/controllers/front"
 | 
			
		||||
	"PaymentCenter/app/http/middlewares"
 | 
			
		||||
	"PaymentCenter/app/http/trace"
 | 
			
		||||
	"PaymentCenter/app/utils/metric"
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	ginSwagger "github.com/swaggo/gin-swagger"
 | 
			
		||||
	"github.com/swaggo/gin-swagger/swaggerFiles"
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"github.com/qit-team/snow-core/http/middleware"
 | 
			
		||||
	"github.com/qit-team/snow-core/log/logger"
 | 
			
		||||
	"github.com/swaggo/gin-swagger"
 | 
			
		||||
	"github.com/swaggo/gin-swagger/swaggerFiles"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// api路由配置
 | 
			
		||||
| 
						 | 
				
			
			@ -44,11 +45,7 @@ func RegisterRoute(router *gin.Engine) {
 | 
			
		|||
	router.Use(middlewares.Cors())
 | 
			
		||||
	router.NoRoute(controllers.Error404)
 | 
			
		||||
 | 
			
		||||
	//api版本
 | 
			
		||||
	//v1 := router.Group("/v1", middlewares.ValidateRequest())
 | 
			
		||||
	//{
 | 
			
		||||
	//
 | 
			
		||||
	//}
 | 
			
		||||
	//router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 | 
			
		||||
 | 
			
		||||
	v1 := router.Group("/v1")
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -61,10 +58,6 @@ func RegisterRoute(router *gin.Engine) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 | 
			
		||||
 | 
			
		||||
	//router.GET("/hello", controllers.HelloHandler)
 | 
			
		||||
	//router.GET("/create", controllers.HelloCreateHandler)
 | 
			
		||||
	//router.GET("/update", controllers.UpdateHandler)
 | 
			
		||||
	//router.GET("/delete", controllers.DeleteHandler)
 | 
			
		||||
	//router.GET("/query", controllers.QueryHandler)
 | 
			
		||||
	pay := v1.Group("pay", middlewares.ValidatePayRequest())
 | 
			
		||||
	pay.POST("web", backend.MerchantList) // 商户列表
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,18 +15,18 @@ var (
 | 
			
		|||
type App struct {
 | 
			
		||||
	Id                int64
 | 
			
		||||
	MerchantId        int64     `xorm:"'merchant_id' bigint(20)"`
 | 
			
		||||
	AppName           string    `xorm:"'app_name' varchar(128)"`
 | 
			
		||||
	AppRemark         string    `xorm:"'app_remark' varchar(255)"`
 | 
			
		||||
	Status            int       `xorm:"'status' int(11)"`
 | 
			
		||||
	KeyType           int       `xorm:"'key_type' int(11)"`
 | 
			
		||||
	AppName           string    `xorm:"'app_name' varchar(20)"`
 | 
			
		||||
	AppRemark         string    `xorm:"'app_remark' varchar(200)"`
 | 
			
		||||
	Status            int32     `xorm:"'status' tinyint(2)"`
 | 
			
		||||
	KeyType           int32     `xorm:"'key_type' tinyint(2)"`
 | 
			
		||||
	PublicKey         string    `xorm:"'public_key' varchar(1024)"`
 | 
			
		||||
	PrivateKey        string    `xorm:"'private_key' varchar(1024)"`
 | 
			
		||||
	PrivateKey        string    `xorm:"'private_key' TEXT"`
 | 
			
		||||
	MerchantPublicKey string    `xorm:"'merchant_public_key' varchar(1024)"`
 | 
			
		||||
	NotifyUrl         string    `xorm:"'notify_url' varchar(128)"`
 | 
			
		||||
	WhiteIp           string    `xorm:"'white_ip' varchar(128)"`
 | 
			
		||||
	CreateTime        time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
	UpdateTime        time.Time `xorm:"'update_time' timestamp updated"`
 | 
			
		||||
	DeleteTime        time.Time `xorm:"'delete_time' timestamp deleted"`
 | 
			
		||||
	NotifyUrl         string    `xorm:"'notify_url' varchar(128)"`
 | 
			
		||||
	WhiteIp           string    `xorm:"'white_ip' varchar(255)"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 表名
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,10 +18,10 @@ type Merchant struct {
 | 
			
		|||
	Contact    string    `xorm:"'contact' varchar(128)"`
 | 
			
		||||
	Phone      string    `xorm:"'phone' varchar(11)"`
 | 
			
		||||
	Remark     string    `xorm:"'remark' varchar(1024)"`
 | 
			
		||||
	Creator    int       `xorm:"'creator' int(10)"`
 | 
			
		||||
	CreateTime time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
	UpdateTime time.Time `xorm:"'update_time' timestamp updated"`
 | 
			
		||||
	DeleteTime time.Time `xorm:"'delete_time' timestamp deleted"`
 | 
			
		||||
	Creator    int       `xorm:"'creator' int(11)"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 表名
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
package orderrequestlogmodel
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/qit-team/snow-core/db"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	once sync.Once
 | 
			
		||||
	m    *OrderRequestLogModel
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 实体
 | 
			
		||||
type OrderRequestLog struct {
 | 
			
		||||
	Id               int64
 | 
			
		||||
	IpAddress        string    `xorm:"'ip_address' varchar(16)"`
 | 
			
		||||
	OrderId          int64     `xorm:"'order_id' bigint(20)"`
 | 
			
		||||
	MerchantRequest  string    `xorm:"'merchant_request' JSON"`
 | 
			
		||||
	MerchantResponse string    `xorm:"'merchant_response' JSON"`
 | 
			
		||||
	CreateTime       time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
	UpdateTime       time.Time `xorm:"'update_time' timestamp updated"`
 | 
			
		||||
	Status           int       `xorm:"'status' TINYINT"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 表名
 | 
			
		||||
func (m *OrderRequestLog) TableName() string {
 | 
			
		||||
	return "order_request_log"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 私有化,防止被外部new
 | 
			
		||||
type OrderRequestLogModel struct {
 | 
			
		||||
	db.Model //组合基础Model,集成基础Model的属性和方法
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 单例模式
 | 
			
		||||
func GetInstance() *OrderRequestLogModel {
 | 
			
		||||
	once.Do(func() {
 | 
			
		||||
		m = new(OrderRequestLogModel)
 | 
			
		||||
		//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
 | 
			
		||||
	})
 | 
			
		||||
	return m
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -13,29 +13,32 @@ var (
 | 
			
		|||
 | 
			
		||||
// 实体
 | 
			
		||||
type Orders struct {
 | 
			
		||||
	Id               int64
 | 
			
		||||
	MerchantId       int64     `xorm:"'merchant_id' bigint(20)"`
 | 
			
		||||
	PayId            int64     `xorm:"'pay_id' bigint(20)"`
 | 
			
		||||
	AppId            int64     `xorm:"'app_id' bigint(20)"`
 | 
			
		||||
	MerchantOrderId  string    `xorm:"'merchant_order_id' varchar(32)"`
 | 
			
		||||
	Status           int       `xorm:"'status' int(11)"`
 | 
			
		||||
	OrderType        int       `xorm:"'order_type' int(11)"`
 | 
			
		||||
	Amount           int       `xorm:"'amount' int(11)"`
 | 
			
		||||
	IpAddress        string    `xorm:"'ip_address' varchar(128)"`
 | 
			
		||||
	MerchantRequest  string    `xorm:"'merchant_request' varchar(2048)"`
 | 
			
		||||
	MerchantResponse string    `xorm:"'merchant_response' varchar(255)"`
 | 
			
		||||
	OrderResponse    string    `xorm:"'order_response' varchar(255)"`
 | 
			
		||||
	ExtJson          string    `xorm:"'ext_json' varchar(1024)"`
 | 
			
		||||
	CreateTime       time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
	UpdateTime       time.Time `xorm:"'update_time' timestamp updated"`
 | 
			
		||||
	DeleteTime       time.Time `xorm:"'delete_time' timestamp deleted"`
 | 
			
		||||
	Id           int64
 | 
			
		||||
	MerchantId   int64     `xorm:"'merchant_id' bigint(20)"`
 | 
			
		||||
	PayChannelId int64     `xorm:"'pay_channel_id' bigint(20)"`
 | 
			
		||||
	AppId        int64     `xorm:"'app_id' bigint(20)"`
 | 
			
		||||
	OutTreadNo   string    `xorm:"'out_tread_no' varchar(50)"`
 | 
			
		||||
	OrderType    int       `xorm:"'order_type' TINYINT"`
 | 
			
		||||
	Amount       int       `xorm:"'amount' int(11)"`
 | 
			
		||||
	ExtJson      string    `xorm:"'ext_json' varchar(1024)"`
 | 
			
		||||
	CreateTime   time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
	UpdateTime   time.Time `xorm:"'update_time' timestamp updated"`
 | 
			
		||||
	Status       int       `xorm:"'status' TINYINT"`
 | 
			
		||||
	DeleteTime   time.Time `xorm:"'delete_time' timestamp deleted"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type OrdersBackendList struct {
 | 
			
		||||
	Orders       `xorm:"extends"`
 | 
			
		||||
	MerchantName string `xorm:"'merchant_name' varchar(128)"`
 | 
			
		||||
	PayName      string `xorm:"'pay_name' varchar(128)"`
 | 
			
		||||
	AppName      string `xorm:"'app_name' varchar(128)"`
 | 
			
		||||
}
 | 
			
		||||
type OrdersLeftPayChannelList struct {
 | 
			
		||||
	Orders      `xorm:"extends"`
 | 
			
		||||
	ChannelType int    `xorm:"'channel_type' int(11)"`
 | 
			
		||||
	AppId       string `xorm:"'app_id' varchar(255)"`
 | 
			
		||||
	ExtJson     string `xorm:"'ext_json' JSON"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 表名
 | 
			
		||||
func (m *Orders) TableName() string {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package orderlogmodel
 | 
			
		||||
package orderthirdpaylogmodel
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/qit-team/snow-core/db"
 | 
			
		||||
| 
						 | 
				
			
			@ -8,34 +8,34 @@ import (
 | 
			
		|||
 | 
			
		||||
var (
 | 
			
		||||
	once sync.Once
 | 
			
		||||
	m    *OrderLogModel
 | 
			
		||||
	m    *OrderThirdPayLogModel
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 实体
 | 
			
		||||
type OrderLog struct {
 | 
			
		||||
type OrderThirdPayLog struct {
 | 
			
		||||
	Id               int64
 | 
			
		||||
	OrderId          int64     `xorm:"'order_id' bigint(20)"`
 | 
			
		||||
	PayCallback      string    `xorm:"'pay_callback' varchar(255)"`
 | 
			
		||||
	Status           int       `xorm:"'status' int(11)"`
 | 
			
		||||
	Status           int       `xorm:"'status' TINYINT"`
 | 
			
		||||
	MerchantParam    string    `xorm:"'merchant_param' varchar(255)"`
 | 
			
		||||
	MerchantCallback string    `xorm:"'merchant_callback' varchar(255)"`
 | 
			
		||||
	CreateTime       time.Time `xorm:"'create_time' datetime created"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 表名
 | 
			
		||||
func (m *OrderLog) TableName() string {
 | 
			
		||||
	return "order_log"
 | 
			
		||||
func (m *OrderThirdPayLog) TableName() string {
 | 
			
		||||
	return "order_third_pay_log"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 私有化,防止被外部new
 | 
			
		||||
type OrderLogModel struct {
 | 
			
		||||
type OrderThirdPayLogModel struct {
 | 
			
		||||
	db.Model //组合基础Model,集成基础Model的属性和方法
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 单例模式
 | 
			
		||||
func GetInstance() *OrderLogModel {
 | 
			
		||||
func GetInstance() *OrderThirdPayLogModel {
 | 
			
		||||
	once.Do(func() {
 | 
			
		||||
		m = new(OrderLogModel)
 | 
			
		||||
		m = new(OrderThirdPayLogModel)
 | 
			
		||||
		//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
 | 
			
		||||
	})
 | 
			
		||||
	return m
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
package services
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/constants/errorcode"
 | 
			
		||||
	"PaymentCenter/app/constants/pojo"
 | 
			
		||||
	"PaymentCenter/app/models/appmodel"
 | 
			
		||||
	"PaymentCenter/app/utils"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AppCheck struct {
 | 
			
		||||
	App  *appmodel.App
 | 
			
		||||
	Code int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAppCheck(app *appmodel.App) *AppCheck {
 | 
			
		||||
	return &AppCheck{
 | 
			
		||||
		App:  app,
 | 
			
		||||
		Code: errorcode.Success,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AppCheck) IpCheck(ip string) bool {
 | 
			
		||||
	if a.App.WhiteIp == "" {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if !utils.ContainsString(strings.Split(a.App.WhiteIp, ","), ip) {
 | 
			
		||||
		a.Code = errorcode.AppIpNotAllow
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AppCheck) Check() *AppCheck {
 | 
			
		||||
 | 
			
		||||
	if a.App.Status == pojo.STATUS_DISABLED {
 | 
			
		||||
		a.Code = errorcode.AppDisabled
 | 
			
		||||
	}
 | 
			
		||||
	if a.App.DeleteTime.Location() == nil {
 | 
			
		||||
		a.Code = errorcode.AppNotFound
 | 
			
		||||
	}
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AppCheck) GetCode() int {
 | 
			
		||||
	return a.Code
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
package apicrypt
 | 
			
		||||
 | 
			
		||||
import "PaymentCenter/app/models/appmodel"
 | 
			
		||||
 | 
			
		||||
func NewRsa(app *appmodel.App) ApiDecrypt {
 | 
			
		||||
	return &Rsa{
 | 
			
		||||
		App: app,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *Rsa) Encrypt(decryptData interface{}) (encryptData string, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *Rsa) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
package apicrypt
 | 
			
		||||
 | 
			
		||||
func (r *SM2) Encrypt(decryptData interface{}) (encryptData string, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *SM2) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
package apicrypt
 | 
			
		||||
 | 
			
		||||
func (r *SM4) Encrypt(decryptData interface{}) (encryptData string, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *SM4) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
package apicrypt
 | 
			
		||||
 | 
			
		||||
import "PaymentCenter/app/models/appmodel"
 | 
			
		||||
 | 
			
		||||
type (
 | 
			
		||||
	ApiDecrypt interface {
 | 
			
		||||
		Encrypt(decryptData interface{}) (encryptData string, err error)
 | 
			
		||||
		Decrypt(encryptData string) (decryptData map[string]interface{}, err error)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Rsa struct {
 | 
			
		||||
		App *appmodel.App
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	SM2 struct {
 | 
			
		||||
		App *appmodel.App
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	SM4 struct {
 | 
			
		||||
		App *appmodel.App
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ import (
 | 
			
		|||
	"PaymentCenter/app/models/appmodel"
 | 
			
		||||
	"PaymentCenter/app/models/merchantmodel"
 | 
			
		||||
	"PaymentCenter/app/models/paychannelmodel"
 | 
			
		||||
	"database/sql"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +65,7 @@ func AppUpdate(app *appmodel.App) (code int) {
 | 
			
		|||
	} else {
 | 
			
		||||
		_, err = repo.AppUpdate(app, conn)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	code = handErr(err)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -82,18 +83,19 @@ func AppDelete(req entities.IdRequest) (code int) {
 | 
			
		|||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func AppGet(app *appmodel.App) (code int) {
 | 
			
		||||
	repo := data.NewAppRepo(appmodel.GetInstance().GetDb())
 | 
			
		||||
func AppFindOne(req entities.IdRequest, col ...string) (row *appmodel.App, code int) {
 | 
			
		||||
	repo := data.NewAppRepo(paychannelmodel.GetInstance().GetDb())
 | 
			
		||||
 | 
			
		||||
	// 拼接查询条件
 | 
			
		||||
	conn := builder.NewCond()
 | 
			
		||||
	conn = conn.And(builder.Eq{"id": app.Id})
 | 
			
		||||
	has, err := repo.AppGet(app, conn)
 | 
			
		||||
	conn = conn.And(builder.Eq{"Id": req.Id})
 | 
			
		||||
	m := appmodel.App{Id: req.Id}
 | 
			
		||||
	row, err := repo.AppFindOne(&m, conn, col...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return handErr(err)
 | 
			
		||||
		if err == sql.ErrNoRows {
 | 
			
		||||
			return nil, errorcode.AppNotFound
 | 
			
		||||
		}
 | 
			
		||||
		return row, errorcode.SystemError
 | 
			
		||||
	}
 | 
			
		||||
	if !has {
 | 
			
		||||
		return errorcode.AppNotFound
 | 
			
		||||
	}
 | 
			
		||||
	code = errorcode.Success
 | 
			
		||||
	return
 | 
			
		||||
	return row, errorcode.Success
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,8 +3,9 @@ package services
 | 
			
		|||
import (
 | 
			
		||||
	"PaymentCenter/app/data"
 | 
			
		||||
	"PaymentCenter/app/http/entities/backend"
 | 
			
		||||
	"PaymentCenter/app/models/orderlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderrequestlogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/ordersmodel"
 | 
			
		||||
	"PaymentCenter/app/models/orderthirdpaylogmodel"
 | 
			
		||||
	"PaymentCenter/app/models/paychannelmodel"
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -49,16 +50,25 @@ func OrderList(req backend.OrderList) (result []ordersmodel.OrdersBackendList, t
 | 
			
		|||
	return orderList, count, code
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func OrderLogsList(req backend.OrderLogsListRequest) (result []orderlogmodel.OrderLog, total int64, code int) {
 | 
			
		||||
	repo := data.NewOrderLogRepo(paychannelmodel.GetInstance().GetDb())
 | 
			
		||||
func OrderLogsList(req backend.OrderLogsListRequest) (requestLog []orderrequestlogmodel.OrderRequestLog, thirdLod []orderthirdpaylogmodel.OrderThirdPayLog, code int) {
 | 
			
		||||
	requestRepo := data.NewOrderRequestLogRepo(paychannelmodel.GetInstance().GetDb())
 | 
			
		||||
	thirdRepo := data.NewOrderThirdPayLogRepo(paychannelmodel.GetInstance().GetDb())
 | 
			
		||||
 | 
			
		||||
	conn := builder.NewCond()
 | 
			
		||||
	if req.OrderId > 0 {
 | 
			
		||||
		conn = conn.And(builder.Eq{"order_id": req.OrderId})
 | 
			
		||||
	}
 | 
			
		||||
	// 调用repo
 | 
			
		||||
	orderLogList := make([]orderlogmodel.OrderLog, 0)
 | 
			
		||||
	count, err := repo.OrderLogList(conn, req.PageRequest, &orderLogList)
 | 
			
		||||
	// 请求日志
 | 
			
		||||
	orderLogList := make([]orderrequestlogmodel.OrderRequestLog, 0)
 | 
			
		||||
	_, err := requestRepo.OrderRequestLogList(conn, req.PageRequest, &orderLogList)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		code = handErr(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	// 三方日志
 | 
			
		||||
	thirdLogList := make([]orderthirdpaylogmodel.OrderThirdPayLog, 0)
 | 
			
		||||
	_, err = thirdRepo.OrderThirdPayLogList(conn, req.PageRequest, &thirdLogList)
 | 
			
		||||
	code = handErr(err)
 | 
			
		||||
 | 
			
		||||
	return orderLogList, count, code
 | 
			
		||||
	return orderLogList, thirdLogList, code
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,110 @@
 | 
			
		|||
package rsa
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"crypto/rsa"
 | 
			
		||||
	"crypto/sha256"
 | 
			
		||||
	"crypto/x509"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"encoding/pem"
 | 
			
		||||
	"fmt"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// parseRSAPublicKeyFromPEM 解析PEM编码的RSA公钥
 | 
			
		||||
func parseRSAPublicKeyFromPEM(pemData []byte) (*rsa.PublicKey, error) {
 | 
			
		||||
	block, _ := pem.Decode(pemData)
 | 
			
		||||
	if block == nil || block.Type != "PUBLIC KEY" {
 | 
			
		||||
		return nil, fmt.Errorf("failed to parse PEM block containing the RSA public key")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pub, err := x509.ParsePKIXPublicKey(block.Bytes)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch pub := pub.(type) {
 | 
			
		||||
	case *rsa.PublicKey:
 | 
			
		||||
		return pub, nil
 | 
			
		||||
	default:
 | 
			
		||||
		return nil, fmt.Errorf("unknown public key type in PKIX wrapping")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// encrypt 使用RSA公钥加密数据
 | 
			
		||||
func Encrypt(publicKeyPEM string, plaintext []byte) ([]byte, error) {
 | 
			
		||||
	// 将PEM编码的公钥转换为[]byte
 | 
			
		||||
	pemData := []byte(publicKeyPEM)
 | 
			
		||||
 | 
			
		||||
	// 解析PEM数据以获取公钥
 | 
			
		||||
	pubKey, err := parseRSAPublicKeyFromPEM(pemData)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 创建用于加密的随机填充
 | 
			
		||||
	label := []byte("") // OAEP标签,对于某些情况可能是非空的
 | 
			
		||||
	ciphertext, err := rsa.EncryptOAEP(sha256.New(), rand.Reader, pubKey, plaintext, label)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return ciphertext, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// parseRSAPrivateKeyFromPEM 解析PEM编码的RSA私钥
 | 
			
		||||
func parseRSAPrivateKeyFromPEM(pemData []byte) (*rsa.PrivateKey, error) {
 | 
			
		||||
	block, _ := pem.Decode(pemData)
 | 
			
		||||
	if block == nil || block.Type != "RSA PRIVATE KEY" {
 | 
			
		||||
		return nil, fmt.Errorf("failed to parse PEM block containing the RSA private key")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 尝试使用PKCS#1 v1.5
 | 
			
		||||
	priv, err := x509.ParsePKCS1PrivateKey(block.Bytes)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// 如果失败,尝试使用PKCS#8
 | 
			
		||||
		privInterface, err := x509.ParsePKCS8PrivateKey(block.Bytes)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		switch k := privInterface.(type) {
 | 
			
		||||
		case *rsa.PrivateKey:
 | 
			
		||||
			priv = k
 | 
			
		||||
		default:
 | 
			
		||||
			return nil, fmt.Errorf("unknown private key type in PKCS#8 wrapping")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return priv, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// decrypt 使用RSA私钥解密数据
 | 
			
		||||
func Decrypt(privateKeyPEM string, encryptedDataBase64 string) ([]byte, error) {
 | 
			
		||||
	// 将PEM编码的私钥转换为[]byte
 | 
			
		||||
	pemData := []byte(privateKeyPEM)
 | 
			
		||||
 | 
			
		||||
	// 解析PEM数据以获取私钥
 | 
			
		||||
	privKey, err := parseRSAPrivateKeyFromPEM(pemData)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 将Base64编码的加密数据解码为字节切片
 | 
			
		||||
	encryptedData, err := base64.StdEncoding.DecodeString(encryptedDataBase64)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 根据你的加密方式选择合适的解密函数
 | 
			
		||||
	// 这里假设使用的是OAEP填充和SHA-256哈希函数
 | 
			
		||||
	label := []byte("") // OAEP标签,对于某些情况可能是非空的
 | 
			
		||||
	decrypted, err := rsa.DecryptOAEP(sha256.New(), rand.Reader, privKey, encryptedData, label)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// 如果失败,可以尝试使用PKCS#1 v1.5填充
 | 
			
		||||
		decrypted, err = rsa.DecryptPKCS1v15(rand.Reader, privKey, encryptedData)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return decrypted, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
package rsa
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	PRI = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmjK6SPkrP03ssex5Dxn4KZeVm9rQoJMslru13GNgoGKJAq13xwUGl6lpGlhzM9IMzg0ldOO2a0SQPPjc0fLrDjIgHPfIT6H1hDGkZdPaF4D0OfiHGzlLwXq7FyyyGc2JXILsniMBXcCxNFhbW0jAaJyYrBJb3q84a5y5AtK3IC+eDV6Bj2J4HlQVGKgW9u2ic6Jxl23sacXY6iifi+KEuoXNCJrmYlgRWTaQovLmTCLkErkzxzG9DFRDWGoz25LthDPqcCSUmWEbJ+obwIGB4r2WCbFXvaeVBQORlyVRyNUvYMItjHBQIKinDWZ6y8KzA0YKOoxEfr0KfE8Uk4PQBAgMBAAECggEABTAX0PzelN4uyvTT0sMi/R0YRKPgepP40vtBsNvF10E7Lp4ClAupHpYFSrJq178xu1/2dVBXEGM9hw8GUQd7RCjuD3cFwcp/EKU+Zy6uQ38iZRTskEDa3bC+q3EXzuFXDxqOfIhai262UTlkATw0sjUwJRdkbMxoeWHkSNuH7UBVddxFL8Bq1DKaPzRCqQ8zlkMZHy8Xbf2b8rFoi1oPBoPjHyxCo33zcnSg5xntIoA5pkD6x4z5cAnU55aBoYUiRv7jmG+MVp1jpDvAmJLfUayVZNakgX1r74bMPsl9kpA7dVdgOlWrIkbJE1plVXXswBb8QKN0/Yx2vv/YASSi0QKBgQDaO9BkRjvht/lrsQEur1wXf5ITnsVWsqlUhYQKGHihzOj7e0rGO9QICM4eQZH9ssHfxEXhmEoFdkaqo3Fo47NI+yinpWm+KruwrRFkCGejlKZ4bhn9zWPb8L1qJbN4UD1c5jUNk1B0EEdnLRFg0/O7xm602bGilvY5x2nf0v95+QKBgQDDXyiiGNV7GO4h8OQYJwq0IqenPyIanRgYI3rw//tg147mhWcxT6ms6dMUh9nEXEFali2J1En+aVvx1Xn47CuGrRmZOLaGkw9ESFA/4ngYdea+xgttbKMXm0QwIwvATq2jxxrYEKmnr/+EUUWzIWioM1zQffAhVlkLFVnImquMSQKBgDe7qNfC/A4ELwWqubOTg0BZCxRJqvoePJJiWrs9Tql7rFB1Rz5jDx5SKVmew0r4OP0Nog8gFl9YumlfvlncNPBBfDt8SgoP3ckcGeHjJ5ymHPGKpMaliogj7ivKnw/t5g3wmMHzyksp0SJvZw3Ec22UGrfDFNOCHDXbUJWhzC75AoGBALbM6rAAnH65LNcFFeajYRh69HNAVyCfrFOpnvawDPzntAVs/MjeyNvJTH8BPXjE+UFREvrLbxBkdGsqWx3VnEQ+4pzCu8XfA4HYR33+4G/CoUwO8dJIu7DyzjJcGDqvYzjCqxNPQ+5qdqHPiW+56rq2lDlgHLaUnGwKZh+U2L5BAoGAeogtSQbnZaLQofSGcUOol2fyG24NU1JK3My+N1ypkSpD+y1KiFQeM5kg7UcJB6LBKZ/lRCKcjEMaxMyj57ETMkbRVKBLvsIL5QYolJLIHYqBul0AeFJ4K51SKK2Xk5rFvyuJKkJBux26WodtCXTnEzP1KRZGlSxJeN/V1yXjSEU="
 | 
			
		||||
 | 
			
		||||
	PUB = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApoyukj5Kz9N7LHseQ8Z+CmXlZva0KCTLJa7tdxjYKBiiQKtd8cFBpepaRpYczPSDM4NJXTjtmtEkDz43NHy6w4yIBz3yE+h9YQxpGXT2heA9Dn4hxs5S8F6uxcsshnNiVyC7J4jAV3AsTRYW1tIwGicmKwSW96vOGucuQLStyAvng1egY9ieB5UFRioFvbtonOicZdt7GnF2Ooon4vihLqFzQia5mJYEVk2kKLy5kwi5BK5M8cxvQxUQ1hqM9uS7YQz6nAklJlhGyfqG8CBgeK9lgmxV72nlQUDkZclUcjVL2DCLYxwUCCopw1mesvCswNGCjqMRH69CnxPFJOD0AQIDAQAB"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestRsaEncrypt(t *testing.T) {
 | 
			
		||||
	fmt.Println(time.Now().UnixNano() / (1000000))
 | 
			
		||||
	//fmt.Printf("%s\n", encrypt())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRsaDecrypt(t *testing.T) {
 | 
			
		||||
	data := encrypt()
 | 
			
		||||
	privateKeyPEM := `-----BEGIN RSA PRIVATE KEY-----  
 | 
			
		||||
` + PRI + `  
 | 
			
		||||
-----END RSA PRIVATE KEY-----`
 | 
			
		||||
	res, err := Decrypt(privateKeyPEM, data)
 | 
			
		||||
	fmt.Println(string(res), err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func encrypt() string {
 | 
			
		||||
	data := "{\"name\":\"张三\",\"sex\":1,\"is_human\":true}"
 | 
			
		||||
	dataJson := []byte(data)
 | 
			
		||||
	pub := `-----BEGIN PUBLIC KEY-----  
 | 
			
		||||
` + PUB + `  
 | 
			
		||||
-----END PUBLIC KEY-----`
 | 
			
		||||
	en, err := Encrypt(pub, dataJson)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return base64.StdEncoding.EncodeToString(en)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
package sm2
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
| 
						 | 
				
			
			@ -16,12 +15,21 @@ func GenerateSM2Key() (PublicKey string, PrivateKey string, err error) {
 | 
			
		|||
	// 生成私钥、公钥
 | 
			
		||||
	privKey, err := sm2.GenerateKey(rand.Reader)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println("生成密钥对失败:", err)
 | 
			
		||||
 | 
			
		||||
		return "", "", err
 | 
			
		||||
	}
 | 
			
		||||
	return PublicKeyToString(&privKey.PublicKey), PrivateKeyToString(privKey), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GenerateKey 生成密钥对
 | 
			
		||||
func GenerateKey() (string, string) {
 | 
			
		||||
	pri, _ := sm2.GenerateKey(rand.Reader)
 | 
			
		||||
	hexPri := pri.D.Text(16)
 | 
			
		||||
	// 获取公钥
 | 
			
		||||
	publicKeyHex := PublicKeyToString(&pri.PublicKey)
 | 
			
		||||
	return strings.ToUpper(hexPri), publicKeyHex
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PublicKeyToString 公钥sm2.PublicKey转字符串(与java中org.bouncycastle.crypto生成的公私钥完全互通使用)
 | 
			
		||||
func PublicKeyToString(publicKey *sm2.PublicKey) string {
 | 
			
		||||
	xBytes := publicKey.X.Bytes()
 | 
			
		||||
| 
						 | 
				
			
			@ -48,27 +56,27 @@ func PrivateKeyToString(privateKey *sm2.PrivateKey) string {
 | 
			
		|||
	return strings.ToUpper(hex.EncodeToString(privateKey.D.Bytes()))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SM2Decrypt(cipherText string) (string, error) {
 | 
			
		||||
func SM2Decrypt(cipherText, publicKey string, privateKey string) (string, error) {
 | 
			
		||||
	if cipherText == "" {
 | 
			
		||||
		return "", nil
 | 
			
		||||
	}
 | 
			
		||||
	decodedBytes, err := base64.StdEncoding.DecodeString(cipherText)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println("解码错误:", err)
 | 
			
		||||
 | 
			
		||||
		return "", nil
 | 
			
		||||
	}
 | 
			
		||||
	decrypt, err := decryptLoc(config.GetConf().Sm2.PublicKey, config.GetConf().Sm2.PrivateKey, string(decodedBytes))
 | 
			
		||||
	decrypt, err := decryptLoc(publicKey, privateKey, string(decodedBytes))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return decrypt, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SM2Encrypt(cipherText string) (string, error) {
 | 
			
		||||
func SM2Encrypt(cipherText string, privateKey string) (string, error) {
 | 
			
		||||
	if cipherText == "" {
 | 
			
		||||
		return "", nil
 | 
			
		||||
	}
 | 
			
		||||
	decrypt, err := encryptLoc(config.GetConf().Sm2.PublicKey, cipherText)
 | 
			
		||||
	decrypt, err := encryptLoc(privateKey, cipherText)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -78,11 +86,11 @@ func SM2Encrypt(cipherText string) (string, error) {
 | 
			
		|||
func encryptLoc(publicKeyStr, data string) (string, error) {
 | 
			
		||||
	publicKeyObj, err := StringToPublicKey(publicKeyStr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println(err)
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	decrypt, err := sm2.Encrypt(publicKeyObj, []byte(data), rand.Reader, sm2.C1C2C3)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println(err)
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	resultStr := hex.EncodeToString(decrypt)
 | 
			
		||||
	return base64.StdEncoding.EncodeToString([]byte(resultStr)), nil
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +111,6 @@ func decryptLoc(publicKeyStr, privateKeyStr, cipherText string) (string, error)
 | 
			
		|||
		fmt.Println(err)
 | 
			
		||||
	}
 | 
			
		||||
	resultStr := string(decrypt)
 | 
			
		||||
	fmt.Println("解密后的字符串:", resultStr)
 | 
			
		||||
	return resultStr, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
package sm2
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	SELF_PRI = "EA7CB6F907A96264D6763F8C46AB96B476538D2ABC880A459E10BE5A1C30013D"
 | 
			
		||||
 | 
			
		||||
	SELF_PUB = "04363DF574D4FE34EE58FB8A3F7CB08E6CA5EBB3B7335CBAE10A2900551F6450AB3AD25DBC0A76EFA9E6D44D2C51E3027483F7BFD09996457888BAFD1AF673817F"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGenerateSM2KeyPair(t *testing.T) {
 | 
			
		||||
	// Generate a new SM2 key pair
 | 
			
		||||
	privateKey, publicKey := GenerateKey()
 | 
			
		||||
 | 
			
		||||
	// Print the private and public keys
 | 
			
		||||
	fmt.Printf("Private Key: %s\n", privateKey)
 | 
			
		||||
	fmt.Printf("Public Key: %s", publicKey)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSM2Encrypt(t *testing.T) {
 | 
			
		||||
	t.Log(encrypt())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSM2Decrypt(t *testing.T) {
 | 
			
		||||
	en := encrypt()
 | 
			
		||||
	decrypt, err := SM2Decrypt(en, SELF_PUB, SELF_PRI)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	t.Log(decrypt)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func encrypt() string {
 | 
			
		||||
	data := "{\"name\":\"张三\",\"sex\":1,\"is_human\":true}"
 | 
			
		||||
	en, err := SM2Encrypt(data, SELF_PUB)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	return en
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
* 来源于 github.com/tjfoc/gmsm
 | 
			
		||||
* 修改适配 邮储对接
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,219 @@
 | 
			
		|||
package sm2
 | 
			
		||||
 | 
			
		||||
// reference to ecdsa
 | 
			
		||||
import (
 | 
			
		||||
	"crypto"
 | 
			
		||||
	"crypto/elliptic"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/asn1"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/tjfoc/gmsm/sm3"
 | 
			
		||||
	"io"
 | 
			
		||||
	"math/big"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	default_uid = []byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PublicKey struct {
 | 
			
		||||
	elliptic.Curve
 | 
			
		||||
	X, Y *big.Int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PrivateKey struct {
 | 
			
		||||
	PublicKey
 | 
			
		||||
	D *big.Int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type sm2Signature struct {
 | 
			
		||||
	R, S *big.Int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (priv *PrivateKey) Public() crypto.PublicKey {
 | 
			
		||||
	return &priv.PublicKey
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var errZeroParam = errors.New("zero parameter")
 | 
			
		||||
var one = new(big.Int).SetInt64(1)
 | 
			
		||||
var two = new(big.Int).SetInt64(2)
 | 
			
		||||
 | 
			
		||||
func (priv *PrivateKey) Sign(random io.Reader, msg []byte, signer crypto.SignerOpts) ([]byte, error) {
 | 
			
		||||
	r, s, err := Sm2Sign(priv, msg, nil, random)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return asn1.Marshal(sm2Signature{r, s})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Sm2Sign(priv *PrivateKey, msg, uid []byte, random io.Reader) (r, s *big.Int, err error) {
 | 
			
		||||
	digest, err := priv.PublicKey.Sm3Digest(msg, uid)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, nil, err
 | 
			
		||||
	}
 | 
			
		||||
	e := new(big.Int).SetBytes(digest)
 | 
			
		||||
	c := priv.PublicKey.Curve
 | 
			
		||||
	N := c.Params().N
 | 
			
		||||
	if N.Sign() == 0 {
 | 
			
		||||
		return nil, nil, errZeroParam
 | 
			
		||||
	}
 | 
			
		||||
	var k *big.Int
 | 
			
		||||
	for { // 调整算法细节以实现SM2
 | 
			
		||||
		for {
 | 
			
		||||
			k, err = randFieldElement(c, random)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				r = nil
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			r, _ = priv.Curve.ScalarBaseMult(k.Bytes())
 | 
			
		||||
			r.Add(r, e)
 | 
			
		||||
			r.Mod(r, N)
 | 
			
		||||
			if r.Sign() != 0 {
 | 
			
		||||
				if t := new(big.Int).Add(r, k); t.Cmp(N) != 0 {
 | 
			
		||||
					break
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		rD := new(big.Int).Mul(priv.D, r)
 | 
			
		||||
		s = new(big.Int).Sub(k, rD)
 | 
			
		||||
		d1 := new(big.Int).Add(priv.D, one)
 | 
			
		||||
		d1Inv := new(big.Int).ModInverse(d1, N)
 | 
			
		||||
		s.Mul(s, d1Inv)
 | 
			
		||||
		s.Mod(s, N)
 | 
			
		||||
		if s.Sign() != 0 {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (pub *PublicKey) Sm3Digest(msg, uid []byte) ([]byte, error) {
 | 
			
		||||
	if len(uid) == 0 {
 | 
			
		||||
		uid = default_uid
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	za, err := getZ(pub, uid)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	e, err := msgHash(za, msg)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return e.Bytes(), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Sm2Verify(pub *PublicKey, msg, uid []byte, r, s *big.Int) bool {
 | 
			
		||||
	c := pub.Curve
 | 
			
		||||
	N := c.Params().N
 | 
			
		||||
	one := new(big.Int).SetInt64(1)
 | 
			
		||||
	if r.Cmp(one) < 0 || s.Cmp(one) < 0 {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if r.Cmp(N) >= 0 || s.Cmp(N) >= 0 {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if len(uid) == 0 {
 | 
			
		||||
		uid = default_uid
 | 
			
		||||
	}
 | 
			
		||||
	za, err := getZ(pub, uid)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	e, err := msgHash(za, msg)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	t := new(big.Int).Add(r, s)
 | 
			
		||||
	t.Mod(t, N)
 | 
			
		||||
	if t.Sign() == 0 {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	var x *big.Int
 | 
			
		||||
	x1, y1 := c.ScalarBaseMult(s.Bytes())
 | 
			
		||||
	x2, y2 := c.ScalarMult(pub.X, pub.Y, t.Bytes())
 | 
			
		||||
	x, _ = c.Add(x1, y1, x2, y2)
 | 
			
		||||
 | 
			
		||||
	x.Add(x, e)
 | 
			
		||||
	x.Mod(x, N)
 | 
			
		||||
	return x.Cmp(r) == 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func msgHash(za, msg []byte) (*big.Int, error) {
 | 
			
		||||
	e := sm3.New()
 | 
			
		||||
	e.Write(za)
 | 
			
		||||
	e.Write(msg)
 | 
			
		||||
	return new(big.Int).SetBytes(e.Sum(nil)[:32]), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func bigIntToByte(n *big.Int) []byte {
 | 
			
		||||
	byteArray := n.Bytes()
 | 
			
		||||
	// If the most significant byte's most significant bit is set,
 | 
			
		||||
	// prepend a 0 byte to the slice to avoid being interpreted as a negative number.
 | 
			
		||||
	if (byteArray[0] & 0x80) != 0 {
 | 
			
		||||
		byteArray = append([]byte{0}, byteArray...)
 | 
			
		||||
	}
 | 
			
		||||
	return byteArray
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getZ(pub *PublicKey, uid []byte) ([]byte, error) {
 | 
			
		||||
	z := sm3.New()
 | 
			
		||||
	uidLen := len(uid) * 8
 | 
			
		||||
	entla := []byte{byte(uidLen >> 8), byte(uidLen & 255)}
 | 
			
		||||
	z.Write(entla)
 | 
			
		||||
	z.Write(uid)
 | 
			
		||||
 | 
			
		||||
	// a 先写死,原来的没有暴露
 | 
			
		||||
	z.Write(bigIntToByte(sm2P256ToBig(&sm2P256.a)))
 | 
			
		||||
	z.Write(bigIntToByte(sm2P256.B))
 | 
			
		||||
	z.Write(bigIntToByte(sm2P256.Gx))
 | 
			
		||||
	z.Write(bigIntToByte(sm2P256.Gy))
 | 
			
		||||
 | 
			
		||||
	z.Write(bigIntToByte(pub.X))
 | 
			
		||||
	z.Write(bigIntToByte(pub.Y))
 | 
			
		||||
	return z.Sum(nil), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func randFieldElement(c elliptic.Curve, random io.Reader) (k *big.Int, err error) {
 | 
			
		||||
	if random == nil {
 | 
			
		||||
		random = rand.Reader //If there is no external trusted random source,please use rand.Reader to instead of it.
 | 
			
		||||
	}
 | 
			
		||||
	params := c.Params()
 | 
			
		||||
	b := make([]byte, params.BitSize/8+8)
 | 
			
		||||
	_, err = io.ReadFull(random, b)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	k = new(big.Int).SetBytes(b)
 | 
			
		||||
	n := new(big.Int).Sub(params.N, one)
 | 
			
		||||
	k.Mod(k, n)
 | 
			
		||||
	k.Add(k, one)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GenerateKey(random io.Reader) (*PrivateKey, error) {
 | 
			
		||||
	c := P256Sm2()
 | 
			
		||||
	if random == nil {
 | 
			
		||||
		random = rand.Reader //If there is no external trusted random source,please use rand.Reader to instead of it.
 | 
			
		||||
	}
 | 
			
		||||
	params := c.Params()
 | 
			
		||||
	b := make([]byte, params.BitSize/8+8)
 | 
			
		||||
	_, err := io.ReadFull(random, b)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	k := new(big.Int).SetBytes(b)
 | 
			
		||||
	n := new(big.Int).Sub(params.N, two)
 | 
			
		||||
	k.Mod(k, n)
 | 
			
		||||
	k.Add(k, one)
 | 
			
		||||
	priv := new(PrivateKey)
 | 
			
		||||
	priv.PublicKey.Curve = c
 | 
			
		||||
	priv.D = k
 | 
			
		||||
	priv.PublicKey.X, priv.PublicKey.Y = c.ScalarBaseMult(k.Bytes())
 | 
			
		||||
 | 
			
		||||
	return priv, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
package sm2
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"math/big"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func ReadPrivateKeyFromHex(Dhex string) (*PrivateKey, error) {
 | 
			
		||||
	c := P256Sm2()
 | 
			
		||||
	d, err := hex.DecodeString(Dhex)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	k := new(big.Int).SetBytes(d)
 | 
			
		||||
	params := c.Params()
 | 
			
		||||
	one := new(big.Int).SetInt64(1)
 | 
			
		||||
	n := new(big.Int).Sub(params.N, one)
 | 
			
		||||
	if k.Cmp(n) >= 0 {
 | 
			
		||||
		return nil, errors.New("privateKey's D is overflow.")
 | 
			
		||||
	}
 | 
			
		||||
	priv := new(PrivateKey)
 | 
			
		||||
	priv.PublicKey.Curve = c
 | 
			
		||||
	priv.D = k
 | 
			
		||||
	priv.PublicKey.X, priv.PublicKey.Y = c.ScalarBaseMult(k.Bytes())
 | 
			
		||||
	return priv, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ReadPublicKeyFromHex(Qhex string) (*PublicKey, error) {
 | 
			
		||||
	q, err := hex.DecodeString(Qhex)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if len(q) == 65 && q[0] == byte(0x04) {
 | 
			
		||||
		q = q[1:]
 | 
			
		||||
	}
 | 
			
		||||
	if len(q) != 64 {
 | 
			
		||||
		return nil, errors.New("publicKey is not uncompressed.")
 | 
			
		||||
	}
 | 
			
		||||
	pub := new(PublicKey)
 | 
			
		||||
	pub.Curve = P256Sm2()
 | 
			
		||||
	pub.X = new(big.Int).SetBytes(q[:32])
 | 
			
		||||
	pub.Y = new(big.Int).SetBytes(q[32:])
 | 
			
		||||
	return pub, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,163 @@
 | 
			
		|||
package util
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/utils/encrypt/sm4/internal/sm2"
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"crypto/elliptic"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"errors"
 | 
			
		||||
	zzsm2 "github.com/ZZMarquis/gm/sm2"
 | 
			
		||||
	"github.com/tjfoc/gmsm/sm3"
 | 
			
		||||
	"github.com/tjfoc/gmsm/x509"
 | 
			
		||||
	"math/big"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Sm2Decrypt(privateKey *sm2.PrivateKey, encryptData []byte) ([]byte, error) {
 | 
			
		||||
	C1Byte := make([]byte, 65)
 | 
			
		||||
	copy(C1Byte, encryptData[:65])
 | 
			
		||||
	x, y := elliptic.Unmarshal(privateKey.Curve, C1Byte)
 | 
			
		||||
	dBC1X, dBC1Y := privateKey.Curve.ScalarMult(x, y, bigIntToByte(privateKey.D))
 | 
			
		||||
	dBC1Bytes := elliptic.Marshal(privateKey.Curve, dBC1X, dBC1Y)
 | 
			
		||||
 | 
			
		||||
	kLen := len(encryptData) - 65 - 32
 | 
			
		||||
	t, err := kdf(dBC1Bytes, kLen)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	M := make([]byte, kLen)
 | 
			
		||||
	for i := 0; i < kLen; i++ {
 | 
			
		||||
		M[i] = encryptData[65+i] ^ t[i]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	C3 := make([]byte, 32)
 | 
			
		||||
	copy(C3, encryptData[len(encryptData)-32:])
 | 
			
		||||
	u := calculateHash(dBC1X, M, dBC1Y)
 | 
			
		||||
 | 
			
		||||
	if bytes.Compare(u, C3) == 0 {
 | 
			
		||||
		return M, nil
 | 
			
		||||
	} else {
 | 
			
		||||
		return nil, errors.New("解密失败")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Sm2Encrypt(publicKey *sm2.PublicKey, m []byte) ([]byte, error) {
 | 
			
		||||
	kLen := len(m)
 | 
			
		||||
	var C1, t []byte
 | 
			
		||||
	var err error
 | 
			
		||||
	var kx, ky *big.Int
 | 
			
		||||
	for {
 | 
			
		||||
		k, _ := rand.Int(rand.Reader, publicKey.Params().N)
 | 
			
		||||
		C1x, C1y := zzsm2.GetSm2P256V1().ScalarBaseMult(bigIntToByte(k))
 | 
			
		||||
		// C1x, C1y := sm2.P256Sm2().ScalarBaseMult(bigIntToByte(k))
 | 
			
		||||
		C1 = elliptic.Marshal(publicKey.Curve, C1x, C1y)
 | 
			
		||||
 | 
			
		||||
		kx, ky = publicKey.ScalarMult(publicKey.X, publicKey.Y, bigIntToByte(k))
 | 
			
		||||
		kpbBytes := elliptic.Marshal(publicKey, kx, ky)
 | 
			
		||||
		t, err = kdf(kpbBytes, kLen)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		if !isAllZero(t) {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	C2 := make([]byte, kLen)
 | 
			
		||||
	for i := 0; i < kLen; i++ {
 | 
			
		||||
		C2[i] = m[i] ^ t[i]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	C3 := calculateHash(kx, m, ky)
 | 
			
		||||
 | 
			
		||||
	r := make([]byte, 0, len(C1)+len(C2)+len(C3))
 | 
			
		||||
	r = append(r, C1...)
 | 
			
		||||
	r = append(r, C2...)
 | 
			
		||||
	r = append(r, C3...)
 | 
			
		||||
	return r, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func isAllZero(m []byte) bool {
 | 
			
		||||
	for i := 0; i < len(m); i++ {
 | 
			
		||||
		if m[i] != 0 {
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func calculateHash(x *big.Int, M []byte, y *big.Int) []byte {
 | 
			
		||||
	digest := sm3.New()
 | 
			
		||||
	digest.Write(bigIntToByte(x))
 | 
			
		||||
	digest.Write(M)
 | 
			
		||||
	digest.Write(bigIntToByte(y))
 | 
			
		||||
	result := digest.Sum(nil)[:32]
 | 
			
		||||
	return result
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func bigIntToByte(n *big.Int) []byte {
 | 
			
		||||
	byteArray := n.Bytes()
 | 
			
		||||
	// If the most significant byte's most significant bit is set,
 | 
			
		||||
	// prepend a 0 byte to the slice to avoid being interpreted as a negative number.
 | 
			
		||||
	if (byteArray[0] & 0x80) != 0 {
 | 
			
		||||
		byteArray = append([]byte{0}, byteArray...)
 | 
			
		||||
	}
 | 
			
		||||
	return byteArray
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func kdf(Z []byte, klen int) ([]byte, error) {
 | 
			
		||||
	ct := 1
 | 
			
		||||
	end := (klen + 31) / 32
 | 
			
		||||
	result := make([]byte, 0)
 | 
			
		||||
	for i := 1; i <= end; i++ {
 | 
			
		||||
		b, err := sm3hash(Z, toByteArray(ct))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		result = append(result, b...)
 | 
			
		||||
		ct++
 | 
			
		||||
	}
 | 
			
		||||
	last, err := sm3hash(Z, toByteArray(ct))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if klen%32 == 0 {
 | 
			
		||||
		result = append(result, last...)
 | 
			
		||||
	} else {
 | 
			
		||||
		result = append(result, last[:klen%32]...)
 | 
			
		||||
	}
 | 
			
		||||
	return result, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func sm3hash(sources ...[]byte) ([]byte, error) {
 | 
			
		||||
	b, err := joinBytes(sources...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	md := make([]byte, 32)
 | 
			
		||||
	h := x509.SM3.New()
 | 
			
		||||
	h.Write(b)
 | 
			
		||||
	h.Sum(md[:0])
 | 
			
		||||
	return md, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func joinBytes(params ...[]byte) ([]byte, error) {
 | 
			
		||||
	var buffer bytes.Buffer
 | 
			
		||||
	for i := 0; i < len(params); i++ {
 | 
			
		||||
		_, err := buffer.Write(params[i])
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return buffer.Bytes(), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func toByteArray(i int) []byte {
 | 
			
		||||
	byteArray := []byte{
 | 
			
		||||
		byte(i >> 24),
 | 
			
		||||
		byte((i & 16777215) >> 16),
 | 
			
		||||
		byte((i & 65535) >> 8),
 | 
			
		||||
		byte(i & 255),
 | 
			
		||||
	}
 | 
			
		||||
	return byteArray
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,62 @@
 | 
			
		|||
package util
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/md5"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"math/big"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func GenerateSM4Key() []byte {
 | 
			
		||||
	str := "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
 | 
			
		||||
	buffer := make([]byte, 16)
 | 
			
		||||
	for i := 0; i < 16; i++ {
 | 
			
		||||
		nextInt, _ := rand.Int(rand.Reader, big.NewInt(int64(len(str))))
 | 
			
		||||
		buffer[i] = str[nextInt.Int64()]
 | 
			
		||||
	}
 | 
			
		||||
	return buffer
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GenAccessToken(token string) string {
 | 
			
		||||
	if token != "" {
 | 
			
		||||
		return token
 | 
			
		||||
	}
 | 
			
		||||
	now := time.Now()
 | 
			
		||||
	return strings.ToUpper(Md5Hash(now.Format("2006A01B02CD15E04F05"), ""))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Md5Hash(password, salt string) string {
 | 
			
		||||
	m := md5.New()
 | 
			
		||||
	m.Write([]byte(salt + password))
 | 
			
		||||
	return hex.EncodeToString(m.Sum(nil))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetSM4IV 获取SM4的IV
 | 
			
		||||
func GetSM4IV() []byte {
 | 
			
		||||
	return []byte("UISwD9fW6cFh9SNS")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Padding(input []byte, mode int) []byte {
 | 
			
		||||
	if input == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	} else {
 | 
			
		||||
		var ret []byte
 | 
			
		||||
		if mode == 1 {
 | 
			
		||||
			p := 16 - len(input)%16
 | 
			
		||||
			ret = make([]byte, len(input)+p)
 | 
			
		||||
			copy(ret, input)
 | 
			
		||||
 | 
			
		||||
			for i := 0; i < p; i++ {
 | 
			
		||||
				ret[len(input)+i] = byte(p)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			p := input[len(input)-1]
 | 
			
		||||
			ret = make([]byte, len(input)-int(p))
 | 
			
		||||
			copy(ret, input[:len(input)-int(p)])
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return ret
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,203 @@
 | 
			
		|||
package sm4
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/utils/encrypt/sm4/internal/sm2"
 | 
			
		||||
	"PaymentCenter/app/utils/encrypt/sm4/internal/util"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/ZZMarquis/gm/sm4"
 | 
			
		||||
	"math/big"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func checkInData(reqData map[string]string, key string) (string, error) {
 | 
			
		||||
	data, ok := reqData[key]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return "", errors.New("请求数据中不存在" + key)
 | 
			
		||||
	}
 | 
			
		||||
	return data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Sm4Decrypt(merchantId, privateKey, sopPublicKey, respJson string, isRequest bool) (string, error) {
 | 
			
		||||
	var reqData map[string]string
 | 
			
		||||
	err := json.Unmarshal([]byte(respJson), &reqData)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	keys := [4]string{}
 | 
			
		||||
	if isRequest {
 | 
			
		||||
		keys = [4]string{"request", "signature", "encryptKey", "accessToken"}
 | 
			
		||||
	} else {
 | 
			
		||||
		keys = [4]string{"response", "signature", "encryptKey", "accessToken"}
 | 
			
		||||
	}
 | 
			
		||||
	var inEncryptKey, inAccessToken, inData, inSignature string
 | 
			
		||||
 | 
			
		||||
	for i := 0; i < 4; i++ {
 | 
			
		||||
		data, err := checkInData(reqData, keys[i])
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
		switch keys[i] {
 | 
			
		||||
		case "request", "response":
 | 
			
		||||
			inData = data
 | 
			
		||||
		case "signature":
 | 
			
		||||
			inSignature = data
 | 
			
		||||
		case "encryptKey":
 | 
			
		||||
			inEncryptKey = data
 | 
			
		||||
		case "accessToken":
 | 
			
		||||
			inAccessToken = data
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	checked := verify(fmt.Sprintf("%s%s%s", inData, inEncryptKey, inAccessToken), inSignature, sopPublicKey, merchantId)
 | 
			
		||||
	if !checked {
 | 
			
		||||
		return "", errors.New("签名验证失败")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	priKey, err := sm2.ReadPrivateKeyFromHex(privateKey)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errors.New("读取私钥失败")
 | 
			
		||||
	}
 | 
			
		||||
	hexEncryptKey, err := hex.DecodeString(inEncryptKey)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errors.New("解密sm4key失败")
 | 
			
		||||
	}
 | 
			
		||||
	sm4Key, err := util.Sm2Decrypt(priKey, hexEncryptKey)
 | 
			
		||||
 | 
			
		||||
	request, _ := base64.StdEncoding.DecodeString(inData)
 | 
			
		||||
 | 
			
		||||
	encryptedSm4Key, err := sm4.CBCDecrypt(sm4Key, util.GetSM4IV(), request)
 | 
			
		||||
 | 
			
		||||
	return string(util.Padding(encryptedSm4Key, 0)), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Sm4Encrypt(merchantId, privateKey, sopPublicKey, inputJson, token string, isRequest bool) (string, error) {
 | 
			
		||||
	sm4Key := util.GenerateSM4Key()
 | 
			
		||||
	iv := util.GetSM4IV()
 | 
			
		||||
	tmp, err := sm4.CBCEncrypt(sm4Key, iv, util.Padding([]byte(inputJson), 1))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	responseMsg := base64.StdEncoding.EncodeToString(tmp)
 | 
			
		||||
	responseMsg = addNewline(responseMsg)
 | 
			
		||||
 | 
			
		||||
	pubKey, err := sm2.ReadPublicKeyFromHex(sopPublicKey)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", errors.New("读取私钥失败")
 | 
			
		||||
	}
 | 
			
		||||
	encryptKeyBytes, err := util.Sm2Encrypt(pubKey, sm4Key)
 | 
			
		||||
	encryptKey := strings.ToUpper(hex.EncodeToString(encryptKeyBytes))
 | 
			
		||||
 | 
			
		||||
	accessToken := util.GenAccessToken(token)
 | 
			
		||||
	signContent := fmt.Sprintf("%s%s%s", responseMsg, encryptKey, accessToken)
 | 
			
		||||
	signature, err := sign(merchantId, privateKey, signContent)
 | 
			
		||||
 | 
			
		||||
	var reqData map[string]string
 | 
			
		||||
 | 
			
		||||
	if isRequest {
 | 
			
		||||
		reqData = map[string]string{
 | 
			
		||||
			"request":     responseMsg,
 | 
			
		||||
			"signature":   signature,
 | 
			
		||||
			"encryptKey":  encryptKey,
 | 
			
		||||
			"accessToken": accessToken,
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		reqData = map[string]string{
 | 
			
		||||
			"response":    responseMsg,
 | 
			
		||||
			"signature":   signature,
 | 
			
		||||
			"encryptKey":  encryptKey,
 | 
			
		||||
			"accessToken": accessToken,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	jsonStr, err := json.Marshal(reqData)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return string(jsonStr), err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GenerateKey 生成密钥对
 | 
			
		||||
func GenerateKey() (string, string) {
 | 
			
		||||
	pri, _ := sm2.GenerateKey(rand.Reader)
 | 
			
		||||
	hexPri := pri.D.Text(16)
 | 
			
		||||
	// 获取公钥
 | 
			
		||||
	publicKeyHex := publicKeyToString(&pri.PublicKey)
 | 
			
		||||
	return strings.ToUpper(hexPri), publicKeyHex
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// publicKeyToString 公钥sm2.PublicKey转字符串(与java中org.bouncycastle.crypto生成的公私钥完全互通使用)
 | 
			
		||||
func publicKeyToString(publicKey *sm2.PublicKey) string {
 | 
			
		||||
	xBytes := publicKey.X.Bytes()
 | 
			
		||||
	yBytes := publicKey.Y.Bytes()
 | 
			
		||||
 | 
			
		||||
	// 确保坐标字节切片长度相同
 | 
			
		||||
	byteLen := len(xBytes)
 | 
			
		||||
	if len(yBytes) > byteLen {
 | 
			
		||||
		byteLen = len(yBytes)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 为坐标补齐前导零
 | 
			
		||||
	xBytes = append(make([]byte, byteLen-len(xBytes)), xBytes...)
 | 
			
		||||
	yBytes = append(make([]byte, byteLen-len(yBytes)), yBytes...)
 | 
			
		||||
 | 
			
		||||
	// 添加 "04" 前缀
 | 
			
		||||
	publicKeyBytes := append([]byte{0x04}, append(xBytes, yBytes...)...)
 | 
			
		||||
 | 
			
		||||
	return strings.ToUpper(hex.EncodeToString(publicKeyBytes))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func addNewline(str string) string {
 | 
			
		||||
	lineLength := 76
 | 
			
		||||
	var result strings.Builder
 | 
			
		||||
	for i := 0; i < len(str); i++ {
 | 
			
		||||
		if i > 0 && i%lineLength == 0 {
 | 
			
		||||
			result.WriteString("\r\n")
 | 
			
		||||
		}
 | 
			
		||||
		result.WriteByte(str[i])
 | 
			
		||||
	}
 | 
			
		||||
	return result.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func sign(merchantId string, privateKeyHex string, signContent string) (string, error) {
 | 
			
		||||
	privateKey, err := sm2.ReadPrivateKeyFromHex(privateKeyHex)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	r, s, err := sm2.Sm2Sign(privateKey, []byte(signContent), []byte(merchantId), rand.Reader)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return rSToSign(r, s), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func verify(content string, signature string, publicKeyStr string, merchantId string) bool {
 | 
			
		||||
	pubKey, err := sm2.ReadPublicKeyFromHex(publicKeyStr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(fmt.Sprintf("pubKeyBytes sm2 ReadPublicKeyFromHex err: %v", err))
 | 
			
		||||
	}
 | 
			
		||||
	r, s := signToRS(signature)
 | 
			
		||||
	return sm2.Sm2Verify(pubKey, []byte(content), []byte(merchantId), r, s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func signToRS(signStr string) (*big.Int, *big.Int) {
 | 
			
		||||
	signSub := strings.Split(signStr, "#")
 | 
			
		||||
	if len(signSub) != 2 {
 | 
			
		||||
		panic(fmt.Sprintf("err rs: %x", signSub))
 | 
			
		||||
	}
 | 
			
		||||
	r, _ := new(big.Int).SetString(signSub[0], 16)
 | 
			
		||||
	s, _ := new(big.Int).SetString(signSub[1], 16)
 | 
			
		||||
	return r, s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func rSToSign(r *big.Int, s *big.Int) string {
 | 
			
		||||
	rStr := r.Text(16)
 | 
			
		||||
	sStr := s.Text(16)
 | 
			
		||||
	return fmt.Sprintf("%s#%s", rStr, sStr)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,44 @@
 | 
			
		|||
package sm4
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	SELF_PRI = "EA7CB6F907A96264D6763F8C46AB96B476538D2ABC880A459E10BE5A1C30013D"
 | 
			
		||||
 | 
			
		||||
	SELF_PUB = "04363DF574D4FE34EE58FB8A3F7CB08E6CA5EBB3B7335CBAE10A2900551F6450AB3AD25DBC0A76EFA9E6D44D2C51E3027483F7BFD09996457888BAFD1AF673817F"
 | 
			
		||||
 | 
			
		||||
	PARTY_PRI = "EEB0A34DE1F05154E4B96E50BFC1F8B9750EEAE799F5708C7AFBABB9AFCFA1BF"
 | 
			
		||||
 | 
			
		||||
	PARTY_PUB = "0420425DF33945C9D5596A33ED60ABEEFD0165C27BA7D6C95D37344E9223149FEAF4C10CEACD7EC88E8DD1E0BDEA71FD09BE2077A1BDC61BC45587B7CC3613F85A"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGenerateKey(t *testing.T) {
 | 
			
		||||
	hexPri, publicKeyHex := GenerateKey()
 | 
			
		||||
	fmt.Println(hexPri, publicKeyHex)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSM4Encrypt(t *testing.T) {
 | 
			
		||||
	t.Log(encrypt())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSM4Decrypt(t *testing.T) {
 | 
			
		||||
	uid, en := encrypt()
 | 
			
		||||
	decrypt, err := Sm4Decrypt(uid, SELF_PRI, PARTY_PUB, en, true)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	t.Log(decrypt)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func encrypt() (string, string) {
 | 
			
		||||
	uid := "1234567890"
 | 
			
		||||
	data := "{\"name\":\"张三\",\"sex\":1,\"is_human\":true}"
 | 
			
		||||
	en, err := Sm4Encrypt(uid, PARTY_PRI, SELF_PUB, data, "", true)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	return uid, en
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,89 +1,89 @@
 | 
			
		|||
package mq
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"PaymentCenter/app/utils"
 | 
			
		||||
	"PaymentCenter/config"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/Shopify/sarama"
 | 
			
		||||
	"github.com/qit-team/snow-core/redis"
 | 
			
		||||
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"sync"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type KafkaMq struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 同步
 | 
			
		||||
func (n KafkaMq) Produce(name string, log interface{}, delayTime int, args ...interface{}) error {
 | 
			
		||||
	kafConfig := sarama.NewConfig()
 | 
			
		||||
	kafConfig.Producer.RequiredAcks = sarama.WaitForAll          // 发送完数据需要leader和follow都确认
 | 
			
		||||
	kafConfig.Producer.Partitioner = sarama.NewRandomPartitioner // 新选出一个partition
 | 
			
		||||
	kafConfig.Producer.Return.Successes = true                   // 成功交付的消息将在success channel返回
 | 
			
		||||
 | 
			
		||||
	// 构造一个消息
 | 
			
		||||
	msg := &sarama.ProducerMessage{}
 | 
			
		||||
	msg.Topic = name
 | 
			
		||||
	var data, _ = json.Marshal(log)
 | 
			
		||||
	msg.Value = sarama.StringEncoder(string(data))
 | 
			
		||||
	// 连接kafka
 | 
			
		||||
	client, err := sarama.NewSyncProducer(config.GetConf().KafkaUrl, kafConfig)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println("producer closed, err:", err)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	defer client.Close()
 | 
			
		||||
	// 发送消息
 | 
			
		||||
	pid, offset, err := client.SendMessage(msg)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		utils.Log(nil, "send msg failed, err:", err, pid, offset)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n KafkaMq) Consume(name string, hand interface{}) {
 | 
			
		||||
	consumer, err := sarama.NewConsumer(config.GetConf().KafkaUrl, nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		utils.Log(nil, "kafka comsume", err.Error())
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	partitionList, err := consumer.Partitions(name) // 根据topic取到所有的分区
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		utils.Log(nil, "kafka comsume", err.Error())
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	//utils.Log(nil,"kafka comsume",name,partitionList)
 | 
			
		||||
	for partition := range partitionList { // 遍历所有的分区
 | 
			
		||||
		// 针对每个分区创建一个对应的分区消费者
 | 
			
		||||
		var offsetReDis, _ = redis.GetRedis().Incr(context.Background(), "kafka_consume:"+strconv.Itoa(int(partition))).Result() //保证多消费者不重复消费
 | 
			
		||||
		var offset int64 = sarama.OffsetNewest
 | 
			
		||||
		if offsetReDis > 0 {
 | 
			
		||||
			//offset = int64(offsetReDis)
 | 
			
		||||
		}
 | 
			
		||||
		pc, err := consumer.ConsumePartition(name, int32(partition), offset)
 | 
			
		||||
		//utils.Log(nil,"partion",int32(partition))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Printf("failed to start consumer for partition %d,err:%v\n", partition, err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		defer pc.AsyncClose()
 | 
			
		||||
		var wg sync.WaitGroup
 | 
			
		||||
		wg.Add(1)
 | 
			
		||||
		// 异步从每个分区消费信息
 | 
			
		||||
		go func(sarama.PartitionConsumer) {
 | 
			
		||||
			for msg := range pc.Messages() {
 | 
			
		||||
				defer wg.Done()
 | 
			
		||||
				var handler = hand.(func(tag uint64, ch interface{}, msg []byte))
 | 
			
		||||
				handler(0, nil, msg.Value)
 | 
			
		||||
				//utils.Log(nil,"hand msg",string(msg.Value),msg.Offset)
 | 
			
		||||
			}
 | 
			
		||||
		}(pc)
 | 
			
		||||
		wg.Wait()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
func (n KafkaMq) DelyConsume(name string, hand interface{}) {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
//
 | 
			
		||||
//import (
 | 
			
		||||
//	"PaymentCenter/app/utils"
 | 
			
		||||
//	"PaymentCenter/config"
 | 
			
		||||
//	"context"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"github.com/Shopify/sarama"
 | 
			
		||||
//	"github.com/qit-team/snow-core/redis"
 | 
			
		||||
//
 | 
			
		||||
//	"strconv"
 | 
			
		||||
//	"sync"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//type KafkaMq struct {
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//// 同步
 | 
			
		||||
//func (n KafkaMq) Produce(name string, log interface{}, delayTime int, args ...interface{}) error {
 | 
			
		||||
//	//kafConfig := sarama.NewConfig()
 | 
			
		||||
//	//kafConfig.Producer.RequiredAcks = sarama.WaitForAll          // 发送完数据需要leader和follow都确认
 | 
			
		||||
//	//kafConfig.Producer.Partitioner = sarama.NewRandomPartitioner // 新选出一个partition
 | 
			
		||||
//	//kafConfig.Producer.Return.Successes = true                   // 成功交付的消息将在success channel返回
 | 
			
		||||
//	//
 | 
			
		||||
//	//// 构造一个消息
 | 
			
		||||
//	//msg := &sarama.ProducerMessage{}
 | 
			
		||||
//	//msg.Topic = name
 | 
			
		||||
//	//var data, _ = json.Marshal(log)
 | 
			
		||||
//	//msg.Value = sarama.StringEncoder(string(data))
 | 
			
		||||
//	//// 连接kafka
 | 
			
		||||
//	//client, err := sarama.NewSyncProducer(config.GetConf().KafkaUrl, kafConfig)
 | 
			
		||||
//	//if err != nil {
 | 
			
		||||
//	//	fmt.Println("producer closed, err:", err)
 | 
			
		||||
//	//	return nil
 | 
			
		||||
//	//}
 | 
			
		||||
//	//defer client.Close()
 | 
			
		||||
//	//// 发送消息
 | 
			
		||||
//	//pid, offset, err := client.SendMessage(msg)
 | 
			
		||||
//	//if err != nil {
 | 
			
		||||
//	//	utils.Log(nil, "send msg failed, err:", err, pid, offset)
 | 
			
		||||
//	//	return nil
 | 
			
		||||
//	//}
 | 
			
		||||
//	return nil
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func (n KafkaMq) Consume(name string, hand interface{}) {
 | 
			
		||||
//	consumer, err := sarama.NewConsumer(config.GetConf().KafkaUrl, nil)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		utils.Log(nil, "kafka comsume", err.Error())
 | 
			
		||||
//		return
 | 
			
		||||
//	}
 | 
			
		||||
//	partitionList, err := consumer.Partitions(name) // 根据topic取到所有的分区
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		utils.Log(nil, "kafka comsume", err.Error())
 | 
			
		||||
//		return
 | 
			
		||||
//	}
 | 
			
		||||
//	//utils.Log(nil,"kafka comsume",name,partitionList)
 | 
			
		||||
//	for partition := range partitionList { // 遍历所有的分区
 | 
			
		||||
//		// 针对每个分区创建一个对应的分区消费者
 | 
			
		||||
//		var offsetReDis, _ = redis.GetRedis().Incr(context.Background(), "kafka_consume:"+strconv.Itoa(int(partition))).Result() //保证多消费者不重复消费
 | 
			
		||||
//		var offset int64 = sarama.OffsetNewest
 | 
			
		||||
//		if offsetReDis > 0 {
 | 
			
		||||
//			//offset = int64(offsetReDis)
 | 
			
		||||
//		}
 | 
			
		||||
//		pc, err := consumer.ConsumePartition(name, int32(partition), offset)
 | 
			
		||||
//		//utils.Log(nil,"partion",int32(partition))
 | 
			
		||||
//		if err != nil {
 | 
			
		||||
//			fmt.Printf("failed to start consumer for partition %d,err:%v\n", partition, err)
 | 
			
		||||
//			return
 | 
			
		||||
//		}
 | 
			
		||||
//		defer pc.AsyncClose()
 | 
			
		||||
//		var wg sync.WaitGroup
 | 
			
		||||
//		wg.Add(1)
 | 
			
		||||
//		// 异步从每个分区消费信息
 | 
			
		||||
//		go func(sarama.PartitionConsumer) {
 | 
			
		||||
//			for msg := range pc.Messages() {
 | 
			
		||||
//				defer wg.Done()
 | 
			
		||||
//				var handler = hand.(func(tag uint64, ch interface{}, msg []byte))
 | 
			
		||||
//				handler(0, nil, msg.Value)
 | 
			
		||||
//				//utils.Log(nil,"hand msg",string(msg.Value),msg.Offset)
 | 
			
		||||
//			}
 | 
			
		||||
//		}(pc)
 | 
			
		||||
//		wg.Wait()
 | 
			
		||||
//	}
 | 
			
		||||
//}
 | 
			
		||||
//func (n KafkaMq) DelyConsume(name string, hand interface{}) {
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ import (
 | 
			
		|||
	"encoding/hex"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/aliyun/aliyun-oss-go-sdk/oss"
 | 
			
		||||
	"github.com/bytedance/sonic"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"github.com/golang-jwt/jwt/v4"
 | 
			
		||||
	"github.com/pkg/errors"
 | 
			
		||||
| 
						 | 
				
			
			@ -411,6 +412,35 @@ func ParseToken(tokenString string) (*jwt.Token, *Claims, error) {
 | 
			
		|||
	return token, Claims, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func PopLast[T any](slice *[]T) (T, bool) {
 | 
			
		||||
	if len(*slice) == 0 {
 | 
			
		||||
		var zero T
 | 
			
		||||
		return zero, false
 | 
			
		||||
	}
 | 
			
		||||
	index := len(*slice) - 1
 | 
			
		||||
	lastElement := (*slice)[index]
 | 
			
		||||
	*slice = (*slice)[:index] // 移除最后一个元素
 | 
			
		||||
	return lastElement, true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SonicApiDataToStruct(data interface{}, structInterFace interface{}) (dataStruct interface{}, err error) {
 | 
			
		||||
	bytes, err := sonic.Marshal(data)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	err = sonic.Unmarshal(bytes, &structInterFace)
 | 
			
		||||
	return structInterFace, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ContainsString(slice []string, s string) bool {
 | 
			
		||||
	for _, item := range slice {
 | 
			
		||||
		if item == s {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 判断切片是否包含指定字符串
 | 
			
		||||
func SliceInStr(s string, slice []string) bool {
 | 
			
		||||
	for _, v := range slice {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,7 @@ type Config struct {
 | 
			
		|||
	Debug                   bool               `toml:"Debug"`
 | 
			
		||||
	PrometheusCollectEnable bool               `toml:"PrometheusCollectEnable"`
 | 
			
		||||
	SkyWalkingOapServer     string             `toml:"SkyWalkingOapServer"`
 | 
			
		||||
	TimeOut                 int64              `toml:"TimeOut"`
 | 
			
		||||
	Log                     config.LogConfig   `toml:"Log"`
 | 
			
		||||
	Redis                   config.RedisConfig `toml:"Redis"`
 | 
			
		||||
	Mns                     config.MnsConfig   `toml:"AliMns"`
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +38,7 @@ type Config struct {
 | 
			
		|||
	Jwt                     Jwt                `toml:"Jwt"`
 | 
			
		||||
	AliOss                  AliOss             `toml:"AliOss"`
 | 
			
		||||
	AdminGate               []string           `toml:"AdminGate"`
 | 
			
		||||
	CronConfig              CronConfig         `toml:"CronConfig"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type AliOss struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -83,6 +85,12 @@ type Nacos struct {
 | 
			
		|||
	Port int64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type CronConfig struct {
 | 
			
		||||
	CloseOrderTime   int `toml:"CloseOrderTime"`
 | 
			
		||||
	QueryOrderTime   int `toml:"QueryOrderTime"`
 | 
			
		||||
	ConcurrentNumber int `toml:"ConcurrentNumber"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newConfig() *Config {
 | 
			
		||||
	return new(Config)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										10
									
								
								go.mod
								
								
								
								
							| 
						 | 
				
			
			@ -6,8 +6,10 @@ require (
 | 
			
		|||
	gitee.com/chengdu_blue_brothers/openapi-go-sdk v0.0.2
 | 
			
		||||
	github.com/BurntSushi/toml v0.4.1
 | 
			
		||||
	github.com/Shopify/sarama v1.19.0
 | 
			
		||||
	github.com/ZZMarquis/gm v1.3.2
 | 
			
		||||
	github.com/ahmetb/go-linq/v3 v3.2.0
 | 
			
		||||
	github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
 | 
			
		||||
	github.com/bytedance/sonic v1.10.2
 | 
			
		||||
	github.com/forgoer/openssl v1.6.0
 | 
			
		||||
	github.com/gin-gonic/gin v1.7.7
 | 
			
		||||
	github.com/go-pay/gopay v1.5.103
 | 
			
		||||
| 
						 | 
				
			
			@ -23,6 +25,7 @@ require (
 | 
			
		|||
	github.com/qit-team/snow-core v0.1.28
 | 
			
		||||
	github.com/qit-team/work v0.3.11
 | 
			
		||||
	github.com/robfig/cron v1.2.0
 | 
			
		||||
	github.com/spf13/cobra v1.2.1
 | 
			
		||||
	github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
 | 
			
		||||
	github.com/swaggo/gin-swagger v1.3.3
 | 
			
		||||
	github.com/swaggo/swag v1.7.9
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +53,8 @@ require (
 | 
			
		|||
	github.com/beorn7/perks v1.0.1 // indirect
 | 
			
		||||
	github.com/buger/jsonparser v1.1.1 // indirect
 | 
			
		||||
	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 | 
			
		||||
	github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
 | 
			
		||||
	github.com/chenzhuoyu/iasm v0.9.1 // indirect
 | 
			
		||||
	github.com/davecgh/go-spew v1.1.1 // indirect
 | 
			
		||||
	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 | 
			
		||||
	github.com/eapache/go-resiliency v1.1.0 // indirect
 | 
			
		||||
| 
						 | 
				
			
			@ -76,10 +81,12 @@ require (
 | 
			
		|||
	github.com/google/uuid v1.3.0 // indirect
 | 
			
		||||
	github.com/hetiansu5/accesslog v1.0.0 // indirect
 | 
			
		||||
	github.com/hetiansu5/cores v1.0.0 // indirect
 | 
			
		||||
	github.com/inconshreveable/mousetrap v1.0.0 // indirect
 | 
			
		||||
	github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
 | 
			
		||||
	github.com/josharian/intern v1.0.0 // indirect
 | 
			
		||||
	github.com/json-iterator/go v1.1.12 // indirect
 | 
			
		||||
	github.com/klauspost/compress v1.13.6 // indirect
 | 
			
		||||
	github.com/klauspost/cpuid/v2 v2.2.6 // indirect
 | 
			
		||||
	github.com/leodido/go-urn v1.2.1 // indirect
 | 
			
		||||
	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
 | 
			
		||||
	github.com/lestrrat-go/strftime v1.0.5 // indirect
 | 
			
		||||
| 
						 | 
				
			
			@ -98,16 +105,19 @@ require (
 | 
			
		|||
	github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
 | 
			
		||||
	github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 // indirect
 | 
			
		||||
	github.com/sirupsen/logrus v1.8.1 // indirect
 | 
			
		||||
	github.com/spf13/pflag v1.0.5 // indirect
 | 
			
		||||
	github.com/syndtr/goleveldb v1.0.0 // indirect
 | 
			
		||||
	github.com/tidwall/gjson v1.12.1 // indirect
 | 
			
		||||
	github.com/tidwall/match v1.1.1 // indirect
 | 
			
		||||
	github.com/tidwall/pretty v1.2.0 // indirect
 | 
			
		||||
	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
 | 
			
		||||
	github.com/ugorji/go/codec v1.2.6 // indirect
 | 
			
		||||
	github.com/valyala/bytebufferpool v1.0.0 // indirect
 | 
			
		||||
	github.com/valyala/fasttemplate v1.2.1 // indirect
 | 
			
		||||
	go.uber.org/atomic v1.9.0 // indirect
 | 
			
		||||
	go.uber.org/multierr v1.6.0 // indirect
 | 
			
		||||
	go.uber.org/zap v1.21.0 // indirect
 | 
			
		||||
	golang.org/x/arch v0.6.0 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.25.0 // indirect
 | 
			
		||||
	golang.org/x/net v0.25.0 // indirect
 | 
			
		||||
	golang.org/x/sync v0.7.0 // indirect
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										31
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										31
									
								
								go.sum
								
								
								
								
							| 
						 | 
				
			
			@ -58,6 +58,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
 | 
			
		|||
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
 | 
			
		||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
 | 
			
		||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
 | 
			
		||||
github.com/ZZMarquis/gm v1.3.2 h1:lFtpzg5zeeVMZ/gKi0gtYcKLBEo9XTqsZDHDz6s3Gow=
 | 
			
		||||
github.com/ZZMarquis/gm v1.3.2/go.mod h1:wWbjZYgruQVd7Bb8UkSN8ujU931kx2XUW6nZLCiDE0Q=
 | 
			
		||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
 | 
			
		||||
github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs=
 | 
			
		||||
github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
 | 
			
		||||
| 
						 | 
				
			
			@ -110,6 +112,10 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
 | 
			
		|||
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
 | 
			
		||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
 | 
			
		||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
 | 
			
		||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
 | 
			
		||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
 | 
			
		||||
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
 | 
			
		||||
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
 | 
			
		||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
 | 
			
		||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
 | 
			
		||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 | 
			
		||||
| 
						 | 
				
			
			@ -117,6 +123,13 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
 | 
			
		|||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
 | 
			
		||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
 | 
			
		||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
 | 
			
		||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
 | 
			
		||||
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
 | 
			
		||||
github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
 | 
			
		||||
github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
 | 
			
		||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
 | 
			
		||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
 | 
			
		||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
 | 
			
		||||
| 
						 | 
				
			
			@ -380,6 +393,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
 | 
			
		|||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
 | 
			
		||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 | 
			
		||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 | 
			
		||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
 | 
			
		||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 | 
			
		||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
 | 
			
		||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
 | 
			
		||||
| 
						 | 
				
			
			@ -460,6 +474,10 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
 | 
			
		|||
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
 | 
			
		||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
 | 
			
		||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
 | 
			
		||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
 | 
			
		||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
 | 
			
		||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
 | 
			
		||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
| 
						 | 
				
			
			@ -683,9 +701,11 @@ github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJ
 | 
			
		|||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
 | 
			
		||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 | 
			
		||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
 | 
			
		||||
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
 | 
			
		||||
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
 | 
			
		||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
 | 
			
		||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 | 
			
		||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
			
		||||
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
 | 
			
		||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
 | 
			
		||||
| 
						 | 
				
			
			@ -695,6 +715,8 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J
 | 
			
		|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
 | 
			
		||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 | 
			
		||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 | 
			
		||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 | 
			
		||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 | 
			
		||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 | 
			
		||||
| 
						 | 
				
			
			@ -702,6 +724,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
 | 
			
		|||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 | 
			
		||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
 | 
			
		||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 | 
			
		||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
 | 
			
		||||
| 
						 | 
				
			
			@ -725,6 +748,8 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso
 | 
			
		|||
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
 | 
			
		||||
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
 | 
			
		||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
 | 
			
		||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
 | 
			
		||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
 | 
			
		||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
 | 
			
		||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
 | 
			
		||||
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
 | 
			
		||||
| 
						 | 
				
			
			@ -787,6 +812,9 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
 | 
			
		|||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
 | 
			
		||||
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
 | 
			
		||||
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
 | 
			
		||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
 | 
			
		||||
golang.org/x/arch v0.6.0 h1:S0JTfE48HbRj80+4tbvZDYsJ3tGv6BUU3XxyZ7CirAc=
 | 
			
		||||
golang.org/x/arch v0.6.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
			
		||||
| 
						 | 
				
			
			@ -1002,6 +1030,7 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
 | 
			
		|||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
 | 
			
		||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
			
		||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 | 
			
		||||
| 
						 | 
				
			
			@ -1388,7 +1417,9 @@ modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
 | 
			
		|||
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
 | 
			
		||||
modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY=
 | 
			
		||||
modernc.org/z v1.2.20/go.mod h1:zU9FiF4PbHdOTUxw+IF8j7ArBMRPsHgq10uVPt6xTzo=
 | 
			
		||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
 | 
			
		||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 | 
			
		||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 | 
			
		||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 | 
			
		||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 | 
			
		||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue