diff --git a/bin/marketserver/res/recharge@recharge.json b/bin/marketserver/res/recharge@recharge.json index 014a4d3e..8471d911 100644 --- a/bin/marketserver/res/recharge@recharge.json +++ b/bin/marketserver/res/recharge@recharge.json @@ -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" } ] \ No newline at end of file diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index a7f35892..352591b4 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -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) } diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index 8d3ed5a8..c74375c0 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -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{}) { diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index be6b3ad0..b7cb7fcc 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -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 diff --git a/server/marketserver/router/recharge/recharge.go b/server/marketserver/router/recharge/recharge.go index 9f9f53ad..92f14f7b 100644 --- a/server/marketserver/router/recharge/recharge.go +++ b/server/marketserver/router/recharge/recharge.go @@ -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) }