|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "fmt"
- )
-
- func GetHwOrderByOne(oid, mid, types string) *model.HwOrder {
- var data model.HwOrder
- get, err := ZhimengDb.Where("uid=? and oid=? and type=?", mid, oid, types).Get(&data)
- if get == false || err != nil {
- fmt.Println(err)
- return nil
- }
- return &data
- }
- func GetHwOrderList(args map[string]string) []model.HwOrder {
- /***
- p 页数
- size 个数
- start_time 开始时间
- end_time 结束时间
- ord_type 订单类型
- video_type 视频类型
- status 订单状态
- settle_status 结算状态
- oid 订单号
- sort 排序
- is_to_settle 智盟结算
- to_settle_time 结算上月时间
- */
- var data = make([]model.HwOrder, 0)
- size := utils.StrToInt(args["size"])
- offet := (utils.StrToInt(args["p"]) - 1) * size
- sess := ZhimengDb.Where("1=1")
- if args["start_time"] != "" {
- sess = sess.And("update_time>=?", args["start_time"])
- }
- if args["end_time"] != "" {
- sess = sess.And("update_time<=?", args["end_time"])
- }
- if args["type"] != "" {
- sess = sess.And("type=?", args["type"])
- }
- if args["uid"] != "" {
- sess = sess.And("uid=?", args["uid"])
- }
- if args["status"] != "" {
- sess = sess.And("status=?", args["status"])
- }
- if args["to_settle_time"] != "" {
- sess = sess.And("create_time<?", args["to_settle_time"])
- }
- sort := "update_time desc,id desc"
- if args["sort"] != "" {
- sort = args["sort"]
- }
- if args["is_to_settle"] == "1" {
- sess = sess.And("settle_time=?", 0)
- }
- if args["is_commission"] == "1" {
- sess = sess.And("commission>?", 0)
- }
- err := sess.Limit(size, offet).OrderBy(sort).Find(&data)
- fmt.Println(err)
- fmt.Println(sess.LastSQL())
- return data
- }
- func GetHwOrderListTotal(args map[string]string) ([]model.HwOrder, int64) {
- var data = make([]model.HwOrder, 0)
- size := utils.StrToInt(args["size"])
- offet := (utils.StrToInt(args["p"]) - 1) * size
- sess := ZhimengDb.Where("1=1")
- if args["start_time"] != "" {
- sess = sess.And("create_time>=?", args["start_time"])
- }
- if args["end_time"] != "" {
- sess = sess.And("create_time<=?", args["end_time"])
- }
- if args["type"] != "" {
- sess = sess.And("type=?", args["type"])
- }
- if args["settle_type"] == "0" {
- sess = sess.And("settle_time=?", 0)
- }
- if args["settle_type"] == "1" {
- sess = sess.And("settle_time>?", 0)
- }
- if args["uid"] != "" {
- sess = sess.And("uid=?", args["uid"])
- }
- if args["zuid"] != "" {
- sess = sess.And("zuid=?", args["zuid"])
- }
- if args["status"] != "" {
- sess = sess.And("status=?", args["status"])
- }
-
- sort := "create_time desc,id desc"
- if args["sort"] != "" {
- sort = args["sort"]
- }
-
- total, err := sess.Limit(size, offet).OrderBy(sort).FindAndCount(&data)
- fmt.Println(err)
- fmt.Println(sess.LastSQL())
- return data, total
- }
|