Bladeren bron

add reverse:for v1.0.1 条件统计

tags/v1.0.1
huangjiajun 2 jaren geleden
bovenliggende
commit
52bdee83cc
5 gewijzigde bestanden met toevoegingen van 137 en 0 verwijderingen
  1. +18
    -0
      db/db_b2c_ord.go
  2. +15
    -0
      db/db_mall_order.go
  3. +27
    -0
      db/db_o2o_ord.go
  4. +17
    -0
      db/db_order.go
  5. +60
    -0
      hdl/hdl_condition.go

+ 18
- 0
db/db_b2c_ord.go Bestand weergeven

@@ -0,0 +1,18 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model"
zhios_condition_statistics_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/utils/logx"
"fmt"
"xorm.io/xorm"
)

func B2cOrdByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) {
total, err := Db.Where("uid = ? AND state in (?) AND create_time > ? AND create_time < ?", uid, state, stime, etime).Sum(&model.B2cOrd{}, "cost_price")
fmt.Println(err)
fmt.Println(total)
if err != nil {
return 0, zhios_condition_statistics_logx.Error(err)
}
return total, nil
}

+ 15
- 0
db/db_mall_order.go Bestand weergeven

@@ -2,6 +2,7 @@ package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model"
zhios_condition_statistics_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/utils"
zhios_condition_statistics_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/utils/logx"
"fmt"
"xorm.io/xorm"
@@ -62,3 +63,17 @@ func MallOrderRelateListByTimeByState(Db *xorm.Engine, uid, state, startTime, en
}
return &idAmountMap, sum, nil
}

func MallOrdByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) {
sess := Db.Where("uid = ? AND state in (?) AND create_time > ? AND create_time < ?", uid, state, stime, etime)
if zhios_condition_statistics_utils.AnyToInt64(buyType) > 0 {
sess.And("order_type", buyType)
}
total, err := sess.Sum(&model.MallOrd{}, "cost_price")
fmt.Println(err)
fmt.Println(total)
if err != nil {
return 0, zhios_condition_statistics_logx.Error(err)
}
return total, nil
}

+ 27
- 0
db/db_o2o_ord.go Bestand weergeven

@@ -0,0 +1,27 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model"
zhios_condition_statistics_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/utils/logx"
"fmt"
"xorm.io/xorm"
)

func O2oOrdByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) {
total, err := Db.Where("uid = ? AND state in (?) AND create_time > ? AND create_time < ?", uid, state, stime, etime).Sum(&model.O2oOrd{}, "cost_price")
fmt.Println(err)
fmt.Println(total)
if err != nil {
return 0, zhios_condition_statistics_logx.Error(err)
}
return total, nil
}
func O2oOrdPayToMerchantByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) {
total, err := Db.Where("uid = ? AND state in (?) AND create_time > ? AND create_time < ?", uid, state, stime, etime).Sum(&model.O2oPayToMerchant{}, "actual_pay_amount")
fmt.Println(err)
fmt.Println(total)
if err != nil {
return 0, zhios_condition_statistics_logx.Error(err)
}
return total, nil
}

+ 17
- 0
db/db_order.go Bestand weergeven

@@ -66,3 +66,20 @@ func OrderRelateListByTimeByState(Db *xorm.Engine, uid, state, startTime, endTim

return &idAmountMap, nil
}

// OrderListPaidPriceByUIDByOrderTypeByTime is 查询订单 by uid by time ,获取规定时间内的订单类型的订单消费金额
func OrderListPaidPriceByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) {

str := fmt.Sprintf("uid = %s AND order_type = %s AND ( state in (%s) or settle_at>0) AND create_at > %s AND create_at < %s",
zhios_condition_statistics_utils.AnyToString(uid), buyType, state, stime, etime)
fmt.Println("============test订单数=================")
fmt.Println(str)
total, err := Db.Where("uid = ? AND order_type = ? AND ( state in (?) or settle_at>0) AND create_at > ? AND create_at < ?", uid, buyType, state, stime, etime).Sum(&model.OrdList{}, "paid_price")
fmt.Println(err)
fmt.Println(total)

if err != nil {
return 0, zhios_condition_statistics_logx.Error(err)
}
return total, nil
}

+ 60
- 0
hdl/hdl_condition.go Bestand weergeven

@@ -153,6 +153,66 @@ func ExtendByLvCount(engine *xorm.Engine, uid interface{}, task map[string]strin
return count
}

// 累计自购消费金额

func OwnbuySum(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {
var total float64 = 0
var err error
if zhios_condition_statistics_utils.InArr(task["task_type_pvd"], []string{"0", "1"}) {
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Unix()
etime := t.Unix()
total, err = db.OrderListPaidPriceByUIDByOrderTypeByTime(engine, uid, 0, "3,5", stime, etime)
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return ""
}
}
if zhios_condition_statistics_utils.InArr(task["task_type_pvd"], []string{"0", "2", "8", "9"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
orderType := 0
if zhios_condition_statistics_utils.InArr(task["task_type_pvd"], []string{"8", "9"}) {
orderType = zhios_condition_statistics_utils.StrToInt(task["task_type_pvd"])
}
//确认收货的才算
mallTotal, err := db.MallOrdByTime(engine, uid, orderType, "3", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return zhios_condition_statistics_utils.Float64ToStr(total)
}
total += mallTotal
}
if zhios_condition_statistics_utils.InArr(task["task_type_pvd"], []string{"0", "3"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
//确认收货的才算
o2oTotal, err := db.O2oOrdByTime(engine, uid, 0, "3", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return zhios_condition_statistics_utils.Float64ToStr(total)
}
total += o2oTotal
o2oTotal1, err := db.O2oOrdPayToMerchantByTime(engine, uid, 0, "1", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return zhios_condition_statistics_utils.Float64ToStr(total)
}
total += o2oTotal1
}
if zhios_condition_statistics_utils.InArr(task["task_type_pvd"], []string{"0", "4"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
//确认收货的才算
b2cTotal, err := db.B2cOrdByTime(engine, uid, 0, "3", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return zhios_condition_statistics_utils.Float64ToStr(total)
}
total += b2cTotal
}
return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2))
}

//累计团队消费金额
func TeamBuySum(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {



Laden…
Annuleren
Opslaan