fulu_gosdk

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-2-Clause Imports: 12 Imported by: 0

README

fulu-gosdk

福禄API sdk golang实现

Installation

go get github.com/t2krew/fulu-gosdk

Usage

import (
    "context"
	"time"
	"os"
	"log"
    fulu"github.com/t2krew/fulu-gosdk"
)

var cfg = Config{
    Debug:     true,
    Endpoint:  "https://openapi.fulu.com/api/getway",
    AppKey:    os.Getenv("FULU_APPKEY"),
    AppSecret: os.Getenv("FULU_APPSECRET"),
}

client, err := fulu.New(cfg)
if err != nil {
	panic(err)
}

// 查询商品信息

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

var productID string
productInfo, err := client.GetProductInfo(ctx, productID)
if err != nil {
	panic(err)
}

log.Printf("product: %+v", productInfo)

Documentation

Index

Constants

View Source
const (
	MethodGetProductList          = Method("fulu.goods.list.get")
	MethodGetProductInfo          = Method("fulu.goods.info.get")
	MethodGetProductTemplate      = Method("fulu.goods.template.get")
	MethodCheckProductStock       = Method("fulu.goods.stock.check")
	MethodGetAccountInfo          = Method("fulu.user.info.get")
	MethodGetQQNickname           = Method("fulu.market.qqnickname.get")
	MethodGetMobileInfo           = Method("fulu.mobile.info.get")
	MethodGetMobileMaintainStatus = Method("fulu.mobile.maintain.check")
	MethodCreateDirectOrder       = Method("fulu.order.direct.add")
	MethodCreateCardOrder         = Method("fulu.order.card.add")
	MethodCreateMobileOrder       = Method("fulu.order.mobile.add")
	MethodQueryOrder              = Method("fulu.order.info.get")
	MethodQueryOrderExtend        = Method("fulu.order.extend.get")
)
View Source
const (
	OrderStateSuccess    = "success"    // 成功
	OrderStateProcessing = "processing" // 处理中
	OrderStateFailed     = "failed"     // 失败
	OrderStateUntreated  = "untreated"  // 未处理
)
View Source
const (
	ProductDetailFormatPlain = 0 // 纯文本
	ProductDetailFormatJSON  = 1 // json
)
View Source
const (
	SaleStatusValid         = SaleStatus("上架")
	SaleStatusInvalid       = SaleStatus("下架")
	SaleStatusMaintain      = SaleStatus("维护中")
	SaleStatusStockMaintain = SaleStatus("库存维护")
)
View Source
const (
	StockStatusEnough = StockStatus("充足")
	StockStatusOut    = StockStatus("断货")
	StockStatusAlarm  = StockStatus("警报")
)
View Source
const (
	SpChinaMobile  = MobileSpType("1") // 中国移动
	SpChinaTelecom = MobileSpType("2") // 中国电信
	SpChinaUnicom  = MobileSpType("3") // 中国联通
)
View Source
const (
	MaintainStateOK    = MobileMaintainState("正常")
	MaintainStateNotOK = MobileMaintainState("维护")
)
View Source
const (
	TimestampFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func MD5

func MD5(str string) string

Types

type AccountInfo

type AccountInfo struct {
	Name    string  `json:"name"`
	Balance float64 `json:"balance"`
	IsOpen  int     `json:"is_open"`
}

type CardItem

type CardItem struct {
	CardType     int    `json:"card_type"`
	CardNumber   string `json:"card_number"`
	CardPwd      string `json:"card_pwd"`
	CardDeadline string `json:"card_deadline"`
}

CardItem 卡密商品

type CardOrderResult

type CardOrderResult struct {
	OrderID              string  `json:"order_id"`
	CustomerOrderNO      string  `json:"customer_order_no"`
	ProductID            int64   `json:"product_id"`
	ProductName          string  `json:"product_name"`
	BuyNum               int     `json:"buy_num"`
	OrderType            int     `json:"order_type"`
	OrderPrice           float64 `json:"order_price"`
	OrderState           string  `json:"order_state"`
	CreateTime           string  `json:"create_time"`
	FinishTime           string  `json:"finish_time"`
	OperatorSerialNumber string  `json:"operator_serial_number"`
}

type CheckProductStockParams

type CheckProductStockParams struct {
	BuyNum    int    `json:"buy_num"`
	ProductID string `json:"product_id"`
}

CheckProductStockParams 校验库存请求参数

type CheckProductStockResult

type CheckProductStockResult struct {
	StockStatus string `json:"stock_status"`
	ProductID   int    `json:"product_id"`
}

CheckProductStockResult 校验库存结果

type Client

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

func New

func New(cfg Config) (*Client, error)

New 初始化福禄sdk实例

func NewWithClient

func NewWithClient(cfg Config, httpClient *http.Client) (*Client, error)

NewWithClient 初始化自定义http.Client的福禄sdk实例

func (*Client) CheckProductStock

func (c *Client) CheckProductStock(ctx context.Context, productID string, num int) (*CheckProductStockResult, error)

CheckProductStock 校验商品库存

func (*Client) CreateCardOrder

func (c *Client) CreateCardOrder(ctx context.Context, params CreateCardOrderBizContent) (*CardOrderResult, error)

CreateCardOrder 创建卡密订单

func (*Client) CreateDirectOrder

func (c *Client) CreateDirectOrder(ctx context.Context, params CreateDirectOrderBizContent) (*DirectOrderResult, error)

CreateDirectOrder 创建直充订单

func (*Client) CreateMobileOrder

func (c *Client) CreateMobileOrder(ctx context.Context, params CreateMobileOrderBizContent) (*MobileOrderResult, error)

CreateMobileOrder 创建话费订单

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context) (*AccountInfo, error)

