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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ type RechargeRouter struct{}
func (er *RechargeRouter) InitRouter() { func (er *RechargeRouter) InitRouter() {
api := v1.ApiGroupApp.RechargeApiGroup 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/goods", api.RechargeApi.RechargeList)
f5.GetApp().GetGinEngine().GET("/api/recharge/pay", api.RechargeApi.Pay) f5.GetApp().GetGinEngine().GET("/api/recharge/pay", api.RechargeApi.Pay)
} }