This commit is contained in:
aozhiwei 2024-06-16 10:48:04 +08:00
parent a7c073ada9
commit 19794eae8b

View File

@ -8,7 +8,7 @@ import (
"main/common" "main/common"
. "main/global" . "main/global"
"fmt" "fmt"
//"strings" "strings"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -170,18 +170,61 @@ SELECT * FROM t_order A WHERE idx > %d AND net_id = %d
} }
func (this *MarketApi) TransactionHistory(c *gin.Context) { func (this *MarketApi) TransactionHistory(c *gin.Context) {
netId := c.Param("netId") pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
tokenId := c.Param("tokenId") if pageSize < 0 {
f5.GetHttpCliMgr().SendGoStyleRequest( pageSize = 1
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", } else if pageSize > 100 {
map[string]string{ pageSize = 100
"c": "OutAppNft", }
"a": "nftMetaView", cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
"nft_type": "gold_bullion", netId := q5.ToInt64(c.Param("net_id"))
"net_id": netId, accountAddress := strings.ToLower(c.Param("account_address"))
"token_id": tokenId, filterType := q5.ToInt32(c.DefaultQuery("type", ""))
sql := fmt.Sprintf(`
SELECT A.idx, A.net_id, A.token_type, A.token_id, A.contract_address, B.status FROM t_nft A LEFT JOIN t_order B
ON A.net_id = B.net_id AND A.contract_address = B.contract_address AND A.token_id = B.token_id
WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? `,
cursor, netId)
if filterType == 1 {
sql += "B.status = '" + constant.ORDER_STATUS_ACTIVE + "'"
} else if filterType == 2 {
sql += "B.status <> '" + constant.ORDER_STATUS_ACTIVE + "'"
}
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []interface{} `json:"rows"`
}{
Rows : []interface{}{},
}
nfts := []*common.NftDto{}
f5.GetGoStyleDb().StreamPageQuery(
constant.BCNFT_DB,
pageSize,
cursor,
sql,
[]string{
accountAddress,
}, },
func (rsp f5.HttpCliResponse) { f5.GetDbFilter().Comp(
c.String(200, rsp.GetRawData()) ),
"",
func (err error, pagination *f5.StreamPagination) {
rspObj.Page.FillPage(pagination)
},
func (ds *f5.DataSet) {
p := new(common.NftDto)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contract_address")
p.TokenId = ds.GetByName("token_id")
q5.AppendSlice(&nfts, p)
}) })
GetCacheMgr().GetNfts(nfts)
{
for _, val := range nfts {
q5.AppendSlice(&rspObj.Rows, val.NftCache.GetJsonData())
}
}
c.JSON(200, rspObj)
} }