diff --git a/db/model/user_statistics.go b/db/model/user_statistics.go new file mode 100644 index 0000000..730b42b --- /dev/null +++ b/db/model/user_statistics.go @@ -0,0 +1,14 @@ +package model + +type UserStatistics struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + ImportFinTotal string `json:"import_fin_total" xorm:"comment('导入的累计收益') DECIMAL(30,4)"` + FinTotal string `json:"fin_total" xorm:"comment('系统统计的累计收益') DECIMAL(30,4)"` + Uid int `json:"uid" xorm:"default 0 index INT(11)"` + Month string `json:"month" xorm:"default 0.0000 DECIMAL(30,4)"` + LastMonth string `json:"last_month" xorm:"default 0.0000 DECIMAL(30,4)"` + MonthChangeTime int `json:"month_change_time" xorm:"default 0 INT(11)"` + WaitSettle string `json:"wait_settle" xorm:"default 0.0000 DECIMAL(30,4)"` + Today string `json:"today" xorm:"DECIMAL(30,4)"` + Yestday string `json:"yestday" xorm:"DECIMAL(30,4)"` +} diff --git a/hdl/hdl_upgrade.go b/hdl/hdl_upgrade.go index 591d1ec..3c88be3 100644 --- a/hdl/hdl_upgrade.go +++ b/hdl/hdl_upgrade.go @@ -363,21 +363,30 @@ func GetFinishCount(params map[string]string, blockStarChain string, engine *xor var payOrdId int64 switch task.TaskType { case 20: - sum, _ := engine.Where("type=0 and uid=?", uid).Sum(&model.FinUserFlow{}, "amount") - mallSum, _ := engine.Where("uid=? AND type=? and ord_title=?", uid, 1, "订单退款").Sum(&model.FinUserFlow{}, "amount") - deSum2, _ := engine.Where("uid=? AND type=? and ord_type=?", uid, 0, "withdraw").Sum(&model.FinUserFlow{}, "amount") - deSum3, _ := engine.Where("uid=? AND type=? and ord_title like ?", uid, 1, "%扣除%").Sum(&model.FinUserFlow{}, "amount") - dsCheck, _ := db.SysCfgGetOne(engine, "ds_check") - money := sum - deSum2 - deSum3 + mallSum - if dsCheck != nil && dsCheck.Val == "1" { - withdrawingSuccess, _ := engine.Where("uid=? ", uid).In("state", []string{"1", "2"}).Sum(&model.FinWithdrawApply{}, "amount") - sql := `SELECT cast(SUM(LEFT(olr.amount,LENGTH(olr.amount)-2)) as decimal(50,4)) AS amount FROM ord_list_relate olr JOIN ord_list ol ON olr.oid = ol.ord_id WHERE olr.level=0 and olr.uid = " . $uid . " AND ol.state IN (0,1,2,3) and ol.is_transfer=1;` - nativeString, _ := db.QueryNativeString(engine, sql) - money = withdrawingSuccess - for _, v := range nativeString { - money += zhios_condition_statistics_utils.StrToFloat64(v["amount"]) + var money float64 = 0 + shownewFinTotal, _ := db.SysCfgGetOne(engine, "shownew_fin_total") + if shownewFinTotal != nil && shownewFinTotal.Val == "1" { + var userStatistics model.UserStatistics + engine.Where("uid=?", uid).Get(&userStatistics) + money = zhios_condition_statistics_utils.StrToFloat64(userStatistics.ImportFinTotal) + zhios_condition_statistics_utils.StrToFloat64(userStatistics.FinTotal) + } else { + sum, _ := engine.Where("type=0 and uid=?", uid).Sum(&model.FinUserFlow{}, "amount") + mallSum, _ := engine.Where("uid=? AND type=? and ord_title=?", uid, 1, "订单退款").Sum(&model.FinUserFlow{}, "amount") + deSum2, _ := engine.Where("uid=? AND type=? and ord_type=?", uid, 0, "withdraw").Sum(&model.FinUserFlow{}, "amount") + deSum3, _ := engine.Where("uid=? AND type=? and ord_title like ?", uid, 1, "%扣除%").Sum(&model.FinUserFlow{}, "amount") + dsCheck, _ := db.SysCfgGetOne(engine, "ds_check") + money = sum - deSum2 - deSum3 + mallSum + if dsCheck != nil && dsCheck.Val == "1" { + withdrawingSuccess, _ := engine.Where("uid=? ", uid).In("state", []string{"1", "2"}).Sum(&model.FinWithdrawApply{}, "amount") + sql := `SELECT cast(SUM(LEFT(olr.amount,LENGTH(olr.amount)-2)) as decimal(50,4)) AS amount FROM ord_list_relate olr JOIN ord_list ol ON olr.oid = ol.ord_id WHERE olr.level=0 and olr.uid = " . $uid . " AND ol.state IN (0,1,2,3) and ol.is_transfer=1;` + nativeString, _ := db.QueryNativeString(engine, sql) + money = withdrawingSuccess + for _, v := range nativeString { + money += zhios_condition_statistics_utils.StrToFloat64(v["amount"]) + } } } + return zhios_condition_statistics_utils.Float64ToStr(money), hasPay, payOrdId case 22: lvTime := db.GetOneCirclesUserLvTime(engine, uid)