diff --git a/platformapi/jdapi/order.go b/platformapi/jdapi/order.go index 4a40a73b..2ce8c9b3 100644 --- a/platformapi/jdapi/order.go +++ b/platformapi/jdapi/order.go @@ -10,7 +10,8 @@ import ( ) const ( - AfsPicPrefix = "http://img10.360buyimg.com/o2o" + AfsPicPrefix = "http://img10.360buyimg.com/o2o" + AfsPicPrefixHttps = "https://img10.360buyimg.com/o2o" ) const ( @@ -675,11 +676,19 @@ func (a *API) AfsSubmit(OrderID, pin, questionTypeCode, questionDesc, questionPi } func ProcessQuestionPic(questionPic string) (outQuestionPic string) { + const httpsPrefix = "https:" if questionPic != "" { picList := strings.Split(questionPic, ",") - picList2 := make([]string, len(picList)) - for index, pic := range picList { - picList2[index] = AfsPicPrefix + "/" + pic + var picList2 []string + for _, pic := range picList { + baseURL := AfsPicPrefix + pic2 := strings.ReplaceAll(pic, httpsPrefix, "") + if pic2 != pic { + baseURL = AfsPicPrefixHttps + } + if pic2 = utils.TrimBlankChar(pic2); pic2 != "" { + picList2 = append(picList2, utils.GenerateGetURL(baseURL, pic2, nil)) + } } outQuestionPic = strings.Join(picList2, ",") } diff --git a/platformapi/jdapi/order_test.go b/platformapi/jdapi/order_test.go index b95119c4..e8c8ad39 100644 --- a/platformapi/jdapi/order_test.go +++ b/platformapi/jdapi/order_test.go @@ -259,3 +259,29 @@ func TestCheckSelfPickCode(t *testing.T) { t.Fatal(err.Error()) } } + +func TestProcessQuestionPic(t *testing.T) { + for _, v := range [][]string{ + []string{ + "http://img10.360buyimg.com/o2o/jfs/a.jpg", + ",,,jfs/a.jpg", + }, + []string{ + "http://img10.360buyimg.com/o2o/jfs/a.jpg,https://img10.360buyimg.com/o2o/jfs/b.jpg", + " , ,, jfs/a.jpg,https:jfs/b.jpg", + }, + []string{ + "https://img10.360buyimg.com/o2o/jfs/a.jpg", + ",https:jfs/a.jpg", + }, + []string{ + "", + ",https:", + }, + } { + str := ProcessQuestionPic(v[1]) + if str != v[0] { + t.Fatalf("%s, desired:%s, but its:%s", v[1], v[0], str) + } + } +} diff --git a/platformapi/jdapi/store_test.go b/platformapi/jdapi/store_test.go index 0c809544..33531478 100644 --- a/platformapi/jdapi/store_test.go +++ b/platformapi/jdapi/store_test.go @@ -153,7 +153,7 @@ func TestUpdateStoreFreightConfigNew(t *testing.T) { } func TestPrivilegeSearchUser(t *testing.T) { - result, err := api.PrivilegeSearchUser(1, 1) + result, _, _, err := api.PrivilegeSearchUser(1) if err != nil { t.Fatal(err) }