Browse Source

Merge remote-tracking branch 'origin/master'

master
huangjiajun 1 month ago
parent
commit
97dc810148
3 changed files with 18 additions and 3 deletions
  1. +10
    -0
      app/svc/svc_data_center_generate_data.go
  2. +3
    -3
      app/svc/svc_wx_data.go
  3. +5
    -0
      app/utils/rand.go

+ 10
- 0
app/svc/svc_data_center_generate_data.go View File

@@ -186,10 +186,20 @@ func DataCenterGenerateDataDel(c *gin.Context, req md.DataCenterGenerateDataComm
if data.IsGenerateReport == 1 {
return errors.New("记录已应用,不能删除")
}

// 1、删除 generate_wx_ad_data 数据
_, err := db.Db.Where("id=?", req.Id).Delete(&model.GenerateWxAdData{})
if err != nil {
return err
}

// 2、删除 generate_wx_ad_data_with_agent_flow 数据
_, err = db.Db.Where("generate_data_id=?", req.Id).Delete(&model.GenerateWxAdDataWithAgentFlow{})
if err != nil {
return err
}

// 3、修改 original_wx_ad_data 状态值
db.Db.Where("id=?", data.OriginalDataId).Cols("is_apply").Update(&model.OriginalWxAdData{IsApply: 0})
return nil
}


+ 3
- 3
app/svc/svc_wx_data.go View File

@@ -43,8 +43,8 @@ func GenerateWxAdData(req md.GenerateWxAdData) (err error, generateWxAdData mode

// 3、计算媒体、代理收益、平台留存、佣金留存、协议分成、协议总分成
publisherIncome := float64(originalWxAdData.PublisherIncome)
mediaRevenue := publisherIncome * float64(mediumDivisionStrategy.MediaRevenueRate) / 100 // 媒体收益
agentRevenue := publisherIncome * float64(mediumDivisionStrategy.AgentRevenueRate) / 100 // 代理收益
mediaRevenue := utils.RoundToTwoDecimalPlaces(publisherIncome * float64(mediumDivisionStrategy.MediaRevenueRate) / 100) // 媒体收益
agentRevenue := utils.RoundToTwoDecimalPlaces(publisherIncome * float64(mediumDivisionStrategy.AgentRevenueRate) / 100) // 代理收益
platformRetention := publisherIncome * float64(mediumDivisionStrategy.PlatformRetentionRate) / 100 // 平台留存
commissionRetention := publisherIncome * float64(mediumDivisionStrategy.CommissionRetentionRate) / 100 // 佣金留存
agreementSharingTotal := (mediaRevenue + agentRevenue) / ((100 - float64(mediumDivisionStrategy.AgreementSharingRate)) / 100) // 协议总分成(倒推)
@@ -75,7 +75,7 @@ func GenerateWxAdData(req md.GenerateWxAdData) (err error, generateWxAdData mode
ExtraRevenue int `json:"extra_revenue"`
}
for _, v := range *mediumDivisionStrategyWithAgentFlows {
tmpAgentRevenue := agentRevenue * float64(v.AgentRevenueRate) / 100
tmpAgentRevenue := utils.RoundToTwoDecimalPlaces(agentRevenue * float64(v.AgentRevenueRate) / 100)
tmpExtraRevenue := commissionRetention * float64(v.ExtraRevenueRate) / 100
extraRevenue += tmpExtraRevenue
agentRevenueFlows = append(agentRevenueFlows, struct {


+ 5
- 0
app/utils/rand.go View File

@@ -3,6 +3,7 @@ package utils
import (
crand "crypto/rand"
"fmt"
"math"
"math/big"
"math/rand"
"strconv"
@@ -52,3 +53,7 @@ func GenerateUniqueRandomNumbers(n int) string {

return numbersStr
}

func RoundToTwoDecimalPlaces(num float64) float64 {
return math.Round(num*100) / 100
}

Loading…
Cancel
Save