This commit is contained in:
yangduo 2024-08-01 14:20:53 +08:00
parent ee7707286f
commit df4f74dedf
5 changed files with 67 additions and 57 deletions

View File

@ -1,50 +1,56 @@
[
{
"recharge_cost_num": 15,
"recharge_cost_num": "15",
"recharge_icon": "itemIcon_diamond01",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 15,
"id": 1001
"recharge_item_num": 15,
"recharge_currency": "test currency",
"id": "1001"
},
{
"recharge_cost_num": 62,
"recharge_cost_num": "62",
"recharge_icon": "itemIcon_diamond02",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 62,
"id": 1002
"recharge_item_num": 62,
"recharge_currency": "test currency",
"id": "1002"
},
{
"recharge_cost_num": 162,
"recharge_cost_num": "162",
"recharge_icon": "itemIcon_diamond03",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 162,
"id": 1003
"recharge_item_num": 162,
"recharge_currency": "test currency",
"id": "1003"
},
{
"recharge_cost_num": 325,
"recharge_cost_num": "325",
"recharge_icon": "itemIcon_diamond04",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 325,
"id": 1004
"recharge_item_num": 325,
"recharge_currency": "test currency",
"id": "1004"
},
{
"recharge_cost_num": 800,
"recharge_cost_num": "800",
"recharge_icon": "itemIcon_diamond05",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 800,
"id": 1005
"recharge_item_num": 800,
"recharge_currency": "test currency",
"id": "1005"
},
{
"recharge_cost_num": 1680,
"recharge_cost_num": "",
"recharge_icon": "itemIcon_diamond06",
"recharge_item": 10014,
"recharge_type": 1,
"recharge_item_num": 1680,
"id": 1006
"recharge_item_num": 0,
"recharge_currency": "test currency",
"id": "1006"
}
]

View File

