Ver código fonte

add reverse:for v1.0.5 任务条件

tags/v1.0.5
huangjiajun 2 anos atrás
pai
commit
191a298c1c
2 arquivos alterados com 26 adições e 32 exclusões
  1. +7
    -13
      db/db_order.go
  2. +19
    -19
      hdl/hdl_condition.go

+ 7
- 13
db/db_order.go Ver arquivo

@@ -14,14 +14,11 @@ func OrderListCountByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, state,
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).Count(&model.OrdList{})
fmt.Println(err)
total, _ := Db.Where("uid = ? AND create_at > ? AND create_at < ? and settle_at=0", uid, stime, etime).In("state", state).Count(&model.OrdList{})
total1, _ := Db.Where("uid = ? AND create_at > ? AND create_at < ? and settle_at>0", uid, stime, etime).Count(&model.OrdList{})
fmt.Println(total)

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

// 查询用户某时间段内某状态的佣金(ord_id => amount)
@@ -46,7 +43,7 @@ func OrderRelateListByTimeByState(Db *xorm.Engine, uid, state, startTime, endTim
fmt.Println("============test佣金数=================")
fmt.Println(str)
// 已结算的订单数据
err = Db.In("ord_id", ids).Where("state in (?) AND create_at > ? AND create_at < ?", state, startTime, endTime).Find(&o)
err = Db.In("ord_id", ids).In("state", state).Where(" create_at > ? AND create_at < ?", startTime, endTime).Find(&o)
if err != nil {
zhios_condition_statistics_logx.Error(err)
return nil, err
@@ -74,12 +71,9 @@ func OrderListPaidPriceByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, sta
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)
total, _ := Db.Where("uid = ? AND create_at > ? AND create_at < ? and settle_at=0", uid, stime, etime).In("state", state).Sum(&model.OrdList{}, "paid_price")
total1, _ := Db.Where("uid = ? AND create_at > ? AND create_at < ? and settle_at>0", uid, stime, etime).Sum(&model.OrdList{}, "paid_price")
fmt.Println(total)

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

+ 19
- 19
hdl/hdl_condition.go Ver arquivo

@@ -13,15 +13,15 @@ import (
// 累计自购数
func OwnBuyTotal(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Unix()
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.OrderListCountByUIDByOrderTypeByTime(engine, uid, 0, "1,2,3,5", stime, etime)
total, err := db.OrderListCountByUIDByOrderTypeByTime(engine, uid, 0, []string{"1", "2", "3", "5"}, stime, etime)
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return ""
}
mallStime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location())
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
//确认收货的才算
mallTotal, err := db.MallOrdByTimeWithCount(engine, uid, 0, "3", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
@@ -36,10 +36,10 @@ func OwnBuyTotal(engine *xorm.Engine, uid interface{}, task map[string]string, t
// 累计已结算佣金
func SettleOrderSum(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Unix()
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()
// 用户分佣的订单
idAmountMap, err := db.OrderRelateListByTimeByState(engine, uid, "1,2,3,5", stime, etime)
idAmountMap, err := db.OrderRelateListByTimeByState(engine, uid, []string{"1", "2", "3", "5"}, stime, etime)
if err != nil {
zhios_condition_statistics_logx.Warn(err)
return ""
@@ -48,7 +48,7 @@ func SettleOrderSum(engine *xorm.Engine, uid interface{}, task map[string]string
for _, item := range *idAmountMap {
sum += item
}
mallStime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location())
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
_, mallSum, err := db.MallOrderRelateListByTimeByState(engine, uid, 3, mallStime, mallEtime)
if err != nil {
@@ -62,8 +62,8 @@ func SettleOrderSum(engine *xorm.Engine, uid interface{}, task map[string]string
func ExtendCount(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

// 累计直推人数
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
etime := t.Format("2006-01-02 15:04:05")
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
etime := t.Format("2006-1-02 15:04:05")
sqlTpl := `SELECT count(*) as count
FROM user_profile as up
LEFT JOIN user as u ON u.uid=up.uid
@@ -84,8 +84,8 @@ func ExtendCount(engine *xorm.Engine, uid interface{}, task map[string]string, t
func TeamCount(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

// 累计团队有效直推人数
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
etime := t.Format("2006-01-02 15:04:05")
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
etime := t.Format("2006-1-02 15:04:05")
sqlTpl := `SELECT count(*) as count
FROM user_profile as up
LEFT JOIN user as u ON u.uid=up.uid
@@ -108,8 +108,8 @@ func TeamCount(engine *xorm.Engine, uid interface{}, task map[string]string, t t

func TeamByLvCount(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
etime := t.Format("2006-01-02 15:04:05")
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
etime := t.Format("2006-1-02 15:04:05")
sqlTpl := `SELECT count(*) as count
FROM user_relate as ur
LEFT JOIN user as u ON u.uid=ur.uid
@@ -132,8 +132,8 @@ func TeamByLvCount(engine *xorm.Engine, uid interface{}, task map[string]string,

func ExtendByLvCount(engine *xorm.Engine, uid interface{}, task map[string]string, t time.Time) string {

stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), 0, 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
etime := t.Format("2006-01-02 15:04:05")
stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
etime := t.Format("2006-1-02 15:04:05")

sqlTpl := `SELECT count(*) as count
FROM user_relate as ur
@@ -159,16 +159,16 @@ func OwnbuySum(engine *xorm.Engine, uid interface{}, task map[string]string, t t
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"]), 0, 0, 0, 0, t.Location()).Unix()
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, "1,2,3,5", stime, etime)
total, err = db.OrderListPaidPriceByUIDByOrderTypeByTime(engine, uid, 0, []string{"1", "2", "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"]), 0, 0, 0, 0, t.Location())
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"}) {
@@ -183,7 +183,7 @@ func OwnbuySum(engine *xorm.Engine, uid interface{}, task map[string]string, t t
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"]), 0, 0, 0, 0, t.Location())
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"))
@@ -200,7 +200,7 @@ func OwnbuySum(engine *xorm.Engine, uid interface{}, task map[string]string, t t
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"]), 0, 0, 0, 0, t.Location())
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"))


Carregando…
Cancelar
Salvar