forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package consumer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"stat/common/log"
|
||||
"stat/common/utils"
|
||||
"stat/models/rechargechannelmod"
|
||||
"stat/models/rechargemod"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func RechargeChannelHandle(ctx context.Context, rechageInfo *rechargemod.RechargeMod) error {
|
||||
sumDate := utils.BeginWithTime(rechageInfo.SuccessAt)
|
||||
rate := float64(4)
|
||||
if rechageInfo.Rate != "" && rechageInfo.ChannelName != "daichong" {
|
||||
rateF, err := strconv.ParseFloat(rechageInfo.Rate, 64)
|
||||
if err != nil {
|
||||
log.Error("RechargeChannelHandle rate is err", log.Any("rate", rechageInfo.Rate), log.Any("userid", rechageInfo.UserId), log.Any("appid", rechageInfo.AppId))
|
||||
return err
|
||||
}
|
||||
rate = rateF
|
||||
} else if rechageInfo.ChannelName == "daichong" {
|
||||
rate = float64(8)
|
||||
rechageInfo.CID = "daichong"
|
||||
}
|
||||
channelMoney := int64((rate * float64(rechageInfo.PayMoney)) / 100)
|
||||
err := rechargechannelmod.UpsertOneUserRechargeStat(ctx, rechageInfo.CID, rechageInfo.AppId, sumDate, rechageInfo.BlocDeduction, rechageInfo.Money, rechageInfo.PayMoney, channelMoney)
|
||||
if err != nil {
|
||||
log.Error("RechargeChannelHandle UpsertOneUserRechargeStat", log.Any("rate", rechageInfo.Rate), log.Any("userid", rechageInfo.UserId), log.Any("appid", rechageInfo.AppId), log.E(err))
|
||||
}
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user