This commit is contained in:
aozhiwei 2024-08-29 16:00:01 +08:00
parent 2293b64a96
commit 43bd0ac3dd

View File

@ -101,9 +101,13 @@ func (this *RechargeApi) BuyWithEmail(c *gin.Context) {
CurrencyAddress string `json:"currency_address"`
}{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
f5.GetSysLog().Info("BuyWithEmail passport_address:%s err:%s",
passportAddress, err)
f5.RspErr(c, 1, err.Error())
return
}
f5.GetSysLog().Info("BuyWithEmail passport_address:%s email:%s reqJson:%s",
passportAddress, email, q5.EncodeJson(&reqJson))
if email == "" {
f5.RspErr(c, 1, "email is empty")
return
@ -119,28 +123,34 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
passportAddress = strings.ToLower(passportAddress)
currencyMeta := mt.Table.Currency.GetByNetIdAddress(netId, currencyAddress)
if currencyMeta == nil {
f5.GetSysLog().Info("internalBuy error:1")
f5.RspErr(c, 2, "server internal error")
return
}
currencyContractMeta := currencyMeta.GetContract()
if currencyContractMeta == nil {
f5.GetSysLog().Info("internalBuy error:2")
f5.RspErr(c, 2, "server internal error")
return
}
goodsMeta := mt.Table.Recharge.GetById(q5.ToInt64(goodsId))
if goodsMeta == nil {
f5.GetSysLog().Info("internalBuy error:3")
f5.RspErr(c, 2, "goods id param error")
return
}
if goodsMeta.GetPrice() <= 0 {
f5.GetSysLog().Info("internalBuy error:4")
f5.RspErr(c, 2, "goods id param error")
return
}
if goodsNum <= 0 || goodsNum > goodsMeta.GetMaxBuyTimes() {
f5.GetSysLog().Info("internalBuy error:5")
f5.RspErr(c, 2, "num param error")
return
}
if email != "" && goodsMeta.GetCanEmailBuy() == 0 {
f5.GetSysLog().Info("internalBuy error:6")
f5.RspErr(c, 2, "cant email buy")
return
}
@ -161,6 +171,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
var err error
orderId, err = transId.ToString()
if err != nil {
f5.GetSysLog().Info("internalBuy error:6")
f5.RspErr(c, 2, "server internal error")
return
}
@ -175,13 +186,16 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
f5.GetSysLog().Info("recharge net_id:%d currency_name:%s decimal:%d srcPrice:%d bnPrice:%s",
netId, currencyMeta.GetCurrencyName(), currencyMeta.GetCurrencyDecimal(), srcPrice, bnPrice.String());
if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(srcPrice)) < 0 {
f5.GetSysLog().Info("internalBuy error:7")
f5.RspErr(c, 3, "server internal error")
return
}
if ok, err := service.User.InBlackList(accountAddress); err != nil {
f5.GetSysLog().Info("internalBuy error:8")
f5.RspErr(c, 500, "server internal error")
return
} else if ok {
f5.GetSysLog().Info("internalBuy error:9")
f5.RspErr(c, 501, "illegal user")
return
}
@ -210,10 +224,12 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
params,
func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil {
f5.GetSysLog().Info("internalBuy error:a")
f5.RspErr(c, 500, "server internal error")
return
}
if q5.DecodeJson(rsp.GetRawData(), &jsonRspObj) != nil {
f5.GetSysLog().Info("internalBuy error:b")
f5.RspErr(c, 500, "server internal error")
return
}
@ -236,6 +252,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
diamond,
presentDiamond,
email) {
f5.GetSysLog().Info("internalBuy error:c")
f5.RspErr(c, 500, "server internal error")
return
}