- 添加了部分到家订单级促销

This commit is contained in:
gazebo
2019-04-04 21:03:10 +08:00
parent ef69a4f60d
commit c3e3c32d44
14 changed files with 294 additions and 107 deletions

View File

@@ -454,6 +454,8 @@ func FlatMap(in map[string]interface{}) map[string]interface{} {
vMap = FlatMap(vMap)
maps = append(maps, vMap)
keys = append(keys, k)
} else {
fmt.Printf("%s is %s\n", k, reflect.TypeOf(v).String())
}
}
if len(maps) > 0 {
@@ -473,8 +475,9 @@ func Struct2FlatMap(obj interface{}) map[string]interface{} {
func Struct2MapWithIgnore(obj interface{}, ignoreValues map[string]interface{}) map[string]interface{} {
mapData := Struct2FlatMap(obj)
for k, v := range mapData {
if ignoreValues[k] == v {
for k, v := range ignoreValues {
// todo 性能考虑?
if fmt.Sprint(mapData[k]) == fmt.Sprint(v) {
delete(mapData, k)
}
}

View File

@@ -3,6 +3,7 @@ package utils
import (
"encoding/json"
"testing"
"time"
)
func TestConv(t *testing.T) {
@@ -69,3 +70,17 @@ func TestMarshal(t *testing.T) {
t.Log(Format4Output(obj2, false))
t.Log(Format4Output(Struct2FlatMap(obj2), false))
}
func TestTime(t *testing.T) {
for _, v := range [][]interface{}{
[]interface{}{
"2019-04-01",
Str2Time("2019-04-01 00:00:00"),
},
} {
data := Str2Time(v[0].(string))
if data != v[1].(time.Time) {
t.Fatal("Interface2Int64WithDefault failed")
}
}
}