huangjiajun před 6 měsíci
rodič
revize
a15bc382bb
5 změnil soubory, kde provedl 49 přidání a 10 odebrání
  1. +11
    -3
      db/db_order_count.go
  2. +11
    -4
      db/db_order_sum.go
  3. +1
    -1
      go.mod
  4. +4
    -0
      go.sum
  5. +22
    -2
      hdl/hdl_upgrade.go

+ 11
- 3
db/db_order_count.go Zobrazit soubor

@@ -9,7 +9,7 @@ import (
)

// OrderListCountByUIDByOrderTypeByTime is 查询订单 by uid by time ,获取规定时间内的订单类型的订单数
func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, task *model.UserLevelUpgradeTask) (int64, error) {
func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, types string, task *model.UserLevelUpgradeTask) (int64, error) {

state := []string{"1", "2", "3", "5"}
timeType := "confirm_at"
@@ -32,6 +32,10 @@ func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, t
sess1 := Db.Where("uid = ? and settle_at>0", uid)
sess2 := Db.Where("uid = ?", uid)
sess4 := Db.Where("uid = ?", uid)
if types == "free" {
sess.And("price_type>0 or second_price_type>0 or third_price_type>0")
sess1.And("price_type>0 or second_price_type>0 or third_price_type>0")
}
if task.WithinDays > 0 {
sqlStr := fmt.Sprintf(" %s > %d AND %s < %d", timeType, stime.Unix(), timeType, etime.Unix())
sess = sess.And(sqlStr)
@@ -55,8 +59,12 @@ func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, t
}
}
total1, _ := sess1.Count(&model.OrdList{})
total2, _ := sess2.Where("state=?", uid, 1).Count(&model.PrivilegeCardOrd{})
total4, _ := sess4.Where("status=?", uid, "已付款").Count(&model.RechargeOrder{})
var total2 int64
var total4 int64
if types != "free" {
total2, _ = sess2.Where("state=?", uid, 1).Count(&model.PrivilegeCardOrd{})
total4, _ = sess4.Where("status=?", uid, "已付款").Count(&model.RechargeOrder{})
}

fmt.Println(total)



+ 11
- 4
db/db_order_sum.go Zobrazit soubor

@@ -10,7 +10,7 @@ import (
)

// OrderListCountByUIDByOrderTypeByTime is 查询订单 by uid by time ,获取规定时间内的订单类型的订单数
func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, task *model.UserLevelUpgradeTask) (float64, error) {
func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, types string, task *model.UserLevelUpgradeTask) (float64, error) {
state := []string{"1", "2", "3", "5"}
timeType := "confirm_at"
if task.OrdState == 1 { //已付款
@@ -32,6 +32,10 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, tas
sess1 := Db.Where("uid = ? and settle_at>0", uid)
sess2 := Db.Where("uid = ?", uid)
sess4 := Db.Where("uid = ?", uid)
if types == "free" {
sess.And("price_type>0 or second_price_type>0 or third_price_type>0")
sess1.And("price_type>0 or second_price_type>0 or third_price_type>0")
}
if task.WithinDays > 0 {
sqlStr := fmt.Sprintf(" %s > %d AND %s < %d", timeType, stime.Unix(), timeType, etime.Unix())
sqlStr2 := fmt.Sprintf(" %s > %d AND %s < %d", timeType2, stime.Unix(), timeType2, etime.Unix())
@@ -51,9 +55,12 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, tas
total += total3
}
total1, _ := sess1.Sum(&model.OrdList{}, "paid_price")
total2, _ := sess2.Where("state=?", uid, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price")
total4, _ := sess4.Where("status=?", uid, "已付款").Sum(&model.RechargeOrder{}, "amount")

var total2 float64
var total4 float64
if types != "free" {
total2, _ = sess2.Where("state=?", uid, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price")
total4, _ = sess4.Where("status=?", uid, "已付款").Sum(&model.RechargeOrder{}, "amount")
}
fmt.Println(total)

return total + total1 + total2 + total4, nil


+ 1
- 1
go.mod Zobrazit soubor

@@ -3,7 +3,7 @@ module code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git
go 1.15

require (
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240118152737-08e0d2709655 // indirect
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240118152737-08e0d2709655
github.com/syyongx/php2go v0.9.6
go.uber.org/zap v1.13.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0


+ 4
- 0
go.sum Zobrazit soubor

@@ -73,6 +73,7 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
@@ -99,6 +100,7 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -192,6 +194,7 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
@@ -324,6 +327,7 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=


+ 22
- 2
hdl/hdl_upgrade.go Zobrazit soubor

@@ -397,9 +397,29 @@ func GetFinishCount(params map[string]string, blockStarChain string, engine *xor
days = 0
}
return zhios_condition_statistics_utils.IntToStr(days), hasPay, payOrdId
case 23:
// 累计新人免单自购数
total, err := db.OrderListCountByUIDByOrderTypeByTimeNew(engine, uid, "free", task)
if err != nil {
return "", hasPay, payOrdId
}
return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
case 24:
// 累计自购消费金额

var total float64 = 0
var err error
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) {
total, err = db.OrderListSumByUIDByOrderTypeByTimeNew(engine, uid, "free", task)
if err != nil {
return "", hasPay, payOrdId
}
}
return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2)), hasPay, payOrdId

case 1:
// 累计自购数
total, err := db.OrderListCountByUIDByOrderTypeByTimeNew(engine, uid, task)
total, err := db.OrderListCountByUIDByOrderTypeByTimeNew(engine, uid, "", task)
if err != nil {
return "", hasPay, payOrdId
}
@@ -425,7 +445,7 @@ func GetFinishCount(params map[string]string, blockStarChain string, engine *xor
var total float64 = 0
var err error
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) {
total, err = db.OrderListSumByUIDByOrderTypeByTimeNew(engine, uid, task)
total, err = db.OrderListSumByUIDByOrderTypeByTimeNew(engine, uid, "", task)
if err != nil {
return "", hasPay, payOrdId
}


Načítá se…
Zrušit
Uložit