huangjiajun 5 miesięcy temu
rodzic
commit
402650660a
5 zmienionych plików z 106 dodań i 11 usunięć
  1. +6
    -3
      db/db_order.go
  2. +17
    -3
      db/db_order_count.go
  3. +6
    -2
      db/db_order_relate.go
  4. +22
    -3
      db/db_order_sum.go
  5. +55
    -0
      db/model/express_order.go

+ 6
- 3
db/db_order.go Wyświetl plik

@@ -28,10 +28,11 @@ func OrderListCountByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, state,
total3, _ := Db.Where("uid = ? AND settle_at > ? AND settle_at < ? and confirm_at=0", uid, stime, etime).Count(&model.OrdList{})
total2, _ := Db.Where("uid = ? AND created_at > ? AND created_at < ? and state=?", uid, stime, etime, 1).Count(&model.PrivilegeCardOrd{})
total4, _ := Db.Where("uid = ? AND create_time > ? AND create_time < ? and status=?", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05"), "已付款").Count(&model.RechargeOrder{})
total5, _ := Db.In("status", []string{"待取件", "运输中", "已完成"}).Where("uid = ? AND create_time > ? AND create_time < ? ", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05")).Count(&model.ExpressOrder{})

fmt.Println(total)

return total + total1 + total2 + total3 + total4, nil
return total + total1 + total2 + total3 + total4 + total5, nil
}

// 查询用户某时间段内某状态的佣金(ord_id => amount)
@@ -89,7 +90,8 @@ func OrderListPaidPriceByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, sta
total1, _ := Db.Where("uid = ? AND settle_at > ? AND settle_at < ? and settle_at>0", uid, stime, etime).Sum(&model.OrdList{}, "paid_price")
total2, _ := Db.Where("uid = ? AND created_at > ? AND created_at < ? and state=?", uid, stime, etime, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price")
total4, _ := Db.Where("uid = ? AND create_time > ? AND create_time < ? and status=?", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05"), "已付款").Sum(&model.RechargeOrder{}, "amount")
total = total + total1 + total2 + total4
total5, _ := Db.In("status", []string{"待取件", "运输中", "已完成"}).Where("uid = ? AND create_time > ? AND create_time < ? ", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05")).Sum(&model.ExpressOrder{}, "money")
total = total + total1 + total2 + total4 + total5
} else {
types := "confirm_at"
serializeStr := zhios_condition_statistics_utils.SerializeStr(state)
@@ -107,7 +109,8 @@ func OrderListPaidPriceByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, sta
total1, _ := Db.Where("uid = ? AND ? and settle_at>0", uid, sqlStr).Sum(&model.OrdList{}, "paid_price")
total2, _ := Db.Where("uid = ? AND created_at > ? AND created_at < ? and state=?", uid, stime, etime, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price")
total4, _ := Db.Where("uid = ? AND create_time > ? AND create_time < ? and status=?", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05"), "已付款").Sum(&model.RechargeOrder{}, "amount")
total = total + total1 + total2 + total4
total5, _ := Db.In("status", []string{"待取件", "运输中", "已完成"}).Where("uid = ? AND create_time > ? AND create_time < ? ", uid, time.Unix(zhios_condition_statistics_utils.AnyToInt64(stime), 0).Format("2006-01-02 15:04:05"), time.Unix(zhios_condition_statistics_utils.AnyToInt64(etime), 0).Format("2006-01-02 15:04:05")).Sum(&model.ExpressOrder{}, "money")
total = total + total1 + total2 + total4 + total5
}

fmt.Println(total)


+ 17
- 3
db/db_order_count.go Wyświetl plik

@@ -19,10 +19,12 @@ func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, t
}
timeType2 := "created_at"
timeType4 := "create_time"
timeType5 := "create_time"
if task.OrdState == 3 {
timeType = "settle_at"
timeType2 = "settle_at"
timeType4 = "settle_at"
timeType5 = "settle_time"
}
if types == "free" {
timeType = "create_at"
@@ -36,6 +38,7 @@ 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)
sess5 := 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")
@@ -48,10 +51,19 @@ func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, t
sess2 = sess2.And(sqlStr2)
sqlStr4 := fmt.Sprintf(" %s >'%s' AND %s < '%s'", timeType4, stime.Format("2006-01-02 15:04:05"), timeType4, etime.Format("2006-01-02 15:04:05"))
sess4 = sess4.And(sqlStr4)
if timeType5 == "settle_time" {
sqlStr5 := fmt.Sprintf(" %s >'%s' AND %s < '%s'", timeType5, stime.Format("2006-01-02 15:04:05"), timeType5, etime.Format("2006-01-02 15:04:05"))
sess5 = sess5.And(sqlStr5)
} else {
sqlStr5 := fmt.Sprintf(" %s > %d AND %s < %d", timeType5, stime.Unix(), timeType5, etime.Unix())
sess5 = sess5.And(sqlStr5)
}

}
if task.OrdState == 3 {
sess2 = sess2.And("settle_at>0")
sess4 = sess4.And("settle_at>0")
sess5 = sess5.And("settle_time>0")
}
var err error
if task.OrdState != 3 {
@@ -65,14 +77,16 @@ func OrderListCountByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, t
total1, _ := sess1.Count(&model.OrdList{})
var total2 int64
var total4 int64
var total5 int64
if types != "free" {
total2, _ = sess2.Where("state=?", uid, 1).Count(&model.PrivilegeCardOrd{})
total4, _ = sess4.Where("status=?", uid, "已付款").Count(&model.RechargeOrder{})
total2, _ = sess2.Where("state=?", 1).Count(&model.PrivilegeCardOrd{})
total5, _ = sess5.In("status", []string{"待取件", "运输中", "已完成"}).Count(&model.ExpressOrder{})
total4, _ = sess4.Where("status=?", "已付款").Count(&model.RechargeOrder{})
}

fmt.Println(total)

return total + total1 + total2 + total4, nil
return total + total1 + total2 + total4 + total5, nil
}

func MallOrdWithCountNew(Db *xorm.Engine, uid interface{}, task *model.UserLevelUpgradeTask) (int64, error) {


+ 6
- 2
db/db_order_relate.go Wyświetl plik

@@ -25,6 +25,7 @@ func OrderRelateListByTimeByStateNew(Db *xorm.Engine, uid interface{}, task *mod
timeStr += " or (dol.create_at>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and dol.create_at<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (ro.create_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and ro.create_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (pso.create_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and pso.create_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (eo.create_time>='" + stime.Format("2006-01-02 15:04:05") + "' and eo.create_time<='" + etime.Format("2006-01-02 15:04:05") + "')"
timeStr += " )"
}
if task.OrdState == 1 { //已付款
@@ -37,6 +38,7 @@ func OrderRelateListByTimeByStateNew(Db *xorm.Engine, uid interface{}, task *mod
timeStr += " or (dol.create_at>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and dol.create_at<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (ro.create_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and ro.create_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (pso.create_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and pso.create_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (eo.create_time>='" + stime.Format("2006-01-02 15:04:05") + "' and eo.create_time<='" + etime.Format("2006-01-02 15:04:05") + "')"
timeStr += " )"
}
}
@@ -50,9 +52,10 @@ func OrderRelateListByTimeByStateNew(Db *xorm.Engine, uid interface{}, task *mod
timeStr += " or (dol.settle_at>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and dol.settle_at<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (ro.settle_at>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and ro.settle_at<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (pso.settle_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and pso.settle_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " or (eo.settle_time>=" + zhios_condition_statistics_utils.Int64ToStr(stime.Unix()) + " and eo.settle_time<=" + zhios_condition_statistics_utils.Int64ToStr(etime.Unix()) + ")"
timeStr += " )"
}
timeStr += " and (ol.settle_at>0 or pco.settle_at>0 or dol.settle_at>0 or ro.settle_at>0 or pso.settle_time>0)"
timeStr += " and (ol.settle_at>0 or pco.settle_at>0 or dol.settle_at>0 or ro.settle_at>0 or pso.settle_time>0 or eo.settle_time>0)"
}

var sum float64 = 0
@@ -64,8 +67,9 @@ FROM ord_list_relate olr
LEFT JOIN privilege_card_ord pco ON olr.oid =pco.ord_id
LEFT JOIN duoyou_ord_list dol ON olr.oid =dol.oid
LEFT JOIN recharge_order ro ON olr.oid =ro.oid
LEFT JOIN express_order eo ON olr.oid =eo.oid
LEFT JOIN playlet_sale_order pso ON olr.oid =pso.custom_oid
WHERE olr.uid = ? %s AND (ol.state in(%s) or pco.state=1 or dol.id>0 or ro.status<>'已退款' or pso.status<>'订单退款');
WHERE olr.uid = ? %s AND (ol.state in(%s) or pco.state=1 or dol.id>0 or ro.status<>'已退款' or pso.status<>'订单退款' or eo.status in('待取件','运输中','已完成'));
`
sqlTpl = fmt.Sprintf(sqlTpl, timeStr, state)
todayResult, err := QueryNativeString(Db, sqlTpl, uid)


+ 22
- 3
db/db_order_sum.go Wyświetl plik

@@ -19,10 +19,14 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, typ
}
timeType2 := "created_at"
timeType4 := "create_time"
timeType5 := "create_time"

if task.OrdState == 3 {
timeType = "settle_at"
timeType2 = "settle_at"
timeType4 = "settle_at"
timeType5 = "settle_time"

}
t := time.Now()
stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
@@ -32,6 +36,8 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, typ
sess1 := Db.Where("uid = ? and settle_at>0", uid)
sess2 := Db.Where("uid = ?", uid)
sess4 := Db.Where("uid = ?", uid)
sess5 := 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")
@@ -44,10 +50,19 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, typ
sess1.And(sqlStr)
sess2.And(sqlStr2)
sess4.And(sqlStr4)
if timeType5 == "settle_time" {
sqlStr5 := fmt.Sprintf(" %s >'%s' AND %s < '%s'", timeType5, stime.Format("2006-01-02 15:04:05"), timeType5, etime.Format("2006-01-02 15:04:05"))
sess5 = sess5.And(sqlStr5)
} else {
sqlStr5 := fmt.Sprintf(" %s > %d AND %s < %d", timeType5, stime.Unix(), timeType5, etime.Unix())
sess5 = sess5.And(sqlStr5)
}
}
if task.OrdState == 3 {
sess2.And("settle_at>0")
sess4.And("settle_at>0")
sess5 = sess5.And("settle_time>0")

}
if task.OrdState != 3 {
total, _ = sess.In("state", state).Sum(&model.OrdList{}, "paid_price")
@@ -57,13 +72,17 @@ func OrderListSumByUIDByOrderTypeByTimeNew(Db *xorm.Engine, uid interface{}, typ
total1, _ := sess1.Sum(&model.OrdList{}, "paid_price")
var total2 float64
var total4 float64
var total5 float64

if types != "free" {
total2, _ = sess2.Where("state=?", uid, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price")
total4, _ = sess4.Where("status=?", uid, "已付款").Sum(&model.RechargeOrder{}, "amount")
total5, _ = sess5.In("status", []string{"待取件", "运输中", "已完成"}).Sum(&model.ExpressOrder{}, "money")

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

return total + total1 + total2 + total4, nil
return total + total1 + total2 + total4 + total5, nil
}

func MallOrdWithSumNew(Db *xorm.Engine, uid interface{}, orderType int, task *model.UserLevelUpgradeTask) (float64, error) {


+ 55
- 0
db/model/express_order.go Wyświetl plik

@@ -0,0 +1,55 @@
package model

import (
"time"
)

type ExpressOrder struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Oid string `json:"oid" xorm:"VARCHAR(255)"`
PvdOid string `json:"pvd_oid" xorm:"VARCHAR(255)"`
CreateTime time.Time `json:"create_time" xorm:"DATETIME"`
PayTime time.Time `json:"pay_time" xorm:"DATETIME"`
SupplementPayTime time.Time `json:"supplement_pay_time" xorm:"comment('补交时间') DATETIME"`
Money string `json:"money" xorm:"default 0.00000000 comment('第一次') DECIMAL(20,8)"`
Profit string `json:"profit" xorm:"default 0.00000000 comment('利润') DECIMAL(20,8)"`
RealProfit string `json:"real_profit" xorm:"default 0.00000000 comment('利润') DECIMAL(20,8)"`
SupplementMoney string `json:"supplement_money" xorm:"default 0.00000000 DECIMAL(20,8)"`
IsPay int `json:"is_pay" xorm:"default 0 INT(1)"`
IsSupplementPay int `json:"is_supplement_pay" xorm:"default 0 INT(1)"`
Status string `json:"status" xorm:"VARCHAR(255)"`
Ext string `json:"ext" xorm:"TEXT"`
IsRefund int `json:"is_refund" xorm:"default 0 INT(1)"`
RefundTime time.Time `json:"refund_time" xorm:"DATETIME"`
IsCancel int `json:"is_cancel" xorm:"default 0 INT(1)"`
PayWay int `json:"pay_way" xorm:"default 0 INT(11)"`
CommissionTime int `json:"commission_time" xorm:"default 0 INT(11)"`
SettleTime int `json:"settle_time" xorm:"default 0 INT(11)"`
CancelTime time.Time `json:"cancel_time" xorm:"DATETIME"`
Info string `json:"info" xorm:"TEXT"`
SendInfo string `json:"send_info" xorm:"TEXT"`
WlOid string `json:"wl_oid" xorm:"VARCHAR(255)"`
EmpName string `json:"emp_name" xorm:"VARCHAR(255)"`
SenderPhone string `json:"sender_phone" xorm:"VARCHAR(255)"`
ReceiverPhone string `json:"receiver_phone" xorm:"VARCHAR(255)"`
CompanyCode string `json:"company_code" xorm:"VARCHAR(255)"`
ExpressFirstAddPrice string `json:"express_first_add_price" xorm:"VARCHAR(255)"`
ExpressSecondAddPrice string `json:"express_second_add_price" xorm:"VARCHAR(255)"`
AgentPay int `json:"agent_pay" xorm:"default 0 INT(11)"`
StationPay int `json:"station_pay" xorm:"default 0 INT(11)"`
IsNew int `json:"is_new" xorm:"default 0 INT(11)"`
AgentPrice string `json:"agent_price" xorm:"default 0.00 comment('第一次') DECIMAL(20,2)"`
StationPrice string `json:"station_price" xorm:"default 0.00 comment('第一次') DECIMAL(20,2)"`
PlatformPrice string `json:"platform_price" xorm:"default 0.00 comment('第一次') DECIMAL(20,2)"`
PlatformSupplementMoney string `json:"platform_supplement_money" xorm:"default 0.00 comment('第一次') DECIMAL(20,2)"`
CreateMsg string `json:"create_msg" xorm:"TEXT"`
ApiMsg string `json:"api_msg" xorm:"TEXT"`
StationSupplementMoney string `json:"station_supplement_money" xorm:"default 0.00000000 DECIMAL(20,8)"`
AgentSupplementMoney string `json:"agent_supplement_money" xorm:"default 0.00000000 DECIMAL(20,8)"`
IsStationSupplementPay int `json:"is_station_supplement_pay" xorm:"default 0 INT(1)"`
IsAgentSupplementPay int `json:"is_agent_supplement_pay" xorm:"default 0 INT(1)"`
Platform int `json:"platform" xorm:"default 0 INT(1)"`
Own int `json:"own" xorm:"default 0 INT(1)"`
NeedDeduct string `json:"need_deduct" xorm:"default 0.00000000 DECIMAL(20,8)"`
}

Ładowanie…
Anuluj
Zapisz