@ -27,12 +27,10 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
mt.Table.Recharge.RawMetaTable.Traverse(func(tb *mt.Recharge) bool {
tmpmap := map[string]interface{}{}
tmpmap["id"] = tb.GetId()
tmpmap["recharge_cost_num"] = tb.GetRechargeCostNum()
tmpmap["recharge_icon"] = tb.GetRechargeIcon()
tmpmap["recharge_item"] = tb.GetRechargeItem()
tmpmap["recharge_type"] = tb.GetRechargeType()
tmpmap["recharge_item_num"] = tb.GetRechargeItemNum()
tmpmap["goods_id"] = tb.GetId()
tmpmap["diamond"] = tb.GetRechargeItemNum()
tmpmap["currency"] = tb.GetRechargeCurrency()
tmpmap["price"] = tb.GetRechargeCostNum()
rspObj.Rows = append(rspObj.Rows, tmpmap)
@ -44,10 +42,10 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
func (this *RechargeApi) Pay(c *gin.Context) {
reqJson := struct {
NetId int32 `json:"net_id"`
GoodsId string `json:"goods_id"`
NetId int32 `json:"net_id"`
GoodsId string `json:"goods_id"`
AccountAddress string `json:"account_address"`
} {}
}{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
c.JSON(http.StatusOK, gin.H{
"errcode": 1,
@ -57,15 +55,15 @@ func (this *RechargeApi) Pay(c *gin.Context) {
}
orderId := q5.ToString(f5.GetApp().NewLockNodeUuid())
params := map[string]string{
"c" : "BcService",
"a" : "recharge",
"net_id" : q5.ToString(reqJson.NetId),
"order_id" : orderId,
"c": "BcService",
"a": "recharge",
"net_id": q5.ToString(reqJson.NetId),
"order_id": orderId,
}
jsonRspObj := &struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Calls []jccommon.ContractCall `json:"calls"`
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Calls []jccommon.ContractCall `json:"calls"`
}{}
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Web3ServiceCluster.RandElement().GetUrl())
f5.GetHttpCliMgr().SendGoStyleRequest(
@ -80,12 +78,13 @@ func (this *RechargeApi) Pay(c *gin.Context) {
f5.RspErr(c, 500, "server internal error")
return
}
c.JSON(200, jsonRspObj);
c.JSON(200, jsonRspObj)
})
}
func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
account := strings.ToLower(c.Param("account_address"))
netId := q5.ToInt64(c.Param("net_id"))
reqJson := struct {
PageSize interface{} `json:"page_size"`
Cursor interface{} `json:"cursor"`
@ -115,8 +114,8 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
sql := fmt.Sprintf(`
SELECT * FROM t_recharge
WHERE idx > %d AND buyer = ?`,
cursor)
WHERE idx > %d AND net_id = %d AND buyer = ?`,
cursor, netId)
params := []string{account}
subFilters := []f5.DbQueryFilter{}
@ -152,15 +151,12 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []struct {
TxHash string `json:"txhash"`
NetID int64 `json:"net_id"`
ContractAddress string `json:"contact_address"`
Passport string `json:"passport"`
OrderID string `json:"order_id"`
Currency string `json:"currency"`
Amount string `json:"amount"`
Status int32 `json:"status"`
Date int32 `json:"date"`
OrderID string `json:"order_id"`
TxHash string `json:"txhash"`
NetID int64 `json:"net_id"`
Currency string `json:"currency"`
Amount string `json:"amount"`
Date int32 `json:"createtime"`
} `json:"rows"`
}{}
q5.NewSlice(&rspObj.Rows, 0, 10)
@ -181,13 +177,10 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
p.TxHash = ds.GetByName("txhash")
p.NetID = q5.SafeToInt64(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contact_address")
p.Passport = ds.GetByName("passport")
p.OrderID = ds.GetByName("order_id")
p.Currency = ds.GetByName("currency")
p.Amount = ds.GetByName("amount")
p.Status = q5.SafeToInt32(ds.GetByName("status"))
p.Date = q5.SafeToInt32(ds.GetByName("date"))
p.Date = q5.SafeToInt32(ds.GetByName("createtime"))
})
c.JSON(200, rspObj)
}

View File

@ -79,12 +79,13 @@ type Language struct {
}
type Recharge struct {
recharge_cost_num int32
recharge_cost_num string
recharge_icon string
recharge_item int32
recharge_type int32
recharge_item_num int32
id int32
id string
recharge_currency string
_flags1_ uint64
_flags2_ uint64
@ -360,7 +361,7 @@ func (this *Language) HasEn() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Recharge) GetRechargeCostNum() int32 {
func (this *Recharge) GetRechargeCostNum() string {
return this.recharge_cost_num
}
@ -400,7 +401,7 @@ func (this *Recharge) HasRechargeItemNum() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *Recharge) GetId() int32 {
func (this *Recharge) GetId() string {
return this.id
}
@ -408,6 +409,14 @@ func (this *Recharge) HasId() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *Recharge) GetRechargeCurrency() string {
return this.recharge_currency
}
func (this *Recharge) HasRechargeCurrency() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *Web3ServiceCluster) GetUrl() string {
return this.url
}
@ -485,6 +494,7 @@ func (this *Recharge) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.recharge_type, "recharge_type", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.recharge_item_num, "recharge_item_num", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.recharge_currency, "recharge_currency", &this._flags1_, 7, kv)
}
func (this *Web3ServiceCluster) LoadFromKv(kv map[string]interface{}) {

View File

@ -64,12 +64,13 @@ message Language
message Recharge
{
optional int32 recharge_cost_num = 1;
optional string recharge_cost_num = 1;
optional string recharge_icon =2;
optional int32 recharge_item =3;
optional int32 recharge_type =4;
optional int32 recharge_item_num =5;
optional int32 id =6;
optional string id =6;
optional string recharge_currency = 7;
}
message Web3ServiceCluster

View File

@ -9,7 +9,7 @@ type RechargeRouter struct{}
func (er *RechargeRouter) InitRouter() {
api := v1.ApiGroupApp.RechargeApiGroup
f5.GetApp().GetGinEngine().GET("/api/recharge/history/:account_address", api.RechargeApi.RechargeQuery)
f5.GetApp().GetGinEngine().GET("/api/recharge/history/:net_id/:account_address", api.RechargeApi.RechargeQuery)
f5.GetApp().GetGinEngine().GET("/api/recharge/goods", api.RechargeApi.RechargeList)
f5.GetApp().GetGinEngine().GET("/api/recharge/pay", api.RechargeApi.Pay)
}