kashangwl

package module
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 14 Imported by: 0

README

Golang

📦 Golang 权益销售系统开放平台

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/kashangwl@v1.0.36

Documentation

Index

Constants

View Source
const (
	CodeSuccess = "ok"
)
View Source
const (
	LogTable = "kashangwl"
)
View Source
const (
	Version = "1.0.36"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiBuyResponse

type ApiBuyResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		OrderId      string `json:"order_id"`      // 订单号
		ProductPrice string `json:"product_price"` // 商品价格
		TotalPrice   string `json:"total_price"`   // 总支付价格
		RechargeUrl  string `json:"recharge_url"`  // 卡密充值网址
		State        int    `json:"state"`         // 订单状态(100:等待发货,101:正在充值,200:交易成功,500:交易失败,501:未知状态)
		Cards        []struct {
			CardNo       string `json:"card_no"`
			CardPassword string `json:"card_password"`
		} `json:"cards,omitempty"` // 卡密(仅当订单成功并且商品类型为卡密时返回此数据)
		Tickets []struct {
			No     string `json:"no"`
			Ticket string `json:"ticket"`
		} `json:"tickets,omitempty"` // 卡券(仅当订单成功并且商品类型为卡券时返回此数据)
	} `json:"data"`
}

type ApiBuyResult

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

type ApiCustomerResponse

type ApiCustomerResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Id      int    `json:"id"`      // 商家编号
		Name    string `json:"name"`    // 商家名称
		Balance string `json:"balance"` // 余额
	} `json:"data"`
}

type ApiCustomerResult

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

type ApiOrderResponse

type ApiOrderResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Id                 string `json:"id"`                        // 订单号
		ProductId          int    `json:"product_id"`                // 商品编号
		ProductName        string `json:"product_name"`              // 商品名称
		ProductType        int    `json:"product_type"`              // 商品类型(1:充值,2:卡密,3:卡券,4:人工)
		ProductPrice       string `json:"product_price"`             // 售价
		Quantity           int    `json:"quantity"`                  // 购买数量
		TotalPrice         string `json:"total_price"`               // 总支付价格
		RefundedAmount     string `json:"refunded_amount,omitempty"` // 已退款金额
		BuyerCustomerId    int    `json:"buyer_customer_id"`         // 买家编号
		BuyerCustomerName  string `json:"buyer_customer_name"`       // 买家名称
		SellerCustomerId   int    `json:"seller_customer_id"`        // 卖家编号
		SellerCustomerName string `json:"seller_customer_name"`      // 卖家名称
		State              int    `json:"state"`                     // 订单状态(100:等待发货,101:正在充值,200:交易成功,500:交易失败,501:未知状态)
		CreatedAt          string `json:"created_at"`                // 下单时间
		RechargeAccount    string `json:"recharge_account"`          // 充值账号
		ProgressInit       int    `json:"progress_init,omitempty"`   // 充值进度:初始值
		ProgressNow        int    `json:"progress_now,omitempty"`    // 充值进度:现在值
		ProgressTarget     int    `json:"progress_target,omitempty"` // 充值进度:目标值
		RechargeInfo       string `json:"recharge_info,omitempty"`   // 返回信息
		RechargeUrl        string `json:"recharge_url,omitempty"`    // 卡密充值网址
		//Cards              []struct {
		//	No       string `json:"no,omitempty"`
		//	Password string `json:"password,omitempty"`
		//} `json:"cards,omitempty"` //【卡密类订单】卡密
		RechargeParams string `json:"recharge_params"`          //【充值类订单】
		OuterOrderId   string `json:"outer_order_id,omitempty"` // 外部订单号
	} `json:"data"`
}

type ApiOrderResult

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

type ApiOuterOrderResponse

type ApiOuterOrderResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Id                 string `json:"id"`                        // 订单号
		ProductId          int    `json:"product_id"`                // 商品编号
		ProductName        string `json:"product_name"`              // 商品名称
		ProductType        int    `json:"product_type"`              // 商品类型(1:充值,2:卡密,3:卡券,4:人工)
		ProductPrice       string `json:"product_price"`             // 售价
		Quantity           int    `json:"quantity"`                  // 购买数量
		TotalPrice         string `json:"total_price"`               // 总支付价格
		RefundedAmount     string `json:"refunded_amount,omitempty"` // 已退款金额
		BuyerCustomerId    int    `json:"buyer_customer_id"`         // 买家编号
		BuyerCustomerName  string `json:"buyer_customer_name"`       // 买家名称
		SellerCustomerId   int    `json:"seller_customer_id"`        // 卖家编号
		SellerCustomerName string `json:"seller_customer_name"`      // 卖家名称
		State              int    `json:"state"`                     // 订单状态(100:等待发货,101:正在充值,200:交易成功,500:交易失败,501:未知状态)
		CreatedAt          string `json:"created_at"`                // 下单时间
		RechargeAccount    string `json:"recharge_account"`          // 充值账号
		ProgressInit       int    `json:"progress_init,omitempty"`   // 充值进度:初始值
		ProgressNow        int    `json:"progress_now,omitempty"`    // 充值进度:现在值
		ProgressTarget     int    `json:"progress_target,omitempty"` // 充值进度:目标值
		RechargeInfo       string `json:"recharge_info,omitempty"`   // 返回信息
		RechargeUrl        string `json:"recharge_url,omitempty"`    // 卡密充值网址
		//Cards              []struct {
		//	No       string `json:"no,omitempty"`
		//	Password string `json:"password,omitempty"`
		//} `json:"cards,omitempty"` //【卡密类订单】卡密
		RechargeParams string `json:"recharge_params"`          //【充值类订单】
		OuterOrderId   string `json:"outer_order_id,omitempty"` // 外部订单号
	} `json:"data"`
}

func (ApiOuterOrderResponse) GetStateDesc added in v1.0.32

func (resp ApiOuterOrderResponse) GetStateDesc(state int) string

type ApiOuterOrderResult

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

type ApiProductRechargeParamsResponse

type ApiProductRechargeParamsResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		RechargeAccountLabel string `json:"recharge_account_label"` // 充值账号类型名称
		RechargeParams       []struct {
			Name    string `json:"name"`
			Type    string `json:"type"`
			Options string `json:"options"`
		} `json:"recharge_params"` // 	充值参数
	} `json:"data"`
}

type ApiProductRechargeParamsResult

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

type ApiProductResponse

type ApiProductResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Id                      int64  `json:"id"`                        // 商品编号
		ProductName             string `json:"product_name,omitempty"`    // 商品名称
		Name                    string `json:"name"`                      // 规格名称
		Price                   string `json:"price"`                     // 售价
		ValidPurchasingQuantity string `json:"valid_purchasing_quantity"` // 合法的购买数量
		SuperiorCommissionsRate int    `json:"superior_commissions_rate"` // 上级佣金比例
		Type                    int    `json:"type"`                      // 商品类型(1:充值,2:卡密,3:卡券,4:人工)
		SupplyState             int    `json:"supply_state"`              // 库存状态(1:充足,2:断货)
		StockState              int    `json:"stock_state"`               // 状态(1:上架,2:维护,3:下架)
		BanStartAt              string `json:"ban_start_at,omitempty"`    // 禁售开始时间
		BanEndAt                string `json:"ban_end_at,omitempty"`      // 禁售结束时间
	} `json:"data"`
}

type ApiProductResult

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

type Client

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

Client 实例

func NewClient

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

NewClient 创建实例化

func (*Client) ApiBuy

func (c *Client) ApiBuy(ctx context.Context, productID int64, quantity int64, notMustParams ...gorequest.Params) (*ApiBuyResult, error)

