From 9b7c89307ea9e8f7a75b7cfa768e2ae8d63750a1 Mon Sep 17 00:00:00 2001 From: yangduo Date: Fri, 2 Aug 2024 16:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketserver/api/v1/recharge/recharge.go | 73 ++++++------------- 1 file changed, 23 insertions(+), 50 deletions(-) diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index c71e56e5..0ac4673d 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -46,7 +46,7 @@ func (this *RechargeApi) Buy(c *gin.Context) { passportAddress := c.MustGet("account_address").(string) reqJson := struct { NetId int32 `json:"net_id"` - GoodsId int32 `json:"goods_id"` + GoodsId int32 `json:"goods_id"` AccountAddress string `json:"account_address"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { @@ -89,14 +89,14 @@ func (this *RechargeApi) Buy(c *gin.Context) { } price := "1" params := map[string]string{ - "c": "BcService", - "a": "recharge", - "net_id": q5.ToString(reqJson.NetId), - "order_id": orderId, - "account_address": reqJson.AccountAddress, + "c": "BcService", + "a": "recharge", + "net_id": q5.ToString(reqJson.NetId), + "order_id": orderId, + "account_address": reqJson.AccountAddress, "passport_address": passportAddress, - "amount": price, - "currency_name": currencyMeta.GetName(), + "amount": price, + "currency_name": currencyMeta.GetName(), "currency_address": currencyMeta.GetAddress(), } jsonRspObj := &struct { @@ -145,17 +145,10 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) { reqJson := struct { PageSize interface{} `json:"page_size"` Cursor interface{} `json:"cursor"` - Search struct { - Name string `json:"name"` - } `json:"search"` - Filter struct { - ItemIds []interface{} `json:"item_ids"` - } `json:"filter"` - Sort struct { - Fields []struct { - Name string `json:"name"` - Type interface{} `json:"type"` - } `json:"fields"` + Search struct{} `json:"search"` + Filter struct{} `json:"filter"` + Sort struct { + Fields []struct{} `json:"fields"` } `json:"sort"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { @@ -169,38 +162,18 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) { pageSize := q5.AdjustRangeValue(q5.SafeToInt32(reqJson.PageSize), 1, 20) cursor := q5.SafeToInt64(reqJson.Cursor) + /* sql := fmt.Sprintf(` + SELECT * FROM t_recharge_order + WHERE idx > %d AND net_id = %d AND passport_address = ?`, + cursor, netId) */ sql := fmt.Sprintf(` - SELECT * FROM t_recharge - WHERE idx > %d AND net_id = %d AND buyer = ?`, - cursor, netId) + SELECT * FROM t_recharge_order + WHERE idx > %d AND passport_address = ?`, + cursor) params := []string{account} subFilters := []f5.DbQueryFilter{} - { - itemIds := map[int32]int32{} - if reqJson.Search.Name != "" { - mt.Table.Item.Search(reqJson.Search.Name, itemIds) - } - for _, val := range reqJson.Filter.ItemIds { - itemId := q5.SafeToInt32(val) - itemIds[itemId] = 1 - } - 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()) - } - } orderBy := " ORDER BY createtime DESC " rspObj := struct { @@ -219,7 +192,7 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) { q5.NewSlice(&rspObj.Rows, 0, 10) f5.GetGoStyleDb().StreamPageQuery( - constant.BCEVENT_DB, + constant.BCNFT_DB, pageSize, cursor, sql, @@ -233,10 +206,10 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) { p := q5.NewSliceElement(&rspObj.Rows) p.TxHash = ds.GetByName("txhash") - p.NetID = q5.SafeToInt64(ds.GetByName("net_id")) + p.NetID = netId //q5.SafeToInt64(ds.GetByName("net_id")) p.OrderID = ds.GetByName("order_id") - p.Currency = ds.GetByName("currency") - p.Amount = ds.GetByName("amount") + p.Currency = ds.GetByName("currency_name") + p.Amount = ds.GetByName("item_num") p.Date = q5.SafeToInt32(ds.GetByName("createtime")) }) c.JSON(200, rspObj)