|
|
@@ -0,0 +1,55 @@ |
|
|
|
package svc |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/cfg" |
|
|
|
"applet/app/db" |
|
|
|
"applet/app/md" |
|
|
|
"crypto/tls" |
|
|
|
"encoding/json" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func SaveCapitalPoolOrderByCommApi(eg *xorm.Engine, masterId string, req *md.InsertCapitalPoolOrdBelongData) { |
|
|
|
ms, err := db.CapitalPoolByIsUse(eg) |
|
|
|
if ms == nil || err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
host := cfg.AppComm.URL + "/api/v1/comm/CapitalPool/addBonusOrd" |
|
|
|
tr := &http.Transport{ |
|
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
|
|
|
} |
|
|
|
client := &http.Client{ |
|
|
|
Timeout: 15 * time.Second, |
|
|
|
Transport: tr, |
|
|
|
} |
|
|
|
byte1, _ := json.Marshal(req) |
|
|
|
req1, _ := http.NewRequest("POST", host, strings.NewReader(string(byte1))) |
|
|
|
req1.Header.Set("master_id", masterId) |
|
|
|
req1.Header.Set("Content-Type", "application/json") |
|
|
|
resp, err := (client).Do(req1) |
|
|
|
if err != nil || resp == nil { |
|
|
|
return |
|
|
|
} |
|
|
|
defer resp.Body.Close() |
|
|
|
respByte, _ := ioutil.ReadAll(resp.Body) |
|
|
|
|
|
|
|
if len(respByte) == 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
var serverResp map[string]interface{} |
|
|
|
err = json.Unmarshal(respByte, &serverResp) |
|
|
|
if err != nil || serverResp == nil { |
|
|
|
return |
|
|
|
} |
|
|
|
if serverResp["data"] == nil { |
|
|
|
if serverResp["msg"] != "" { |
|
|
|
return |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
return |
|
|
|
} |