Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -16,7 +16,7 @@ func TestOrderGet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderGet2(t *testing.T) {
|
||||
result, err := api.OrderGet2("1576493808229489038")
|
||||
result, err := api.OrderGet2("1577252398158729707")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
@@ -42,7 +42,7 @@ func TestOrderList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderListAll(t *testing.T) {
|
||||
result, err := api.OrderListAll("", 32267089397, 1563379200, 1563465599, 0)
|
||||
result, err := api.OrderListAll("", 32267184047, utils.Str2Time("2019-12-25").Unix(), utils.Str2Time("2019-12-26").Unix(), 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
@@ -145,3 +145,10 @@ func TestOrderPartRefund(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrderCancel(t *testing.T) {
|
||||
err := api.OrderCancel("2122788271803194389", CancelTypeCustom, "admin")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ const (
|
||||
|
||||
var (
|
||||
shopSkuBatchFailedSkuReg = regexp.MustCompile(`请核查以下sku:(\{.*\})`)
|
||||
|
||||
skuExistMsgList = []string{"商品已存在", "shop sku exist", "已被使用,请更换"}
|
||||
skuNotExistMsgList = []string{"sku_id与shop_id不匹配", "SKU不存在或者已经被删除", "商品不存在"}
|
||||
)
|
||||
|
||||
type CategoryInfo struct {
|
||||
@@ -551,11 +554,19 @@ func IsErrCategoryNotExist(err error) (isNotExist bool) {
|
||||
}
|
||||
|
||||
func IsErrSkuExist(err error) (isExist bool) {
|
||||
return utils.IsErrMatch(err, "1", []string{"商品已存在", "shop sku exist", "已被使用,请更换"})
|
||||
return utils.IsErrMatch(err, "1", skuExistMsgList)
|
||||
}
|
||||
|
||||
func IsErrSkuNotExist(err error) (isExist bool) {
|
||||
return utils.IsErrMatch(err, "1", []string{"sku_id与shop_id不匹配", "SKU不存在或者已经被删除", "商品不存在"})
|
||||
return utils.IsErrMatch(err, "1", skuNotExistMsgList)
|
||||
}
|
||||
|
||||
func IsMsgSkuExist(msg string) bool {
|
||||
return utils.IsErrMsgMatch(msg, skuExistMsgList)
|
||||
}
|
||||
|
||||
func IsMsgSkuNotExist(msg string) bool {
|
||||
return utils.IsErrMsgMatch(msg, skuNotExistMsgList)
|
||||
}
|
||||
|
||||
func (a *API) GetEbaiSkuIDFromCustomID(shopID, customSkuID string) (ebaiSkuID int64) {
|
||||
|
||||
@@ -71,19 +71,24 @@ func IsErrMatch(err error, strCode string, strList []string) (isMatch bool) {
|
||||
if err != nil {
|
||||
if codeErr, ok := err.(*ErrorWithCode); ok {
|
||||
if strCode == "" || codeErr.Code() == strCode {
|
||||
isMatch = len(strList) == 0
|
||||
for _, v := range strList {
|
||||
if strings.Index(codeErr.ErrMsg(), v) >= 0 {
|
||||
isMatch = true
|
||||
break
|
||||
}
|
||||
}
|
||||
isMatch = IsErrMsgMatch(codeErr.ErrMsg(), strList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return isMatch
|
||||
}
|
||||
|
||||
func IsErrMsgMatch(errMsg string, strList []string) (isMatch bool) {
|
||||
isMatch = len(strList) == 0
|
||||
for _, v := range strList {
|
||||
if strings.Index(errMsg, v) >= 0 {
|
||||
isMatch = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return isMatch
|
||||
}
|
||||
|
||||
func GetErrMsg(err error) (errMsg string) {
|
||||
if errExt, ok := err.(*ErrorWithCode); ok {
|
||||
errMsg = errExt.ErrMsg()
|
||||
|
||||
Reference in New Issue
Block a user