[FIX] fix charge sverify bug

This commit is contained in:
qingguo 2018-03-27 11:39:48 +08:00
parent 8f017a1a8c
commit 53727e343e
2 changed files with 2 additions and 9 deletions

View File

@ -52,7 +52,7 @@ import (
// default:
// schema:
// "$ref": "#/responses/commandResponse"
// description: 统一返回格式
// description: 状态码非200表示验证过程发生错误。状态码200msg代表实际状态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")

View File

@ -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&region=%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&region=%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)