From aab33a9cb41bba7d74a6a6119cfe3a6122629fb9 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 29 Jun 2023 18:08:17 +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_order.go | 15 +++++++++++---- db/model/recharge_order.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 db/model/recharge_order.go diff --git a/db/db_order.go b/db/db_order.go index ee08944..3619728 100644 --- a/db/db_order.go +++ b/db/db_order.go @@ -5,6 +5,7 @@ import ( 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" + "time" "xorm.io/xorm" ) @@ -25,10 +26,11 @@ func OrderListCountByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, state, total1, _ := Db.Where("uid = ? AND confirm_at > ? AND confirm_at < ? and settle_at>0", uid, stime, etime).Count(&model.OrdList{}) 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{}) fmt.Println(total) - return total + total1 + total2 + total3, nil + return total + total1 + total2 + total3 + total4, nil } // 查询用户某时间段内某状态的佣金(ord_id => amount) @@ -84,9 +86,11 @@ func OrderListPaidPriceByUIDByOrderTypeByTime(Db *xorm.Engine, uid, buyType, sta total, _ := Db.Where("uid = ? AND confirm_at > ? AND confirm_at < ? and settle_at=0", uid, stime, etime).In("state", state).Sum(&model.OrdList{}, "paid_price") total1, _ := Db.Where("uid = ? AND confirm_at > ? AND confirm_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") + fmt.Println(total) - return total + total1 + total2, nil + return total + total1 + total2 + total4, nil } // OrderListCountByUIDByOrderTypeByTime is 查询订单 by uid by time ,获取规定时间内的订单类型的订单数 @@ -104,10 +108,11 @@ func OrderListCountByUIDByOrderType(Db *xorm.Engine, uid, buyType, state interfa total1, _ := Db.Where("uid = ? and settle_at>0", uid).Count(&model.OrdList{}) total3, _ := Db.Where("uid = ? and confirm_at=0", uid).Count(&model.OrdList{}) total2, _ := Db.Where("uid = ? and state=?", uid, 1).Count(&model.PrivilegeCardOrd{}) + total4, _ := Db.Where("uid = ? and status=?", uid, "已付款").Count(&model.RechargeOrder{}) fmt.Println(total) - return total + total1 + total2 + total3, nil + return total + total1 + total2 + total3 + total4, nil } // 查询用户某时间段内某状态的佣金(ord_id => amount) @@ -163,7 +168,9 @@ func OrderListPaidPriceByUIDByOrderType(Db *xorm.Engine, uid, buyType, state int total, _ := Db.Where("uid = ? and settle_at=0", uid).In("state", state).Sum(&model.OrdList{}, "paid_price") total1, _ := Db.Where("uid = ? and settle_at>0", uid).Sum(&model.OrdList{}, "paid_price") total2, _ := Db.Where("uid = ? and state=?", uid, 1).Sum(&model.PrivilegeCardOrd{}, "paid_price") + total4, _ := Db.Where("uid = ? and status=?", uid, "已付款").Sum(&model.RechargeOrder{}, "amount") + fmt.Println(total) - return total + total1 + total2, nil + return total + total1 + total2 + total4, nil } diff --git a/db/model/recharge_order.go b/db/model/recharge_order.go new file mode 100644 index 0000000..55a6ea7 --- /dev/null +++ b/db/model/recharge_order.go @@ -0,0 +1,36 @@ +package model + +import ( + "time" +) + +type RechargeOrder struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uid int `json:"uid" xorm:"default 0 INT(11)"` + PayMethod int `json:"pay_method" xorm:"default 0 comment('支付方式') INT(11)"` + Oid string `json:"oid" xorm:"comment('站内订单号') VARCHAR(255)"` + PlatformOid string `json:"platform_oid" xorm:"comment('平台订单号') VARCHAR(255)"` + Type string `json:"type" xorm:"comment('充值类型') VARCHAR(255)"` + Status string `json:"status" xorm:"comment('订单状态') VARCHAR(255)"` + CreateTime time.Time `json:"create_time" xorm:"DATETIME"` + PayTime time.Time `json:"pay_time" xorm:"DATETIME"` + RefundTime time.Time `json:"refund_time" xorm:"DATETIME"` + SuccessTime time.Time `json:"success_time" xorm:"DATETIME"` + Account string `json:"account" xorm:"VARCHAR(255)"` + Province string `json:"province" xorm:"VARCHAR(255)"` + Amount string `json:"amount" xorm:"default 0.00 DECIMAL(20,2)"` + GoodsId int `json:"goods_id" xorm:"default 0 INT(11)"` + Title string `json:"title" xorm:"VARCHAR(255)"` + Profit string `json:"profit" xorm:"default 0.00 DECIMAL(20,2)"` + ZyAmount string `json:"zy_amount" xorm:"default 0.00 DECIMAL(20,2)"` + City string `json:"city" xorm:"VARCHAR(255)"` + Ytype string `json:"ytype" xorm:"VARCHAR(255)"` + IdCardNo string `json:"id_card_no" xorm:"VARCHAR(255)"` + TradeNo string `json:"trade_no" xorm:"VARCHAR(255)"` + PayTradeNo string `json:"pay_trade_no" xorm:"VARCHAR(255)"` + OfficalAmount string `json:"offical_amount" xorm:"default 0.00 DECIMAL(20,2)"` + RechargeStatus string `json:"recharge_status" xorm:"VARCHAR(255)"` + UserCommission string `json:"user_commission" xorm:"default 0.0000 DECIMAL(20,4)"` + Price string `json:"price" xorm:"default 0.0000 DECIMAL(20,4)"` + SettleAt int `json:"settle_at" xorm:"default 0 INT(11)"` +}