|
|
@@ -66,62 +66,65 @@ func handleEggEnergyAutoScoreDataConsume(msgData []byte) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 请求获取预测分数 |
|
|
|
req := md.GetPredictReq{ |
|
|
|
Ecpm: msg.Ecpm, |
|
|
|
InviteUserNums: msg.InviteUserNums, |
|
|
|
TeamActivityNums: msg.TeamActivityNums, |
|
|
|
SignInNums: msg.SignInNums, |
|
|
|
ImActivityNums: msg.ImActivityNums, |
|
|
|
SendRedPackageNums: msg.SendRedPackageNums, |
|
|
|
EggEnergyExchangeAccountBalance: msg.EggEnergyExchangeAccountBalance, |
|
|
|
AccountBalanceExchangeEggEnergyNums: msg.AccountBalanceExchangeEggEnergyNums, |
|
|
|
SendCircleOfFriendNums: msg.SendCircleOfFriendNums, |
|
|
|
ForumCommentsNums: msg.ForumCommentsNums, |
|
|
|
CollegeLearningNums: msg.CollegeLearningNums, |
|
|
|
ViolateNums: msg.ViolateNums, |
|
|
|
BrowseInterfaceNums: msg.BrowseInterfaceNums, |
|
|
|
PersonAddActivityValue: msg.PersonAddActivityValue, |
|
|
|
} |
|
|
|
|
|
|
|
reqBytes, err := json.Marshal(req) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedMarshal_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
url := "http://ddf.ddstaros.cn/predict" |
|
|
|
|
|
|
|
request, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(reqBytes)) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedNewRequest_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
request.Header.Set("Content-Type", "application/json") |
|
|
|
client := &http.Client{Timeout: 5 * time.Second} // 设置请求超时时长5s |
|
|
|
resp, err := client.Do(request) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedPostRequest_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
defer resp.Body.Close() |
|
|
|
var scoreValue float64 |
|
|
|
if msg.Ecpm == 0 && msg.SignInNums == 0 { |
|
|
|
scoreValue = 60 |
|
|
|
} else { |
|
|
|
// 2. 请求获取预测分数 |
|
|
|
req := md.GetPredictReq{ |
|
|
|
Ecpm: msg.Ecpm, |
|
|
|
InviteUserNums: msg.InviteUserNums, |
|
|
|
TeamActivityNums: msg.TeamActivityNums, |
|
|
|
SignInNums: msg.SignInNums, |
|
|
|
ImActivityNums: msg.ImActivityNums, |
|
|
|
SendRedPackageNums: msg.SendRedPackageNums, |
|
|
|
EggEnergyExchangeAccountBalance: msg.EggEnergyExchangeAccountBalance, |
|
|
|
AccountBalanceExchangeEggEnergyNums: msg.AccountBalanceExchangeEggEnergyNums, |
|
|
|
SendCircleOfFriendNums: msg.SendCircleOfFriendNums, |
|
|
|
ForumCommentsNums: msg.ForumCommentsNums, |
|
|
|
CollegeLearningNums: msg.CollegeLearningNums, |
|
|
|
ViolateNums: msg.ViolateNums, |
|
|
|
BrowseInterfaceNums: msg.BrowseInterfaceNums, |
|
|
|
PersonAddActivityValue: msg.PersonAddActivityValue, |
|
|
|
} |
|
|
|
reqBytes, err := json.Marshal(req) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedMarshal_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
url := "http://ddf.ddstaros.cn/predict" |
|
|
|
request, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(reqBytes)) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedNewRequest_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
request.Header.Set("Content-Type", "application/json") |
|
|
|
client := &http.Client{Timeout: 5 * time.Second} // 设置请求超时时长5s |
|
|
|
resp, err := client.Do(request) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedPostRequest_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
defer resp.Body.Close() |
|
|
|
|
|
|
|
respBody, err := ioutil.ReadAll(resp.Body) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedIOReadAll_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
respBody, err := ioutil.ReadAll(resp.Body) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedIOReadAll_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
var score md.GetPredictResp |
|
|
|
err = json.Unmarshal(respBody, &score) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedUnmarshal_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
var score md.GetPredictResp |
|
|
|
err = json.Unmarshal(respBody, &score) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("EggEnergyAutoScoreConsumeFailedUnmarshal_ERR:::::", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
scoreValue = score.PredictedScore |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 更新上周得分 |
|
|
|
updateMap := make(map[string]interface{}) |
|
|
|
updateMap["score_value"] = score.PredictedScore |
|
|
|
updateMap["score_value"] = scoreValue |
|
|
|
updateMap["score_value_kind"] = 2 |
|
|
|
now := time.Now() |
|
|
|
lastWeek := now.AddDate(0, 0, -7) |
|
|
|