GetAccountInfo 获取用户信息

func (*Client) GetMobileInfo

func (c *Client) GetMobileInfo(ctx context.Context, mobileNO string, faceValue ...float64) (*GetMobileInfoResult, error)

GetMobileInfo 获取手机归属地

func (*Client) GetMobileMaintainStatus

func (c *Client) GetMobileMaintainStatus(ctx context.Context, mobileNO string, faceValue int) (*GetMobileMaintainStatusResult, error)

GetMobileMaintainStatus 话费维护状态检查

func (*Client) GetProductChangeInfo

func (c *Client) GetProductChangeInfo(data interface{})

func (*Client) GetProductInfo

func (c *Client) GetProductInfo(ctx context.Context, productID string, format ...ProductDetailFormat) (*ProductInfo, error)

GetProductInfo 获取商品信息 method: fulu.goods.info.get

func (*Client) GetProductList

func (c *Client) GetProductList(ctx context.Context, params *GetProductListParams) ([]ProductListItem, error)

GetProductList 获取商品列表 method: fulu.goods.list.get

func (*Client) GetProductTemplate

func (c *Client) GetProductTemplate(ctx context.Context, templateID string) (*ProductTemplate, error)

GetProductTemplate 获取商品模板

func (*Client) GetQQNickname

func (c *Client) GetQQNickname(ctx context.Context, qqNumber string) (*GetQQNicknameResult, error)

GetQQNickname 获取qq昵称

func (*Client) GetReconciliation

func (c *Client) GetReconciliation(ctx context.Context)

GetReconciliation 对账单申请

func (*Client) QueryOrder

func (c *Client) QueryOrder(ctx context.Context, customerOrderNO string) (*Order, error)

QueryOrder 订单查询

func (*Client) QueryOrderExtend

func (c *Client) QueryOrderExtend(ctx context.Context, customerOrderNO string) (*OrderExtend, error)

QueryOrderExtend 订单扩展信息查询

func (*Client) Request

func (c *Client) Request(ctx context.Context, method Method, bizContent interface{}, result interface{}) error

Request 发起接口请求

type Config

type Config struct {
	Debug        bool   `json:"debug" yaml:"debug"`
	Endpoint     string `json:"endpoint" yaml:"endpoint"`
	AppKey       string `json:"app_key" yaml:"app_key"`
	AppSecret    string `json:"app_secret" yaml:"app_secret"`
	Format       string `json:"format" yaml:"format"`
	Version      string `json:"version" yaml:"version"`
	Charset      string `json:"charset" yaml:"charset"`
	SignType     string `json:"sign_type" yaml:"sign_type"`
	AppAuthToken string `json:"app_auth_token" yaml:"app_auth_token"`
}

type CreateCardOrderBizContent

type CreateCardOrderBizContent struct {
	ProductID       int64   `json:"product_id"`
	BuyNum          int     `json:"buy_num"`
	CustomerOrderNO string  `json:"customer_order_no"`
	CustomerPrice   float64 `json:"customer_price"`
	ShopType        string  `json:"shop_type"`
	ExternalBizID   string  `json:"external_biz_id"`
}

type CreateDirectOrderBizContent

