|
@ -2,6 +2,9 @@ package productrpc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
|
|
|
"log" |
|
|
|
|
|
"sort" |
|
|
|
|
|
"strconv" |
|
|
// "strconv"
|
|
|
// "strconv"
|
|
|
// "time"
|
|
|
// "time"
|
|
|
) |
|
|
) |
|
@ -48,7 +51,40 @@ func GetActivity(site_id, dbname, id string, sku_id string, url ...string) ([]ma |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
return res_arr, nil |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var activitys Activitys |
|
|
|
|
|
|
|
|
|
|
|
if len(res_arr) > 0 { |
|
|
|
|
|
var start int |
|
|
|
|
|
|
|
|
|
|
|
for _, item := range res_arr { |
|
|
|
|
|
start, err = strconv.Atoi(item["Starttime"]) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
} |
|
|
|
|
|
activitys = append(activitys, Activity{ |
|
|
|
|
|
Id: item["Id"], |
|
|
|
|
|
Start: start, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sort.Sort(activitys) |
|
|
|
|
|
|
|
|
|
|
|
var list []map[string]string = make([]map[string]string, 0) |
|
|
|
|
|
|
|
|
|
|
|
if len(activitys) > 0 { |
|
|
|
|
|
for _, v := range activitys { |
|
|
|
|
|
for _, old := range res_arr { |
|
|
|
|
|
if v.Id == old["Id"] { |
|
|
|
|
|
list = append(list, old) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -93,7 +129,40 @@ func GetWarmingActivity(site_id, dbname, id string, sku_id string, url ...string |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
return res_arr, nil |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var activitys Activitys |
|
|
|
|
|
|
|
|
|
|
|
if len(res_arr) > 0 { |
|
|
|
|
|
var start int |
|
|
|
|
|
|
|
|
|
|
|
for _, item := range res_arr { |
|
|
|
|
|
start, err = strconv.Atoi(item["Starttime"]) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
} |
|
|
|
|
|
activitys = append(activitys, Activity{ |
|
|
|
|
|
Id: item["Id"], |
|
|
|
|
|
Start: start, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sort.Sort(activitys) |
|
|
|
|
|
|
|
|
|
|
|
var list []map[string]string = make([]map[string]string, 0) |
|
|
|
|
|
|
|
|
|
|
|
if len(activitys) > 0 { |
|
|
|
|
|
for _, v := range activitys { |
|
|
|
|
|
for _, old := range res_arr { |
|
|
|
|
|
if v.Id == old["Id"] { |
|
|
|
|
|
list = append(list, old) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -138,5 +207,55 @@ func GetAllActivity(site_id, dbname, id string, sku_id string, url ...string) ([ |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
return res_arr, nil |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var activitys Activitys |
|
|
|
|
|
|
|
|
|
|
|
if len(res_arr) > 0 { |
|
|
|
|
|
var start int |
|
|
|
|
|
|
|
|
|
|
|
for _, item := range res_arr { |
|
|
|
|
|
start, err = strconv.Atoi(item["Starttime"]) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
} |
|
|
|
|
|
activitys = append(activitys, Activity{ |
|
|
|
|
|
Id: item["Id"], |
|
|
|
|
|
Start: start, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sort.Sort(activitys) |
|
|
|
|
|
|
|
|
|
|
|
var list []map[string]string = make([]map[string]string, 0) |
|
|
|
|
|
|
|
|
|
|
|
if len(activitys) > 0 { |
|
|
|
|
|
for _, v := range activitys { |
|
|
|
|
|
for _, old := range res_arr { |
|
|
|
|
|
if v.Id == old["Id"] { |
|
|
|
|
|
list = append(list, old) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Activity struct { |
|
|
|
|
|
Id string |
|
|
|
|
|
Start int |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Activitys []Activity |
|
|
|
|
|
|
|
|
|
|
|
func (s Activitys) Len() int { |
|
|
|
|
|
return len(s) |
|
|
|
|
|
} |
|
|
|
|
|
func (s Activitys) Swap(i, j int) { |
|
|
|
|
|
s[i], s[j] = s[j], s[i] |
|
|
|
|
|
} |
|
|
|
|
|
func (s Activitys) Less(i, j int) bool { |
|
|
|
|
|
return s[i].Start < s[j].Start |
|
|
} |
|
|
} |