更新京东商品jdprice

This commit is contained in:
苏尹岚
2020-06-10 09:07:21 +08:00
parent 7f50e32711
commit d57093e920
2 changed files with 52 additions and 121 deletions

View File

@@ -151,6 +151,7 @@ type UpdateWareParam struct {
Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符
Features []*CreateSkuParamFeatures `json:"features"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。
ShopCategorys []int `json:"shopCategorys"` // 否 无 商品店内分类(商家接口获取到的最末级的分类)
JdPrice float64 `json:"jdPrice"` //是 无 京东价必填 单位:元
}
type QueryPictureReuslt struct {

View File

@@ -12,6 +12,8 @@ import (
"io/ioutil"
"math"
"net/http"
"regexp"
"strings"
"testing"
"git.rosy.net.cn/baseapi/platformapi"
@@ -19,6 +21,10 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
)
var (
skuNamePat = regexp.MustCompile(`([\(\[【][^\(\[【\)\]】]*[\)\]】])?(.*?)([(].*[)])?\s*约?([1-9][\d\.]*)(g|G|kg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([(].*[)])?\s*(?:\/||)\s*([^\s()]{0,2})(\s.*)?$\s*([(].*[)])?$`)
)
func TestFindShopCategories(t *testing.T) {
result, err := api.FindShopCategories()
if err != nil {
@@ -448,130 +454,19 @@ func TestUpdateWareSaleAttrvalueAlias(t *testing.T) {
}
func TestSearchSkuList(t *testing.T) {
var wareIDs = []int64{
14518860227,
14518865342,
14518857791,
14518863440,
14518850181,
14518869426,
14518865836,
14518860282,
14518862865,
14518860089,
14518861773,
14518857091,
14518859794,
14518878413,
14518874243,
14518992990,
14519010404,
14519010010,
14519006838,
14519009822,
14541114008,
14542371664,
14542409106,
14542477967,
14542585438,
14542602011,
14542586377,
14542927723,
14542946611,
14542948535,
14543031285,
14543077206,
14544951705,
14546014638,
14565258994,
14565275855,
14566133342,
14566144059,
14566419305,
14566403990,
14566408956,
14567187277,
14567793468,
14567911336,
14567910034,
14567907049,
14567904981,
14567909664,
14567907786,
14568001774,
14568152611,
14568138877,
14568146252,
14568161923,
14568508881,
14568512475,
14568524772,
14568533264,
14568540322,
14568534834,
14568546936,
14568542882,
14568806841,
14576405495,
14576832607,
14576832017,
14576946037,
14576974106,
14576993226,
14579143223,
14581769973,
14581773059,
14581773646,
14581780520,
14581782920,
14581768094,
14581788365,
14581805504,
14581919920,
14581915051,
14581920950,
14581971709,
14581979302,
14581974927,
14581974739,
14581964099,
14581974639,
14581976637,
14581979946,
14581989815,
14581987337,
14581987251,
14581981273,
14581996123,
14581984285,
14581994544,
14581996576,
14582006319,
14582000952,
14582000668,
14581993998,
14581996999,
14582016736,
14582053303,
14594027838,
14594055255,
14594104816,
14594233747,
14594245738,
14594249079,
14594296303,
14594987858,
14596828148,
14600091528,
14600094614,
14600087648,
14566414324}
for _, v := range wareIDs {
result, _ := api.SearchSkuList(v)
var rr []int64
ser, _ := api.SearchWare4Valid("", 1, 100)
for _, v := range ser.Data {
result, _ := api.SearchSkuList(v.WareID)
for _, vv := range result {
api.DeleteSku(vv.SkuID)
result2, _ := api.FindSkuById(vv.SkuID)
_, _, _, specUnit, _, specQuality := SplitSkuName(result2.SaleAttrs[0].AttrValueAlias[0])
if specQuality < 100 && specUnit != "kg" && specUnit != "L" {
rr = append(rr, vv.SkuID)
}
}
}
fmt.Println("test", rr)
// result, err := api.SearchSkuList(14518857091)
// if err != nil {
// t.Fatal(err)
@@ -586,3 +481,38 @@ func TestAAAAAA(t *testing.T) {
}
t.Log(utils.Format4Output(result, false))
}
func SplitSkuName(skuName string) (prefix, name, comment, specUnit, unit string, specQuality float32) {
searchResult := skuNamePat.FindStringSubmatch(skuName)
if searchResult != nil {
if searchResult[3] != "" {
comment = searchResult[3]
} else if searchResult[6] != "" {
comment = searchResult[6]
} else if searchResult[8] != "" {
comment = searchResult[8]
} else if searchResult[9] != "" {
comment = searchResult[9]
}
// comment = TrimDecorationChar(comment)
// name = TrimDecorationChar(searchResult[2])
// if comment != "" {
// // if utf8.RuneCountInString(comment) <= 5 {
// // name += "-" + comment
// // comment = ""
// // }
// }
specUnit = strings.ToLower(strings.Replace(searchResult[5], "克", "g", -1))
if specUnit == "l" {
specUnit = "L"
}
if searchResult[7] == "" {
unit = "份"
} else {
unit = searchResult[7]
}
specQuality = float32(utils.Str2Float64(searchResult[4]))
// prefix = TrimDecorationChar(searchResult[1])
}
return prefix, name, comment, specUnit, unit, specQuality
}