chengquan

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 16 Imported by: 0

README

Golang

📦 Golang 橙券开放平台

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/chengquan@v1.0.4

Documentation

Index

Constants

View Source
const (
	CodeSuccess = 7000
)
View Source
const (
	LogTable = "chengquan"
)

Variables

View Source
var (
	Version = "1.0.4"
)

Functions

func CodeInfo

func CodeInfo[codeT int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | string](code codeT) string

CodeInfo 接口响应返回码

func StateInfo

func StateInfo[codeT int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | string](state codeT) string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 实例

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient 创建实例化

func (*Client) GetAesIv added in v1.0.4

func (c *Client) GetAesIv() string

func (*Client) GetAesKey added in v1.0.4

func (c *Client) GetAesKey() string

func (*Client) GetApiURL added in v1.0.4

func (c *Client) GetApiURL() string

func (*Client) GetAppID added in v1.0.4

func (c *Client) GetAppID() string

func (*Client) GetAppKey added in v1.0.4

func (c *Client) GetAppKey() string

func (*Client) OrderDirectCharge

func (c *Client) OrderDirectCharge(ctx context.Context, orderNo string, rechargeNumber string, productID int64, amount int64, notMustParams ...gorequest.Params) (*OrderDirectChargeResult, error)

OrderDirectCharge 直充下单接口 order_no = 商户提交的订单号,最长32位(商户保证其唯一性) recharge_number = 充值账号 product_id = 充值产品编号 amount = 充值数量(加油卡,视频业务默认为1,其它业务按照实际情况传递)。数量范围1-99999 ip = 充值ip(仅腾讯业务需要,根据实际情况进行传递) oil_phone_account = 加油卡充值时用户的手机号 notify_url = 橙券主动通知订单结果地址 https://chengquan.cn/rechargeInterface/directCharge.html

func (*Client) OrderGet

func (c *Client) OrderGet(ctx context.Context, orderNo string, notMustParams ...gorequest.Params) (*OrderGetResult, error)

OrderGet 订单查询接口 order_no = 商户提交的订单号,最长32位(商户保证其唯一性) https://www.chengquan.cn/rechargeInterface/queryOrder.html

func (*Client) OrderTelPay

func (c *Client) OrderTelPay(ctx context.Context, orderNo string, rechargeNumber string, price int64, notMustParams ...gorequest.Params) (*OrderTelPayResult, error)

OrderTelPay 话费下单接口 order_no = 商户提交的订单号,最长32位(商户保证其唯一性) recharge_number = 充值手机号码 price = 充值面值(单位:分) notify_url = 橙券主动通知订单结果地址 https://www.chengquan.cn/rechargeInterface/tel.html

func (*Client) SetAesIv added in v1.0.3

func (c *Client) SetAesIv(v string) *Client

func (*Client) SetAesKey added in v1.0.3

func (c *Client) SetAesKey(v string) *Client

func (*Client) SetApiURL added in v1.0.3

func (c *Client) SetApiURL(v string) *Client

func (*Client) SetAppID added in v1.0.3

func (c *Client) SetAppID(v string) *Client

func (*Client) SetAppKey added in v1.0.3

func (c *Client) SetAppKey(v string) *Client

func (*Client) SetClientIP added in v1.0.3

func (c *Client) SetClientIP(clientIP string) *Client

SetClientIP 配置

func (*Client) SetLogFun added in v1.0.3

func (c *Client) SetLogFun(logFun gorequest.LogFunc)

SetLogFun 设置日志记录函数

func (*Client) SetTrace added in v1.0.3

func (c *Client) SetTrace(trace bool)

SetTrace 设置OpenTelemetry链路追踪

func (*Client) TraceEndSpan added in v1.0.3

func (c *Client) TraceEndSpan()

TraceEndSpan 结束OpenTelemetry链路追踪状态

func (*Client) TraceGetSpanID added in v1.0.3

func (c *Client) TraceGetSpanID() (spanID string)

TraceGetSpanID 获取OpenTelemetry链路追踪SpanID

func (*Client) TraceGetTraceID added in v1.0.3

func (c *Client) TraceGetTraceID() (traceID string)

TraceGetTraceID 获取OpenTelemetry链路追踪TraceID

func (*Client) TraceRecordError added in v1.0.3

func (c *Client) TraceRecordError(err error, options ...trace.EventOption)

TraceRecordError 记录OpenTelemetry链路追踪错误

func (*Client) TraceSetAttributes added in v1.0.3

