1
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package product_detail_request_out
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type ProductDetailOutRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *ProductDetailParamOutProductId
|
||||
}
|
||||
|
||||
func (c *ProductDetailOutRequest) GetUrlPath() string {
|
||||
return "/product/detail"
|
||||
}
|
||||
|
||||
func New() *ProductDetailOutRequest {
|
||||
request := &ProductDetailOutRequest{
|
||||
Param: &ProductDetailParamOutProductId{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *ProductDetailOutRequest) Execute(accessToken *doudian_sdk.AccessToken) (*product_detail_response.ProductDetailResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &product_detail_response.ProductDetailResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *ProductDetailOutRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *ProductDetailOutRequest) GetParams() *ProductDetailParamOutProductId {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type ProductDetailParamOutProductId struct {
|
||||
// 商品ID,抖店系统生成,店铺下唯一;长度19位。
|
||||
//ProductId string `json:"product_id"`
|
||||
// 外部商家编码,商家自定义字段
|
||||
OutProductId string `json:"out_product_id"`
|
||||
//// true:读取草稿数据;false:读取线上数据;不传默认为false
|
||||
//ShowDraft string `json:"show_draft"`
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
package product_detail_response_out
|
||||
|
||||
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
|
||||
type ProductDetailResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *ProductDetailData `json:"data"`
|
||||
}
|
||||
type TaxExemptionSkuInfo struct {
|
||||
// 是否套装(0 否 1 是)
|
||||
IsSuit int32 `json:"is_suit"`
|
||||
// 套装数量
|
||||
SuitNum int64 `json:"suit_num"`
|
||||
// 净含量
|
||||
Volume int64 `json:"volume"`
|
||||
}
|
||||
type SpecPricesItem struct {
|
||||
// 规格id;抖店系统生成,商品id下唯一。
|
||||
SkuId int64 `json:"sku_id"`
|
||||
// 外部商家skui_id编码,商家自定义字段;推荐使用outer_sku_id字段
|
||||
OutSkuId int64 `json:"out_sku_id"`
|
||||
// 外部商家skui_id编码,商家自定义字段
|
||||
OuterSkuId string `json:"outer_sku_id"`
|
||||
// 规格id列表,多规格以”,“分隔;
|
||||
SpecDetailIds []int64 `json:"spec_detail_ids"`
|
||||
// 可售库存;当前现货可售库存;
|
||||
StockNum int64 `json:"stock_num"`
|
||||
// 商品价格;单位:分
|
||||
Price int64 `json:"price"`
|
||||
// 编码
|
||||
Code string `json:"code"`
|
||||
// 阶梯库存,规则详见名称解释:https://op.jinritemai.com/docs/guide-docs/202/170
|
||||
StepStockNum int64 `json:"step_stock_num"`
|
||||
// 活动库存,,规则详见名称解释:https://op.jinritemai.com/docs/guide-docs/202/170
|
||||
PromStockNum int64 `json:"prom_stock_num"`
|
||||
// 活动阶梯库存,,规则详见名称解释:https://op.jinritemai.com/docs/guide-docs/202/170
|
||||
PromStepStockNum int64 `json:"prom_step_stock_num"`
|
||||
// 【已废弃,无需使用】规格ID
|
||||
SpecDetailId1 int64 `json:"spec_detail_id1"`
|
||||
// 【已废弃,无需使用】规格ID
|
||||
SpecDetailId2 int64 `json:"spec_detail_id2"`
|
||||
// 【已废弃,无需使用】规格ID
|
||||
SpecDetailId3 int64 `json:"spec_detail_id3"`
|
||||
// sku类型;0-普通库存 1-区域库存 10-阶梯库存
|
||||
SkuType int64 `json:"sku_type"`
|
||||
// 供应商编码
|
||||
SupplierId string `json:"supplier_id"`
|
||||
// 活动现货库存
|
||||
PromotionStockNum int64 `json:"promotion_stock_num"`
|
||||
// 活动阶梯库存
|
||||
PromotionStepStockNum int64 `json:"promotion_step_stock_num"`
|
||||
// 海关申报要素(仅海淘商品返回信息)
|
||||
CustomsReportInfo *CustomsReportInfo `json:"customs_report_info"`
|
||||
// 现货订单锁定库存
|
||||
LockStockNum int64 `json:"lock_stock_num"`
|
||||
// 阶梯订单锁定库存
|
||||
LockStepStockNum int64 `json:"lock_step_stock_num"`
|
||||
// 仓ID->库存映射
|
||||
StockNumMap map[string]int64 `json:"stock_num_map"`
|
||||
// 海南免税sku信息(仅海淘商品返回信息)
|
||||
TaxExemptionSkuInfo *TaxExemptionSkuInfo `json:"tax_exemption_sku_info"`
|
||||
// 发货时间(全款预售模式时的发货时间/阶梯模式下阶梯发货时间),9999是当日发、1次日发、2 是48小时发、5、15、45天等。发货时间规则可使用【product/getProductUpdateRule】获取
|
||||
PresellDelay int64 `json:"presell_delay"`
|
||||
// SKU物流信息
|
||||
DeliveryInfos []DeliveryInfosItem `json:"delivery_infos"`
|
||||
}
|
||||
type ValuesItem struct {
|
||||
// 销售属性值ID
|
||||
Id int64 `json:"id"`
|
||||
// 规格ID
|
||||
SpecId int64 `json:"spec_id"`
|
||||
// 销售属性值
|
||||
Name string `json:"name"`
|
||||
// 销售属性ID
|
||||
Pid int64 `json:"pid"`
|
||||
// 是否是销售属性值
|
||||
IsLeaf int16 `json:"is_leaf"`
|
||||
// 在线状态,-2彻底删除、0在线、1下线、2删除
|
||||
Status int16 `json:"status"`
|
||||
}
|
||||
type SpecsItem struct {
|
||||
// 【无需使用】销售属性id
|
||||
Id int64 `json:"id"`
|
||||
// 【无需使用】规格id
|
||||
SpecId int64 `json:"spec_id"`
|
||||
// 销售属性
|
||||
Name string `json:"name"`
|
||||
// 【无需使用】销售属性id
|
||||
Pid int64 `json:"pid"`
|
||||
// 是否是销售属性值
|
||||
IsLeaf int16 `json:"is_leaf"`
|
||||
// 销售属性值
|
||||
Values []ValuesItem `json:"values"`
|
||||
}
|
||||
type QualityListItem struct {
|
||||
// 资质key
|
||||
QualityKey string `json:"quality_key"`
|
||||
// 资质名称
|
||||
QualityName string `json:"quality_name"`
|
||||
// 资质链接
|
||||
QualityAttachments []QualityAttachmentsItem `json:"quality_attachments"`
|
||||
}
|
||||
type CustomsReportInfo struct {
|
||||
// 海关代码
|
||||
HsCode string `json:"hs_code"`
|
||||
// 法定第一计量数量
|
||||
FirstMeasureQty float64 `json:"first_measure_qty"`
|
||||
// 法定第二计量数量
|
||||
SecondMeasureQty float64 `json:"second_measure_qty"`
|
||||
// 法定第一计量单位
|
||||
FirstMeasureUnit string `json:"first_measure_unit"`
|
||||
// 法定第二计量单位
|
||||
SecondMeasureUnit string `json:"second_measure_unit"`
|
||||
// 售卖单位
|
||||
Unit string `json:"unit"`
|
||||
// 品名
|
||||
ReportName string `json:"report_name"`
|
||||
// 品牌
|
||||
ReportBrandName string `json:"report_brand_name"`
|
||||
// 用途
|
||||
Usage string `json:"usage"`
|
||||
// 规格型号
|
||||
GModel string `json:"g_model"`
|
||||
// 条形码
|
||||
BarCode string `json:"bar_code"`
|
||||
}
|
||||
type DeliveryInfosItem struct {
|
||||
// 信息类型
|
||||
InfoType string `json:"info_type"`
|
||||
// 信息值
|
||||
InfoValue string `json:"info_value"`
|
||||
// 信息计量单位
|
||||
InfoUnit string `json:"info_unit"`
|
||||
}
|
||||
type CategoryDetail struct {
|
||||
// 一级类目id
|
||||
FirstCid int64 `json:"first_cid"`
|
||||
// 二级类目id
|
||||
SecondCid int64 `json:"second_cid"`
|
||||
// 三级类目id
|
||||
ThirdCid int64 `json:"third_cid"`
|
||||
// 四级类目id
|
||||
FourthCid int64 `json:"fourth_cid"`
|
||||
// 一级类目名
|
||||
FirstCname string `json:"first_cname"`
|
||||
// 二级类目名
|
||||
SecondCname string `json:"second_cname"`
|
||||
// 三级类目名
|
||||
ThirdCname string `json:"third_cname"`
|
||||
// 四级类目名
|
||||
FourthCname string `json:"fourth_cname"`
|
||||
}
|
||||
type LogisticsInfo struct {
|
||||
// 通关模式,1BBC 2BC 3邮关
|
||||
CustomsClearType int64 `json:"customs_clear_type"`
|
||||
// 原产国id
|
||||
OriginCountryId int64 `json:"origin_country_id"`
|
||||
// 货源国id
|
||||
SourceCountryId int64 `json:"source_country_id"`
|
||||
// 品牌所在地id
|
||||
BrandCountryId int64 `json:"brand_country_id"`
|
||||
// 税金承担方,0商家承担,1用户承担
|
||||
TaxPayer int64 `json:"tax_payer"`
|
||||
// 商品净重
|
||||
NetWeightQty float64 `json:"net_weight_qty"`
|
||||
}
|
||||
type SpecPicsItem struct {
|
||||
// id
|
||||
SpecDetailId int64 `json:"spec_detail_id"`
|
||||
// 规格图片uri
|
||||
Pic string `json:"pic"`
|
||||
}
|
||||
type QualityAttachmentsItem struct {
|
||||
// 1-图片,2-pdf
|
||||
MediaType int64 `json:"media_type"`
|
||||
// 资质url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
type PoiResource struct {
|
||||
// 1 随时退+过期自动退,2 不支持退
|
||||
CouponReturnMethods []int64 `json:"coupon_return_methods"`
|
||||
}
|
||||
type DelayRule struct {
|
||||
// 是否开启特殊日期延迟发货
|
||||
Enable bool `json:"enable"`
|
||||
// 1 时间点;2 时间范围
|
||||
ConfigType int32 `json:"config_type"`
|
||||
// 特殊日期延迟发货时间最晚发货时间,时间戳,单位秒
|
||||
ConfigValue int64 `json:"config_value"`
|
||||
// 特殊日期延迟发货时间下单开始时间,时间戳,单位秒
|
||||
StartTime int64 `json:"start_time"`
|
||||
// 特殊日期延迟发货时间下单结束时间,时间戳,单位秒
|
||||
EndTime int64 `json:"end_time"`
|
||||
}
|
||||
type ProductDetailData struct {
|
||||
// 商品ID,抖店系统生成,店铺下唯一;长度19位。
|
||||
ProductId int64 `json:"product_id"`
|
||||
// 商品ID(字符串类型),抖店系统生成,店铺下唯一;长度19位。
|
||||
ProductIdStr string `json:"product_id_str"`
|
||||
// 【即将废弃】外部商家编码,商家自定义字段。推荐使用,outer_product_id字段
|
||||
OutProductId int64 `json:"out_product_id"`
|
||||
// 外部商家编码,商家自定义字段,支持最多 255个字符
|
||||
OuterProductId string `json:"outer_product_id"`
|
||||
// 【已废弃】open应用id
|
||||
OpenUserId int64 `json:"open_user_id"`
|
||||
// 商品标题,规则:至少输入8个字(16个字符)以上~输入30个字(60个字符)以内。;标题不规范会引起商品下架,影响您的正常销售,详见商品发布规范:https://school.jinritemai.com/doudian/web/article/101800?from=shop_article
|
||||
Name string `json:"name"`
|
||||
// 商品详情,最大支持50张图片,单张详情图宽高比不超2000*2000px,大小5M内,仅支持jpg/jpeg/png格式,返回HTML格式;注意:商品详情不规范,会引起商品下架,影响您的正常销售:https://school.jinritemai.com/doudian/web/article/101800?from=shop_article
|
||||
Description string `json:"description"`
|
||||
// 承诺发货时间,单位是天; 不传则默认为2天,当presell_type为0或2均只支持传入2;当presell_type为1时支持可选值为: 2、3、5、7、10、15;
|
||||
DeliveryMethod int32 `json:"delivery_method"`
|
||||
// 海南免税,海关限购分类编码,仅海淘商品有值返回。
|
||||
CdfCategory string `json:"cdf_category"`
|
||||
// 商品在店铺中状态: 0-在线;1-下线;2-删除;详见商品状态机:https://op.jinritemai.com/docs/question-docs/92/2070
|
||||
Status int64 `json:"status"`
|
||||
// 商品规格,新增商品是全局唯一,注意:有部分历史存量商品可能存在规格复用
|
||||
SpecId int64 `json:"spec_id"`
|
||||
// 商品审核状态: 1-未提交;2-待审核;3-审核通过;4-审核未通过;5-封禁;7-审核通过待上架;详见商品状态机:https://op.jinritemai.com/docs/question-docs/92/2070
|
||||
CheckStatus int64 `json:"check_status"`
|
||||
// 【已废弃】手机号
|
||||
Mobile string `json:"mobile"`
|
||||
// 【已废弃】品牌id,推荐使用standard_brand_id字段,通过【/brand/list】获取,无品牌id商品返回默认值:596120136;
|
||||
BrandId int64 `json:"brand_id"`
|
||||
// 是否是组合商品的子商品;true-是,false-不是;
|
||||
IsSubProduct bool `json:"is_sub_product"`
|
||||
// 草稿状态;0-无草稿,1-未提审,2-待审核,3-审核通过,4-审核未通过。详见:https://op.jinritemai.com/docs/question-docs/92/2070
|
||||
DraftStatus int64 `json:"draft_status"`
|
||||
// 类目详情;商品类目id可使用【/shop/getShopCategory】查询
|
||||
CategoryDetail *CategoryDetail `json:"category_detail"`
|
||||
// 【已废弃】支持的支付方式:0货到付款 1在线支付 2两者都支持
|
||||
PayType int64 `json:"pay_type"`
|
||||
// 【已废弃】商家推荐语
|
||||
RecommendRemark string `json:"recommend_remark"`
|
||||
// 额外信息,如资质
|
||||
Extra string `json:"extra"`
|
||||
// 【已废弃】无业务意义
|
||||
IsCreate int64 `json:"is_create"`
|
||||
// 商品创建时间,时间格式:yyyy-mm-dd hh:mm:ss
|
||||
CreateTime string `json:"create_time"`
|
||||
// 商品更新时间,时间格式:yyyy-mm-dd hh:mm:ss
|
||||
UpdateTime string `json:"update_time"`
|
||||
// 商品主图;最多支持5张图片;仅支持png,jpg,jpeg格式,宽高比例为1:1(至少600*600px),大小5M内
|
||||
Pic []string `json:"pic"`
|
||||
// 【即将废弃】推荐使用product_format_new;属性名称|属性值 之间用|分隔, 多组之间用^分开
|
||||
ProductFormat string `json:"product_format"`
|
||||
// 规格图片
|
||||
SpecPics []SpecPicsItem `json:"spec_pics"`
|
||||
// 商品sku详情
|
||||
SpecPrices []SpecPricesItem `json:"spec_prices"`
|
||||
// 销售属性
|
||||
Specs []SpecsItem `json:"specs"`
|
||||
// 头图,主图第一张
|
||||
Img string `json:"img"`
|
||||
// 预售类型,1-全款预售,0-非预售,2-阶梯库存
|
||||
PresellType int64 `json:"presell_type"`
|
||||
// 单用户下单限购件数
|
||||
MaximumPerOrder int64 `json:"maximum_per_order"`
|
||||
// 单用户累计限购件数
|
||||
LimitPerBuyer int64 `json:"limit_per_buyer"`
|
||||
// 用户每次下单至少购买的件数
|
||||
MinimumPerOrder int64 `json:"minimum_per_order"`
|
||||
// 资质信息
|
||||
QualityList []QualityListItem `json:"quality_list"`
|
||||
// 跨境物流信息(仅海淘商品返回)
|
||||
LogisticsInfo *LogisticsInfo `json:"logistics_info"`
|
||||
// 售后服务
|
||||
AfterSaleService string `json:"after_sale_service"`
|
||||
// 商品价格是否含税
|
||||
PriceHasTax int64 `json:"price_has_tax"`
|
||||
// 可预约发货天数
|
||||
AppointDeliveryDay int64 `json:"appoint_delivery_day"`
|
||||
// 类目属性
|
||||
ProductFormatNew string `json:"product_format_new"`
|
||||
// 品牌库brand id,原brand_id代表商标关系id
|
||||
StandardBrandId int64 `json:"standard_brand_id"`
|
||||
// 划线价 单位分
|
||||
MarketPrice int64 `json:"market_price"`
|
||||
// 售卖价 单位分
|
||||
DiscountPrice int64 `json:"discount_price"`
|
||||
// 汽车vin码
|
||||
CarVinCode string `json:"car_vin_code"`
|
||||
// 生活娱乐充值模式
|
||||
NeedRechargeMode bool `json:"need_recharge_mode"`
|
||||
// 多账号充值账号模板
|
||||
AccountTemplateId string `json:"account_template_id"`
|
||||
// 发货模式:presell_type = 0 现货;presell_type = 2 阶梯;presell_type = 1 && presell_config_level = 0 全款预售;presell_type = 1 && presell_config_level = 1 sku预售;presell_type = 1 && presell_config_level = 2 现货+预售;presell_type = 1 && presell_config_level = 3 新预售
|
||||
PresellConfigLevel int64 `json:"presell_config_level"`
|
||||
// 现货模式的发货天数;阶梯模式现货部分的发货天数,9999=当日发、1=次日发
|
||||
DeliveryDelayDay int64 `json:"delivery_delay_day"`
|
||||
// 阶梯模式阶梯部分的发货天数;商品全款预售模式,预售天数
|
||||
PresellDelay int64 `json:"presell_delay"`
|
||||
// 卡券信息
|
||||
PoiResource *PoiResource `json:"poi_resource"`
|
||||
// 特殊日期延迟发货规则
|
||||
DelayRule *DelayRule `json:"delay_rule"`
|
||||
// 3:4长图url(仅素材中心url有效)
|
||||
LongPicUrl string `json:"long_pic_url"`
|
||||
// 售卖方式;0:全渠道手售卖,1:仅指定直播间售卖
|
||||
SellChannel []int64 `json:"sell_channel"`
|
||||
// 运费模版ID
|
||||
FreightId int64 `json:"freight_id"`
|
||||
// 主图视频ID
|
||||
MaterialVideoId string `json:"material_video_id"`
|
||||
// 提取方式新字段,推荐使用。"0": 普通商品-使用物流发货, "1": 虚拟商品-无需物流与电子交易凭证, "2": 虚拟商品-使用电子交易凭证, "3": 虚拟商品-充值直连
|
||||
PickupMethod string `json:"pickup_method"`
|
||||
// 尺码模板ID
|
||||
SizeInfoTemplateId int64 `json:"size_info_template_id"`
|
||||
// 白底图url(仅素材中心url有效)
|
||||
WhiteBackGroundPicUrl string `json:"white_back_ground_pic_url"`
|
||||
// 销售渠道类型,包括纯电商(onlineOnly)、专柜同款(sameAsOffline),云零售商家(https://fxg.jinritemai.com/ffa/merchant-growth/cloud-retail)可以设置
|
||||
SaleChannelType string `json:"sale_channel_type"`
|
||||
// 门店ID
|
||||
StoreId int64 `json:"store_id"`
|
||||
// 主商品ID
|
||||
MainProductId int64 `json:"main_product_id"`
|
||||
// 限售模板ID
|
||||
SaleLimitId int64 `json:"sale_limit_id"`
|
||||
// 系统推荐的标题前缀
|
||||
NamePrefix string `json:"name_prefix"`
|
||||
}
|
||||
@@ -18,9 +18,8 @@ import (
|
||||
order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response"
|
||||
order_searchList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_searchList/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"math"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.
|
||||
return nil, err
|
||||
}
|
||||
if orderDetail.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetail.Msg)
|
||||
return nil, errors.New(orderDetail.SubMsg)
|
||||
}
|
||||
|
||||
return orderDetail.Data.ShopOrderDetail, nil
|
||||
@@ -322,13 +321,9 @@ func (a *API) LogisticsAdd(orderId string, companyCode string, isRefundReject bo
|
||||
return nil
|
||||
}
|
||||
|
||||
/***********************************************/
|
||||
// CreateOrderCallback 订单创建,抖店创建订单后,回调消息通知本服务器
|
||||
func (a *API) CreateOrderCallback(request *http.Request) (map[string][]interface{}, *CallbackResponse) {
|
||||
orderStatus, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
return nil, &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
func (a *API) CreateOrderCallback(orderStatus []byte) (map[string][]interface{}, *CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("88888888888888=%s", utils.Format4Output(string(orderStatus), false))
|
||||
|
||||
var resp []*OrderCallback
|
||||
if err := json.Unmarshal(orderStatus, &resp); err != nil {
|
||||
@@ -551,122 +546,122 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, *Callb
|
||||
switch msgId {
|
||||
case CallbackCreatedOrderMsgTagId: // 创建订单
|
||||
create := CreateOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", Err2CallbackResponse(err, "")
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPayOrderMsgTagId: // 支付订单
|
||||
create := PayOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackWaitOrderMsgTagId: // 支付订单待处理(风控审核)
|
||||
create := WaitOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPartGoodsMsgTagId: // 卖家部分发货
|
||||
create := SomeSendOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPartAllGoodsMsgTagId: // 卖家发货
|
||||
create := BusinessDeliveryData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackCancelOrderMsgTagId: // 取消订单
|
||||
create := CancelOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackSuccessOrderMsgTagId: // 卖家确认收货时,会自动完成
|
||||
create := SuccessOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackWayBillChangeOrderMsgTagId: // 发货物流消息便跟
|
||||
create := WayBillChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReceivingChangeOrderMsgTagId: // 收货地址消息变更(商家审核通过触发)
|
||||
create := ReceivingAddressChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackChangeMoneyMsgTagId: // 卖家修改订单/运单金额回调
|
||||
create := UpdateAmountChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackBusinessRemarkMsgTagId: // 买家收货消息变更(手机,地址,姓名),用户C端修改触发(需要上面审核接口)
|
||||
create := BuyerUpdateWayBillData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackApplyUpdateAddressMsgTagId: // 商家修改交易备注回调
|
||||
create := BusinessUpdateRemakeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackSendOrderTimeChangeMsgTagId: // 订单发货时消息变更回调
|
||||
create := AppointmentChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return create.PId, Err2CallbackResponse(nil, "")
|
||||
/*********下面属于订单退货消息************/
|
||||
case CallbackRefundOrderMsgTagId: // 买家发起售后申请消息
|
||||
create := BuyerRefundCreatedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackUpdateRefundOrderMsgTagId: // 买家修改售后申请消息
|
||||
create := BuyerRefundModifiedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundOrderSuccessMsgTagId: // 退款成功消息
|
||||
create := BusinessRefundSuccessData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundOrderRefuseMsgTagId: // 拒绝退款消息
|
||||
create := BusinessNotRefundRefusedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundShopMsgTagId: // 拒绝退货申请消息
|
||||
create := BusinessNotReturnApplyRefusedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReturnApplyAgreedMsgTagId: // 卖家同意时,推送此消息
|
||||
create := BusinessReturnApplyAgreedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReturnRefundAgreedMsgTagId: // 同意退款消息
|
||||
create := AppointmentChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return create.PId, Err2CallbackResponse(nil, "")
|
||||
|
||||
@@ -15,11 +15,11 @@ func GetCmd(request *http.Request) (cmd string) {
|
||||
}
|
||||
|
||||
// EventSignChange 回调消息防伪标签校验
|
||||
func (a *API) EventSignChange(c *http.Request) *CallbackResponse {
|
||||
func (a *API) EventSignChange(c *http.Request) (*CallbackResponse, []byte) {
|
||||
body, _ := ioutil.ReadAll(c.Body)
|
||||
signParam := a.appKey + string(body) + a.appSecret
|
||||
sign := fmt.Sprintf("%X", md5.Sum([]byte(signParam)))
|
||||
return CallbackResponseErr(sign != c.Header.Get("event-sign"))
|
||||
return CallbackResponseErr(sign != c.Header.Get("event-sign")), body
|
||||
}
|
||||
|
||||
func (a *API) unmarshalData(data []byte, msg interface{}) (callbackResponse *CallbackResponse) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
product_del_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_del/request"
|
||||
product_detail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/request"
|
||||
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
||||
product_detail_request_out "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail_out_productId/request"
|
||||
product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request"
|
||||
product_editV2_commit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2_commit/request"
|
||||
product_getCatePropertyV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_getCatePropertyV2/request"
|
||||
@@ -197,7 +198,7 @@ func (a *API) ProductSetOffline(productId int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSkuDetail 查询单个商品详情 美团商品id(19位),本地商品id
|
||||
// GetSkuDetail 查询单个商品详情(这个只有抖店平台商品id有效)
|
||||
func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_response.ProductDetailData, error) {
|
||||
request := product_detail_request.New()
|
||||
param := request.GetParams()
|
||||
@@ -218,6 +219,25 @@ func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_resp
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// GetSkuDetailLocalID 查询单个商品详情(这个只有京西平台商品id有效)
|
||||
func (a *API) GetSkuDetailLocalID(productId, outProductId string) (*product_detail_response.ProductDetailData, error) {
|
||||
request := product_detail_request_out.New()
|
||||
param := request.GetParams()
|
||||
|
||||
if outProductId != "" {
|
||||
param.OutProductId = outProductId
|
||||
}
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// GetSkuDetailList 批量获取商品列表
|
||||
func (a *API) GetSkuDetailList(param *product_listV2_request.ProductListV2Param) (*product_listV2_response.ProductListV2Data, error) {
|
||||
request := product_listV2_request.New()
|
||||
|
||||
@@ -220,6 +220,7 @@ func TestInt16(t *testing.T) {
|
||||
fmt.Println(utils.Str2Int16(strings.ReplaceAll("08:00", ":", "")))
|
||||
}
|
||||
|
||||
// 查询商品详情(抖音平台id)
|
||||
func TestGetSkuDetail(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
|
||||
@@ -229,6 +230,16 @@ func TestGetSkuDetail(t *testing.T) {
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
|
||||
// 查询商品详情本地商品id
|
||||
func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
data, err := a.GetSkuDetail("", "")
|
||||
fmt.Println(err)
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
|
||||
func TestUpdateSkuStore(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
|
||||
Reference in New Issue
Block a user