@@ -347,70 +347,128 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
// 累计自购数
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.OrderListCountByUIDByOrderTypeByTime(engine, uid, 0, "3,5", stime, etime)
if err != nil {
return "", hasPay, payOrdId
}
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, 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"))
if err != nil {
return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
}
total += mallTotal
return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
case 10:
// 累计自购消费金额
var total float64 = 0
var total int64
var err error
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)
//联盟结算后的
if task.WithinDays <= 0 {
total, err = db.OrderListCountByUIDByOrderType(engine, uid, 0, "3,5")
if err != nil {
return "", hasPay, payOrdId
}
}
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "2", "8", "9"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
orderType := 0
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) {
orderType = task.TaskTypePvd
}
//确认收货的才算
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.MallOrdWithCount(engine, uid, 0, "3")
if err != nil {
return zhios_condition_statistics_utils.Floa t64ToStr(total), hasPay, payOrdId
return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
}
total += mallTotal
}
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
//确认收货的才算
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"))
} else {
total, err = db.OrderListCountByUIDByOrderTypeByTime(engine, uid, 0, "3,5", stime, etime)
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(total) , hasPay, payOrdId
return "", 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"))
//确认收货的才算
mallTotal, err := db.MallOrdByTimeWithCount(engine, uid, 0, "3" , mallStime.Format("2006-01-02 15:04:05"), mallEtime.Format("2006-01-02 15:04:05"))
if err != nil {
return zhios_condition_statistics_utils.Floa t64ToStr(total), hasPay, payOrdId
return zhios_condition_statistics_utils.In t64ToStr(total), hasPay, payOrdId
}
total += o2oTotal1
total += mallTotal
}
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
//确认收货的才算
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"))
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
case 10:
// 累计自购消费金额
var total float64 = 0
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"})
if err != nil {
return "", hasPay, payOrdId
}
}
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "2", "8", "9"}) {
orderType := 0
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) {
orderType = task.TaskTypePvd
}
//确认收货的才算
mallTotal, err := db.MallOrd(engine, uid, orderType, []string{"3"})
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"}) {
//确认收货的才算
o2oTotal, err := db.O2oOrd(engine, uid, 0, []string{"3"})
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
}
total += o2oTotal
o2oTotal1, err := db.O2oOrdPayToMerchant(engine, uid, 0, []string{"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"}) {
//确认收货的才算
b2cTotal, err := db.B2cOrd(engine, uid, 0, []string{"3"})
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
}
total += b2cTotal
}
} else {
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)
if err != nil {
return "", hasPay, payOrdId
}
}
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "2", "8", "9"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
orderType := 0
if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) {
orderType = task.TaskTypePvd
}
//确认收货的才算
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"))
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"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
//确认收货的才算
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"))
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"))
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"}) {
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
//确认收货的才算
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"))
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
}
total += b2cTotal
}
total += b2cTotal
}
return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2)), hasPay, payOrdId
@@ -418,22 +476,39 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
// 累计已结算佣金
stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Unix()
etime := t.Unix()
// 用户分佣的订单
idAmountMap, err := db.OrderRelateListByTimeByState(engine, uid, "3,5", stime, etime)
if err != nil {
return "", hasPay, payOrdId
}
var sum float64
for _, item := range *idAmountMap {
sum += item
}
mallStime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
mallEtime := t
_, mallSum, err := db.MallOrderRelateListByTimeByState(engine, uid, 3, mallStime, mallEtime)
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
var sum float64
if task.WithinDays <= 0 {
// 用户分佣的订单
idAmountMap, err := db.OrderRelateListByState(engine, uid, "3,5")
if err != nil {
return "", hasPay, payOrdId
}
for _, item := range *idAmountMap {
sum += item
}
_, mallSum, err := db.MallOrderRelateListByState(engine, uid, 3)
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
}
sum += mallSum
} else {
// 用户分佣的订单
idAmountMap, err := db.OrderRelateListByTimeByState(engine, uid, "3,5", stime, etime)
if err != nil {
return "", hasPay, payOrdId
}
for _, item := range *idAmountMap {
sum += item
}
_, mallSum, err := db.MallOrderRelateListByTimeByState(engine, uid, 3, mallStime, mallEtime)
if err != nil {
return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
}
sum += mallSum
}
sum += mallSum
return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
case 3:
// 累计直推人数
@@ -443,7 +518,12 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
FROM user_profile as up
LEFT JOIN user as u ON u.uid=up.uid
WHERE %s;`
condStr := fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), stime, etime)
var condStr string
if task.WithinDays <= 0 {
condStr = fmt.Sprintf("up.parent_uid=%s ", zhios_condition_statistics_utils.AnyToString(uid))
} else {
condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), stime, etime)
}
sql := fmt.Sprintf(sqlTpl, condStr)
results, err := db.QueryNativeString(engine, sql)
if err != nil {
@@ -462,7 +542,13 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
FROM user_profile as up
LEFT JOIN user as u ON u.uid=up.uid
WHERE %s;`
condStr := fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1)
var condStr string
if task.WithinDays <= 0 {
condStr = fmt.Sprintf("up.parent_uid=%s and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), 1)
} else {
condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1)
}
sql := fmt.Sprintf(sqlTpl, condStr)
results, err := db.QueryNativeString(engine, sql)
if err != nil {
@@ -487,10 +573,17 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
if levelList != nil {
levelWeight = levelList.LevelWeight
}
condStr := fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
var condStr string
if task.WithinDays <= 0 {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight))
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight))
}
} else {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
}
}
sql := fmt.Sprintf(sqlTpl, condStr)
fmt.Println(sql)
@@ -519,10 +612,18 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{},
if levelList != nil {
levelWeight = levelList.LevelWeight
}
condStr := fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
var condStr string
if task.WithinDays <= 0 {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight))
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight))
}
} else {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
if blockStarChain == "1" {
condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
}
}
sql := fmt.Sprintf(sqlTpl, condStr)
fmt.Println(sql)
@@ -687,13 +788,20 @@ WHERE olr.uid = ?
sqlTpl := `select ur.parent_uid,COUNT(*) as count FROM user_relate ur
LEFT JOIN user u on u.uid=ur.uid
LEFT JOIN user_level ul on u.level=ul.id
where ur.parent_uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1 ) and ul.level_weight>=%s and u.level_arrive_at>='%s' and u.level_arrive_at<='%s' GROUP BY ur.parent_uid;`
where ur.parent_uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1 ) and ul.level_weight>=%s %s GROUP BY ur.parent_uid;`
levelList := allLvMap[task.TaskTypeLevelId]
levelWeight := 0
if levelList != nil {
levelWeight = levelList.LevelWeight
}
sql := fmt.Sprintf(sqlTpl, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
sql := ""
if task.WithinDays <= 0 {
sql = fmt.Sprintf(sqlTpl, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "")
} else {
sql = fmt.Sprintf(sqlTpl, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "and u.level_arrive_at>='"+stime+"' and u.level_arrive_at<='"+etime+"'")
}
results, err := db.QueryNativeString(engine, sql)
if err != nil {
@@ -702,8 +810,13 @@ where ur.parent_uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and leve
sqlTpl1 := `select ur.uid FROM user_relate ur
LEFT JOIN user u on u.uid=ur.uid
LEFT JOIN user_level ul on u.level=ul.id
where ur.parent_uid=%s and ur.level=1 and ul.level_weight>=%s and u.level_arrive_at>='%s' and u.level_arrive_at<='%s' ;`
sql1 := fmt.Sprintf(sqlTpl1, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
where ur.parent_uid=%s and ur.level=1 and ul.level_weight>=%s %s ;`
sql1 := ""
if task.WithinDays <= 0 {
sql1 = fmt.Sprintf(sqlTpl1, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "")
} else {
sql1 = fmt.Sprintf(sqlTpl1, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "and u.level_arrive_at>='"+stime+"' and u.level_arrive_at<='"+etime+"'")
}
results1, err1 := db.QueryNativeString(engine, sql1)
if err1 != nil {
return "", hasPay, payOrdId
@@ -734,7 +847,7 @@ where ur.parent_uid=%s and ur.level=1 and ul.level_weight>=%s and u.level_arri
// 小区消费金额
sqlTpl := `SELECT SUM(molr.goods_price) as price FROM mall_ord_list_relate molr
LEFT JOIN mall_ord mo on mo.ord_id=molr.oid and mo.state in (%s)
WHERE molr.uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1) and mo.create_time>=' %s' and mo.create_time<='%s' GROUP BY molr.uid ;`
WHERE molr.uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1) %s GROUP BY molr.uid ;`
state := "1,2,3"
if task.TaskTypePvd == 1 {
state = "2,3"
@@ -742,7 +855,12 @@ WHERE molr.uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1)
if task.TaskTypePvd == 2 {
state = "3"
}
sql := fmt.Sprintf(sqlTpl, state, zhios_condition_statistics_utils.AnyToString(uid), stime, etime)
sql := ""
if task.WithinDays <= 0 {
sql = fmt.Sprintf(sqlTpl, state, zhios_condition_statistics_utils.AnyToString(uid), "")
} else {
sql = fmt.Sprintf(sqlTpl, state, zhios_condition_statistics_utils.AnyToString(uid), "and mo.create_time>='"+stime+"' and mo.create_time<='"+etime+"'")
}
results, err := db.QueryNativeString(engine, sql)
if err != nil {