ApiBuy 购买商品 product_id = 商品编号 recharge_account = 充值账号 recharge_template_input_items = 模板充值参数 quantity = 购买数量 notify_url = 异步通知地址 outer_order_id = 外部订单号 safe_cost = 安全进价 client_ip = 购买的用户真实IP http://doc.cqmeihu.cn/sales/buy.html

func (*Client) ApiBuyNotifyHttp added in v1.0.33

func (c *Client) ApiBuyNotifyHttp(ctx context.Context, r *http.Request) (validateJson ResponseApiBuyNotifyHttp, err error)

ApiBuyNotifyHttp 购买商品 - 回调通知 http://doc.cqmeihu.cn/sales/order-status-notify.html

func (*Client) ApiCustomer

func (c *Client) ApiCustomer(ctx context.Context, customerID int64, notMustParams ...gorequest.Params) (*ApiCustomerResult, error)

ApiCustomer 获取商家信息 customer_id = 商家编号 http://doc.cqmeihu.cn/sales/merchant-info.html

func (*Client) ApiOrder

func (c *Client) ApiOrder(ctx context.Context, orderID int64, notMustParams ...gorequest.Params) (*ApiOrderResult, error)

ApiOrder 获取单个订单信息。仅能获取自己购买的订单。 order_id = 订单号 http://doc.cqmeihu.cn/sales/order-info.html

func (*Client) ApiOuterOrder

func (c *Client) ApiOuterOrder(ctx context.Context, outerOrderID string, notMustParams ...gorequest.Params) (*ApiOuterOrderResult, error)

ApiOuterOrder 使用外部订单号获取单个订单信息 仅能获取自己购买的订单 outer_order_id = 外部订单号 http://doc.cqmeihu.cn/sales/outer-order-info.html

func (*Client) ApiProduct

func (c *Client) ApiProduct(ctx context.Context, productID int64, notMustParams ...gorequest.Params) (*ApiProductResult, error)

ApiProduct 获取单个商品信息 product_id = 商品编号 http://doc.cqmeihu.cn/sales/product-info.html

func (*Client) ApiProductRechargeParams

func (c *Client) ApiProductRechargeParams(ctx context.Context, productID int64, notMustParams ...gorequest.Params) (*ApiProductRechargeParamsResult, error)

ApiProductRechargeParams 获取商品的充值参数(仅支持充值类商品) product_id = 商品编号 http://doc.cqmeihu.cn/sales/recharge-params.html

func (*Client) ConfigApiGormFun added in v1.0.32

func (c *Client) ConfigApiGormFun(apiClientFun golog.ApiGormFun)

ConfigApiGormFun 接口日志配置

func (*Client) SetConfig added in v1.0.8

func (c *Client) SetConfig(config *SetConfigConfig) *Client

SetConfig 配置

type ClientConfig added in v1.0.11

type ClientConfig struct {
	CustomerId  int64  // 商家编号
	CustomerKey string // 商家密钥
}

ClientConfig 实例配置

type ResponseApiBuyNotifyHttp added in v1.0.33

type ResponseApiBuyNotifyHttp struct {
	OrderId      string `json:"order_id"`                 // 订单编号
	OuterOrderId string `json:"outer_order_id,omitempty"` // 商户订单号
	ProductId    int64  `json:"product_id,omitempty"`     // 商品编号
	Quantity     int64  `json:"quantity"`                 // 购买数量
	State        int64  `json:"state"`                    // 订单状态(100:等待发货,101:正在充值,200:交易成功,500:交易失败,501:未知状态)
	StateInfo    string `json:"state_info,omitempty"`     // 状态信息
	CreatedAt    string `json:"created_at"`               // 购买数量
}

ResponseApiBuyNotifyHttp 购买商品 - 回调通知 - 请求参数

type SetConfigConfig added in v1.0.8

type SetConfigConfig struct {
	CustomerId  int64  // 商家编号
	CustomerKey string // 商家密钥
}

Jump to

Keyboard shortcuts

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