type CreateDirectOrderBizContent struct {
	ProductID        int64   `json:"product_id"`
	CustomerOrder    string  `json:"customer_order"`
	ChargeAccount    string  `json:"charge_account"`
	BuyNum           int     `json:"buy_num"`
	ChargeGameName   string  `json:"charge_game_name"`
	ChargeGameRegion string  `json:"charge_game_region"`
	ChargeType       string  `json:"charge_type"`
	ChargePassword   string  `json:"charge_password"`
	ChargeIp         string  `json:"charge_ip"`
	ContactQQ        string  `json:"contact_qq"`
	ContactTel       string  `json:"contact_tel"`
	RemainingNumber  string  `json:"remaining_number"`
	ChargeGameRole   string  `json:"charge_game_role"`
	CustomerPrice    float64 `json:"customer_price"`
	ShopType         string  `json:"shop_type"`
	ExternalBizId    string  `json:"external_biz_id"`
}

type CreateMobileOrderBizContent

type CreateMobileOrderBizContent struct {
	ChargePhone     string  `json:"charge_phone"`
	ChargeValue     float64 `json:"charge_value"`
	CustomerOrderNO string  `json:"customer_order_no"`
	CustomerPrice   float64 `json:"customer_price"`
	ShopType        string  `json:"shop_type"`
	ExternalBizID   string  `json:"external_biz_id"`
}

type DirectOrderResult

type DirectOrderResult struct {
	OrderID              string  `json:"order_id"`
	CustomerOrderNO      string  `json:"customer_order_no"`
	ProductID            int64   `json:"product_id"`
	ProductName          string  `json:"product_name"`
	ChargeAccount        string  `json:"charge_account"`
	BuyNum               int     `json:"buy_num"`
	OrderType            int     `json:"order_type"`
	OrderPrice           float64 `json:"order_price"`
	PrderState           string  `json:"prder_state"`
	CreateTime           string  `json:"create_time"`
	FinishTime           string  `json:"finish_time"`
	Area                 string  `json:"area"`
	Server               string  `json:"server"`
	Type                 string  `json:"type"`
	OperatorSerialNumber string  `json:"operator_serial_number"`
}

type GetMobileInfoReqParams

type GetMobileInfoReqParams struct {
	Phone     string  `json:"phone"`
	FaceValue float64 `json:"face_value,omitempty"`
}

type GetMobileInfoResult

type GetMobileInfoResult struct {
	SP        string    `json:"sp"`         // 运营商名称
	CityCode  string    `json:"city_code"`  // 城市编码
	FaceValue []float64 `json:"face_value"` // 可充值面值
	City      string    `json:"city"`       // 城市名称
	Province  string    `json:"province"`   // 省份名称
	SpType    string    `json:"sp_type"`    // 运营商类型 1:移动 2:电信 3:联通
}

type GetMobileMaintainStatusReqParams

type GetMobileMaintainStatusReqParams struct {
	Mobile    string `json:"mobile"`
	FaceValue int    `json:"face_value"`
}

GetMobileMaintainStatusReqParams 话费维护状态检查请求参数

type GetMobileMaintainStatusResult

type GetMobileMaintainStatusResult struct {
	Province           string  `json:"province"`
	City               string  `json:"city"`
	Sp                 string  `json:"sp"`
	SpType             string  `json:"sp_type"`
	MaintainState      string  `json:"maintain_state"`
	CurrentSuccessRate float64 `json:"current_success_rate"`
}

GetMobileMaintainStatusResult 话费维护状态检查结果

type GetProductInfoParams

type GetProductInfoParams struct {
	ProductID    string `json:"product_id"`
	DetailFormat int    `json:"detail_format,omitempty"`
}

GetProductInfoParams 获取商品信息请求参数

type GetProductListParams

type GetProductListParams struct {
	ProductID        int64   `json:"product_id,omitempty"`
	ProductName      string  `json:"product_name,omitempty"`
	ProductType      string  `json:"product_type,omitempty"`
	FaceValue        float64 `json:"face_value,omitempty"`
	FirstCategoryID  int     `json:"first_category_id,omitempty"`
	SecondCategoryID int     `json:"second_category_id,omitempty"`
	ThirdCategoryID  int     `json:"third_category_id,omitempty"`
}

GetProductListParams 获取商品列表请求参数

type GetProductTemplateParams

type GetProductTemplateParams struct {
	TemplateID string `json:"template_id"` // 商品模板编号
}

GetProductTemplateParams 获取商品模板请求参数

type GetQQNicknameResult

type GetQQNicknameResult struct {
	Nickname string `json:"nickname"`
	Photo    string `json:"photo"`
}

type Method

type Method string

type MobileMaintainState

type MobileMaintainState string

type MobileOrderResult

