|
|
@@ -1,7 +1,11 @@ |
|
|
|
package svc |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/task/md" |
|
|
|
"applet/app/utils" |
|
|
|
"applet/app/utils/logx" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"fmt" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
@@ -14,4 +18,58 @@ func DealPlatformRevenueData(eg *xorm.Engine, dbName string) { |
|
|
|
} |
|
|
|
}() |
|
|
|
|
|
|
|
revenueDataDb := implement.NewPlatformRevenueDataDb(eg) |
|
|
|
revenueDataList, err := revenueDataDb.PlatformRevenueDataFindNotFinish() |
|
|
|
if err != nil { |
|
|
|
_ = logx.Error(err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
revenueDatas := make([]md.RevenueDataNode, len(revenueDataList)) |
|
|
|
for i, data := range revenueDataList { |
|
|
|
// 总执行次数 按十分钟更新 |
|
|
|
times := data.Hours * 60 / md.ExecutionInterval |
|
|
|
// 每次更新金额 |
|
|
|
amount := utils.AnyToFloat64(data.TotalAmount) / utils.AnyToFloat64(times) |
|
|
|
tempData := md.RevenueDataNode{ |
|
|
|
Data: model.PlatformRevenueData{ |
|
|
|
Id: data.Id, |
|
|
|
Kind: data.Kind, |
|
|
|
TotalAmount: data.TotalAmount, |
|
|
|
BalanceAmount: data.BalanceAmount, |
|
|
|
Hours: data.Hours, |
|
|
|
BalanceTimes: data.BalanceTimes, |
|
|
|
Memo: data.Memo, |
|
|
|
CreateAt: data.CreateAt, |
|
|
|
UpdateAt: data.UpdateAt, |
|
|
|
}, |
|
|
|
EveryAmount: utils.AnyToString(amount), |
|
|
|
} |
|
|
|
revenueDatas[i] = tempData |
|
|
|
} |
|
|
|
|
|
|
|
// 修改当前数据 |
|
|
|
for _, data := range revenueDatas { |
|
|
|
// 变更后余额 |
|
|
|
balanceAmount := utils.AnyToFloat64(data.Data.BalanceAmount) - utils.AnyToFloat64(data.EveryAmount) |
|
|
|
m := model.PlatformRevenueData{ |
|
|
|
Id: data.Data.Id, |
|
|
|
Kind: data.Data.Kind, |
|
|
|
TotalAmount: data.Data.TotalAmount, |
|
|
|
BalanceAmount: utils.AnyToString(balanceAmount), |
|
|
|
Hours: data.Data.Hours, |
|
|
|
BalanceTimes: data.Data.BalanceTimes - 1, |
|
|
|
Memo: data.Data.Memo, |
|
|
|
CreateAt: data.Data.CreateAt, |
|
|
|
UpdateAt: data.Data.UpdateAt, |
|
|
|
} |
|
|
|
forceColumns := []string{ |
|
|
|
"balance_times", |
|
|
|
} |
|
|
|
_, err := revenueDataDb.PlatformRevenueDataUpdate(m, forceColumns...) |
|
|
|
if err != nil { |
|
|
|
_ = logx.Error(err) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |