Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -66,12 +67,14 @@ func CreateSaleTemp(storeId int64, api *tiktokShop.API) (int64, error) {
|
|||||||
func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao.StoreDetail) (int64, error) {
|
func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao.StoreDetail) (int64, error) {
|
||||||
// 没有模板是查询线上模板
|
// 没有模板是查询线上模板
|
||||||
freightId, _ := api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
|
freightId, _ := api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
|
||||||
|
globals.SugarLogger.Debugf("freightId =err %d", freightId)
|
||||||
if freightId == 0 {
|
if freightId == 0 {
|
||||||
// 创建门店运费模板
|
// 创建门店运费模板
|
||||||
|
productProvince := utils.Str2Int64(utils.Int2Str(storeDetail.ProvinceCode)[0:2])
|
||||||
tempDetail := &freightTemplate_create_request.FreightTemplateCreateParam{
|
tempDetail := &freightTemplate_create_request.FreightTemplateCreateParam{
|
||||||
Template: &freightTemplate_create_request.Template{
|
Template: &freightTemplate_create_request.Template{
|
||||||
TemplateName: storeDetail.Name + "_" + utils.Int64ToStr(rand.Int63n(int64(storeDetail.ID))) + "_系统模板",
|
TemplateName: storeDetail.Name + "_" + utils.Int64ToStr(rand.Int63n(int64(storeDetail.ID))) + "_系统模板",
|
||||||
ProductProvince: utils.Str2Int64(utils.Int2Str(storeDetail.ProvinceCode)[0:2]),
|
ProductProvince: productProvince,
|
||||||
ProductCity: int64(storeDetail.CityCode),
|
ProductCity: int64(storeDetail.CityCode),
|
||||||
CalculateType: 2,
|
CalculateType: 2,
|
||||||
TransferType: 1, // 快递方式-1.快递 目前仅支持1
|
TransferType: 1, // 快递方式-1.快递 目前仅支持1
|
||||||
@@ -80,12 +83,12 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao
|
|||||||
},
|
},
|
||||||
Columns: []freightTemplate_create_request.ColumnsItem{
|
Columns: []freightTemplate_create_request.ColumnsItem{
|
||||||
{
|
{
|
||||||
RuleAddress: fmt.Sprintf(`{"%s":{"%s":{"%s":nil}}}`, utils.Int2Str(storeDetail.ProvinceCode)[0:2], utils.Int2Str(storeDetail.CityCode), utils.Int2Str(storeDetail.DistrictCode)),
|
RuleAddress: fmt.Sprintf(`{"%d":{"%s":{"%s":nil}}}`, productProvince, utils.Int2Str(storeDetail.CityCode), utils.Int2Str(storeDetail.DistrictCode)),
|
||||||
IsOverFree: true,
|
IsOverFree: true,
|
||||||
OverAmount: int64(storeDetail.DeliveryFeeDeductionSill),
|
OverAmount: int64(storeDetail.DeliveryFeeDeductionSill),
|
||||||
ProvinceInfos: []freightTemplate_create_request.ProvinceInfosItem{
|
ProvinceInfos: []freightTemplate_create_request.ProvinceInfosItem{
|
||||||
{
|
{
|
||||||
Id: utils.Str2Int64(utils.Int2Str(storeDetail.ProvinceCode)[0:2]),
|
Id: productProvince,
|
||||||
Children: []freightTemplate_create_request.ChildrenItem_4{
|
Children: []freightTemplate_create_request.ChildrenItem_4{
|
||||||
{
|
{
|
||||||
Id: int64(storeDetail.CityCode),
|
Id: int64(storeDetail.CityCode),
|
||||||
@@ -102,6 +105,8 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
temp, err := api.FreightTemplateCreate(tempDetail)
|
temp, err := api.FreightTemplateCreate(tempDetail)
|
||||||
|
globals.SugarLogger.Debugf("FreightTemplateCreate =err %s", utils.Format4Output(temp, false))
|
||||||
|
globals.SugarLogger.Debugf("FreightTemplateCreate =err %s", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -111,11 +116,12 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao
|
|||||||
StoreId: utils.Str2Int64(vendorStoreID),
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
FreightId: temp.TemplateId,
|
FreightId: temp.TemplateId,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("BindFreightTemplate =err %s", err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
freightId = temp.TemplateId
|
freightId = temp.TemplateId
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("freightId =last %d", freightId)
|
||||||
return freightId, nil
|
return freightId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user