- SplitSkuName don't use comment as name

- add DownloadFileByURL
- refactor UploadWeimobImg4SkuName
- ignore RefreshMissingDadaStores error
- add BuildSkuFromEbaiStore
This commit is contained in:
gazebo
2019-03-20 09:31:33 +08:00
parent d0587fef0a
commit d8b7b41b01
8 changed files with 311 additions and 23 deletions

View File

@@ -1,13 +1,17 @@
package jxutils
import (
"crypto/md5"
"fmt"
"io/ioutil"
"math"
"net/http"
"reflect"
"regexp"
"strings"
"time"
"git.rosy.net.cn/baseapi/platformapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
)
@@ -254,3 +258,25 @@ func (s SkuList) Swap(i, j int) {
s[i] = s[j]
s[j] = tmp
}
func DownloadFileByURL(fileURL string) (bodyData []byte, fileMD5 string, err error) {
response, err := http.Get(fileURL)
if err == nil {
defer func() {
response.Body.Close()
}()
if response.StatusCode == http.StatusOK {
if bodyData, err = ioutil.ReadAll(response.Body); err == nil {
fileMD5 = fmt.Sprintf("%X", md5.Sum(bodyData))
}
} else {
err = platformapi.ErrHTTPCodeIsNot200
}
}
return bodyData, fileMD5, err
}
/////
func GenPicFileName(suffix string) string {
return fmt.Sprintf("%x%s", md5.Sum([]byte(utils.GetUUID()+suffix)), suffix)
}