1
This commit is contained in:
parent
6860d1fe77
commit
6d03e9448f
@ -5,6 +5,7 @@ import (
|
||||
"f5"
|
||||
"main/constant"
|
||||
"main/common"
|
||||
. "main/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -16,7 +17,10 @@ func (this *ShopCartApi) List(c *gin.Context) {
|
||||
rspObj := &struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Data []interface{} `json:"data"`
|
||||
Data []struct{
|
||||
Event interface{} `json:"event"`
|
||||
Nft interface{} `json:"nft"`
|
||||
} `json:"data"`
|
||||
}{}
|
||||
openId := c.MustGet("open_id").(string)
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
@ -33,11 +37,50 @@ func (this *ShopCartApi) List(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
cartDb := new(common.ShopCart)
|
||||
nfts := []*common.NftDto{}
|
||||
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
|
||||
})
|
||||
for _, val := range cartDb.Goods {
|
||||
var err1 error
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
constant.BCNFT_DB,
|
||||
"t_order",
|
||||
[][]string{
|
||||
{"net_id", q5.ToString(val.NetId)},
|
||||
{"contract_address", q5.ToString(val.ContractAddress)},
|
||||
{"token_id", q5.ToString(val.TokenId)},
|
||||
{"status", constant.ORDER_STATUS_ACTIVE},
|
||||
},
|
||||
func (err error, ds* f5.DataSet) {
|
||||
err1 = err
|
||||
if err == nil {
|
||||
p := new(common.NftDto)
|
||||
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
|
||||
p.ContractAddress = ds.GetByName("contract_address")
|
||||
p.TokenId = ds.GetByName("token_id")
|
||||
p.Payload = map[string]interface{}{}
|
||||
q5.DecodeJson(ds.GetByName("event_data"), &p.Payload)
|
||||
q5.AppendSlice(&nfts, p)
|
||||
}
|
||||
})
|
||||
if err1 != nil {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "server internal error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
GetCacheMgr().GetNfts(nfts)
|
||||
{
|
||||
for _, val := range nfts {
|
||||
p := q5.NewSliceElement(&rspObj.Data)
|
||||
p.Event = val.Payload
|
||||
p.Nft = val.NftCache.GetJsonData()
|
||||
}
|
||||
}
|
||||
c.JSON(200, rspObj)
|
||||
})
|
||||
|
@ -63,7 +63,8 @@ type StreamPagination struct {
|
||||
|
||||
type ShopCartGoods struct {
|
||||
NetId int32 `json:"net_id"`
|
||||
ContractAddress uint32 `json:"address"`
|
||||
ContractAddress string `json:"address"`
|
||||
TokenId string `json:"token_id"`
|
||||
SortIdx uint32 `json:"idx"`
|
||||
CreateTime int32 `json:"addtime"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user