This commit is contained in:
邹宗楠
2022-10-25 11:26:12 +08:00
parent d962b4ed37
commit f78ca1769e
2 changed files with 28 additions and 21 deletions

View File

@@ -67,13 +67,12 @@ func CreateSaleTemp(storeId int64, api *tiktokShop.API) (int64, error) {
func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao.StoreDetail) (int64, error) {
// 没有模板是查询线上模板
freightId, _ := api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
globals.SugarLogger.Debugf("freightId =err %d", freightId)
if freightId == 0 {
// 创建门店运费模板
productProvince := utils.Str2Int64(utils.Int2Str(storeDetail.ProvinceCode)[0:2])
tempDetail := &freightTemplate_create_request.FreightTemplateCreateParam{
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: productProvince,
ProductCity: int64(storeDetail.CityCode),
CalculateType: 2,
@@ -81,7 +80,8 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao
RuleType: 1, // 模板类型-0:阶梯计价 1:固定运费 2:卖家包邮 3:货到付款
FixedAmount: 500, //固定运费 单位:分
},
Columns: []freightTemplate_create_request.ColumnsItem{
}
Columns := []freightTemplate_create_request.ColumnsItem{
{
RuleAddress: fmt.Sprintf(`{"%d":{"%s":{"%s":nil}}}`, productProvince, utils.Int2Str(storeDetail.CityCode), utils.Int2Str(storeDetail.DistrictCode)),
IsOverFree: true,
@@ -102,7 +102,14 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao
}},
},
},
},
}
// 固定运费模板
if storeDetail.DeliveryFeeDeductionSill == 0 {
tempDetail.Template.TemplateName += "固定运费模板"
} else {
// 满减运费模板
tempDetail.Template.TemplateName += "满减运费模板"
tempDetail.Columns = Columns // 满减
}
globals.SugarLogger.Debugf("tempDetail ========= %s", utils.Format4Output(tempDetail, false))
temp, err := api.FreightTemplateCreate(tempDetail)