1
This commit is contained in:
parent
778351dccc
commit
2bc0efc771
@ -18,6 +18,11 @@ type AssetApi struct {
|
|||||||
*/
|
*/
|
||||||
func (this *AssetApi) AccountAsset(c *gin.Context) {
|
func (this *AssetApi) AccountAsset(c *gin.Context) {
|
||||||
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
|
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
|
||||||
|
if pageSize < 0 {
|
||||||
|
pageSize = 1
|
||||||
|
} else if pageSize > 100 {
|
||||||
|
pageSize = 100
|
||||||
|
}
|
||||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||||
netId := q5.ToInt64(c.Param("net_id"))
|
netId := q5.ToInt64(c.Param("net_id"))
|
||||||
accountAddress := strings.ToLower(c.Param("account_address"))
|
accountAddress := strings.ToLower(c.Param("account_address"))
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package market
|
package market
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"q5"
|
||||||
"f5"
|
"f5"
|
||||||
"mt"
|
"mt"
|
||||||
|
"main/constant"
|
||||||
|
"fmt"
|
||||||
|
//"strings"
|
||||||
|
"net/http"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,20 +16,136 @@ type MarketApi struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *MarketApi) ProductList(c *gin.Context) {
|
func (this *MarketApi) ProductList(c *gin.Context) {
|
||||||
netId := c.Param("netId")
|
netId := q5.ToInt64(c.Param("net_id"))
|
||||||
tokenId := c.Param("tokenId")
|
reqJson := struct {
|
||||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
PageSize interface{} `json:"page_size"`
|
||||||
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
|
Cursor interface{} `json:"cursor"`
|
||||||
map[string]string{
|
Search struct {
|
||||||
"c": "OutAppNft",
|
Name string `json:"name"`
|
||||||
"a": "nftMetaView",
|
} `json:"cursor"`
|
||||||
"nft_type": "hero",
|
Filter struct {
|
||||||
"net_id": netId,
|
PriceMin interface{} `json:"price_min"`
|
||||||
"token_id": tokenId,
|
PriceMax interface{} `json:"price_max"`
|
||||||
},
|
ItemIds []int32 `json:"item_ids"`
|
||||||
func (rsp f5.HttpCliResponse) {
|
HeroRanks []int32 `json:"hero_ranks"`
|
||||||
c.String(200, rsp.GetRawData())
|
} `json:"filter"`
|
||||||
|
Sort struct {
|
||||||
|
Fields [] struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type interface{} `json:"type"`
|
||||||
|
} `json:"fields"`
|
||||||
|
} `json:"sort"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"code": 1,
|
||||||
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pageSize := q5.SafeToInt32(reqJson.PageSize)
|
||||||
|
if pageSize < 0 {
|
||||||
|
pageSize = 1
|
||||||
|
} else if pageSize > 20 {
|
||||||
|
pageSize = 20
|
||||||
|
}
|
||||||
|
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||||
|
sql := fmt.Sprintf(`
|
||||||
|
SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s"
|
||||||
|
`,
|
||||||
|
cursor, netId, constant.ORDER_STATUS_ACTIVE, pageSize + 1)
|
||||||
|
|
||||||
|
orderBy := ""
|
||||||
|
{
|
||||||
|
for _, val := range reqJson.Sort.Fields {
|
||||||
|
if val.Name == "price" && orderBy == "" {
|
||||||
|
t := q5.SafeToInt32(val.Type)
|
||||||
|
if t < 0 {
|
||||||
|
orderBy = " ORDER BY LENGTH(price) DESC, price DESC"
|
||||||
|
} else {
|
||||||
|
orderBy = " ORDER BY LENGTH(price) ASC, price ASC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subFilters := []f5.DbQueryFilter{}
|
||||||
|
{
|
||||||
|
priceMin := q5.SafeToString(reqJson.Filter.PriceMin)
|
||||||
|
priceMax := q5.SafeToString(reqJson.Filter.PriceMax)
|
||||||
|
if !q5.IsPureNumber(priceMin) {
|
||||||
|
priceMin = ""
|
||||||
|
}
|
||||||
|
if !q5.IsPureNumber(priceMax) {
|
||||||
|
priceMax = ""
|
||||||
|
}
|
||||||
|
if priceMin != "" && priceMax != "" {
|
||||||
|
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(
|
||||||
|
fmt.Sprintf(`LENGTH(price) >= LENGTH('%s') AND price >= '%s' AND
|
||||||
|
LENGTH(price) <= LENGTH('%s') AND price <= '%s'`,
|
||||||
|
priceMin,
|
||||||
|
priceMin,
|
||||||
|
priceMax,
|
||||||
|
priceMax)).And())
|
||||||
|
} else if priceMin != "" {
|
||||||
|
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(
|
||||||
|
fmt.Sprintf(`LENGTH(price) >= LENGTH('%s') AND price >= '%s'`,
|
||||||
|
priceMin,
|
||||||
|
priceMin)).And())
|
||||||
|
} else if priceMax != "" {
|
||||||
|
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(
|
||||||
|
fmt.Sprintf(`LENGTH(price) <= LENGTH('%s') AND price <= '%s'`,
|
||||||
|
priceMax,
|
||||||
|
priceMax)).And())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
itemIds := map[int32]int32{}
|
||||||
|
if len(itemIds) > 0 {
|
||||||
|
inSub := `item_id IN (`
|
||||||
|
i := 0
|
||||||
|
for key, _ := range(itemIds) {
|
||||||
|
if i == 0 {
|
||||||
|
inSub += q5.ToString(key)
|
||||||
|
} else {
|
||||||
|
inSub += "," + q5.ToString(key)
|
||||||
|
}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
inSub += ")"
|
||||||
|
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(inSub).And())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nfts := []struct{
|
||||||
|
idx int64
|
||||||
|
netId int32
|
||||||
|
tokenType int32
|
||||||
|
tokenId string
|
||||||
|
contractAddress string
|
||||||
|
}{}
|
||||||
|
f5.GetGoStyleDb().StreamPageQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
pageSize,
|
||||||
|
cursor,
|
||||||
|
sql,
|
||||||
|
[]string{
|
||||||
|
},
|
||||||
|
f5.GetDbFilter().Comp(subFilters...),
|
||||||
|
orderBy,
|
||||||
|
func (err error, pagination *f5.StreamPagination) {
|
||||||
|
|
||||||
|
},
|
||||||
|
func (ds *f5.DataSet) {
|
||||||
|
var p = q5.NewSliceElement(&nfts)
|
||||||
|
p.idx = q5.ToInt64(ds.GetByName("idx"))
|
||||||
|
p.netId = q5.ToInt32(ds.GetByName("net_id"))
|
||||||
|
p.tokenType = q5.ToInt32(ds.GetByName("token_type"))
|
||||||
|
p.tokenId = ds.GetByName("token_id")
|
||||||
|
p.contractAddress = ds.GetByName("contract_address")
|
||||||
|
f5.GetSysLog().Info("idx:%s", p.idx)
|
||||||
|
})
|
||||||
|
f5.GetSysLog().Info("dafdf")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MarketApi) TransactionHistory(c *gin.Context) {
|
func (this *MarketApi) TransactionHistory(c *gin.Context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user