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/global"
"fmt"
//"strings"
"strings"
"net/http"
"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) {
netId := c.Param("netId")
tokenId := c.Param("tokenId")
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
map[string]string{
"c": "OutAppNft",
"a": "nftMetaView",
"nft_type": "gold_bullion",
"net_id": netId,
"token_id": tokenId,
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
if pageSize < 0 {
pageSize = 1
} else if pageSize > 100 {
pageSize = 100
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
netId := q5.ToInt64(c.Param("net_id"))
accountAddress := strings.ToLower(c.Param("account_address"))
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) {
c.String(200, rsp.GetRawData())
f5.GetDbFilter().Comp(
),
"",
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)
}