type MobileOrderResult struct {
	OrderID              string  `json:"order_id"`
	CustomerOrderNO      string  `json:"customer_order_no"`
	ProductID            int64   `json:"product_id"`
	ProductName          string  `json:"product_name"`
	ChargeAccount        string  `json:"charge_account"`
	BuyNum               int     `json:"buy_num"`
	OrderPrice           float64 `json:"order_price"`
	OrderType            int     `json:"order_type"`
	OrderState           string  `json:"order_state"`
	CreateTime           string  `json:"create_time"`
	FinishTime           string  `json:"finish_time"`
	OperatorSerialNumber string  `json:"operator_serial_number"`
}

type MobileSpType

type MobileSpType string

type Order

type Order struct {
	OrderID              string     `json:"order_id"`
	CustomerOrderNO      string     `json:"customer_order_no"`
	ProductID            int64      `json:"product_id"`
	ProductName          string     `json:"product_name"`
	ChargeAccount        string     `json:"charge_account"`
	BuyNum               int        `json:"buy_num"`
	OrderPrice           float64    `json:"order_price"`
	OrderType            int        `json:"order_type"`
	OrderState           string     `json:"order_state"`
	CreateTime           string     `json:"create_time"`
	FinishTime           string     `json:"finish_time"`
	Area                 string     `json:"area"`
	Server               string     `json:"server"`
	Type                 string     `json:"type"`
	Cards                []CardItem `json:"cards"`
	OperatorSerialNumber string     `json:"operator_serial_number"`
}

Order 订单信息

type OrderExtend

type OrderExtend struct {
	OrderID            string              `json:"order_id"`
	CustomerOrderNO    string              `json:"customer_order_no"`
	OrderExtendContent *OrderExtendContent `json:"order_extend_content"`
}

type OrderExtendContent

type OrderExtendContent struct {
	ExpressNumber       string `json:"express_number"`
	RechargeDescription string `json:"recharge_description"`
	ExternalBizID       string `json:"external_biz_id"`
}

type OrderExtendTemp

type OrderExtendTemp struct {
	OrderID            string `json:"order_id"`
	CustomerOrderNO    string `json:"customer_order_no"`
	OrderExtendContent string `json:"order_extend_content"`
}

type OrderState

type OrderState string

type ProductDetailFormat

type ProductDetailFormat int

type ProductInfo

type ProductInfo struct {
	ProductID        int64   `json:"product_id"`
	ProductName      string  `json:"product_name"`
	FaceValue        float64 `json:"face_value"`
	ProductType      string  `json:"product_type"`
	PurchasePrice    float64 `json:"purchase_price"`
	TemplateID       string  `json:"template_id"`
	StockStatus      string  `json:"stock_status"`
	SalesStatus      string  `json:"sales_status"`
	Details          string  `json:"details"`
	FourCategoryIcon string  `json:"four_category_icon"`
	DetailType       int     `json:"detail_type"`
}

ProductInfo 商品信息

type ProductListItem

type ProductListItem struct {
	ProductID     int64   `json:"product_id"`
	ProductName   string  `json:"product_name"`
	ProductType   string  `json:"product_type"`
	FaceValue     float64 `json:"face_value"`
	PurchasePrice float64 `json:"purchase_price"`
	SalesStatus   string  `json:"sales_status"`
	StockStatus   string  `json:"stock_status"`
	TemplateID    string  `json:"template_id"`
	Details       string  `json:"details"`
}

ProductListItem 商品列表项

type ProductTemplate

type ProductTemplate struct {
	AddressID               string                            `json:"AddressId"`               // 商品模板编号
	ElementInfo             productTemplateElementInfo        `json:"ElementInfo"`             // 包括元素
	AddressName             string                            `json:"AddressName"`             // 模板名称
	IsServiceArea           bool                              `json:"IsServiceArea"`           // 是否有区服(预留字段,不用关注)
	GameTempaltePreviewList []productTemplateGameTemplateItem `json:"GameTempaltePreviewList"` // 游戏区服模板信息
}

ProductTemplate 商品模板内容

type ReqParams

type ReqParams struct {
	AppKey       string `json:"app_key"`
	Method       Method `json:"method"`
	Timestamp    string `json:"timestamp"`
	Version      string `json:"version"`
	Format       string `json:"format"`
	Charset      string `json:"charset"`
	SignType     string `json:"sign_type"`
	Sign         string `json:"sign"`
	AppAuthToken string `json:"app_auth_token"`
	BizContent   string `json:"biz_content"`
}

type RespData

type RespData struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Result  string `json:"result"`
	Sign    string `json:"sign"`
}

type SaleStatus

type SaleStatus string

SaleStatus 销售状态

type StockStatus

type StockStatus string

StockStatus 库存状态

Jump to

Keyboard shortcuts

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