1
This commit is contained in:
parent
4710749f3a
commit
63a087da8d
@ -49,18 +49,25 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
// reqJson := struct {
|
||||
// NetId int32 `json:"net_id"`
|
||||
// GoodsId int32 `json:"goods_id"`
|
||||
// Num int32 `json:"goods_num"`
|
||||
// AccountAddress string `json:"account_address"`
|
||||
// }{}
|
||||
// if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
// f5.RspErr(c, 1, err.Error())
|
||||
// return
|
||||
// }
|
||||
}
|
||||
|
||||
func (this *RechargeApi) BuyWithEmail(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
netId int32, goodsId int32, goodsNum int32, accountAddress string) {
|
||||
passportAddress := c.MustGet("account_address").(string)
|
||||
reqJson := struct {
|
||||
NetId int32 `json:"net_id"`
|
||||
GoodsId int32 `json:"goods_id"`
|
||||
Num int32 `json:"goods_num"`
|
||||
AccountAddress string `json:"account_address"`
|
||||
}{}
|
||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
f5.RspErr(c, 1, err.Error())
|
||||
return
|
||||
}
|
||||
currencyMeta := mt.Table.Currency.Get(reqJson.NetId)
|
||||
currencyMeta := mt.Table.Currency.Get(netId)
|
||||
if currencyMeta == nil {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
@ -75,12 +82,12 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
}
|
||||
currencyContractMeta := mt.Table.Contract.GetByNetIdName(reqJson.NetId, currencyMeta.GetCurrencyName())
|
||||
currencyContractMeta := mt.Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName())
|
||||
if currencyContractMeta == 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(goodsId))
|
||||
if goodsMeta == nil {
|
||||
f5.RspErr(c, 2, "goods id param error")
|
||||
return
|
||||
@ -89,7 +96,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
f5.RspErr(c, 2, "goods id param error")
|
||||
return
|
||||
}
|
||||
if reqJson.Num <= 0 || reqJson.Num > goodsMeta.GetMaxBuyTimes() {
|
||||
if goodsNum <= 0 || goodsNum > goodsMeta.GetMaxBuyTimes() {
|
||||
f5.RspErr(c, 2, "num param error")
|
||||
return
|
||||
}
|
||||
@ -103,7 +110,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
nowTime,
|
||||
0,
|
||||
[3]int64{
|
||||
q5.ToInt64(reqJson.Num),
|
||||
q5.ToInt64(goodsNum),
|
||||
q5.ToInt64(goodsMeta.GetId()),
|
||||
shortOrderId,
|
||||
})
|
||||
@ -115,7 +122,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * q5.ToInt64(goodsMeta.GetPrice()) *
|
||||
q5.ToInt64(reqJson.Num)
|
||||
q5.ToInt64(goodsNum)
|
||||
if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) {
|
||||
f5.RspErr(c, 3, "server internal error")
|
||||
return
|
||||
@ -123,9 +130,9 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
params := map[string]string{
|
||||
"c": "BcService",
|
||||
"a": "recharge",
|
||||
"net_id": q5.ToString(reqJson.NetId),
|
||||
"net_id": q5.ToString(netId),
|
||||
"order_id": orderId,
|
||||
"account_address": reqJson.AccountAddress,
|
||||
"account_address": accountAddress,
|
||||
"passport_address": passportAddress,
|
||||
"amount": q5.ToString(price),
|
||||
"currency_name": currencyContractMeta.GetName(),
|
||||
@ -136,7 +143,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Calls []jccommon.ContractCall `json:"calls"`
|
||||
}{}
|
||||
var itemNum int32 = reqJson.Num
|
||||
var itemNum int32 = goodsNum
|
||||
var diamond int64 = q5.ToInt64(goodsMeta.GetDiamond()) * int64(itemNum)
|
||||
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Web3SignCluster.RandElement().GetUrl())
|
||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
||||
@ -158,8 +165,8 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
if !service.AddRechargeOrder(
|
||||
orderId,
|
||||
q5.ToString(shortOrderId),
|
||||
reqJson.NetId,
|
||||
reqJson.AccountAddress,
|
||||
netId,
|
||||
accountAddress,
|
||||
passportAddress,
|
||||
currencyContractMeta.GetName(),
|
||||
currencyContractMeta.GetAddress(),
|
||||
@ -174,9 +181,6 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func (this *RechargeApi) BuyWithEmail(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
||||
account := strings.ToLower(c.Param("account_address"))
|
||||
netId := q5.ToInt64(c.Param("net_id"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user