- category sync almost ok.

- refactor tasksch (isContinueWhenError)
This commit is contained in:
gazebo
2018-09-22 10:26:31 +08:00
parent 0623d31c71
commit 81089fb85c
13 changed files with 283 additions and 114 deletions

View File

@@ -3,6 +3,7 @@ package jxutils
import (
"fmt"
"math"
"reflect"
"strings"
"time"
@@ -17,8 +18,13 @@ func MergeStoreStatus(status int, vendorStatus int) int {
return vendorStatus
}
func SplitSlice(list []interface{}, batchCount int) (listInList [][]interface{}) {
len := len(list)
func SplitSlice(list interface{}, batchCount int) (listInList [][]interface{}) {
typeInfo := reflect.TypeOf(list)
if typeInfo.Kind() != reflect.Slice {
panic("list must be slice")
}
valueInfo := reflect.ValueOf(list)
len := valueInfo.Len()
if len > 0 {
listInListLen := (len-1)/batchCount + 1
listInList = make([][]interface{}, listInListLen)
@@ -32,7 +38,7 @@ func SplitSlice(list []interface{}, batchCount int) (listInList [][]interface{})
}
listInList[index] = make([]interface{}, arrLen)
}
listInList[index][i%batchCount] = list[i]
listInList[index][i%batchCount] = valueInfo.Index(i).Interface()
}
}
return listInList
@@ -107,3 +113,7 @@ func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string) int {
}
return int(math.Round(float64(float32(unitPrice) * specQuality / 500)))
}
func GetSliceLen(list interface{}) int {
return reflect.ValueOf(list).Len()
}