Browse Source

update

master
dengbiao 2 days ago
parent
commit
bee33f9548
3 changed files with 61 additions and 58 deletions
  1. +53
    -50
      consume/egg_energy_auto_score_consume.go
  2. +2
    -2
      consume/init.go
  3. +6
    -6
      k8s/zyos-go-mq-consume-prd.yaml

+ 53
- 50
consume/egg_energy_auto_score_consume.go View File

@@ -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)


+ 2
- 2
consume/init.go View File

@@ -30,8 +30,8 @@ func initConsumes() {
jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈
jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 提现

jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
jobs[consumeMd.EggEnergyTemporaryDealUserECPMFunName] = TemporaryEggEnergyDealUserECPMConsume // 临时处理给用户Ecpm值
jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
//jobs[consumeMd.EggEnergyTemporaryDealUserECPMFunName] = TemporaryEggEnergyDealUserECPMConsume // 临时处理给用户Ecpm值
jobs[consumeMd.EggCanalInviteUserNumsFunName] = EggCanalInviteUserNumsConsume // 处理拉新人数
jobs[consumeMd.EggCanalViolateNumsFunName] = EggCanalViolateNumsConsume // 处理违规次数
jobs[consumeMd.IMEggEnergySendRedPackageFunName] = IMEggEnergySendRedPackageConsume // 处理用户发送红包次数


+ 6
- 6
k8s/zyos-go-mq-consume-prd.yaml View File

@@ -2,10 +2,10 @@ kind: Deployment
apiVersion: apps/v1
# 元数据
metadata:
name: egg-go-mq-consume
name: egg-gim-mq-consume-v1
namespace: egg
labels:
app: egg-go-mq-consume
app: egg-gim-mq-consume-v1
annotations:
kubesphere.io/creator: dengbiao
# deployment主要部分
@@ -14,12 +14,12 @@ spec:
selector:
matchLabels:
# 名称与上面的labels对应
app: egg-go-mq-consume
app: egg-gim-mq-consume-v1
template:
metadata:
labels:
# 名称与上面的matchLabels对应
app: egg-go-mq-consume
app: egg-gim-mq-consume-v1
spec:
# 声明挂载卷(将外部已存在的pvc、config等挂载进来)
volumes:
@@ -36,9 +36,9 @@ spec:
defaultMode: 420
containers:
# 主容器
- name: egg-go-mq-consume
- name: egg-gim-mq-consume-v1
# 镜像地址(提前打包好并推送的镜像仓库)
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/egg-go-mq-consume:0.0.1'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/egg-gim-mq-consume-v1:0.0.1'
# 将前面volume声明的需要用到的pvc、config挂载上来
volumeMounts:
- name: host-time


Loading…
Cancel
Save