创建项目
This commit is contained in:
		
						commit
						32a7e74aed
					
				| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					/.idea
 | 
				
			||||||
 | 
					/.vscode
 | 
				
			||||||
 | 
					/vendor
 | 
				
			||||||
 | 
					/runtime
 | 
				
			||||||
 | 
					*.log
 | 
				
			||||||
 | 
					.env
 | 
				
			||||||
 | 
					app/.DS_Store
 | 
				
			||||||
 | 
					.DS_Store
 | 
				
			||||||
 | 
					composer_test.lock
 | 
				
			||||||
 | 
					.phpunit.result.cache
 | 
				
			||||||
 | 
					config/pem
 | 
				
			||||||
 | 
					config/bale
 | 
				
			||||||
 | 
					config/alipaycash
 | 
				
			||||||
 | 
					config/wechatcash
 | 
				
			||||||
 | 
					config/wechat_cert.pem
 | 
				
			||||||
 | 
					config/wechat_private_key.pem
 | 
				
			||||||
 | 
					/app/api/ForExample.php
 | 
				
			||||||
 | 
					/route/test.php
 | 
				
			||||||
 | 
					/public/data/
 | 
				
			||||||
 | 
					/app/api/Test.php
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,73 @@
 | 
				
			||||||
 | 
					GOHOSTOS:=$(shell go env GOHOSTOS)
 | 
				
			||||||
 | 
					GOPATH:=$(shell go env GOPATH)
 | 
				
			||||||
 | 
					VERSION=$(shell git describe --tags --always)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ifeq ($(GOHOSTOS), windows)
 | 
				
			||||||
 | 
						#the `find.exe` is different from `find` in bash/shell.
 | 
				
			||||||
 | 
						#to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find.
 | 
				
			||||||
 | 
						#changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git.
 | 
				
			||||||
 | 
						#Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git)))
 | 
				
			||||||
 | 
						Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git))))
 | 
				
			||||||
 | 
						INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto")
 | 
				
			||||||
 | 
						API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto")
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
 | 
				
			||||||
 | 
						API_PROTO_FILES=$(shell find api -name *.proto)
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apigen
 | 
				
			||||||
 | 
					# 根据api创建http文件
 | 
				
			||||||
 | 
					apigen:
 | 
				
			||||||
 | 
						cd cmd/api/desc && goctl api go -api *.api -dir ../  --style=goZero
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: rpcgen
 | 
				
			||||||
 | 
					# 根据protoc创建rpc文件
 | 
				
			||||||
 | 
					rpcgen:
 | 
				
			||||||
 | 
						cd cmd/rpc/pb && goctl rpc protoc *.proto --go_out=../pb --go-grpc_out=../pb  --zrpc_out=../ --client=false --style=goZero
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apiinitrpc
 | 
				
			||||||
 | 
					# api端生成rpc
 | 
				
			||||||
 | 
					apiinitrpc:
 | 
				
			||||||
 | 
						cd cmd/api/pb && goctl rpc protoc *.proto --go_out=../ --go-grpc_out=../  --zrpc_out=../ --client=false --style=goZero
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: rpcrun
 | 
				
			||||||
 | 
					# 运行rpc
 | 
				
			||||||
 | 
					rpcrun:
 | 
				
			||||||
 | 
						cd cmd/rpc && go run transfer.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apirun
 | 
				
			||||||
 | 
					# 运行rpc
 | 
				
			||||||
 | 
					apirun:
 | 
				
			||||||
 | 
						cd cmd/api && go run transfer.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apivalidate
 | 
				
			||||||
 | 
					# 运行rpc
 | 
				
			||||||
 | 
					apivalidate:
 | 
				
			||||||
 | 
						cd cmd/api/desc && goctl api validate --api *.api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apiformat
 | 
				
			||||||
 | 
					# 运行rpc
 | 
				
			||||||
 | 
					apiformat:
 | 
				
			||||||
 | 
						cd cmd/api/desc && goctl api format --dir ./
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: apitodoc
 | 
				
			||||||
 | 
					# 运行rpc
 | 
				
			||||||
 | 
					apitodoc:
 | 
				
			||||||
 | 
						cd cmd/api/desc && goctl api doc --dir ./
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: templateUpdate
 | 
				
			||||||
 | 
					# rpcdocker
 | 
				
			||||||
 | 
					templateUpdate:
 | 
				
			||||||
 | 
						cd template && goctl template update   --home ./
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: rpcdocker
 | 
				
			||||||
 | 
					# rpcdocker
 | 
				
			||||||
 | 
					rpcdocker:
 | 
				
			||||||
 | 
						 goctl docker -go ./cmd/rpc/transfer.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					package etc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ExtraConfig struct {
 | 
				
			||||||
 | 
						Nacos NacosConf
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type NacosConf struct {
 | 
				
			||||||
 | 
						Hosts       []string
 | 
				
			||||||
 | 
						NameSpace   string
 | 
				
			||||||
 | 
						TimeOut     uint64
 | 
				
			||||||
 | 
						ServiceName string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					package config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/zrpc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/etc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/logic/po/zltx/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Config struct {
 | 
				
			||||||
 | 
						zrpc.RpcServerConf
 | 
				
			||||||
 | 
						etc.ExtraConfig
 | 
				
			||||||
 | 
						DB struct {
 | 
				
			||||||
 | 
							Master struct {
 | 
				
			||||||
 | 
								DataSource string
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							Slave struct {
 | 
				
			||||||
 | 
								DataSource string
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							MarketReseller struct {
 | 
				
			||||||
 | 
								DataSource string
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Cache cache.CacheConf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ZLTX types.ZLTXConf
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"github.com/pkg/errors"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/xerr"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/jinzhu/copier"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type GetResellerByAppIdLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewGetResellerByAppIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetResellerByAppIdLogic {
 | 
				
			||||||
 | 
						return &GetResellerByAppIdLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *GetResellerByAppIdLogic) GetResellerByAppId(in *transfer.GetResellerByAppIdReq) (*transfer.GetResellerByAppIdRes, error) {
 | 
				
			||||||
 | 
						var res transfer.GetResellerByAppIdRes
 | 
				
			||||||
 | 
						reseller, err := l.svcCtx.DbReseller.ResellerMerchant.FindOneByAppId(l.ctx, in.AppId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, errors.Wrapf(xerr.NewErrMsg(l.ctx, "未找到分销商信息"), "temp in : %+v", err, in.AppId)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = copier.Copy(&res, &reseller)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type PublicRecharge struct {
 | 
				
			||||||
 | 
						MerchantId int
 | 
				
			||||||
 | 
						TimeStamp  int
 | 
				
			||||||
 | 
						Sign       string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ExtendParameter struct {
 | 
				
			||||||
 | 
						ExtendParameter string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZLTXConf struct {
 | 
				
			||||||
 | 
						Host string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type BaseRes struct {
 | 
				
			||||||
 | 
						Code    string `json:"code"`
 | 
				
			||||||
 | 
						Message string `json:"message"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CardParam struct {
 | 
				
			||||||
 | 
						OutTradeNo  string
 | 
				
			||||||
 | 
						ProductId   int
 | 
				
			||||||
 | 
						Mobile      string
 | 
				
			||||||
 | 
						AccountType int
 | 
				
			||||||
 | 
						Number      int
 | 
				
			||||||
 | 
						NotifyUrl   string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CardRes struct {
 | 
				
			||||||
 | 
						Code    string `json:"code"`
 | 
				
			||||||
 | 
						Message string `json:"message"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CardQueryRes struct {
 | 
				
			||||||
 | 
						Code       string `json:"code"`
 | 
				
			||||||
 | 
						Message    string `json:"message"`
 | 
				
			||||||
 | 
						Status     string `json:"status"`
 | 
				
			||||||
 | 
						OutTradeNo string `json:"outTradeNo"`
 | 
				
			||||||
 | 
						CardCode   string `json:"cardCode"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type OrderSmsParam struct {
 | 
				
			||||||
 | 
						OutTradeNo string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type OrderSmsRes struct {
 | 
				
			||||||
 | 
						Code       string `json:"code"`
 | 
				
			||||||
 | 
						Message    string `json:"message"`
 | 
				
			||||||
 | 
						Status     string `json:"status"`
 | 
				
			||||||
 | 
						OutTradeNo string `json:"outTradeNo"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeParam struct {
 | 
				
			||||||
 | 
						OutTradeNo      string
 | 
				
			||||||
 | 
						ProductId       int
 | 
				
			||||||
 | 
						RechargeAccount string
 | 
				
			||||||
 | 
						AccountType     int
 | 
				
			||||||
 | 
						Number          int
 | 
				
			||||||
 | 
						NotifyUrl       string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeQueryRes struct {
 | 
				
			||||||
 | 
						Code       string `json:"code"`
 | 
				
			||||||
 | 
						Message    string `json:"message"`
 | 
				
			||||||
 | 
						Status     string `json:"status"`
 | 
				
			||||||
 | 
						OutTradeNo string `json:"outTradeNo"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeInfoParam struct {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeInfoRes struct {
 | 
				
			||||||
 | 
						Code    string `json:"code"`
 | 
				
			||||||
 | 
						Balance string `json:"balance"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeProductParam struct {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeProductRes struct {
 | 
				
			||||||
 | 
						Code     string            `json:"code"`
 | 
				
			||||||
 | 
						Products []RechargeProduct `json:"products"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RechargeProduct struct {
 | 
				
			||||||
 | 
						ProductId     int    `json:"product_id"`
 | 
				
			||||||
 | 
						ChannelPrice  string `json:"channel_price"`
 | 
				
			||||||
 | 
						ItemName      string `json:"item_name"`
 | 
				
			||||||
 | 
						OriginalPrice string `json:"original_price"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,126 @@
 | 
				
			||||||
 | 
					package zltx
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/logic/po/zltx/types"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/logic/vo"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/request"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrder struct {
 | 
				
			||||||
 | 
						Conf        *types.ZLTXConf
 | 
				
			||||||
 | 
						RequestBody map[string]string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderRequest struct {
 | 
				
			||||||
 | 
						*ZltxOrder
 | 
				
			||||||
 | 
						RequestBody map[string]string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrder(conf types.ZLTXConf) *ZltxOrder {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return &ZltxOrder{
 | 
				
			||||||
 | 
							Conf: &conf,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrder) SetData(data map[string]interface{}) *ZltxOrderRequest {
 | 
				
			||||||
 | 
						data["timeStamp"] = time.Now().Unix()
 | 
				
			||||||
 | 
						a := data
 | 
				
			||||||
 | 
						delete(a, "extendParameter")
 | 
				
			||||||
 | 
						delete(a, "sign")
 | 
				
			||||||
 | 
						data["sign"] = common.ZltxSign(a, "8db16e8cc8363ed4eb4c14f9520bcc32")
 | 
				
			||||||
 | 
						//data := common.MergeMaps(common.ToMap(p), common.ToMap(r), common.ToMap(e))*/
 | 
				
			||||||
 | 
						requestBody := make(map[string]string, len(data))
 | 
				
			||||||
 | 
						for key, value := range data {
 | 
				
			||||||
 | 
							requestBody[key] = fmt.Sprintf("%v", value)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return &ZltxOrderRequest{
 | 
				
			||||||
 | 
							ZltxOrder:   r,
 | 
				
			||||||
 | 
							RequestBody: requestBody,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) request(url string) (*request.Response, error) {
 | 
				
			||||||
 | 
						req := request.Request{
 | 
				
			||||||
 | 
							Method: "POST",
 | 
				
			||||||
 | 
							Url:    fmt.Sprintf("%s%s", r.Conf.Host, url),
 | 
				
			||||||
 | 
							Data:   r.RequestBody,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						resp, _ := req.Send()
 | 
				
			||||||
 | 
						return &resp, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) RechargeOrder() (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
						var res transfer.DefaultRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_RECHARGE)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) RechargeQuery() (*transfer.ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
						var res transfer.ZltxOrderCardQueryRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_RECHARGE_QUERY)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) CardOrder() (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
						var res transfer.DefaultRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_CARD)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) CardQuery() (*transfer.ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
						var res transfer.ZltxOrderCardQueryRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_CARD_QUERY)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) OrderSendSms() (*transfer.ZltxOrderSmsRes, error) {
 | 
				
			||||||
 | 
						var res transfer.ZltxOrderSmsRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_CARD_ISSUE)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) RechargeProduct() (*types.RechargeProductRes, error) {
 | 
				
			||||||
 | 
						var res types.RechargeProductRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_RECHARGE_PRODUCT)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (r *ZltxOrderRequest) RechargeInfo() (*transfer.ZltxRechargeInfoRes, error) {
 | 
				
			||||||
 | 
						var res transfer.ZltxRechargeInfoRes
 | 
				
			||||||
 | 
						req, err := r.request(vo.ZLTX_RECHARGE_INFO)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = json.Unmarshal([]byte(req.Text), &res)
 | 
				
			||||||
 | 
						return &res, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					package vo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						//券码生成
 | 
				
			||||||
 | 
						KEY_SEND = "openApi/v1/market/key/send"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//券码作废
 | 
				
			||||||
 | 
						KEY_DISCARD = "openApi/v1/market/key/discard"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//券码详情
 | 
				
			||||||
 | 
						KEY_QUERY = "openApi/v1/market/key/query"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					package vo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						// 直充下单
 | 
				
			||||||
 | 
						ZLTX_RECHARGE = "recharge/order"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 直充查询
 | 
				
			||||||
 | 
						ZLTX_RECHARGE_QUERY = "recharge/query"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 卡密下单
 | 
				
			||||||
 | 
						ZLTX_CARD = "card/order"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 卡密查询
 | 
				
			||||||
 | 
						ZLTX_CARD_QUERY = "card/query"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 卡密重发短信
 | 
				
			||||||
 | 
						ZLTX_CARD_ISSUE = "card/issue"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 获取商品列表
 | 
				
			||||||
 | 
						ZLTX_RECHARGE_PRODUCT = "recharge/product"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 余额查询
 | 
				
			||||||
 | 
						ZLTX_RECHARGE_INFO = "recharge/info"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderCardLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrderCardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxOrderCardLogic {
 | 
				
			||||||
 | 
						return &ZltxOrderCardLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxOrderCardLogic) ZltxOrderCard(in *transfer.ZltxOrderCardReq) (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).CardOrder()
 | 
				
			||||||
 | 
						return &transfer.DefaultRes{
 | 
				
			||||||
 | 
							Code:    res.Code,
 | 
				
			||||||
 | 
							Message: res.Message,
 | 
				
			||||||
 | 
						}, err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderCardQueryLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrderCardQueryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxOrderCardQueryLogic {
 | 
				
			||||||
 | 
						return &ZltxOrderCardQueryLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxOrderCardQueryLogic) ZltxOrderCardQuery(in *transfer.ZltxOrderCardQueryReq) (*transfer.ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).CardQuery()
 | 
				
			||||||
 | 
						return &transfer.ZltxOrderCardQueryRes{
 | 
				
			||||||
 | 
							Code:       res.Code,
 | 
				
			||||||
 | 
							Message:    res.Message,
 | 
				
			||||||
 | 
							Status:     res.Status,
 | 
				
			||||||
 | 
							OutTradeNo: res.OutTradeNo,
 | 
				
			||||||
 | 
						}, err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderRechargeLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrderRechargeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxOrderRechargeLogic {
 | 
				
			||||||
 | 
						return &ZltxOrderRechargeLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxOrderRechargeLogic) ZltxOrderRecharge(in *transfer.ZltxOrderRechargeReq) (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).RechargeOrder()
 | 
				
			||||||
 | 
						return &transfer.DefaultRes{
 | 
				
			||||||
 | 
							Code:    res.Code,
 | 
				
			||||||
 | 
							Message: res.Message,
 | 
				
			||||||
 | 
						}, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderRechargeQueryLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrderRechargeQueryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxOrderRechargeQueryLogic {
 | 
				
			||||||
 | 
						return &ZltxOrderRechargeQueryLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxOrderRechargeQueryLogic) ZltxOrderRechargeQuery(in *transfer.ZltxOrderRechargeQueryReq) (*transfer.ZltxOrderRechargeQueryRes, error) {
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).RechargeQuery()
 | 
				
			||||||
 | 
						return &transfer.ZltxOrderRechargeQueryRes{
 | 
				
			||||||
 | 
							Code:       res.Code,
 | 
				
			||||||
 | 
							Message:    res.Message,
 | 
				
			||||||
 | 
							Status:     res.Status,
 | 
				
			||||||
 | 
							OutTradeNo: res.OutTradeNo,
 | 
				
			||||||
 | 
						}, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"github.com/jinzhu/copier"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxOrderSmsLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxOrderSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxOrderSmsLogic {
 | 
				
			||||||
 | 
						return &ZltxOrderSmsLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxOrderSmsLogic) ZltxOrderSms(in *transfer.ZltxOrderSmsReq) (*transfer.ZltxOrderSmsRes, error) {
 | 
				
			||||||
 | 
						var result = &transfer.ZltxOrderSmsRes{}
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).OrderSendSms()
 | 
				
			||||||
 | 
						_ = copier.Copy(result, &res)
 | 
				
			||||||
 | 
						return result, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,32 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxRechargeInfoLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxRechargeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxRechargeInfoLogic {
 | 
				
			||||||
 | 
						return &ZltxRechargeInfoLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxRechargeInfoLogic) ZltxRechargeInfo(in *transfer.DefaultReq) (*transfer.ZltxRechargeInfoRes, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).RechargeInfo()
 | 
				
			||||||
 | 
						//_ = copier.Copy(result, &res)
 | 
				
			||||||
 | 
						return res, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"github.com/jinzhu/copier"
 | 
				
			||||||
 | 
						"trasfer_middleware/pkg/common"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ZltxRechargeProductLogic struct {
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewZltxRechargeProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZltxRechargeProductLogic {
 | 
				
			||||||
 | 
						return &ZltxRechargeProductLogic{
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *ZltxRechargeProductLogic) ZltxRechargeProduct(in *transfer.DefaultReq) (*transfer.ZltxRechargeProductRes, error) {
 | 
				
			||||||
 | 
						var result = &transfer.ZltxRechargeProductRes{}
 | 
				
			||||||
 | 
						res, err := l.svcCtx.ZltxOrder.SetData(common.StructToMap(in)).RechargeProduct()
 | 
				
			||||||
 | 
						_ = copier.Copy(result, &res)
 | 
				
			||||||
 | 
						return result, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,63 @@
 | 
				
			||||||
 | 
					// Code generated by goctl. DO NOT EDIT.
 | 
				
			||||||
 | 
					// Source: transfer.proto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/logic"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type TransferServer struct {
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
						transfer.UnimplementedTransferServer
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewTransferServer(svcCtx *svc.ServiceContext) *TransferServer {
 | 
				
			||||||
 | 
						return &TransferServer{
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) GetResellerByAppId(ctx context.Context, in *transfer.GetResellerByAppIdReq) (*transfer.GetResellerByAppIdRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewGetResellerByAppIdLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.GetResellerByAppId(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxOrderRecharge(ctx context.Context, in *transfer.ZltxOrderRechargeReq) (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxOrderRechargeLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxOrderRecharge(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxOrderRechargeQuery(ctx context.Context, in *transfer.ZltxOrderRechargeQueryReq) (*transfer.ZltxOrderRechargeQueryRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxOrderRechargeQueryLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxOrderRechargeQuery(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxOrderCard(ctx context.Context, in *transfer.ZltxOrderCardReq) (*transfer.DefaultRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxOrderCardLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxOrderCard(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxOrderCardQuery(ctx context.Context, in *transfer.ZltxOrderCardQueryReq) (*transfer.ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxOrderCardQueryLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxOrderCardQuery(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxOrderSms(ctx context.Context, in *transfer.ZltxOrderSmsReq) (*transfer.ZltxOrderSmsRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxOrderSmsLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxOrderSms(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxRechargeInfo(ctx context.Context, in *transfer.DefaultReq) (*transfer.ZltxRechargeInfoRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxRechargeInfoLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxRechargeInfo(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *TransferServer) ZltxRechargeProduct(ctx context.Context, in *transfer.DefaultReq) (*transfer.ZltxRechargeProductRes, error) {
 | 
				
			||||||
 | 
						l := logic.NewZltxRechargeProductLogic(ctx, s.svcCtx)
 | 
				
			||||||
 | 
						return l.ZltxRechargeProduct(in)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,57 @@
 | 
				
			||||||
 | 
					package svc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/redis"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/config"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/logic/po/zltx"
 | 
				
			||||||
 | 
						"trasfer_middleware/genModel"
 | 
				
			||||||
 | 
						"trasfer_middleware/genModel/marketReseller"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ServiceContext struct {
 | 
				
			||||||
 | 
						Config      config.Config
 | 
				
			||||||
 | 
						RedisClient *redis.Redis
 | 
				
			||||||
 | 
						DbRead      *Model
 | 
				
			||||||
 | 
						DbWrite     *Model
 | 
				
			||||||
 | 
						DbReseller  *MarkerReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ZltxOrder *zltx.ZltxOrder
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewServiceContext(c config.Config) *ServiceContext {
 | 
				
			||||||
 | 
						return &ServiceContext{
 | 
				
			||||||
 | 
							Config: c,
 | 
				
			||||||
 | 
							RedisClient: redis.MustNewRedis(redis.RedisConf{
 | 
				
			||||||
 | 
								Host: c.Redis.Host,
 | 
				
			||||||
 | 
								Type: c.Redis.Type,
 | 
				
			||||||
 | 
								Pass: c.Redis.Pass,
 | 
				
			||||||
 | 
							}),
 | 
				
			||||||
 | 
							DbRead:     DbModel(c.DB.Master.DataSource, c),
 | 
				
			||||||
 | 
							DbWrite:    DbModel(c.DB.Slave.DataSource, c),
 | 
				
			||||||
 | 
							DbReseller: ResellerModel(c.DB.MarketReseller.DataSource, c),
 | 
				
			||||||
 | 
							ZltxOrder:  zltx.NewZltxOrder(c.ZLTX),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func DbModel(datasource string, c config.Config) *Model {
 | 
				
			||||||
 | 
						sqlConn := sqlx.NewMysql(datasource)
 | 
				
			||||||
 | 
						return &Model{
 | 
				
			||||||
 | 
							ClientModel: genModel.NewServerClientModel(sqlConn, c.Cache),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Model struct {
 | 
				
			||||||
 | 
						ClientModel genModel.ServerClientModel
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func ResellerModel(datasource string, c config.Config) *MarkerReseller {
 | 
				
			||||||
 | 
						sqlConn := sqlx.NewMysql(datasource)
 | 
				
			||||||
 | 
						return &MarkerReseller{
 | 
				
			||||||
 | 
							ResellerMerchant: marketReseller.NewResellerMerchantModel(sqlConn, c.Cache),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type MarkerReseller struct {
 | 
				
			||||||
 | 
						ResellerMerchant marketReseller.ResellerMerchantModel
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,151 @@
 | 
				
			||||||
 | 
					syntax = "proto3";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package transfer;
 | 
				
			||||||
 | 
					option go_package="./transfer";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message DefaultRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  string message=2;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message DefaultReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 2;
 | 
				
			||||||
 | 
					  string sign = 3;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					service Zltx {
 | 
				
			||||||
 | 
					  rpc zltxOrderRecharge(ZltxOrderRechargeReq) returns(DefaultRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderRechargeQuery(ZltxOrderRechargeQueryReq) returns(ZltxOrderRechargeQueryRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderCard(ZltxOrderCardReq) returns(DefaultRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderCardQuery(ZltxOrderCardQueryReq) returns(ZltxOrderCardQueryRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderSms(ZltxOrderSmsReq) returns(ZltxOrderSmsRes);
 | 
				
			||||||
 | 
					  rpc zltxRechargeInfo(DefaultReq) returns(ZltxRechargeInfoRes);
 | 
				
			||||||
 | 
					  rpc zltxRechargeProduct(DefaultReq) returns(ZltxRechargeProductRes);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					service Market {
 | 
				
			||||||
 | 
					  rpc zltxOrderRecharge(ZltxOrderRechargeReq) returns(DefaultRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderRechargeQuery(ZltxOrderRechargeQueryReq) returns(ZltxOrderRechargeQueryRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderCard(ZltxOrderCardReq) returns(DefaultRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderCardQuery(ZltxOrderCardQueryReq) returns(ZltxOrderCardQueryRes);
 | 
				
			||||||
 | 
					  rpc zltxOrderSms(ZltxOrderSmsReq) returns(ZltxOrderSmsRes);
 | 
				
			||||||
 | 
					  rpc zltxRechargeInfo(DefaultReq) returns(ZltxRechargeInfoRes);
 | 
				
			||||||
 | 
					  rpc zltxRechargeProduct(DefaultReq) returns(ZltxRechargeProductRes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxRechargeProductRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  repeated Product products=2;
 | 
				
			||||||
 | 
					  message Product{
 | 
				
			||||||
 | 
					   int64 productId=1;
 | 
				
			||||||
 | 
					   string channelPrice=2;
 | 
				
			||||||
 | 
					   string itemName=3;
 | 
				
			||||||
 | 
					   string originalPrice=4;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxRechargeInfoRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  string balance=2;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderSmsRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  string message=2;
 | 
				
			||||||
 | 
					  string status = 3;
 | 
				
			||||||
 | 
					  string outTradeNo=4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderSmsReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 2;
 | 
				
			||||||
 | 
					  string sign = 3;
 | 
				
			||||||
 | 
					  string outTradeNo = 4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderCardQueryRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  string message=2;
 | 
				
			||||||
 | 
					  string status = 3;
 | 
				
			||||||
 | 
					  string outTradeNo=4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					message ZltxOrderCardQueryReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 2;
 | 
				
			||||||
 | 
					  string sign = 3;
 | 
				
			||||||
 | 
					  string outTradeNo = 4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderCardReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  string sign = 2;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 3;
 | 
				
			||||||
 | 
					  string outTradeNo = 4;
 | 
				
			||||||
 | 
					  int64 productId=5;
 | 
				
			||||||
 | 
					  string mobile=6;
 | 
				
			||||||
 | 
					  uint32 accountType=7;
 | 
				
			||||||
 | 
					  int32 number=8;
 | 
				
			||||||
 | 
					  string  notifyUrl=9;
 | 
				
			||||||
 | 
					  string extendParameter=10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderRechargeQueryRes {
 | 
				
			||||||
 | 
					  string code=1;
 | 
				
			||||||
 | 
					  string message=2;
 | 
				
			||||||
 | 
					  string status = 3;
 | 
				
			||||||
 | 
					  string outTradeNo=4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					message ZltxOrderRechargeQueryReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 2;
 | 
				
			||||||
 | 
					  string sign = 3;
 | 
				
			||||||
 | 
					  string outTradeNo = 4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message ZltxOrderRechargeReq {
 | 
				
			||||||
 | 
					  string merchantId = 1;
 | 
				
			||||||
 | 
					  string sign = 2;
 | 
				
			||||||
 | 
					  uint64 timeStamp = 3;
 | 
				
			||||||
 | 
					  string outTradeNo = 4;
 | 
				
			||||||
 | 
					  int64 productId=5;
 | 
				
			||||||
 | 
					  string mobile=6;
 | 
				
			||||||
 | 
					  uint32 accountType=7;
 | 
				
			||||||
 | 
					  int32 number=8;
 | 
				
			||||||
 | 
					  string  notifyUrl=9;
 | 
				
			||||||
 | 
					  string extendParameter=10;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message GetResellerByAppIdReq {
 | 
				
			||||||
 | 
					  string appId = 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message GetResellerByAppIdRes {
 | 
				
			||||||
 | 
					  int64  id=1;
 | 
				
			||||||
 | 
					  string merchantId=2;
 | 
				
			||||||
 | 
					  string resellerId=3;
 | 
				
			||||||
 | 
					  string appId=4;
 | 
				
			||||||
 | 
					  string posId=5;
 | 
				
			||||||
 | 
					  string storeId=6;
 | 
				
			||||||
 | 
					  int32  apiMod=7;
 | 
				
			||||||
 | 
					  string publicKey=8;
 | 
				
			||||||
 | 
					  string privateKey=9;
 | 
				
			||||||
 | 
					  string merchantPublicKey=10;
 | 
				
			||||||
 | 
					  string secretKey=11;
 | 
				
			||||||
 | 
					  string notifyUrl=12;
 | 
				
			||||||
 | 
					  string subscribeEvent=13;
 | 
				
			||||||
 | 
					  int32  status=14;
 | 
				
			||||||
 | 
					  string createTime=15;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -0,0 +1,368 @@
 | 
				
			||||||
 | 
					// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 | 
				
			||||||
 | 
					// versions:
 | 
				
			||||||
 | 
					// - protoc-gen-go-grpc v1.3.0
 | 
				
			||||||
 | 
					// - protoc             v3.6.1
 | 
				
			||||||
 | 
					// source: transfer.proto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package transfer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						context "context"
 | 
				
			||||||
 | 
						grpc "google.golang.org/grpc"
 | 
				
			||||||
 | 
						codes "google.golang.org/grpc/codes"
 | 
				
			||||||
 | 
						status "google.golang.org/grpc/status"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This is a compile-time assertion to ensure that this generated file
 | 
				
			||||||
 | 
					// is compatible with the grpc package it is being compiled against.
 | 
				
			||||||
 | 
					// Requires gRPC-Go v1.32.0 or later.
 | 
				
			||||||
 | 
					const _ = grpc.SupportPackageIsVersion7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						Transfer_GetResellerByAppId_FullMethodName     = "/transfer.Transfer/getResellerByAppId"
 | 
				
			||||||
 | 
						Transfer_ZltxOrderRecharge_FullMethodName      = "/transfer.Transfer/zltxOrderRecharge"
 | 
				
			||||||
 | 
						Transfer_ZltxOrderRechargeQuery_FullMethodName = "/transfer.Transfer/zltxOrderRechargeQuery"
 | 
				
			||||||
 | 
						Transfer_ZltxOrderCard_FullMethodName          = "/transfer.Transfer/zltxOrderCard"
 | 
				
			||||||
 | 
						Transfer_ZltxOrderCardQuery_FullMethodName     = "/transfer.Transfer/zltxOrderCardQuery"
 | 
				
			||||||
 | 
						Transfer_ZltxOrderSms_FullMethodName           = "/transfer.Transfer/zltxOrderSms"
 | 
				
			||||||
 | 
						Transfer_ZltxRechargeInfo_FullMethodName       = "/transfer.Transfer/zltxRechargeInfo"
 | 
				
			||||||
 | 
						Transfer_ZltxRechargeProduct_FullMethodName    = "/transfer.Transfer/zltxRechargeProduct"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TransferClient is the client API for Transfer service.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
 | 
				
			||||||
 | 
					type TransferClient interface {
 | 
				
			||||||
 | 
						GetResellerByAppId(ctx context.Context, in *GetResellerByAppIdReq, opts ...grpc.CallOption) (*GetResellerByAppIdRes, error)
 | 
				
			||||||
 | 
						ZltxOrderRecharge(ctx context.Context, in *ZltxOrderRechargeReq, opts ...grpc.CallOption) (*DefaultRes, error)
 | 
				
			||||||
 | 
						ZltxOrderRechargeQuery(ctx context.Context, in *ZltxOrderRechargeQueryReq, opts ...grpc.CallOption) (*ZltxOrderRechargeQueryRes, error)
 | 
				
			||||||
 | 
						ZltxOrderCard(ctx context.Context, in *ZltxOrderCardReq, opts ...grpc.CallOption) (*DefaultRes, error)
 | 
				
			||||||
 | 
						ZltxOrderCardQuery(ctx context.Context, in *ZltxOrderCardQueryReq, opts ...grpc.CallOption) (*ZltxOrderCardQueryRes, error)
 | 
				
			||||||
 | 
						ZltxOrderSms(ctx context.Context, in *ZltxOrderSmsReq, opts ...grpc.CallOption) (*ZltxOrderSmsRes, error)
 | 
				
			||||||
 | 
						ZltxRechargeInfo(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeInfoRes, error)
 | 
				
			||||||
 | 
						ZltxRechargeProduct(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeProductRes, error)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type transferClient struct {
 | 
				
			||||||
 | 
						cc grpc.ClientConnInterface
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewTransferClient(cc grpc.ClientConnInterface) TransferClient {
 | 
				
			||||||
 | 
						return &transferClient{cc}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) GetResellerByAppId(ctx context.Context, in *GetResellerByAppIdReq, opts ...grpc.CallOption) (*GetResellerByAppIdRes, error) {
 | 
				
			||||||
 | 
						out := new(GetResellerByAppIdRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_GetResellerByAppId_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxOrderRecharge(ctx context.Context, in *ZltxOrderRechargeReq, opts ...grpc.CallOption) (*DefaultRes, error) {
 | 
				
			||||||
 | 
						out := new(DefaultRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxOrderRecharge_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxOrderRechargeQuery(ctx context.Context, in *ZltxOrderRechargeQueryReq, opts ...grpc.CallOption) (*ZltxOrderRechargeQueryRes, error) {
 | 
				
			||||||
 | 
						out := new(ZltxOrderRechargeQueryRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxOrderRechargeQuery_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxOrderCard(ctx context.Context, in *ZltxOrderCardReq, opts ...grpc.CallOption) (*DefaultRes, error) {
 | 
				
			||||||
 | 
						out := new(DefaultRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxOrderCard_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxOrderCardQuery(ctx context.Context, in *ZltxOrderCardQueryReq, opts ...grpc.CallOption) (*ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
						out := new(ZltxOrderCardQueryRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxOrderCardQuery_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxOrderSms(ctx context.Context, in *ZltxOrderSmsReq, opts ...grpc.CallOption) (*ZltxOrderSmsRes, error) {
 | 
				
			||||||
 | 
						out := new(ZltxOrderSmsRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxOrderSms_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxRechargeInfo(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeInfoRes, error) {
 | 
				
			||||||
 | 
						out := new(ZltxRechargeInfoRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxRechargeInfo_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *transferClient) ZltxRechargeProduct(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeProductRes, error) {
 | 
				
			||||||
 | 
						out := new(ZltxRechargeProductRes)
 | 
				
			||||||
 | 
						err := c.cc.Invoke(ctx, Transfer_ZltxRechargeProduct_FullMethodName, in, out, opts...)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return out, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TransferServer is the server API for Transfer service.
 | 
				
			||||||
 | 
					// All implementations must embed UnimplementedTransferServer
 | 
				
			||||||
 | 
					// for forward compatibility
 | 
				
			||||||
 | 
					type TransferServer interface {
 | 
				
			||||||
 | 
						GetResellerByAppId(context.Context, *GetResellerByAppIdReq) (*GetResellerByAppIdRes, error)
 | 
				
			||||||
 | 
						ZltxOrderRecharge(context.Context, *ZltxOrderRechargeReq) (*DefaultRes, error)
 | 
				
			||||||
 | 
						ZltxOrderRechargeQuery(context.Context, *ZltxOrderRechargeQueryReq) (*ZltxOrderRechargeQueryRes, error)
 | 
				
			||||||
 | 
						ZltxOrderCard(context.Context, *ZltxOrderCardReq) (*DefaultRes, error)
 | 
				
			||||||
 | 
						ZltxOrderCardQuery(context.Context, *ZltxOrderCardQueryReq) (*ZltxOrderCardQueryRes, error)
 | 
				
			||||||
 | 
						ZltxOrderSms(context.Context, *ZltxOrderSmsReq) (*ZltxOrderSmsRes, error)
 | 
				
			||||||
 | 
						ZltxRechargeInfo(context.Context, *DefaultReq) (*ZltxRechargeInfoRes, error)
 | 
				
			||||||
 | 
						ZltxRechargeProduct(context.Context, *DefaultReq) (*ZltxRechargeProductRes, error)
 | 
				
			||||||
 | 
						mustEmbedUnimplementedTransferServer()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UnimplementedTransferServer must be embedded to have forward compatible implementations.
 | 
				
			||||||
 | 
					type UnimplementedTransferServer struct {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) GetResellerByAppId(context.Context, *GetResellerByAppIdReq) (*GetResellerByAppIdRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method GetResellerByAppId not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxOrderRecharge(context.Context, *ZltxOrderRechargeReq) (*DefaultRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderRecharge not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxOrderRechargeQuery(context.Context, *ZltxOrderRechargeQueryReq) (*ZltxOrderRechargeQueryRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderRechargeQuery not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxOrderCard(context.Context, *ZltxOrderCardReq) (*DefaultRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderCard not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxOrderCardQuery(context.Context, *ZltxOrderCardQueryReq) (*ZltxOrderCardQueryRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderCardQuery not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxOrderSms(context.Context, *ZltxOrderSmsReq) (*ZltxOrderSmsRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderSms not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxRechargeInfo(context.Context, *DefaultReq) (*ZltxRechargeInfoRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxRechargeInfo not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) ZltxRechargeProduct(context.Context, *DefaultReq) (*ZltxRechargeProductRes, error) {
 | 
				
			||||||
 | 
						return nil, status.Errorf(codes.Unimplemented, "method ZltxRechargeProduct not implemented")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (UnimplementedTransferServer) mustEmbedUnimplementedTransferServer() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UnsafeTransferServer may be embedded to opt out of forward compatibility for this service.
 | 
				
			||||||
 | 
					// Use of this interface is not recommended, as added methods to TransferServer will
 | 
				
			||||||
 | 
					// result in compilation errors.
 | 
				
			||||||
 | 
					type UnsafeTransferServer interface {
 | 
				
			||||||
 | 
						mustEmbedUnimplementedTransferServer()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func RegisterTransferServer(s grpc.ServiceRegistrar, srv TransferServer) {
 | 
				
			||||||
 | 
						s.RegisterService(&Transfer_ServiceDesc, srv)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_GetResellerByAppId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(GetResellerByAppIdReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).GetResellerByAppId(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_GetResellerByAppId_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).GetResellerByAppId(ctx, req.(*GetResellerByAppIdReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxOrderRecharge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(ZltxOrderRechargeReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderRecharge(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxOrderRecharge_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderRecharge(ctx, req.(*ZltxOrderRechargeReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxOrderRechargeQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(ZltxOrderRechargeQueryReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderRechargeQuery(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxOrderRechargeQuery_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderRechargeQuery(ctx, req.(*ZltxOrderRechargeQueryReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxOrderCard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(ZltxOrderCardReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderCard(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxOrderCard_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderCard(ctx, req.(*ZltxOrderCardReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxOrderCardQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(ZltxOrderCardQueryReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderCardQuery(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxOrderCardQuery_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderCardQuery(ctx, req.(*ZltxOrderCardQueryReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxOrderSms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(ZltxOrderSmsReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderSms(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxOrderSms_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxOrderSms(ctx, req.(*ZltxOrderSmsReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxRechargeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(DefaultReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxRechargeInfo(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxRechargeInfo_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxRechargeInfo(ctx, req.(*DefaultReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _Transfer_ZltxRechargeProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 | 
				
			||||||
 | 
						in := new(DefaultReq)
 | 
				
			||||||
 | 
						if err := dec(in); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if interceptor == nil {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxRechargeProduct(ctx, in)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						info := &grpc.UnaryServerInfo{
 | 
				
			||||||
 | 
							Server:     srv,
 | 
				
			||||||
 | 
							FullMethod: Transfer_ZltxRechargeProduct_FullMethodName,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 | 
				
			||||||
 | 
							return srv.(TransferServer).ZltxRechargeProduct(ctx, req.(*DefaultReq))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return interceptor(ctx, in, info, handler)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Transfer_ServiceDesc is the grpc.ServiceDesc for Transfer service.
 | 
				
			||||||
 | 
					// It's only intended for direct use with grpc.RegisterService,
 | 
				
			||||||
 | 
					// and not to be introspected or modified (even as a copy)
 | 
				
			||||||
 | 
					var Transfer_ServiceDesc = grpc.ServiceDesc{
 | 
				
			||||||
 | 
						ServiceName: "transfer.Transfer",
 | 
				
			||||||
 | 
						HandlerType: (*TransferServer)(nil),
 | 
				
			||||||
 | 
						Methods: []grpc.MethodDesc{
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "getResellerByAppId",
 | 
				
			||||||
 | 
								Handler:    _Transfer_GetResellerByAppId_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxOrderRecharge",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxOrderRecharge_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxOrderRechargeQuery",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxOrderRechargeQuery_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxOrderCard",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxOrderCard_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxOrderCardQuery",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxOrderCardQuery_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxOrderSms",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxOrderSms_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxRechargeInfo",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxRechargeInfo_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MethodName: "zltxRechargeProduct",
 | 
				
			||||||
 | 
								Handler:    _Transfer_ZltxRechargeProduct_Handler,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Streams:  []grpc.StreamDesc{},
 | 
				
			||||||
 | 
						Metadata: "transfer.proto",
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,65 @@
 | 
				
			||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"flag"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
 | 
				
			||||||
 | 
						"github.com/zeromicro/zero-contrib/zrpc/registry/nacos"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/config"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/server"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/internal/svc"
 | 
				
			||||||
 | 
						"trasfer_middleware/cmd/rpc/pb/transfer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/conf"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/service"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/zrpc"
 | 
				
			||||||
 | 
						"google.golang.org/grpc"
 | 
				
			||||||
 | 
						"google.golang.org/grpc/reflection"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var configFile = flag.String("f", "../../config/transfer.yaml", "the config file")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func main() {
 | 
				
			||||||
 | 
						flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var c config.Config
 | 
				
			||||||
 | 
						conf.MustLoad(*configFile, &c)
 | 
				
			||||||
 | 
						ctx := svc.NewServiceContext(c)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
 | 
				
			||||||
 | 
							transfer.RegisterTransferServer(grpcServer, server.NewTransferServer(ctx))
 | 
				
			||||||
 | 
							if c.Mode == service.DevMode || c.Mode == service.TestMode {
 | 
				
			||||||
 | 
								reflection.Register(grpcServer)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						registerNacos(&c)
 | 
				
			||||||
 | 
						defer s.Stop()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
 | 
				
			||||||
 | 
						s.Start()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func registerNacos(c *config.Config) {
 | 
				
			||||||
 | 
						sc := []constant.ServerConfig{}
 | 
				
			||||||
 | 
						for _, v := range c.Nacos.Hosts {
 | 
				
			||||||
 | 
							splitSlice := strings.Split(v, ":")
 | 
				
			||||||
 | 
							port, _ := strconv.Atoi(splitSlice[1])
 | 
				
			||||||
 | 
							sc = append(sc, *constant.NewServerConfig(splitSlice[0], uint64(port)))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						cc := &constant.ClientConfig{
 | 
				
			||||||
 | 
							NamespaceId:         c.Nacos.NameSpace,
 | 
				
			||||||
 | 
							TimeoutMs:           c.Nacos.TimeOut,
 | 
				
			||||||
 | 
							NotLoadCacheAtStart: true,
 | 
				
			||||||
 | 
							LogDir:              "/tmp/nacos/log",
 | 
				
			||||||
 | 
							CacheDir:            "/tmp/nacos/cache",
 | 
				
			||||||
 | 
							LogLevel:            "debug",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						opts := nacos.NewNacosConfig(c.Nacos.ServiceName, c.ListenOn, sc, cc)
 | 
				
			||||||
 | 
						err := nacos.RegisterService(opts)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							panic(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					package marketReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ ResellerMerchantModel = (*customResellerMerchantModel)(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						// ResellerMerchantModel is an interface to be customized, add more methods here,
 | 
				
			||||||
 | 
						// and implement the added methods in customResellerMerchantModel.
 | 
				
			||||||
 | 
						ResellerMerchantModel interface {
 | 
				
			||||||
 | 
							resellerMerchantModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						customResellerMerchantModel struct {
 | 
				
			||||||
 | 
							*defaultResellerMerchantModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewResellerMerchantModel returns a model for the database table.
 | 
				
			||||||
 | 
					func NewResellerMerchantModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ResellerMerchantModel {
 | 
				
			||||||
 | 
						return &customResellerMerchantModel{
 | 
				
			||||||
 | 
							defaultResellerMerchantModel: newResellerMerchantModel(conn, c, opts...),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,208 @@
 | 
				
			||||||
 | 
					// Code generated by goctl. DO NOT EDIT.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package marketReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/builder"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlc"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stringx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var (
 | 
				
			||||||
 | 
						resellerMerchantFieldNames          = builder.RawFieldNames(&ResellerMerchant{})
 | 
				
			||||||
 | 
						resellerMerchantRows                = strings.Join(resellerMerchantFieldNames, ",")
 | 
				
			||||||
 | 
						resellerMerchantRowsExpectAutoSet   = strings.Join(stringx.Remove(resellerMerchantFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
 | 
				
			||||||
 | 
						resellerMerchantRowsWithPlaceHolder = strings.Join(stringx.Remove(resellerMerchantFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cacheResellerResellerMerchantIdPrefix         = "cache:reseller:resellerMerchant:id:"
 | 
				
			||||||
 | 
						cacheResellerResellerMerchantAppIdPrefix      = "cache:reseller:resellerMerchant:appId:"
 | 
				
			||||||
 | 
						cacheResellerResellerMerchantMerchantIdPrefix = "cache:reseller:resellerMerchant:merchantId:"
 | 
				
			||||||
 | 
						cacheResellerResellerMerchantPosIdPrefix      = "cache:reseller:resellerMerchant:posId:"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						resellerMerchantModel interface {
 | 
				
			||||||
 | 
							Insert(ctx context.Context, data *ResellerMerchant) (sql.Result, error)
 | 
				
			||||||
 | 
							FindOne(ctx context.Context, id uint64) (*ResellerMerchant, error)
 | 
				
			||||||
 | 
							FindOneByAppId(ctx context.Context, appId string) (*ResellerMerchant, error)
 | 
				
			||||||
 | 
							FindOneByMerchantId(ctx context.Context, merchantId string) (*ResellerMerchant, error)
 | 
				
			||||||
 | 
							FindOneByPosId(ctx context.Context, posId string) (*ResellerMerchant, error)
 | 
				
			||||||
 | 
							Update(ctx context.Context, data *ResellerMerchant) error
 | 
				
			||||||
 | 
							Delete(ctx context.Context, id uint64) error
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defaultResellerMerchantModel struct {
 | 
				
			||||||
 | 
							sqlc.CachedConn
 | 
				
			||||||
 | 
							table string
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ResellerMerchant struct {
 | 
				
			||||||
 | 
							Id                uint64         `db:"id"`
 | 
				
			||||||
 | 
							MerchantId        string         `db:"merchant_id"`         // 商户号
 | 
				
			||||||
 | 
							ResellerId        uint64         `db:"reseller_id"`         // 分销商id
 | 
				
			||||||
 | 
							PosId             string         `db:"pos_id"`              // 平台id 目前都是单平台
 | 
				
			||||||
 | 
							AppId             string         `db:"app_id"`              // appid。目前都是单应用, 通知地址 事件地址都针对于这一个应用配置
 | 
				
			||||||
 | 
							StoreId           string         `db:"store_id"`            // 没有门店,兴业银行需求。 当作后期的扩展字段
 | 
				
			||||||
 | 
							ApiMode           int64          `db:"api_mode"`            // 对接类型 1-RSA+标准接口返回【默认】2-兴业银行模式
 | 
				
			||||||
 | 
							PublicKey         sql.NullString `db:"public_key"`          // 公钥
 | 
				
			||||||
 | 
							PrivateKey        sql.NullString `db:"private_key"`         // 私钥
 | 
				
			||||||
 | 
							MerchantPublicKey sql.NullString `db:"merchant_public_key"` // 客户侧公钥
 | 
				
			||||||
 | 
							SecretKey         string         `db:"secret_key"`          // body加解密密钥
 | 
				
			||||||
 | 
							NotifyUrl         sql.NullString `db:"notify_url"`          // 通知地址配置
 | 
				
			||||||
 | 
							SubscribeEvent    sql.NullString `db:"subscribe_event"`     // 订阅事件
 | 
				
			||||||
 | 
							Status            uint64         `db:"status"`              // 状态 1正常 2禁用
 | 
				
			||||||
 | 
							UpdateTime        sql.NullTime   `db:"update_time"`         // 编辑时间
 | 
				
			||||||
 | 
							CreateTime        time.Time      `db:"create_time"`         // 创建时间
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func newResellerMerchantModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultResellerMerchantModel {
 | 
				
			||||||
 | 
						return &defaultResellerMerchantModel{
 | 
				
			||||||
 | 
							CachedConn: sqlc.NewConn(conn, c, opts...),
 | 
				
			||||||
 | 
							table:      "`reseller_merchant`",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) Delete(ctx context.Context, id uint64) error {
 | 
				
			||||||
 | 
						data, err := m.FindOne(ctx, id)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						resellerResellerMerchantAppIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantAppIdPrefix, data.AppId)
 | 
				
			||||||
 | 
						resellerResellerMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantIdPrefix, id)
 | 
				
			||||||
 | 
						resellerResellerMerchantMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantMerchantIdPrefix, data.MerchantId)
 | 
				
			||||||
 | 
						resellerResellerMerchantPosIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantPosIdPrefix, data.PosId)
 | 
				
			||||||
 | 
						_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, id)
 | 
				
			||||||
 | 
						}, resellerResellerMerchantAppIdKey, resellerResellerMerchantIdKey, resellerResellerMerchantMerchantIdKey, resellerResellerMerchantPosIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) FindOne(ctx context.Context, id uint64) (*ResellerMerchant, error) {
 | 
				
			||||||
 | 
						resellerResellerMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantIdPrefix, id)
 | 
				
			||||||
 | 
						var resp ResellerMerchant
 | 
				
			||||||
 | 
						err := m.QueryRowCtx(ctx, &resp, resellerResellerMerchantIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", resellerMerchantRows, m.table)
 | 
				
			||||||
 | 
							return conn.QueryRowCtx(ctx, v, query, id)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) FindOneByAppId(ctx context.Context, appId string) (*ResellerMerchant, error) {
 | 
				
			||||||
 | 
						resellerResellerMerchantAppIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantAppIdPrefix, appId)
 | 
				
			||||||
 | 
						var resp ResellerMerchant
 | 
				
			||||||
 | 
						err := m.QueryRowIndexCtx(ctx, &resp, resellerResellerMerchantAppIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `app_id` = ? limit 1", resellerMerchantRows, m.table)
 | 
				
			||||||
 | 
							if err := conn.QueryRowCtx(ctx, &resp, query, appId); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return resp.Id, nil
 | 
				
			||||||
 | 
						}, m.queryPrimary)
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) FindOneByMerchantId(ctx context.Context, merchantId string) (*ResellerMerchant, error) {
 | 
				
			||||||
 | 
						resellerResellerMerchantMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantMerchantIdPrefix, merchantId)
 | 
				
			||||||
 | 
						var resp ResellerMerchant
 | 
				
			||||||
 | 
						err := m.QueryRowIndexCtx(ctx, &resp, resellerResellerMerchantMerchantIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `merchant_id` = ? limit 1", resellerMerchantRows, m.table)
 | 
				
			||||||
 | 
							if err := conn.QueryRowCtx(ctx, &resp, query, merchantId); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return resp.Id, nil
 | 
				
			||||||
 | 
						}, m.queryPrimary)
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) FindOneByPosId(ctx context.Context, posId string) (*ResellerMerchant, error) {
 | 
				
			||||||
 | 
						resellerResellerMerchantPosIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantPosIdPrefix, posId)
 | 
				
			||||||
 | 
						var resp ResellerMerchant
 | 
				
			||||||
 | 
						err := m.QueryRowIndexCtx(ctx, &resp, resellerResellerMerchantPosIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `pos_id` = ? limit 1", resellerMerchantRows, m.table)
 | 
				
			||||||
 | 
							if err := conn.QueryRowCtx(ctx, &resp, query, posId); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return resp.Id, nil
 | 
				
			||||||
 | 
						}, m.queryPrimary)
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) Insert(ctx context.Context, data *ResellerMerchant) (sql.Result, error) {
 | 
				
			||||||
 | 
						resellerResellerMerchantAppIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantAppIdPrefix, data.AppId)
 | 
				
			||||||
 | 
						resellerResellerMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantIdPrefix, data.Id)
 | 
				
			||||||
 | 
						resellerResellerMerchantMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantMerchantIdPrefix, data.MerchantId)
 | 
				
			||||||
 | 
						resellerResellerMerchantPosIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantPosIdPrefix, data.PosId)
 | 
				
			||||||
 | 
						ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, resellerMerchantRowsExpectAutoSet)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, data.MerchantId, data.ResellerId, data.PosId, data.AppId, data.StoreId, data.ApiMode, data.PublicKey, data.PrivateKey, data.MerchantPublicKey, data.SecretKey, data.NotifyUrl, data.SubscribeEvent, data.Status)
 | 
				
			||||||
 | 
						}, resellerResellerMerchantAppIdKey, resellerResellerMerchantIdKey, resellerResellerMerchantMerchantIdKey, resellerResellerMerchantPosIdKey)
 | 
				
			||||||
 | 
						return ret, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) Update(ctx context.Context, newData *ResellerMerchant) error {
 | 
				
			||||||
 | 
						data, err := m.FindOne(ctx, newData.Id)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						resellerResellerMerchantAppIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantAppIdPrefix, data.AppId)
 | 
				
			||||||
 | 
						resellerResellerMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantIdPrefix, data.Id)
 | 
				
			||||||
 | 
						resellerResellerMerchantMerchantIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantMerchantIdPrefix, data.MerchantId)
 | 
				
			||||||
 | 
						resellerResellerMerchantPosIdKey := fmt.Sprintf("%s%v", cacheResellerResellerMerchantPosIdPrefix, data.PosId)
 | 
				
			||||||
 | 
						_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, resellerMerchantRowsWithPlaceHolder)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, newData.MerchantId, newData.ResellerId, newData.PosId, newData.AppId, newData.StoreId, newData.ApiMode, newData.PublicKey, newData.PrivateKey, newData.MerchantPublicKey, newData.SecretKey, newData.NotifyUrl, newData.SubscribeEvent, newData.Status, newData.Id)
 | 
				
			||||||
 | 
						}, resellerResellerMerchantAppIdKey, resellerResellerMerchantIdKey, resellerResellerMerchantMerchantIdKey, resellerResellerMerchantPosIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) formatPrimary(primary any) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s%v", cacheResellerResellerMerchantIdPrefix, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
 | 
				
			||||||
 | 
						query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", resellerMerchantRows, m.table)
 | 
				
			||||||
 | 
						return conn.QueryRowCtx(ctx, v, query, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerMerchantModel) tableName() string {
 | 
				
			||||||
 | 
						return m.table
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					package marketReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ ResellerModel = (*customResellerModel)(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						// ResellerModel is an interface to be customized, add more methods here,
 | 
				
			||||||
 | 
						// and implement the added methods in customResellerModel.
 | 
				
			||||||
 | 
						ResellerModel interface {
 | 
				
			||||||
 | 
							resellerModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						customResellerModel struct {
 | 
				
			||||||
 | 
							*defaultResellerModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewResellerModel returns a model for the database table.
 | 
				
			||||||
 | 
					func NewResellerModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ResellerModel {
 | 
				
			||||||
 | 
						return &customResellerModel{
 | 
				
			||||||
 | 
							defaultResellerModel: newResellerModel(conn, c, opts...),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,134 @@
 | 
				
			||||||
 | 
					// Code generated by goctl. DO NOT EDIT.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package marketReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/builder"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlc"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stringx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var (
 | 
				
			||||||
 | 
						resellerFieldNames          = builder.RawFieldNames(&Reseller{})
 | 
				
			||||||
 | 
						resellerRows                = strings.Join(resellerFieldNames, ",")
 | 
				
			||||||
 | 
						resellerRowsExpectAutoSet   = strings.Join(stringx.Remove(resellerFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
 | 
				
			||||||
 | 
						resellerRowsWithPlaceHolder = strings.Join(stringx.Remove(resellerFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cacheResellerResellerIdPrefix = "cache:reseller:reseller:id:"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						resellerModel interface {
 | 
				
			||||||
 | 
							Insert(ctx context.Context, data *Reseller) (sql.Result, error)
 | 
				
			||||||
 | 
							FindOne(ctx context.Context, id uint64) (*Reseller, error)
 | 
				
			||||||
 | 
							Update(ctx context.Context, data *Reseller) error
 | 
				
			||||||
 | 
							Delete(ctx context.Context, id uint64) error
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defaultResellerModel struct {
 | 
				
			||||||
 | 
							sqlc.CachedConn
 | 
				
			||||||
 | 
							table string
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Reseller struct {
 | 
				
			||||||
 | 
							Id               uint64       `db:"id"`                 // 主键
 | 
				
			||||||
 | 
							Creator          int64        `db:"creator"`            // 操作人员
 | 
				
			||||||
 | 
							Code             string       `db:"code"`               // 分销商编号
 | 
				
			||||||
 | 
							Name             string       `db:"name"`               // 分销商名称
 | 
				
			||||||
 | 
							Subject          string       `db:"subject"`            // 分销商主体
 | 
				
			||||||
 | 
							Account          string       `db:"account"`            // 登录账号
 | 
				
			||||||
 | 
							Password         string       `db:"password"`           // 登录密码
 | 
				
			||||||
 | 
							Status           uint64       `db:"status"`             // 分销商账号状态
 | 
				
			||||||
 | 
							HeadImg          string       `db:"head_img"`           // 头像
 | 
				
			||||||
 | 
							SalesmanId       uint64       `db:"salesman_id"`        // 销售人员ID,后台用户表ID
 | 
				
			||||||
 | 
							SalesmanName     string       `db:"salesman_name"`      // 销售人员名称
 | 
				
			||||||
 | 
							CompanyId        uint64       `db:"company_id"`         // 所属公司,公司表ID
 | 
				
			||||||
 | 
							CompanyName      string       `db:"company_name"`       // 公司名称
 | 
				
			||||||
 | 
							IdentityType     uint64       `db:"identity_type"`      // 身份类型
 | 
				
			||||||
 | 
							Balance          float64      `db:"balance"`            // 分销商余额
 | 
				
			||||||
 | 
							BalanceWarning   float64      `db:"balance_warning"`    // 余额预警
 | 
				
			||||||
 | 
							FrozenAmount     float64      `db:"frozen_amount"`      // 冻结金额
 | 
				
			||||||
 | 
							CreditAmount     float64      `db:"credit_amount"`      // 授信金额
 | 
				
			||||||
 | 
							TotalConsumption float64      `db:"total_consumption"`  // 累计消费
 | 
				
			||||||
 | 
							ContactName      string       `db:"contact_name"`       // 联系人名称
 | 
				
			||||||
 | 
							ContactPhone     string       `db:"contact_phone"`      // 联系人电话
 | 
				
			||||||
 | 
							ContactEmail     string       `db:"contact_email"`      // 联系人Email,多个逗号(,)用逗号分开
 | 
				
			||||||
 | 
							CreateTime       time.Time    `db:"create_time"`        // 创建时间
 | 
				
			||||||
 | 
							UpdateTime       sql.NullTime `db:"update_time"`        // 编辑时间
 | 
				
			||||||
 | 
							DeleteTime       sql.NullTime `db:"delete_time"`        // 删除时间
 | 
				
			||||||
 | 
							DirectResellerId uint64       `db:"direct_reseller_id"` // 直连天下分销商映射ID
 | 
				
			||||||
 | 
							MapTime          sql.NullTime `db:"map_time"`           // 映射时间
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func newResellerModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultResellerModel {
 | 
				
			||||||
 | 
						return &defaultResellerModel{
 | 
				
			||||||
 | 
							CachedConn: sqlc.NewConn(conn, c, opts...),
 | 
				
			||||||
 | 
							table:      "`reseller`",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) Delete(ctx context.Context, id uint64) error {
 | 
				
			||||||
 | 
						resellerResellerIdKey := fmt.Sprintf("%s%v", cacheResellerResellerIdPrefix, id)
 | 
				
			||||||
 | 
						_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, id)
 | 
				
			||||||
 | 
						}, resellerResellerIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) FindOne(ctx context.Context, id uint64) (*Reseller, error) {
 | 
				
			||||||
 | 
						resellerResellerIdKey := fmt.Sprintf("%s%v", cacheResellerResellerIdPrefix, id)
 | 
				
			||||||
 | 
						var resp Reseller
 | 
				
			||||||
 | 
						err := m.QueryRowCtx(ctx, &resp, resellerResellerIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", resellerRows, m.table)
 | 
				
			||||||
 | 
							return conn.QueryRowCtx(ctx, v, query, id)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) Insert(ctx context.Context, data *Reseller) (sql.Result, error) {
 | 
				
			||||||
 | 
						resellerResellerIdKey := fmt.Sprintf("%s%v", cacheResellerResellerIdPrefix, data.Id)
 | 
				
			||||||
 | 
						ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, resellerRowsExpectAutoSet)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, data.Creator, data.Code, data.Name, data.Subject, data.Account, data.Password, data.Status, data.HeadImg, data.SalesmanId, data.SalesmanName, data.CompanyId, data.CompanyName, data.IdentityType, data.Balance, data.BalanceWarning, data.FrozenAmount, data.CreditAmount, data.TotalConsumption, data.ContactName, data.ContactPhone, data.ContactEmail, data.DeleteTime, data.DirectResellerId, data.MapTime)
 | 
				
			||||||
 | 
						}, resellerResellerIdKey)
 | 
				
			||||||
 | 
						return ret, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) Update(ctx context.Context, data *Reseller) error {
 | 
				
			||||||
 | 
						resellerResellerIdKey := fmt.Sprintf("%s%v", cacheResellerResellerIdPrefix, data.Id)
 | 
				
			||||||
 | 
						_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, resellerRowsWithPlaceHolder)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, data.Creator, data.Code, data.Name, data.Subject, data.Account, data.Password, data.Status, data.HeadImg, data.SalesmanId, data.SalesmanName, data.CompanyId, data.CompanyName, data.IdentityType, data.Balance, data.BalanceWarning, data.FrozenAmount, data.CreditAmount, data.TotalConsumption, data.ContactName, data.ContactPhone, data.ContactEmail, data.DeleteTime, data.DirectResellerId, data.MapTime, data.Id)
 | 
				
			||||||
 | 
						}, resellerResellerIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) formatPrimary(primary any) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s%v", cacheResellerResellerIdPrefix, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
 | 
				
			||||||
 | 
						query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", resellerRows, m.table)
 | 
				
			||||||
 | 
						return conn.QueryRowCtx(ctx, v, query, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultResellerModel) tableName() string {
 | 
				
			||||||
 | 
						return m.table
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					package marketReseller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var ErrNotFound = sqlx.ErrNotFound
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					package genModel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ ServerClientModel = (*customServerClientModel)(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						// ServerClientModel is an interface to be customized, add more methods here,
 | 
				
			||||||
 | 
						// and implement the added methods in customServerClientModel.
 | 
				
			||||||
 | 
						ServerClientModel interface {
 | 
				
			||||||
 | 
							serverClientModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						customServerClientModel struct {
 | 
				
			||||||
 | 
							*defaultServerClientModel
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewServerClientModel returns a model for the database table.
 | 
				
			||||||
 | 
					func NewServerClientModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ServerClientModel {
 | 
				
			||||||
 | 
						return &customServerClientModel{
 | 
				
			||||||
 | 
							defaultServerClientModel: newServerClientModel(conn, c, opts...),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,134 @@
 | 
				
			||||||
 | 
					// Code generated by goctl. DO NOT EDIT.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package genModel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/builder"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/cache"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlc"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/stringx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var (
 | 
				
			||||||
 | 
						serverClientFieldNames          = builder.RawFieldNames(&ServerClient{})
 | 
				
			||||||
 | 
						serverClientRows                = strings.Join(serverClientFieldNames, ",")
 | 
				
			||||||
 | 
						serverClientRowsExpectAutoSet   = strings.Join(stringx.Remove(serverClientFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
 | 
				
			||||||
 | 
						serverClientRowsWithPlaceHolder = strings.Join(stringx.Remove(serverClientFieldNames, "`client_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cacheTransferServerClientClientIdPrefix = "cache:transfer:serverClient:clientId:"
 | 
				
			||||||
 | 
						cacheTransferServerClientClientIndexPrefix = "cache:transfer:serverClient:clientIndex:"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type (
 | 
				
			||||||
 | 
						serverClientModel interface {
 | 
				
			||||||
 | 
							Insert(ctx context.Context, data *ServerClient) (sql.Result, error)
 | 
				
			||||||
 | 
							FindOne(ctx context.Context, clientId int64) (*ServerClient, error)
 | 
				
			||||||
 | 
							Update(ctx context.Context, data *ServerClient) error
 | 
				
			||||||
 | 
							Delete(ctx context.Context, clientId int64) error
 | 
				
			||||||
 | 
							FindOneByIndex(ctx context.Context, index string) (*ServerClient, error)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defaultServerClientModel struct {
 | 
				
			||||||
 | 
							sqlc.CachedConn
 | 
				
			||||||
 | 
							table string
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ServerClient struct {
 | 
				
			||||||
 | 
							ClientId       int64     `db:"client_id"`
 | 
				
			||||||
 | 
							ClientName     string    `db:"client_name"`  // 客户名称
 | 
				
			||||||
 | 
							ClientIndex    string    `db:"client_index"` // 客户索引
 | 
				
			||||||
 | 
							ZltxMerchantId int64     `db:"zltx_merchant_id"`
 | 
				
			||||||
 | 
							ZltxSecret     string    `db:"zltx_secret"`
 | 
				
			||||||
 | 
							CreateTime     time.Time `db:"create_time"`
 | 
				
			||||||
 | 
							UpdateTime     time.Time `db:"update_time"`
 | 
				
			||||||
 | 
							Status         int64     `db:"status"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func newServerClientModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultServerClientModel {
 | 
				
			||||||
 | 
						return &defaultServerClientModel{
 | 
				
			||||||
 | 
							CachedConn: sqlc.NewConn(conn, c, opts...),
 | 
				
			||||||
 | 
							table:      "`server_client`",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) Delete(ctx context.Context, clientId int64) error {
 | 
				
			||||||
 | 
						transferServerClientClientIdKey := fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, clientId)
 | 
				
			||||||
 | 
						_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("delete from %s where `client_id` = ?", m.table)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, clientId)
 | 
				
			||||||
 | 
						}, transferServerClientClientIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) FindOne(ctx context.Context, clientId int64) (*ServerClient, error) {
 | 
				
			||||||
 | 
						transferServerClientClientIdKey := fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, clientId)
 | 
				
			||||||
 | 
						var resp ServerClient
 | 
				
			||||||
 | 
						err := m.QueryRowCtx(ctx, &resp, transferServerClientClientIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `client_id` = ? limit 1", serverClientRows, m.table)
 | 
				
			||||||
 | 
							return conn.QueryRowCtx(ctx, v, query, clientId)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) FindOneByIndex(ctx context.Context, index string) (*ServerClient, error) {
 | 
				
			||||||
 | 
						transferServerClientClientIndexKey := fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, index)
 | 
				
			||||||
 | 
						var resp ServerClient
 | 
				
			||||||
 | 
						err := m.QueryRowCtx(ctx, &resp, transferServerClientClientIndexKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("select %s from %s where `client_id` = ? limit 1", serverClientRows, m.table)
 | 
				
			||||||
 | 
							return conn.QueryRowCtx(ctx, v, query, index)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						switch err {
 | 
				
			||||||
 | 
						case nil:
 | 
				
			||||||
 | 
							return &resp, nil
 | 
				
			||||||
 | 
						case sqlc.ErrNotFound:
 | 
				
			||||||
 | 
							return nil, ErrNotFound
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) Insert(ctx context.Context, data *ServerClient) (sql.Result, error) {
 | 
				
			||||||
 | 
						transferServerClientClientIdKey := fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, data.ClientId)
 | 
				
			||||||
 | 
						ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, serverClientRowsExpectAutoSet)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, data.ClientId, data.ClientName, data.ClientIndex, data.ZltxMerchantId, data.ZltxSecret, data.Status)
 | 
				
			||||||
 | 
						}, transferServerClientClientIdKey)
 | 
				
			||||||
 | 
						return ret, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) Update(ctx context.Context, data *ServerClient) error {
 | 
				
			||||||
 | 
						transferServerClientClientIdKey := fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, data.ClientId)
 | 
				
			||||||
 | 
						_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
 | 
				
			||||||
 | 
							query := fmt.Sprintf("update %s set %s where `client_id` = ?", m.table, serverClientRowsWithPlaceHolder)
 | 
				
			||||||
 | 
							return conn.ExecCtx(ctx, query, data.ClientName, data.ClientIndex, data.ZltxMerchantId, data.ZltxSecret, data.Status, data.ClientId)
 | 
				
			||||||
 | 
						}, transferServerClientClientIdKey)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) formatPrimary(primary any) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s%v", cacheTransferServerClientClientIdPrefix, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
 | 
				
			||||||
 | 
						query := fmt.Sprintf("select %s from %s where `client_id` = ? limit 1", serverClientRows, m.table)
 | 
				
			||||||
 | 
						return conn.QueryRowCtx(ctx, v, query, primary)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *defaultServerClientModel) tableName() string {
 | 
				
			||||||
 | 
						return m.table
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					package genModel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "github.com/zeromicro/go-zero/core/stores/sqlx"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var ErrNotFound = sqlx.ErrNotFound
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,103 @@
 | 
				
			||||||
 | 
					module trasfer_middleware
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go 1.21
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require (
 | 
				
			||||||
 | 
						github.com/zeromicro/go-zero v1.6.5
 | 
				
			||||||
 | 
						github.com/zeromicro/zero-contrib/zrpc/registry/nacos v0.0.0-20231030135404-af9ae855016f
 | 
				
			||||||
 | 
						google.golang.org/grpc v1.63.2
 | 
				
			||||||
 | 
						google.golang.org/protobuf v1.34.1
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require (
 | 
				
			||||||
 | 
						filippo.io/edwards25519 v1.1.0 // indirect
 | 
				
			||||||
 | 
						github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
 | 
				
			||||||
 | 
						github.com/beorn7/perks v1.0.1 // indirect
 | 
				
			||||||
 | 
						github.com/buger/jsonparser v1.1.1 // indirect
 | 
				
			||||||
 | 
						github.com/cenkalti/backoff/v4 v4.2.1 // indirect
 | 
				
			||||||
 | 
						github.com/cespare/xxhash/v2 v2.2.0 // indirect
 | 
				
			||||||
 | 
						github.com/coreos/go-semver v0.3.1 // indirect
 | 
				
			||||||
 | 
						github.com/coreos/go-systemd/v22 v22.5.0 // indirect
 | 
				
			||||||
 | 
						github.com/davecgh/go-spew v1.1.1 // indirect
 | 
				
			||||||
 | 
						github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 | 
				
			||||||
 | 
						github.com/emicklei/go-restful/v3 v3.11.0 // indirect
 | 
				
			||||||
 | 
						github.com/fatih/color v1.16.0 // indirect
 | 
				
			||||||
 | 
						github.com/go-logr/logr v1.3.0 // indirect
 | 
				
			||||||
 | 
						github.com/go-logr/stdr v1.2.2 // indirect
 | 
				
			||||||
 | 
						github.com/go-openapi/jsonpointer v0.19.6 // indirect
 | 
				
			||||||
 | 
						github.com/go-openapi/jsonreference v0.20.2 // indirect
 | 
				
			||||||
 | 
						github.com/go-openapi/swag v0.22.4 // indirect
 | 
				
			||||||
 | 
						github.com/go-sql-driver/mysql v1.8.1 // indirect
 | 
				
			||||||
 | 
						github.com/gogo/protobuf v1.3.2 // indirect
 | 
				
			||||||
 | 
						github.com/golang/mock v1.6.0 // indirect
 | 
				
			||||||
 | 
						github.com/golang/protobuf v1.5.4 // indirect
 | 
				
			||||||
 | 
						github.com/google/gnostic-models v0.6.8 // indirect
 | 
				
			||||||
 | 
						github.com/google/go-cmp v0.6.0 // indirect
 | 
				
			||||||
 | 
						github.com/google/gofuzz v1.2.0 // indirect
 | 
				
			||||||
 | 
						github.com/google/uuid v1.6.0 // indirect
 | 
				
			||||||
 | 
						github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
 | 
				
			||||||
 | 
						github.com/jinzhu/copier v0.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/jmespath/go-jmespath v0.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/josharian/intern v1.0.0 // indirect
 | 
				
			||||||
 | 
						github.com/json-iterator/go v1.1.12 // indirect
 | 
				
			||||||
 | 
						github.com/mailru/easyjson v0.7.7 // indirect
 | 
				
			||||||
 | 
						github.com/mattn/go-colorable v0.1.13 // indirect
 | 
				
			||||||
 | 
						github.com/mattn/go-isatty v0.0.20 // indirect
 | 
				
			||||||
 | 
						github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
 | 
				
			||||||
 | 
						github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 | 
				
			||||||
 | 
						github.com/modern-go/reflect2 v1.0.2 // indirect
 | 
				
			||||||
 | 
						github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 | 
				
			||||||
 | 
						github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 // indirect
 | 
				
			||||||
 | 
						github.com/openzipkin/zipkin-go v0.4.2 // indirect
 | 
				
			||||||
 | 
						github.com/pelletier/go-toml/v2 v2.2.2 // indirect
 | 
				
			||||||
 | 
						github.com/pkg/errors v0.9.1 // indirect
 | 
				
			||||||
 | 
						github.com/prometheus/client_golang v1.18.0 // indirect
 | 
				
			||||||
 | 
						github.com/prometheus/client_model v0.5.0 // indirect
 | 
				
			||||||
 | 
						github.com/prometheus/common v0.45.0 // indirect
 | 
				
			||||||
 | 
						github.com/prometheus/procfs v0.12.0 // indirect
 | 
				
			||||||
 | 
						github.com/redis/go-redis/v9 v9.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/spaolacci/murmur3 v1.1.0 // indirect
 | 
				
			||||||
 | 
						go.etcd.io/etcd/api/v3 v3.5.13 // indirect
 | 
				
			||||||
 | 
						go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
 | 
				
			||||||
 | 
						go.etcd.io/etcd/client/v3 v3.5.13 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/exporters/zipkin v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/metric v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/sdk v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/otel/trace v1.19.0 // indirect
 | 
				
			||||||
 | 
						go.opentelemetry.io/proto/otlp v1.0.0 // indirect
 | 
				
			||||||
 | 
						go.uber.org/atomic v1.10.0 // indirect
 | 
				
			||||||
 | 
						go.uber.org/automaxprocs v1.5.3 // indirect
 | 
				
			||||||
 | 
						go.uber.org/multierr v1.9.0 // indirect
 | 
				
			||||||
 | 
						go.uber.org/zap v1.24.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/net v0.25.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/oauth2 v0.17.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/sync v0.6.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/sys v0.20.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/term v0.20.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/text v0.15.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/time v0.5.0 // indirect
 | 
				
			||||||
 | 
						google.golang.org/appengine v1.6.8 // indirect
 | 
				
			||||||
 | 
						google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
				
			||||||
 | 
						google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
				
			||||||
 | 
						google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
				
			||||||
 | 
						gopkg.in/inf.v0 v0.9.1 // indirect
 | 
				
			||||||
 | 
						gopkg.in/ini.v1 v1.66.2 // indirect
 | 
				
			||||||
 | 
						gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
 | 
				
			||||||
 | 
						gopkg.in/yaml.v2 v2.4.0 // indirect
 | 
				
			||||||
 | 
						gopkg.in/yaml.v3 v3.0.1 // indirect
 | 
				
			||||||
 | 
						k8s.io/api v0.29.3 // indirect
 | 
				
			||||||
 | 
						k8s.io/apimachinery v0.29.4 // indirect
 | 
				
			||||||
 | 
						k8s.io/client-go v0.29.3 // indirect
 | 
				
			||||||
 | 
						k8s.io/klog/v2 v2.110.1 // indirect
 | 
				
			||||||
 | 
						k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
 | 
				
			||||||
 | 
						k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
 | 
				
			||||||
 | 
						sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
 | 
				
			||||||
 | 
						sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
 | 
				
			||||||
 | 
						sigs.k8s.io/yaml v1.3.0 // indirect
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,63 @@
 | 
				
			||||||
 | 
					package common
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"crypto/md5"
 | 
				
			||||||
 | 
						"encoding/hex"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetMD5Hash(input string) string {
 | 
				
			||||||
 | 
						hash := md5.Sum([]byte(input))
 | 
				
			||||||
 | 
						return hex.EncodeToString(hash[:])
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// toMap 将结构体转换为map[string]interface{}
 | 
				
			||||||
 | 
					// StructToMap 将一个struct转换为map[string]interface{}
 | 
				
			||||||
 | 
					func StructToMap(obj interface{}) map[string]interface{} {
 | 
				
			||||||
 | 
						// 获取obj的类型
 | 
				
			||||||
 | 
						val := reflect.ValueOf(obj)
 | 
				
			||||||
 | 
						if val.Kind() == reflect.Ptr {
 | 
				
			||||||
 | 
							val = val.Elem()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 确保obj是一个struct
 | 
				
			||||||
 | 
						if val.Kind() != reflect.Struct {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 创建一个map来保存结果
 | 
				
			||||||
 | 
						data := make(map[string]interface{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 遍历struct的字段
 | 
				
			||||||
 | 
						for i := 0; i < val.NumField(); i++ {
 | 
				
			||||||
 | 
							// 获取字段的类型和值
 | 
				
			||||||
 | 
							valueField := val.Field(i)
 | 
				
			||||||
 | 
							typeField := val.Type().Field(i)
 | 
				
			||||||
 | 
							jsonTag := typeField.Tag.Get("json")
 | 
				
			||||||
 | 
							if idx := strings.Index(jsonTag, ","); idx != -1 {
 | 
				
			||||||
 | 
								// 如果有逗号,则取逗号之前的部分
 | 
				
			||||||
 | 
								jsonTag = jsonTag[:idx]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							// 忽略未导出的字段(字段名首字母小写)
 | 
				
			||||||
 | 
							if !typeField.IsExported() {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 将字段名和值添加到map中
 | 
				
			||||||
 | 
							data[jsonTag] = valueField.Interface()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return data
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// mergeMaps 合并任意数量的map
 | 
				
			||||||
 | 
					func MergeMaps(maps ...map[string]interface{}) map[string]interface{} {
 | 
				
			||||||
 | 
						merged := make(map[string]interface{})
 | 
				
			||||||
 | 
						for _, m := range maps {
 | 
				
			||||||
 | 
							for k, v := range m {
 | 
				
			||||||
 | 
								merged[k] = v
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return merged
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					package common
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"sort"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func ZltxSign(postData map[string]interface{}, secret string) string {
 | 
				
			||||||
 | 
						// 第一步:把key升序
 | 
				
			||||||
 | 
						keys := make([]string, 0, len(postData))
 | 
				
			||||||
 | 
						for key := range postData {
 | 
				
			||||||
 | 
							keys = append(keys, key)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						sort.Strings(keys)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 第二步:生成签名
 | 
				
			||||||
 | 
						// 拼接用于生成签名的原始字符串
 | 
				
			||||||
 | 
						rawStr := ""
 | 
				
			||||||
 | 
						for _, key := range keys {
 | 
				
			||||||
 | 
							value := fmt.Sprintf("%v", postData[key])
 | 
				
			||||||
 | 
							if rawStr != "" {
 | 
				
			||||||
 | 
								rawStr += "&"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							rawStr += fmt.Sprintf("%s=%s", key, value)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						rawStr += "&key=" + secret
 | 
				
			||||||
 | 
						return strings.ToUpper(GetMD5Hash(rawStr))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,58 @@
 | 
				
			||||||
 | 
					package pkg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func ErrLog(ctx context.Context, errContent ...any) {
 | 
				
			||||||
 | 
						path, _ := errLogFile()
 | 
				
			||||||
 | 
						// 创建一个文件对象
 | 
				
			||||||
 | 
						file, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							logx.Error(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer file.Close()
 | 
				
			||||||
 | 
						// 创建一个日志写入器,将日志写入文件
 | 
				
			||||||
 | 
						writer := logx.NewWriter(file)
 | 
				
			||||||
 | 
						// 使用该写入器记录日志
 | 
				
			||||||
 | 
						logx.SetWriter(writer)
 | 
				
			||||||
 | 
						logx.WithContext(ctx).WithCallerSkip(2).Errorf("errlog:", errContent)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func errLogFile() (string, error) {
 | 
				
			||||||
 | 
						logPath, err := runtimePath()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return "", err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						path := fmt.Sprintf("%s/%s", logPath, "err")
 | 
				
			||||||
 | 
						err = CheckDir(path)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return "", err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s/%s", path, time.Now().Format(time.DateOnly)), nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func runtimePath() (string, error) {
 | 
				
			||||||
 | 
						path, err := os.Getwd()
 | 
				
			||||||
 | 
						return fmt.Sprintf("../%s/%s", path, "runtime"), err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func CheckDir(path string) error {
 | 
				
			||||||
 | 
						// 判断目录是否存在
 | 
				
			||||||
 | 
						if _, err := os.Stat(path); os.IsNotExist(err) {
 | 
				
			||||||
 | 
							// 如果目录不存在,则创建它
 | 
				
			||||||
 | 
							err = os.MkdirAll(path, os.ModePerm)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else if err != nil {
 | 
				
			||||||
 | 
							// 如果Stat返回了其他错误(比如权限问题)
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,130 @@
 | 
				
			||||||
 | 
					package request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"net/url"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 请求结构体
 | 
				
			||||||
 | 
					type Request struct {
 | 
				
			||||||
 | 
						Method   string            `json:"method"`   // 请求方法
 | 
				
			||||||
 | 
						Url      string            `json:"url"`      // 请求url
 | 
				
			||||||
 | 
						Params   map[string]string `json:"params"`   // Query参数
 | 
				
			||||||
 | 
						Headers  map[string]string `json:"headers"`  // 请求头
 | 
				
			||||||
 | 
						Cookies  map[string]string `json:"cookies"`  // todo 处理 Cookies
 | 
				
			||||||
 | 
						Data     map[string]string `json:"data"`     // 表单格式请求数据
 | 
				
			||||||
 | 
						Json     map[string]string `json:"json"`     // JSON格式请求数据 todo 多层 嵌套
 | 
				
			||||||
 | 
						Files    map[string]string `json:"files"`    // todo 处理 Files
 | 
				
			||||||
 | 
						Raw      string            `json:"raw"`      // 原始请求数据
 | 
				
			||||||
 | 
						JsonByte []byte            `json:"json_raw"` // JSON格式请求数据 todo 多层 嵌套
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 响应结构体
 | 
				
			||||||
 | 
					type Response struct {
 | 
				
			||||||
 | 
						StatusCode int               `json:"status_code"` // 状态码
 | 
				
			||||||
 | 
						Reason     string            `json:"reason"`      // 状态码说明
 | 
				
			||||||
 | 
						Elapsed    float64           `json:"elapsed"`     // 请求耗时(秒)
 | 
				
			||||||
 | 
						Content    []byte            `json:"content"`     // 响应二进制内容
 | 
				
			||||||
 | 
						Text       string            `json:"text"`        // 响应文本
 | 
				
			||||||
 | 
						Headers    map[string]string `json:"headers"`     // 响应头
 | 
				
			||||||
 | 
						Cookies    map[string]string `json:"cookies"`     // todo 添加响应Cookies
 | 
				
			||||||
 | 
						Request    *Request          `json:"request"`     // 原始请求
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理请求方法
 | 
				
			||||||
 | 
					func (r *Request) getMethod() string {
 | 
				
			||||||
 | 
						return strings.ToUpper(r.Method) // 必须转为全部大写
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 组装URL
 | 
				
			||||||
 | 
					func (r *Request) getUrl() string {
 | 
				
			||||||
 | 
						if r.Params != nil {
 | 
				
			||||||
 | 
							urlValues := url.Values{}
 | 
				
			||||||
 | 
							Url, _ := url.Parse(r.Url) // todo 处理err
 | 
				
			||||||
 | 
							for key, value := range r.Params {
 | 
				
			||||||
 | 
								urlValues.Set(key, value)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							Url.RawQuery = urlValues.Encode()
 | 
				
			||||||
 | 
							return Url.String()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return r.Url
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 组装请求数据
 | 
				
			||||||
 | 
					func (r *Request) getData() io.Reader {
 | 
				
			||||||
 | 
						var reqBody string
 | 
				
			||||||
 | 
						if r.Headers == nil {
 | 
				
			||||||
 | 
							r.Headers = make(map[string]string, 1)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if r.Raw != "" {
 | 
				
			||||||
 | 
							reqBody = r.Raw
 | 
				
			||||||
 | 
						} else if r.Data != nil {
 | 
				
			||||||
 | 
							urlValues := url.Values{}
 | 
				
			||||||
 | 
							for key, value := range r.Data {
 | 
				
			||||||
 | 
								urlValues.Add(key, value)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							reqBody = urlValues.Encode()
 | 
				
			||||||
 | 
							r.Headers["Content-Type"] = "application/x-www-form-urlencoded"
 | 
				
			||||||
 | 
						} else if r.Json != nil {
 | 
				
			||||||
 | 
							bytesData, _ := json.Marshal(r.Json)
 | 
				
			||||||
 | 
							reqBody = string(bytesData)
 | 
				
			||||||
 | 
							r.Headers["Content-Type"] = "application/json"
 | 
				
			||||||
 | 
						} else if r.JsonByte != nil {
 | 
				
			||||||
 | 
							reqBody = string(r.JsonByte)
 | 
				
			||||||
 | 
							r.Headers["Content-Type"] = "application/json"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return strings.NewReader(reqBody)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 添加请求头-需要在getData后使用
 | 
				
			||||||
 | 
					func (r *Request) addHeaders(req *http.Request) {
 | 
				
			||||||
 | 
						if r.Headers != nil {
 | 
				
			||||||
 | 
							for key, value := range r.Headers {
 | 
				
			||||||
 | 
								req.Header.Add(key, value)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 准备请求
 | 
				
			||||||
 | 
					func (r *Request) prepare() *http.Request {
 | 
				
			||||||
 | 
						Method := r.getMethod()
 | 
				
			||||||
 | 
						Url := r.getUrl()
 | 
				
			||||||
 | 
						Data := r.getData()
 | 
				
			||||||
 | 
						req, _ := http.NewRequest(Method, Url, Data)
 | 
				
			||||||
 | 
						r.addHeaders(req)
 | 
				
			||||||
 | 
						return req
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 组装响应对象
 | 
				
			||||||
 | 
					func (r *Request) packResponse(res *http.Response, elapsed float64) Response {
 | 
				
			||||||
 | 
						var resp Response
 | 
				
			||||||
 | 
						resBody, _ := io.ReadAll(res.Body)
 | 
				
			||||||
 | 
						resp.Content = resBody
 | 
				
			||||||
 | 
						resp.Text = string(resBody)
 | 
				
			||||||
 | 
						resp.StatusCode = res.StatusCode
 | 
				
			||||||
 | 
						resp.Reason = strings.Split(res.Status, " ")[1]
 | 
				
			||||||
 | 
						resp.Elapsed = elapsed
 | 
				
			||||||
 | 
						resp.Headers = map[string]string{}
 | 
				
			||||||
 | 
						for key, value := range res.Header {
 | 
				
			||||||
 | 
							resp.Headers[key] = strings.Join(value, ";")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return resp
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 发送请求
 | 
				
			||||||
 | 
					func (r *Request) Send() (Response, error) {
 | 
				
			||||||
 | 
						req := r.prepare()
 | 
				
			||||||
 | 
						client := &http.Client{}
 | 
				
			||||||
 | 
						start := time.Now()
 | 
				
			||||||
 | 
						res, err := client.Do(req)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return Response{}, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer res.Body.Close()
 | 
				
			||||||
 | 
						elapsed := time.Since(start).Seconds()
 | 
				
			||||||
 | 
						return r.packResponse(res, elapsed), nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,83 @@
 | 
				
			||||||
 | 
					package test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"msgc/pkg/request"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 发送GET 请求
 | 
				
			||||||
 | 
					func TestGet(t *testing.T) {
 | 
				
			||||||
 | 
						r := request.Request{
 | 
				
			||||||
 | 
							Method:  "GET",
 | 
				
			||||||
 | 
							Url:     "https://httpbin.org/get?name=张三&age=12",
 | 
				
			||||||
 | 
							Headers: map[string]string{"Cookie": "abc", "Token": "123"}}
 | 
				
			||||||
 | 
						resp, _ := r.Send()
 | 
				
			||||||
 | 
						fmt.Printf("状态码: %d\n", resp.StatusCode)
 | 
				
			||||||
 | 
						fmt.Printf("原因: %s\n", resp.Reason)
 | 
				
			||||||
 | 
						fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
 | 
				
			||||||
 | 
						fmt.Printf("响应文本: %s\n", resp.Text)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 发送GET 带单独Query参数请求
 | 
				
			||||||
 | 
					func TestWAccessToken(t *testing.T) {
 | 
				
			||||||
 | 
						appid := "wx381e6a04ab7f69b6"
 | 
				
			||||||
 | 
						secret := "16f6152c216c07fdff4c0ecaf1a173ed"
 | 
				
			||||||
 | 
						r := request.Request{
 | 
				
			||||||
 | 
							Method: "GET",
 | 
				
			||||||
 | 
							Url:    "https://api.weixin.qq.com/cgi-bin/token",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Params: map[string]string{"grant_type": "client_credential", "appid": appid, "secret": secret},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						resp, err := r.Send()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							fmt.Println(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fmt.Printf("状态码: %d\n", resp.StatusCode)
 | 
				
			||||||
 | 
						fmt.Printf("原因: %s\n", resp.Reason)
 | 
				
			||||||
 | 
						fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
 | 
				
			||||||
 | 
						fmt.Printf("响应文本: %s\n", resp.Text)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestDtalkBlackBard(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						r := request.Request{
 | 
				
			||||||
 | 
							Method:  "POST",
 | 
				
			||||||
 | 
							Url:     "https://httpbin.org/post",
 | 
				
			||||||
 | 
							Data:    map[string]string{"name": "张三", "age": "12"},
 | 
				
			||||||
 | 
							Headers: map[string]string{"Cookie": "abc", "Token": "123"}}
 | 
				
			||||||
 | 
						resp, _ := r.Send()
 | 
				
			||||||
 | 
						fmt.Printf("状态码: %d\n", resp.StatusCode)
 | 
				
			||||||
 | 
						fmt.Printf("原因: %s\n", resp.Reason)
 | 
				
			||||||
 | 
						fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
 | 
				
			||||||
 | 
						fmt.Printf("响应文本: %s\n", resp.Text)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 发送POST 表单请求
 | 
				
			||||||
 | 
					func TestPostForm(t *testing.T) {
 | 
				
			||||||
 | 
						r := request.Request{
 | 
				
			||||||
 | 
							Method:  "POST",
 | 
				
			||||||
 | 
							Url:     "https://httpbin.org/post",
 | 
				
			||||||
 | 
							Data:    map[string]string{"name": "张三", "age": "12"},
 | 
				
			||||||
 | 
							Headers: map[string]string{"Cookie": "abc", "Token": "123"}}
 | 
				
			||||||
 | 
						resp, _ := r.Send()
 | 
				
			||||||
 | 
						fmt.Printf("状态码: %d\n", resp.StatusCode)
 | 
				
			||||||
 | 
						fmt.Printf("原因: %s\n", resp.Reason)
 | 
				
			||||||
 | 
						fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
 | 
				
			||||||
 | 
						fmt.Printf("响应文本: %s\n", resp.Text)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 发送POST JSON请求
 | 
				
			||||||
 | 
					func TestPostJson(t *testing.T) {
 | 
				
			||||||
 | 
						r := request.Request{
 | 
				
			||||||
 | 
							Method:  "POST",
 | 
				
			||||||
 | 
							Url:     "https://httpbin.org/post",
 | 
				
			||||||
 | 
							Json:    map[string]string{"name": "张三", "age": "12"},
 | 
				
			||||||
 | 
							Headers: map[string]string{"Cookie": "abc", "Token": "123"}}
 | 
				
			||||||
 | 
						resp, _ := r.Send()
 | 
				
			||||||
 | 
						fmt.Printf("状态码: %d\n", resp.StatusCode)
 | 
				
			||||||
 | 
						fmt.Printf("原因: %s\n", resp.Reason)
 | 
				
			||||||
 | 
						fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
 | 
				
			||||||
 | 
						fmt.Printf("响应文本: %s\n", resp.Text)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					package xerr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 成功返回
 | 
				
			||||||
 | 
					const OK uint32 = 200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**(前3位代表业务,后三位代表具体功能)**/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 全局错误码
 | 
				
			||||||
 | 
					const SERVER_AUTH_ERROR uint32 = 100007
 | 
				
			||||||
 | 
					const SERVER_COMMON_ERROR uint32 = 100001
 | 
				
			||||||
 | 
					const REUQEST_PARAM_ERROR uint32 = 100002
 | 
				
			||||||
 | 
					const TOKEN_EXPIRE_ERROR uint32 = 100003
 | 
				
			||||||
 | 
					const TOKEN_GENERATE_ERROR uint32 = 100004
 | 
				
			||||||
 | 
					const DB_ERROR uint32 = 100005
 | 
				
			||||||
 | 
					const DB_UPDATE_AFFECTED_ZERO_ERROR uint32 = 100006
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//用户模块
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,32 @@
 | 
				
			||||||
 | 
					package xerr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var message map[uint32]string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						message = make(map[uint32]string)
 | 
				
			||||||
 | 
						message[OK] = "SUCCESS"
 | 
				
			||||||
 | 
						message[SERVER_AUTH_ERROR] = "鉴权失败"
 | 
				
			||||||
 | 
						message[SERVER_COMMON_ERROR] = "服务器开小差啦,稍后再来试一试"
 | 
				
			||||||
 | 
						message[REUQEST_PARAM_ERROR] = "参数错误"
 | 
				
			||||||
 | 
						message[TOKEN_EXPIRE_ERROR] = "token失效,请重新登陆"
 | 
				
			||||||
 | 
						message[TOKEN_GENERATE_ERROR] = "生成token失败"
 | 
				
			||||||
 | 
						message[DB_ERROR] = "数据库繁忙,请稍后再试"
 | 
				
			||||||
 | 
						message[DB_UPDATE_AFFECTED_ZERO_ERROR] = "更新数据影响行数为0"
 | 
				
			||||||
 | 
						message[SERVER_AUTH_ERROR] = "身份验证失败"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MapErrMsg(errcode uint32) string {
 | 
				
			||||||
 | 
						if msg, ok := message[errcode]; ok {
 | 
				
			||||||
 | 
							return msg
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return "服务器开小差啦,稍后再来试一试"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func IsCodeErr(errcode uint32) bool {
 | 
				
			||||||
 | 
						if _, ok := message[errcode]; ok {
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,42 @@
 | 
				
			||||||
 | 
					package xerr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						pkg "trasfer_middleware/pkg/log"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					常用通用固定错误
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CodeError struct {
 | 
				
			||||||
 | 
						errCode uint32
 | 
				
			||||||
 | 
						errMsg  string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 返回给前端的错误码
 | 
				
			||||||
 | 
					func (e *CodeError) GetErrCode() uint32 {
 | 
				
			||||||
 | 
						return e.errCode
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 返回给前端显示端错误信息
 | 
				
			||||||
 | 
					func (e *CodeError) GetErrMsg() string {
 | 
				
			||||||
 | 
						return e.errMsg
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (e *CodeError) Error() string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("ErrCode:%d,ErrMsg:%s", e.errCode, e.errMsg)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewErrCodeMsg(errCode uint32, errMsg string) *CodeError {
 | 
				
			||||||
 | 
						return &CodeError{errCode: errCode, errMsg: errMsg}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func NewErrCode(errCode uint32) *CodeError {
 | 
				
			||||||
 | 
						return &CodeError{errCode: errCode, errMsg: MapErrMsg(errCode)}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewErrMsg(ctx context.Context, errMsg string) *CodeError {
 | 
				
			||||||
 | 
						pkg.ErrLog(ctx, errMsg)
 | 
				
			||||||
 | 
						return &CodeError{errCode: SERVER_COMMON_ERROR, errMsg: errMsg}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue