diff --git a/server/marketserver/api/v1/shopcart/shopcart.go b/server/marketserver/api/v1/shopcart/shopcart.go index ae04beb3..6d3c524f 100644 --- a/server/marketserver/api/v1/shopcart/shopcart.go +++ b/server/marketserver/api/v1/shopcart/shopcart.go @@ -1,8 +1,10 @@ package shopcart import ( + "q5" "f5" "main/constant" + "main/common" "github.com/gin-gonic/gin" ) @@ -30,6 +32,13 @@ func (this *ShopCartApi) List(c *gin.Context) { c.JSON(200, rspObj) return } + cartDb := new(common.ShopCart) + if q5.DecodeJson(ds.GetByName("data"), cartDb) == nil { + q5.Sort[common.ShopCartGoods](cartDb.Goods, + func (a *common.ShopCartGoods, b *common.ShopCartGoods) bool{ + return a.SortIdx < b.SortIdx + }) + } c.JSON(200, rspObj) }) } diff --git a/server/marketserver/common/types.go b/server/marketserver/common/types.go index e8bb7b87..73fbe19c 100644 --- a/server/marketserver/common/types.go +++ b/server/marketserver/common/types.go @@ -61,12 +61,16 @@ type StreamPagination struct { Remaining int32 `json:"remaining"` } +type ShopCartGoods struct { + NetId int32 `json:"net_id"` + ContractAddress uint32 `json:"address"` + SortIdx uint32 `json:"idx"` + CreateTime int32 `json:"addtime"` +} + type ShopCart struct { - CurrIdx uint32 `json:"curr_idx"` - Goolds map[string] struct { - SortIdx uint32 `json:"sort_idx"` - CreateTime uint32 `json:"createtime"` - } `json:"goods"` + CurrSortIdx uint32 `json:"curr_sort_idx"` + Goods []*ShopCartGoods `json:"goods"` } type NftCache interface {