1
This commit is contained in:
parent
45db73ab04
commit
ae6d441dc3
@ -6,6 +6,7 @@ import (
|
||||
"jccommon"
|
||||
"main/common"
|
||||
"main/constant"
|
||||
"main/service"
|
||||
|
||||
"mt"
|
||||
"net/http"
|
||||
@ -41,6 +42,8 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
accountId := c.MustGet("open_id").(string)
|
||||
passportAddress := c.MustGet("account_address").(string)
|
||||
reqJson := struct {
|
||||
NetId int32 `json:"net_id"`
|
||||
GoodsId int32 `json:"goods_id"`
|
||||
@ -53,6 +56,11 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
})
|
||||
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))
|
||||
if goodsMeta == nil {
|
||||
f5.RspErr(c, 2, "goods id param error")
|
||||
@ -79,11 +87,17 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
price := "1"
|
||||
params := map[string]string{
|
||||
"c": "BcService",
|
||||
"a": "recharge",
|
||||
"net_id": q5.ToString(reqJson.NetId),
|
||||
"order_id": orderId,
|
||||
"account_address": reqJson.AccountAddress,
|
||||
"passport_address": passportAddress,
|
||||
"amount": price,
|
||||
"currency_name": currencyMeta.GetName(),
|
||||
"currency_address": currencyMeta.GetAddress(),
|
||||
}
|
||||
jsonRspObj := &struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
@ -103,6 +117,24 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
f5.RspErr(c, 500, "server internal error")
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
@ -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