func (c *Client) TraceSetAttributes(kv ...attribute.KeyValue)

TraceSetAttributes 设置OpenTelemetry链路追踪属性

func (*Client) TraceSetStatus added in v1.0.3

func (c *Client) TraceSetStatus(code codes.Code, description string)

TraceSetStatus 设置OpenTelemetry链路追踪状态

func (*Client) TraceStartSpan added in v1.0.3

func (c *Client) TraceStartSpan(ctx context.Context, spanName string) context.Context

TraceStartSpan 开始OpenTelemetry链路追踪状态

func (*Client) UserBalanceGet

func (c *Client) UserBalanceGet(ctx context.Context, notMustParams ...gorequest.Params) (*UserBalanceGetResult, error)

UserBalanceGet 账号余额查询接口 https://chengquan.cn/basicData/queryBalance.html

type ClientConfig

type ClientConfig struct {
	ApiURL string
	AppID  string
	AppKey string
	AesKey string
	AesIv  string
}

ClientConfig 实例配置

type OrderDirectChargeResponse

type OrderDirectChargeResponse struct {
	Code    int    `json:"code"`    // 错误代码
	Message string `json:"message"` // 错误信息
	Data    struct {
		AppID          string  `json:"app_id"`          // 商户账号
		OrderNo        string  `json:"order_no"`        // 商户订单号
		RechargeNumber string  `json:"recharge_number"` // 充值手机号码
		StartTime      string  `json:"start_time"`      // 订单创建时间
		EndTime        string  `json:"end_time"`        // 订单完成时间,如果订单为充值中该时间和创建时间相同,如果成功或者失败该时间为订单完成时间。
		State          string  `json:"state"`           // 订单状态
		ConsumeAmount  float64 `json:"consume_amount"`  // 扣款金额(单位:元),保留小数点后四位
	} `json:"data"`
}

type OrderDirectChargeResult

type OrderDirectChargeResult struct {
	Result OrderDirectChargeResponse // 结果
	Body   []byte                    // 内容
	Http   gorequest.Response        // 请求
}

type OrderGetResponse

type OrderGetResponse struct {
	Code    int    `json:"code"`    // 错误代码
	Message string `json:"message"` // 错误信息
	Data    struct {
		AppID          string  `json:"app_id"`          // 商户账号
		OrderNo        string  `json:"order_no"`        // 商户订单号
		RechargeNumber string  `json:"recharge_number"` // 充值账号
		StartTime      string  `json:"start_time"`      // 订单创建时间
		EndTime        string  `json:"end_time"`        // 订单完成时间,如果订单为充值中该时间和创建时间相同,如果成功或者失败该时间为订单完成时间。
		State          string  `json:"state"`           // 订单状态
		ConsumeAmount  float64 `json:"consume_amount"`  // 扣款金额(单位:元),保留小数点后四位
	} `json:"data"`
}

type OrderGetResult

type OrderGetResult struct {
	Result OrderGetResponse   // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

type OrderTelPayResponse

type OrderTelPayResponse struct {
	Code    int    `json:"code"`    // 错误代码
	Message string `json:"message"` // 错误信息
	Data    struct {
		AppID          string  `json:"app_id"`          // 商户账号
		OrderNo        string  `json:"order_no"`        // 商户订单号
		RechargeNumber string  `json:"recharge_number"` // 充值账号
		StartTime      string  `json:"start_time"`      // 订单创建时间
		EndTime        string  `json:"end_time"`        // 订单完成时间,如果订单为充值中该时间和创建时间相同,如果成功或者失败该时间为订单完成时间。
		State          string  `json:"state"`           // 订单状态
		ConsumeAmount  float64 `json:"consume_amount"`  // 扣款金额(单位:元),保留小数点后四位
	} `json:"data"`
}

type OrderTelPayResult

type OrderTelPayResult struct {
	Result OrderTelPayResponse // 结果
	Body   []byte              // 内容
	Http   gorequest.Response  // 请求
}

type UserBalanceGetResponse

type UserBalanceGetResponse struct {
	Code    int    `json:"code"`    // 错误代码
	Message string `json:"message"` // 错误信息
	Data    struct {
		AppID   string  `json:"app_id"`  // 商户账号
		Balance float64 `json:"balance"` // 商户余额(单位:元)
	} `json:"data"`
}

type UserBalanceGetResult

type UserBalanceGetResult struct {
	Result UserBalanceGetResponse // 结果
	Body   []byte                 // 内容
	Http   gorequest.Response     // 请求
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL