From 6918740400257fcf8d02f47a9bdd580bc2a2d4fe Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 11 May 2023 11:55:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/db_mall_order.go | 7 ++- db/model/user_level_upgrade_task.go | 1 + hdl/hdl_upgrade.go | 76 +++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/db/db_mall_order.go b/db/db_mall_order.go index 702f3b0..a391477 100644 --- a/db/db_mall_order.go +++ b/db/db_mall_order.go @@ -65,7 +65,12 @@ func MallOrderRelateListByTimeByState(Db *xorm.Engine, uid, state, startTime, en } func MallOrdByTime(Db *xorm.Engine, uid, buyType, state, stime, etime interface{}) (float64, error) { - sess := Db.Where("uid = ? AND state in (?) AND confirm_time > ? AND confirm_time < ?", uid, state, stime, etime) + sess := Db.Where("uid = ? AND state in (?) ", uid, state) + if state == "1,2,3" { + sess = sess.And(" create_time > ? AND create_time < ?", uid, state, stime, etime) + } else { + sess = sess.And(" confirm_time > ? AND confirm_time < ?", uid, state, stime, etime) + } if zhios_condition_statistics_utils.AnyToInt64(buyType) > 0 { sess.And("order_type", buyType) } diff --git a/db/model/user_level_upgrade_task.go b/db/model/user_level_upgrade_task.go index 71afdbe..ad8cbe9 100644 --- a/db/model/user_level_upgrade_task.go +++ b/db/model/user_level_upgrade_task.go @@ -10,6 +10,7 @@ type UserLevelUpgradeTask struct { SchemeId int `json:"scheme_id" xorm:"not null default 0 comment('区域代理方案id') INT(11)"` IsMustTask int `json:"is_must_task" xorm:"not null default 0 comment('是否必做(0,1)') TINYINT(1)"` TaskTypePvd int `json:"task_type_pvd" xorm:"not null default 0 comment('task_type=15时生效,表示店铺渠道 0 o2o+b2c 1 o2o 3b2c') INT(10)"` + OrdState int `json:"ord_state" xorm:"not null default 0 comment('task_type=15时生效,表示店铺渠道 0 o2o+b2c 1 o2o 3b2c') INT(10)"` TaskTypeCount int `json:"task_type_count" xorm:"not null default 0 comment('task_type=15时生效,表示店铺的数量') INT(10)"` TaskTypeSecondCount int `json:"task_type_second_count" xorm:"not null default 0 comment('task_type=17时生效,表示每条链的数量') INT(10)"` TaskType int `json:"task_type" xorm:"not null default 0 comment('1:累计自购订单总数,2:累计到账佣金,3:累计直推粉丝数量,4:累计团队有效直推人数,5:累计团队符合相应等级的人数,6:付费任务') TINYINT(2)"` diff --git a/hdl/hdl_upgrade.go b/hdl/hdl_upgrade.go index ceee72f..68af4a8 100644 --- a/hdl/hdl_upgrade.go +++ b/hdl/hdl_upgrade.go @@ -386,7 +386,14 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, var err error if task.WithinDays <= 0 { if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) { - total, err = db.OrderListPaidPriceByUIDByOrderType(engine, uid, 0, []string{"3", "5"}) + state := []string{"3", "5"} + if task.OrdState == 1 { //已付款 + state = []string{"0", "1", "2", "3", "5"} + } + if task.OrdState == 2 { //已完成 + state = []string{"1", "2", "3", "5"} + } + total, err = db.OrderListPaidPriceByUIDByOrderType(engine, uid, 0, state) if err != nil { return "", hasPay, payOrdId } @@ -396,29 +403,50 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) { orderType = task.TaskTypePvd } + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - mallTotal, err := db.MallOrd(engine, uid, orderType, []string{"3"}) + mallTotal, err := db.MallOrd(engine, uid, orderType, state) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } total += mallTotal } if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "3"}) { + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - o2oTotal, err := db.O2oOrd(engine, uid, 0, []string{"3"}) + o2oTotal, err := db.O2oOrd(engine, uid, 0, state) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } total += o2oTotal - o2oTotal1, err := db.O2oOrdPayToMerchant(engine, uid, 0, []string{"1", "4"}) + o2oTotal1, err := db.O2oOrdPayToMerchant(engine, uid, 0, "1,4") if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } total += o2oTotal1 } if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "4"}) { + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - b2cTotal, err := db.B2cOrd(engine, uid, 0, []string{"3"}) + b2cTotal, err := db.B2cOrd(engine, uid, 0, state) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } @@ -428,7 +456,14 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) { stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Unix() etime := t.Unix() - total, err = db.OrderListPaidPriceByUIDByOrderTypeByTime(engine, uid, 0, []string{"3", "5"}, stime, etime) + state := []string{"3", "5"} + if task.OrdState == 1 { //已付款 + state = []string{"0", "1", "2", "3", "5"} + } + if task.OrdState == 2 { //已完成 + state = []string{"1", "2", "3", "5"} + } + total, err = db.OrderListPaidPriceByUIDByOrderTypeByTime(engine, uid, 0, state, stime, etime) if err != nil { return "", hasPay, payOrdId } @@ -440,8 +475,15 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) { orderType = task.TaskTypePvd } + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - mallTotal, err := db.MallOrdByTime(engine, uid, orderType, []string{"3"}, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) + mallTotal, err := db.MallOrdByTime(engine, uid, orderType, state, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } @@ -450,13 +492,20 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "3"}) { mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()) mallEtime := t + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - o2oTotal, err := db.O2oOrdByTime(engine, uid, 0, []string{"3"}, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) + o2oTotal, err := db.O2oOrdByTime(engine, uid, 0, state, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } total += o2oTotal - o2oTotal1, err := db.O2oOrdPayToMerchantByTime(engine, uid, 0, []string{"1", "4"}, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) + o2oTotal1, err := db.O2oOrdPayToMerchantByTime(engine, uid, 0, "1,4", mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId } @@ -465,8 +514,15 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "4"}) { mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()) mallEtime := t + state := "3" + if task.OrdState == 1 { //已付款 + state = "1,2,3" + } + if task.OrdState == 2 { //已完成 + state = "3" + } //确认收货的才算 - b2cTotal, err := db.B2cOrdByTime(engine, uid, 0, []string{"3"}, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) + b2cTotal, err := db.B2cOrdByTime(engine, uid, 0, state, mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05")) if err != nil { return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId }