mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[FIX] fix charge sverify bug
This commit is contained in:
parent
8f017a1a8c
commit
53727e343e
@ -52,7 +52,7 @@ import (
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
// description: 状态码非200,表示验证过程发生错误。状态码200,msg代表实际状态:success, illegal_quantity, missing_tenant, owned_fee, region_unauthorized, lack_of_memory
|
||||
func ChargesVerifyController(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if publicCloud := os.Getenv("PUBLIC_CLOUD"); publicCloud != "true" {
|
||||
@ -69,10 +69,6 @@ func ChargesVerifyController(w http.ResponseWriter, r *http.Request) {
|
||||
tenant.EID = eid
|
||||
db.GetManager().TenantDao().UpdateModel(tenant)
|
||||
}
|
||||
cloudAPI := os.Getenv("CLOUD_API")
|
||||
if cloudAPI == "" {
|
||||
cloudAPI = "http://api.goodrain.com"
|
||||
}
|
||||
quantity := r.FormValue("quantity")
|
||||
if quantity == "" {
|
||||
httputil.ReturnError(r, w, 400, "quantity can not found")
|
||||
|
@ -41,7 +41,7 @@ func ChargeSverify(tenant *model.Tenants, quantity int, reason string) *util.API
|
||||
if regionName == "" {
|
||||
return util.CreateAPIHandleError(500, fmt.Errorf("region name must define in api by env REGION_NAME"))
|
||||
}
|
||||
api := fmt.Sprintf("%s/openapi/v1/enterprises/%s/memory-apply?quantity=%d&tid=%s&reason=%s®ion=%s", cloudAPI, tenant.EID, quantity, tenant.UUID, reason, regionName)
|
||||
api := fmt.Sprintf("%s/openapi/console/v1/enterprises/%s/memory-apply?quantity=%d&tid=%s&reason=%s®ion=%s", cloudAPI, tenant.EID, quantity, tenant.UUID, reason, regionName)
|
||||
req, err := http.NewRequest("GET", api, nil)
|
||||
if err != nil {
|
||||
logrus.Error("create request cloud api error", err.Error())
|
||||
@ -52,9 +52,6 @@ func ChargeSverify(tenant *model.Tenants, quantity int, reason string) *util.API
|
||||
logrus.Error("create request cloud api error", err.Error())
|
||||
return util.CreateAPIHandleError(400, fmt.Errorf("create request cloud api error"))
|
||||
}
|
||||
if res.StatusCode == 200 {
|
||||
return nil
|
||||
}
|
||||
if res.Body != nil {
|
||||
defer res.Body.Close()
|
||||
rebody, _ := ioutil.ReadAll(res.Body)
|
||||
|
Loading…
Reference in New Issue
Block a user