调整
This commit is contained in:
parent
32a0445b1f
commit
9b7c89307e
@ -46,7 +46,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
|||||||
passportAddress := c.MustGet("account_address").(string)
|
passportAddress := c.MustGet("account_address").(string)
|
||||||
reqJson := struct {
|
reqJson := struct {
|
||||||
NetId int32 `json:"net_id"`
|
NetId int32 `json:"net_id"`
|
||||||
GoodsId int32 `json:"goods_id"`
|
GoodsId int32 `json:"goods_id"`
|
||||||
AccountAddress string `json:"account_address"`
|
AccountAddress string `json:"account_address"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||||
@ -89,14 +89,14 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
price := "1"
|
price := "1"
|
||||||
params := map[string]string{
|
params := map[string]string{
|
||||||
"c": "BcService",
|
"c": "BcService",
|
||||||
"a": "recharge",
|
"a": "recharge",
|
||||||
"net_id": q5.ToString(reqJson.NetId),
|
"net_id": q5.ToString(reqJson.NetId),
|
||||||
"order_id": orderId,
|
"order_id": orderId,
|
||||||
"account_address": reqJson.AccountAddress,
|
"account_address": reqJson.AccountAddress,
|
||||||
"passport_address": passportAddress,
|
"passport_address": passportAddress,
|
||||||
"amount": price,
|
"amount": price,
|
||||||
"currency_name": currencyMeta.GetName(),
|
"currency_name": currencyMeta.GetName(),
|
||||||
"currency_address": currencyMeta.GetAddress(),
|
"currency_address": currencyMeta.GetAddress(),
|
||||||
}
|
}
|
||||||
jsonRspObj := &struct {
|
jsonRspObj := &struct {
|
||||||
@ -145,17 +145,10 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
|||||||
reqJson := struct {
|
reqJson := struct {
|
||||||
PageSize interface{} `json:"page_size"`
|
PageSize interface{} `json:"page_size"`
|
||||||
Cursor interface{} `json:"cursor"`
|
Cursor interface{} `json:"cursor"`
|
||||||
Search struct {
|
Search struct{} `json:"search"`
|
||||||
Name string `json:"name"`
|
Filter struct{} `json:"filter"`
|
||||||
} `json:"search"`
|
Sort struct {
|
||||||
Filter struct {
|
Fields []struct{} `json:"fields"`
|
||||||
ItemIds []interface{} `json:"item_ids"`
|
|
||||||
} `json:"filter"`
|
|
||||||
Sort struct {
|
|
||||||
Fields []struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Type interface{} `json:"type"`
|
|
||||||
} `json:"fields"`
|
|
||||||
} `json:"sort"`
|
} `json:"sort"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
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)
|
pageSize := q5.AdjustRangeValue(q5.SafeToInt32(reqJson.PageSize), 1, 20)
|
||||||
cursor := q5.SafeToInt64(reqJson.Cursor)
|
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(`
|
sql := fmt.Sprintf(`
|
||||||
SELECT * FROM t_recharge
|
SELECT * FROM t_recharge_order
|
||||||
WHERE idx > %d AND net_id = %d AND buyer = ?`,
|
WHERE idx > %d AND passport_address = ?`,
|
||||||
cursor, netId)
|
cursor)
|
||||||
|
|
||||||
params := []string{account}
|
params := []string{account}
|
||||||
subFilters := []f5.DbQueryFilter{}
|
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 "
|
orderBy := " ORDER BY createtime DESC "
|
||||||
|
|
||||||
rspObj := struct {
|
rspObj := struct {
|
||||||
@ -219,7 +192,7 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
|||||||
q5.NewSlice(&rspObj.Rows, 0, 10)
|
q5.NewSlice(&rspObj.Rows, 0, 10)
|
||||||
|
|
||||||
f5.GetGoStyleDb().StreamPageQuery(
|
f5.GetGoStyleDb().StreamPageQuery(
|
||||||
constant.BCEVENT_DB,
|
constant.BCNFT_DB,
|
||||||
pageSize,
|
pageSize,
|
||||||
cursor,
|
cursor,
|
||||||
sql,
|
sql,
|
||||||
@ -233,10 +206,10 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
|||||||
p := q5.NewSliceElement(&rspObj.Rows)
|
p := q5.NewSliceElement(&rspObj.Rows)
|
||||||
|
|
||||||
p.TxHash = ds.GetByName("txhash")
|
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.OrderID = ds.GetByName("order_id")
|
||||||
p.Currency = ds.GetByName("currency")
|
p.Currency = ds.GetByName("currency_name")
|
||||||
p.Amount = ds.GetByName("amount")
|
p.Amount = ds.GetByName("item_num")
|
||||||
p.Date = q5.SafeToInt32(ds.GetByName("createtime"))
|
p.Date = q5.SafeToInt32(ds.GetByName("createtime"))
|
||||||
})
|
})
|
||||||
c.JSON(200, rspObj)
|
c.JSON(200, rspObj)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user