1
This commit is contained in:
parent
45db73ab04
commit
ae6d441dc3
@ -6,6 +6,7 @@ import (
|
|||||||
"jccommon"
|
"jccommon"
|
||||||
"main/common"
|
"main/common"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"main/service"
|
||||||
|
|
||||||
"mt"
|
"mt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -41,6 +42,8 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *RechargeApi) Buy(c *gin.Context) {
|
func (this *RechargeApi) Buy(c *gin.Context) {
|
||||||
|
accountId := c.MustGet("open_id").(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"`
|
||||||
@ -53,6 +56,11 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
currencyMeta := mt.Table.Contract.GetByNetIdName(reqJson.NetId, "TestToken")
|
||||||
|
if currencyMeta == nil {
|
||||||
|
f5.RspErr(c, 2, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
goodsMeta := mt.Table.Recharge.GetById(q5.ToInt64(reqJson.GoodsId))
|
goodsMeta := mt.Table.Recharge.GetById(q5.ToInt64(reqJson.GoodsId))
|
||||||
if goodsMeta == nil {
|
if goodsMeta == nil {
|
||||||
f5.RspErr(c, 2, "goods id param error")
|
f5.RspErr(c, 2, "goods id param error")
|
||||||
@ -79,11 +87,17 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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,
|
||||||
|
"passport_address": passportAddress,
|
||||||
|
"amount": price,
|
||||||
|
"currency_name": currencyMeta.GetName(),
|
||||||
|
"currency_address": currencyMeta.GetAddress(),
|
||||||
}
|
}
|
||||||
jsonRspObj := &struct {
|
jsonRspObj := &struct {
|
||||||
ErrCode int32 `json:"errcode"`
|
ErrCode int32 `json:"errcode"`
|
||||||
@ -103,6 +117,24 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
|||||||
f5.RspErr(c, 500, "server internal error")
|
f5.RspErr(c, 500, "server internal error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if jsonRspObj.ErrCode != 0 {
|
||||||
|
c.JSON(200, jsonRspObj)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !service.AddRechargeOrder(
|
||||||
|
accountId,
|
||||||
|
orderId,
|
||||||
|
q5.ToString(shortOrderId),
|
||||||
|
reqJson.AccountAddress,
|
||||||
|
passportAddress,
|
||||||
|
currencyMeta.GetName(),
|
||||||
|
currencyMeta.GetAddress(),
|
||||||
|
goodsMeta.GetId(),
|
||||||
|
1,
|
||||||
|
price) {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
c.JSON(200, jsonRspObj)
|
c.JSON(200, jsonRspObj)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"q5"
|
|
||||||
"f5"
|
|
||||||
"main/constant"
|
|
||||||
)
|
|
||||||
|
|
||||||
type inbox struct {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var Inbox = new(inbox)
|
|
||||||
|
|
||||||
func (this *inbox) Mark(accountId string, mailId int64, nowTime int64, expireTime int32) error {
|
|
||||||
var result error
|
|
||||||
f5.GetGoStyleDb().Upsert(
|
|
||||||
constant.MAIL_DB,
|
|
||||||
"t_inbox",
|
|
||||||
[][]string{
|
|
||||||
{"account_id", accountId},
|
|
||||||
{"mail_id", q5.ToString(mailId)},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"state", q5.ToString(constant.INBOX_STATE_READ)},
|
|
||||||
{"expiretime", q5.ToString(expireTime)},
|
|
||||||
{"modifytime", q5.ToString(nowTime)},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"account_id", accountId},
|
|
||||||
{"mail_id", q5.ToString(mailId)},
|
|
||||||
{"state", q5.ToString(constant.INBOX_STATE_READ)},
|
|
||||||
{"expiretime", q5.ToString(expireTime)},
|
|
||||||
{"createtime", q5.ToString(nowTime)},
|
|
||||||
{"modifytime", q5.ToString(nowTime)},
|
|
||||||
},
|
|
||||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
|
||||||
result = err
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *inbox) Delete(accountId string, mailId int64, nowTime int64, expireTime int32) error {
|
|
||||||
var result error
|
|
||||||
f5.GetGoStyleDb().Upsert(
|
|
||||||
constant.MAIL_DB,
|
|
||||||
"t_inbox",
|
|
||||||
[][]string{
|
|
||||||
{"account_id", accountId},
|
|
||||||
{"mail_id", q5.ToString(mailId)},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
|
|
||||||
{"expiretime", q5.ToString(expireTime)},
|
|
||||||
{"modifytime", q5.ToString(nowTime)},
|
|
||||||
},
|
|
||||||
[][]string{
|
|
||||||
{"account_id", accountId},
|
|
||||||
{"mail_id", q5.ToString(mailId)},
|
|
||||||
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
|
|
||||||
{"expiretime", q5.ToString(expireTime)},
|
|
||||||
{"createtime", q5.ToString(nowTime)},
|
|
||||||
{"modifytime", q5.ToString(nowTime)},
|
|
||||||
},
|
|
||||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
|
||||||
result = err
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
}
|
|
30
server/marketserver/service/recharge.go
Normal file
30
server/marketserver/service/recharge.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AddRechargeOrder(accountId string, orderId string, shortOrderId string,
|
||||||
|
accountAddress string, passportAddress string,
|
||||||
|
currencyAddress string, currencyName string, itemId int32, itemNum int64,
|
||||||
|
price string) bool {
|
||||||
|
ok := false
|
||||||
|
f5.GetGoStyleDb().UpsertEx(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
"t_recharge_order",
|
||||||
|
[][]string{
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
ok = err == nil
|
||||||
|
},
|
||||||
|
func (ds* f5.DataSet) bool {
|
||||||
|
ok = false
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
return ok
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user