This commit is contained in:
richboo111
2022-11-22 16:04:17 +08:00
9 changed files with 214 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
package jdapi
import (
"fmt"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
"testing"
@@ -167,4 +168,5 @@ func TestQueryMerchantMemberInfo(t *testing.T) {
}
func Test1111(t *testing.T) {
fmt.Println(len("我爱你 ml1"))
}

View File

@@ -8,7 +8,7 @@ import (
type OrderGetSettleBillDetailV3Request struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *OrderAddressModifyParam
Param *OrderGetSettleBillDetailV3Param
}
func (c *OrderGetSettleBillDetailV3Request) GetUrlPath() string {
@@ -17,7 +17,7 @@ func (c *OrderGetSettleBillDetailV3Request) GetUrlPath() string {
func New() *OrderGetSettleBillDetailV3Request {
request := &OrderGetSettleBillDetailV3Request{
Param: &OrderAddressModifyParam{},
Param: &OrderGetSettleBillDetailV3Param{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
@@ -40,11 +40,11 @@ func (c *OrderGetSettleBillDetailV3Request) GetParamObject() interface{} {
return c.Param
}
func (c *OrderGetSettleBillDetailV3Request) GetParams() *OrderAddressModifyParam {
func (c *OrderGetSettleBillDetailV3Request) GetParams() *OrderGetSettleBillDetailV3Param {
return c.Param
}
type OrderAddressModifyParam struct {
type OrderGetSettleBillDetailV3Param struct {
// 页数支持范围1~100
Size int64 `json:"size"`
// 查询开始时间格式为yyyy-MM-dd HH:mm:ss订单号未传的情况下开始时间必须传注意分页查询时除首次查询外应填入上一次返回的next_start_time

View File

@@ -8,49 +8,89 @@ type OrderGetSettleBillDetailV3Response struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *OrderGetSettleBillDetailV3Data `json:"data"`
}
type DataItem struct {
// 结算时间
SettleTime string `json:"settle_time"`
// 结算单号
RequestNo string `json:"request_no"`
// 订单号
ShopOrderId string `json:"shop_order_id"`
// 子订单号
OrderId string `json:"order_id"`
// 商家实收(分)
SettleAmount int64 `json:"settle_amount"`
// 货款结算对应的账户类型: “聚合账户”“微信”“支付宝”“微信升级前”“合众支付”等
PayTypeDesc string `json:"pay_type_desc"`
// 结算单类型 0 :已结算 1 :结算后退款-原路退回 2 保证金退款-支出退回 3 结算后退款-非原路退回
TradeType int32 `json:"trade_type"`
// 是否包含结算前退款 0不包含 1包含
IsContainsRefundBeforeSettle int32 `json:"is_contains_refund_before_settle"`
// 下单时间
OrderTime string `json:"order_time"`
// 商品id
ProductId string `json:"product_id"`
// 商品数量
GoodsCount int32 `json:"goods_count"`
// 业务类型: 鲁班广告、值点商城、精选联盟、小店自卖等
FlowTypeDesc string `json:"flow_type_desc"`
// 订单类型:普通订单、尾款(尾款已支付)、尾款(已退款)、定金(已退款)、定金(尾款已支付)、定金(尾款未支付)
OrderType string `json:"order_type"`
// 订单总价(分)
TotalAmount int64 `json:"total_amount"`
// 商品总价(分)
TotalGoodsAmount int64 `json:"total_goods_amount"`
// 运费(分)
PostAmount int64 `json:"post_amount"`
// 店铺券(分)
ShopCoupon int64 `json:"shop_coupon"`
// 结算前退款金额(分) (结算前退货+运费-店铺券)
RefundBeforeSettle int64 `json:"refund_before_settle"`
// 平台补贴(分)
PlatformCoupon int64 `json:"platform_coupon"`
// 达人补贴(分)
AuthorCoupon int64 `json:"author_coupon"`
// 抖音支付补贴(分)
ZtPayPromotion int64 `json:"zt_pay_promotion"`
// DOU分期营销补贴
ZrPayPromotion int64 `json:"zr_pay_promotion"`
// 用户实付(分)
RealPayAmount int64 `json:"real_pay_amount"`
// 收入合计(分)
TotalIncome int64 `json:"total_income"`
// 平台服务费(分)
PlatformServiceFee int64 `json:"platform_service_fee"`
// 佣金(分)
Commission int64 `json:"commission"`
// 渠道分成(分)
GoodLearnChannelFee int64 `json:"good_learn_channel_fee"`
// 团长服务费(分)
ColonelServiceFee int64 `json:"colonel_service_fee"`
// 直播间站外推广(分)
ChannelPromotionFee int64 `json:"channel_promotion_fee"`
// 其他分成(学浪)(分)
OtherSharingAmount int64 `json:"other_sharing_amount"`
// 合计支出
TotalOutcome int64 `json:"total_outcome"`
// 备注
Remark string `json:"remark"`
// 打包费,单位:分
PackingAmount int64 `json:"packing_amount"`
}
type OrderGetSettleBillDetailV3Data struct {
Code string `json:"code"` // 返回code 100000为成功其他为失败
CodeMsg string `json:"code_msg"` // 返回信息描述,失败状态下会有失败描述
Data []DataList `json:"data"` // 订单流水明细列表
DataSize string `json:"data_size"` // 结果data的大小
IsEnd string `json:"is_end"` // 判断查询是否结束。0 未结束, 1 结束。未结束时需要把next_start_index作为下一次请求的start_index,next_start_time作为下一次请求的start_time
NextStartIndex string `json:"next_start_index"` // 下一次查询start_index
NextStartTime string `json:"next_start_time"` // 下一次查询start_time
Size string `json:"size"` // 请求的size
}
type DataList struct {
AuthorCoupon string `json:"author_coupon"` // 达人补贴(分)
ChannelPromotionFee string `json:"channel_promotion_fee"` // 直播间站外推广(分)
ColonelServiceFee string `json:"colonel_service_fee"` // 团长服务费(分)
Commission string `json:"commission"` // 佣金(分)
FlowTypeDesc string `json:"flow_type_desc"` // 业务类型: 鲁班广告、值点商城、精选联盟、小店自卖等
GoodLearnChannelFee string `json:"good_learn_channel_fee"` // 渠道分成(分)
GoodsCount string `json:"goods_count"` // 商品数量
IsContainsRefundBeforeSettle string `json:"is_contains_refund_before_settle"` // 是否包含结算前退款 0不包含 1包含
OrderId string `json:"order_id"` // 子订单号
OrderTime string `json:"order_time"` // 下单时间
OrderType string `json:"order_type"` // 订单类型:普通订单、尾款(尾款已支付)、尾款(已退款)、定金(已退款)、定金(尾款已支付)、定金(尾款未支付)
OtherSharingAmount string `json:"other_sharing_amount"` // 其他分成(学浪)(分)
PackingAmount string `json:"packing_amount"` // 打包费,单位:分
PayTypeDesc string `json:"pay_type_desc"` // 货款结算对应的账户类型: “聚合账户”“微信”“支付宝”“微信升级前”“合众支付”等
PlatformCoupon string `json:"platform_coupon"` // 平台补贴(分)
PlatformServiceFee string `json:"platform_service_fee"` // 平台服务费(分)
PostAmount string `json:"post_amount"` // 运费(分)
ProductId string `json:"product_id"` // 商品id
RealPayAmount string `json:"real_pay_amount"` // 用户实付(分)
RefundBeforeSettle string `json:"refund_before_settle"` // 结算前退款金额(分) (结算前退货+运费-店铺券)
Remark string `json:"remark"` // 备注
RequestNo string `json:"request_no"` // 结算单号
SettleAmount string `json:"settle_amount"` // 商家实收(分)
SettleTime string `json:"settle_time"` // 结算时间
ShopCoupon string `json:"shop_coupon"` // 店铺券(分)
ShopOrderId string `json:"shop_order_id"` // 订单号
TotalAmount string `json:"total_amount"` // 订单总价(分)
TotalGoodsAmount string `json:"total_goods_amount"` // 商品总价(分)
TotalIncome string `json:"total_income"` // 收入合计(分)
TotalOutcome string `json:"total_outcome"` // 合计支出
TradeType string `json:"trade_type"` // 结算单类型 0 :已结算 1 :结算后退款-原路退回 2 保证金退款-支出退回 3 结算后退款-非原路退回
ZrPayPromotion string `json:"zr_pay_promotion"` // DOU分期营销补贴
ZtPayPromotion string `json:"zt_pay_promotion"` // 抖音支付补贴(分)
// 返回code 100000为成功其他为失败
Code string `json:"code"`
// 返回信息描述,失败状态下会有失败描述
CodeMsg string `json:"code_msg"`
// 订单流水明细列表
Data []DataItem `json:"data"`
// 请求的size
Size int64 `json:"size"`
// 下一次查询start_index
NextStartIndex string `json:"next_start_index"`
// 下一次查询start_time
NextStartTime string `json:"next_start_time"`
// 判断查询是否结束。0 未结束, 1 结束。未结束时需要把next_start_index作为下一次请求的start_index,next_start_time作为下一次请求的start_time
IsEnd int32 `json:"is_end"`
// 结果data的大小
DataSize int64 `json:"data_size"`
}

View File

@@ -1,5 +1,7 @@
package product_GetRecommendCategory_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type ProductGetRecommendCategoryResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *ProductGetRecommendCategoryData `json:"data"`

View File

@@ -2,6 +2,8 @@ package product_auditList_request
import (
"encoding/json"
product_auditList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_auditList/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type ProductAuditListRequest struct {

View File

@@ -1,5 +1,7 @@
package product_auditList_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type ProductAuditListResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *ProductAuditListData `json:"data"`

View File

@@ -1,22 +1,33 @@
package tiktok_api
import (
"errors"
order_getSettleBillDetailV3_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/request"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
)
// GetSettleBillDetailV3 商家结算账单
// 已结算的订单才会有数据数据T+1生成建议第二天15点之后查询。如因任务积压导致延迟的情况建议重试。
// 1、推荐使用start_index方式查询
func (a *API) GetSettleBillDetailV3(param *order_getSettleBillDetailV3_request.OrderAddressModifyParam) {
func (a *API) GetSettleBillDetailV3(param *order_getSettleBillDetailV3_request.OrderGetSettleBillDetailV3Param) (map[string]int64, string, error) {
request := order_getSettleBillDetailV3_request.New()
request.Param = param
result, err := request.Execute(a.accessTokenObj)
if err != nil {
return
return nil, "", err
}
globals.SugarLogger.Debugf("======:%s", utils.Format4Output(result, false))
globals.SugarLogger.Debugf("======:%s", err)
if result.Code != RequestSuccessCode {
return nil, "", errors.New(result.SubMsg)
}
if len(result.Data.Data) == 0 {
return nil, "", nil
}
totalShopMoney := make(map[string]int64, 0)
for _, v := range result.Data.Data {
totalShopMoney[v.ShopOrderId] = v.SettleAmount
}
return totalShopMoney, result.Data.NextStartIndex, nil
}

View File

@@ -6,8 +6,11 @@ import (
brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request"
order_batchDecrypt_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchDecrypt/request"
order_batchSensitive_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchSensitive/request"
product_GetRecommendCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_GetRecommendCategory/request"
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
product_addV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/response"
product_auditList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_auditList/request"
product_auditList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_auditList/response"
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"
@@ -8144,3 +8147,76 @@ func (a *API) GetProductUpdateRule2(categoryId int64) bool {
}
return result.Data.AfterSaleRule.SupplyDayReturnRule.Enable
}
// GetProductAuditList 获取商品的审核记录
func (a *API) GetProductAuditList(page, pageSize, status int64) ([]product_auditList_response.RecordsItem, int64, error) {
request := product_auditList_request.New()
request.Param.PublishStatus = status
request.Param.Page = page
request.Param.Size = pageSize
result, err := request.Execute(a.accessTokenObj)
if err != nil {
return nil, 0, err
}
if result.Code != RequestSuccessCode {
return nil, 0, errors.New(result.SubMsg)
}
return result.Data.Records, result.Data.Total, nil
}
// GetRecommendCategory 根据图片预测商品类目,优先四级>三级>二级>1级
func (a *API) GetRecommendCategory(picParams []string) int64 {
if len(picParams) == 0 {
return 0
}
request := product_GetRecommendCategory_request.New()
request.Param.Scene = "smart_publish" // 根据图片获取分类属性
picList := make([]product_GetRecommendCategory_request.PicItem, 0, 0)
for _, v := range picParams {
picList = append(picList, product_GetRecommendCategory_request.PicItem{Url: v})
}
request.Param.Pic = picList
result, err := request.Execute(a.accessTokenObj)
if err != nil {
return 0
}
if result.Code != RequestSuccessCode {
return 0
}
var firstCid int64
var secondCid int64
var thirdCid int64
var fourthCid int64
for _, v := range result.Data.CategoryDetails {
if v.CategoryDetail.FirstCid != 0 {
firstCid = v.CategoryDetail.FirstCid
}
if v.CategoryDetail.SecondCid != 0 {
secondCid = v.CategoryDetail.SecondCid
}
if v.CategoryDetail.ThirdCid != 0 {
thirdCid = v.CategoryDetail.ThirdCid
}
if v.CategoryDetail.FourthCid != 0 {
fourthCid = v.CategoryDetail.FourthCid
}
}
if fourthCid != 0 {
return fourthCid
}
if thirdCid != 0 {
return thirdCid
}
if secondCid != 0 {
return secondCid
}
if firstCid != 0 {
return firstCid
}
return 0
}

View File

@@ -318,7 +318,7 @@ func TestBatchDecrypt(t *testing.T) {
func TestGetSkuList(t *testing.T) {
result, err := a.GetSkuDetailList(&product_listV2_request.ProductListV2Param{
Status: 0,
CheckStatus: 3,
CheckStatus: 4,
ProductType: 0,
StartTime: 0,
EndTime: 0,
@@ -326,7 +326,6 @@ func TestGetSkuList(t *testing.T) {
Size: 100,
UpdateStartTime: 0,
UpdateEndTime: 0,
//StoreId: 65402632,
})
for _, v := range result.Data {
@@ -385,3 +384,27 @@ func TestNameeeee(t *testing.T) {
func TestGetProductUpdateRule2(t *testing.T) {
a.GetProductUpdateRule2(20219)
}
func TestPPPPPPPPPPPPPP(t *testing.T) {
aa := "该商品类目选择错误,推荐放置在“面条/挂面(待煮面条)”类目中."
for _, v := range strings.Split(aa, "“") {
fmt.Println(v)
}
}
func TestGetProductAuditList(t *testing.T) {
data, _, _ := a.GetProductAuditList(1, 100, 2)
updateCategory := make(map[string]string, 0) // 修改分类的Map
for _, v := range data {
if _, ok := v.AuditReason["综合原因"]; ok {
if strings.Contains(v.AuditReason["综合原因"][0], "该商品类目选择错误,推荐放置在") {
list := strings.Split(v.AuditReason["综合原因"][0], ``)
list2 := strings.Split(list[1], ``)
categoryNameList := strings.Split(list2[0], "/")
updateCategory[utils.Int64ToStr(v.ProductId)] = categoryNameList[len(categoryNameList)-1]
}
}
}
}