product

package
v0.0.0-...-f5adc6c Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2014 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

商品相关数据结构

Index

Constants

View Source
const (
	// 商品状态
	PRODUCT_STATUS_ALL      = 0 // 所有商品
	PRODUCT_STATUS_ONSHELF  = 1 // 上架商品
	PRODUCT_STATUS_OFFSHELF = 2 // 下架商品
)
View Source
const (
	// 快递ID列表
	EXPRESS_ID_PINGYOU = 10000027 // 平邮
	EXPRESS_ID_KUAIDI  = 10000028 // 快递
	EXPRESS_ID_EMS     = 10000029 // EMS
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrBase

type AttrBase struct {
	Name        string     `json:"name"`                  // 商品名称
	CategoryIds []string   `json:"category_id,omitempty"` // 商品分类id,商品分类列表请通过《获取指定分类的所有子分类》获取
	MainImage   string     `json:"main_img"`              // 商品主图(图片需调用图片上传接口获得图片URL填写至此,否则无法添加商品。图片分辨率推荐尺寸为640×600)
	Images      []string   `json:"img,omitempty"`         // 商品图片列表(图片需调用图片上传接口获得图片URL填写至此,否则无法添加商品。图片分辨率推荐尺寸为640×600)
	Details     []Detail   `json:"detail,omitempty"`      // 商品详情列表,显示在客户端的商品详情页内
	Properties  []Property `json:"property,omitempty"`    // 商品属性列表,属性列表请通过《获取指定分类的所有属性》获取
	SKUInfo     []SKU      `json:"sku_info,omitempty"`    // 商品sku定义,SKU列表请通过《获取指定子分类的所有SKU》获取
	BuyLimit    int        `json:"buy_limit,omitempty"`   // 用户商品限购数量
}

商品基本属性

"product_base": {
    "category_id": [
        "537074298"
    ],
    "property": [
        {
            "id": "1075741879",
            "vid": "1079749967"
        },
        {
            "id": "1075754127",
            "vid": "1079795198"
        },
        {
            "id": "1075777334",
            "vid": "1079837440"
        }
    ],
    "name": "testaddproduct",
    "sku_info": [
        {
            "id": "1075741873",
            "vid": [
                "1079742386",
                "1079742363"
            ]
        }
    ],
    "main_img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0",
    "img": [
        "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0"
    ],
    "detail": [
        {
            "text": "test first"
        },
        {
            "img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ul1UcLcwxrFdwTKYhH9Q5YZoCfX4Ncx655ZK6ibnlibCCErbKQtReySaVA/0"
        },
        {
            "text": "test again"
        }
    ],
    "buy_limit": 10
},

type AttrExt

type AttrExt struct {
	Location Location `json:"location"` // 商品所在地地址

	IsPostFree       int `json:"isPostFree"`       // 是否包邮(0-否, 1-是), 如果包邮delivery_info字段可省略
	IsHasReceipt     int `json:"isHasReceipt"`     // 是否提供发票(0-否, 1-是)
	IsUnderGuaranty  int `json:"isUnderGuaranty"`  // 是否保修(0-否, 1-是)
	IsSupportReplace int `json:"isSupportReplace"` // 是否支持退换货(0-否, 1-是)
}

商品的其他属性

"attrext": {
    "location": {
        "country": "中国",
        "province": "广东省",
        "city": "广州市",
        "address": "T.I.T创意园"
    },
    "isPostFree": 0,
    "isHasReceipt": 1,
    "isUnderGuaranty": 0,
    "isSupportReplace": 0
},

func (*AttrExt) SetHasReceipt

func (attr *AttrExt) SetHasReceipt(b bool)

设置是否 提供发票, true--提供发票, false--不提供发票

func (*AttrExt) SetPostFree

func (attr *AttrExt) SetPostFree(b bool)

设置是否 包邮, true--包邮, false--不包邮

func (*AttrExt) SetSupportReplace

func (attr *AttrExt) SetSupportReplace(b bool)

设置是否支持退货, true--支持退货, false--不支持退货

func (*AttrExt) SetUnderGuaranty

func (attr *AttrExt) SetUnderGuaranty(b bool)

设置是否保修, true--保修, false--不保修

type DeliveryInfo

type DeliveryInfo struct {
	// 运费类型(0-使用下面express字段的默认模板, 1-使用template_id代表的邮费模板, 详见邮费模板相关API)
	DeliveryType int       `json:"delivery_type"`
	TemplateId   int64     `json:"template_id,omitempty"` // 邮费模板ID
	Expresses    []Express `json:"express,omitempty"`
}

运费信息

"delivery_info": {
    "delivery_type": 0,
    "template_id": 0,
    "express": [
        {
            "id": 10000027,
            "price": 100
        },
        {
            "id": 10000028,
            "price": 100
        },
        {
            "id": 10000029,
            "price": 100
        }
    ]
}

func NewDeliveryInfoWithExpresses

func NewDeliveryInfoWithExpresses(expresses []Express) *DeliveryInfo

func NewDeliveryInfoWithTemplate

func NewDeliveryInfoWithTemplate(templateId int64) *DeliveryInfo

func (*DeliveryInfo) SetWithExpresses

func (info *DeliveryInfo) SetWithExpresses(expresses []Express)

func (*DeliveryInfo) SetWithTemplate

func (info *DeliveryInfo) SetWithTemplate(templateId int64)

type Detail

type Detail struct {
	Text  string `json:"text,omitempty"` // 文字描述
	Image string `json:"img,omitempty"`  // 图片(图片需调用图片上传接口获得图片URL填写至此,否则无法添加商品)
}

商品详情的一个单元, 多个这样的 Detail 组成商品的详情.

NOTE: 同一时刻只能设置一个值, 建议使用 Detail.SetToTextDetail, Detail.SetToImageDetail

func (*Detail) SetToImageDetail

func (d *Detail) SetToImageDetail(imageURL string)

func (*Detail) SetToTextDetail

func (d *Detail) SetToTextDetail(text string)

type Express

type Express struct {
	Id    int64  `json:"id"`             // 快递id, 平邮: 10000027, 快递: 10000028, EMS: 10000029
	Name  string `json:"name,omitempty"` // 快递name
	Price int    `json:"price"`          // 运费(单位 : 分)
}

默认的邮费模板

type Location

type Location struct {
	Country  string `json:"country"`  // 国家(详见《地区列表》说明)
	Province string `json:"province"` // 省份(详见《地区列表》说明)
	City     string `json:"city"`     // 城市(详见《地区列表》说明)
	Address  string `json:"address"`  // 地址
}

type Product

type Product struct {
	Id     string `json:"product_id,omitempty"` // 商品id
	Status int    `json:"status,omitempty"`     // 商品状态

	AttrBase     AttrBase      `json:"product_base"`            // 基本属性
	SKUList      []ProductSKU  `json:"sku_list,omitempty"`      // sku信息列表(可为多个),每个sku信息串即为一个确定的商品,比如白色的37码的鞋子
	AttrExt      *AttrExt      `json:"attrext,omitempty"`       // 商品其他属性
	DeliveryInfo *DeliveryInfo `json:"delivery_info,omitempty"` // 运费信息, 如果在 AttrExt 设置包邮, 则这个字段可以省略
}

关于 Product.AttrBase.SKUInfo 和 Product.SKUList 的关系说明: AttrBase.SKUInfo 是指定 Product 的 sku 是由哪些属性组合确定的, 这些属性就是 SKUInfo([]SKU) 的每个 SKU 的 Id(属性id); SKUList 就是具体这些属性的排列组合, SKUInfo 的每个属性取一个属性值做组合, 如: "id1:vid11;id2:vid21;id3:vid32" "id1:vid12;id2:vid22;id3:vid31" 这里的 id1,id2,id3 就是 SKUInfo 里的 SKU 的 Id; vid11,vid12,vid21,vid22,vid31,vid32 就是 SKUInfo 里的 SKU 的 vid;

规则是 SKUList 的 skuid 的组合个数必须是和 SKUInfo 的 SKU 的个数一致!!!

json格式, ver_1.15
{
    "product_base": {
        "category_id": [
            "537074298"
        ],
        "property": [
            {
                "id": "1075741879",
                "vid": "1079749967"
            },
            {
                "id": "1075754127",
                "vid": "1079795198"
            },
            {
                "id": "1075777334",
                "vid": "1079837440"
            }
        ],
        "name": "testaddproduct",
        "sku_info": [
            {
                "id": "1075741873",
                "vid": [
                    "1079742386",
                    "1079742363"
                ]
            }
        ],
        "main_img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0",
        "img": [
            "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0"
        ],
        "detail": [
            {
                "text": "test first"
            },
            {
                "img": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ul1UcLcwxrFdwTKYhH9Q5YZoCfX4Ncx655ZK6ibnlibCCErbKQtReySaVA/0"
            },
            {
                "text": "test again"
            }
        ],
        "buy_limit": 10
    },
    "sku_list": [
        {
            "sku_id": "1075741873:1079742386",
            "price": 30,
            "icon_url": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0",
            "product_code": "testing",
            "ori_price": 9000000,
            "quantity": 800
        },
        {
            "sku_id": "1075741873:1079742363",
            "price": 30,
            "icon_url": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0",
            "product_code": "testingtesting",
            "ori_price": 9000000,
            "quantity": 800
        }
    ],
    "attrext": {
        "location": {
            "country": "中国",
            "province": "广东省",
            "city": "广州市",
            "address": "T.I.T创意园"
        },
        "isPostFree": 0,
        "isHasReceipt": 1,
        "isUnderGuaranty": 0,
        "isSupportReplace": 0
    },
    "delivery_info": {
        "delivery_type": 0,
        "template_id": 0,
        "express": [
            {
                "id": 10000027,
                "price": 100
            },
            {
                "id": 10000028,
                "price": 100
            },
            {
                "id": 10000029,
                "price": 100
            }
        ]
    }
}

func (*Product) IsHasReceipt

func (p *Product) IsHasReceipt() bool

是否提供发票, true--提供发票, false--不提供发票

func (*Product) IsPostFree

func (p *Product) IsPostFree() bool

是否包邮, true--包邮, false--不包邮

func (*Product) IsSupportReplace

func (p *Product) IsSupportReplace() bool

是否支持退货, true--支持退货, false--不支持退货

func (*Product) IsUnderGuaranty

func (p *Product) IsUnderGuaranty() bool

是否保修, true--保修, false--不保修

func (*Product) SetDeliveryInfoWithExpresses

func (p *Product) SetDeliveryInfoWithExpresses(expresses []Express)

使用默认邮费模板

func (*Product) SetDeliveryInfoWithTemplate

func (p *Product) SetDeliveryInfoWithTemplate(templateId int64)

使用自定义的邮费模板

func (*Product) SetHasReceipt

func (p *Product) SetHasReceipt(b bool)

设置是否 提供发票, true--提供发票, false--不提供发票

func (*Product) SetPostFree

func (p *Product) SetPostFree(b bool)

设置是否 包邮, true--包邮, false--不包邮

func (*Product) SetSupportReplace

func (p *Product) SetSupportReplace(b bool)

设置是否支持退货, true--支持退货, false--不支持退货

func (*Product) SetUnderGuaranty

func (p *Product) SetUnderGuaranty(b bool)

设置是否保修, true--保修, false--不保修

type ProductSKU

type ProductSKU struct {
	// sku信息, 参照上述sku_table的定义;
	// 格式 : "id1:vid1;id2:vid2"
	// 规则 : id_info的组合个数必须与sku_table个数一致(若商品无sku信息, 即商品为统一规格,
	// 则此处赋值为空字符串即可)
	Id            string `json:"sku_id"`
	Price         int    `json:"price"`        // sku微信价(单位 : 分, 微信价必须比原价小, 否则添加商品失败)
	IconURL       string `json:"icon_url"`     // sku iconurl(图片需调用图片上传接口获得图片URL)
	ProductCode   string `json:"product_code"` // 商家商品编码
	OriginalPrice int    `json:"ori_price"`    // sku原价(单位 : 分)
	Quantity      int    `json:"quantity"`     // sku库存
}

商品的 SKU 信息

NOTE: ProductSKU.Id 的组合个数必须和 Product.AttrBase.SKUInfo 的长度一致

"sku_list": [
    {
        "sku_id": "1075741873:1079742386",
        "price": 30,
        "icon_url": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0",
        "product_code": "testing",
        "ori_price": 9000000,
        "quantity": 800
    },
    {
        "sku_id": "1075741873:1079742363",
        "price": 30,
        "icon_url": "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0",
        "product_code": "testingtesting",
        "ori_price": 9000000,
        "quantity": 800
    }
],

type Property

type Property struct {
	Id      string `json:"id"`  // 属性id
	ValueId string `json:"vid"` // 属性值id
}

参考 category/Property

type SKU

type SKU struct {
	Id       string   `json:"id"`            // sku属性(SKU列表中id, 支持自定义SKU,格式为"$xxx",xxx即为显示在客户端中的字符串)
	ValueIds []string `json:"vid,omitempty"` // sku值(SKU列表中vid, 如需自定义SKU,格式为"$xxx",xxx即为显示在客户端中的字符串)
}

参考 category/SKU

Jump to

Keyboard shortcuts

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