package db import ( "applet/app/db/model" "applet/app/utils" "fmt" ) func GetGuideOrderByOne(oid, mid, types string) *model.GuideOrder { var data model.GuideOrder get, err := ZhimengDb.Where("uid=? and pvd_oid=? and pvd=?", mid, oid, types).Get(&data) if get == false || err != nil { fmt.Println(err) return nil } return &data } func GetGuideOrderList(args map[string]string) []model.GuideOrder { /*** 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.GuideOrder, 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("pvd=?", 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("platform_settle_time?", 0) } err := sess.Limit(size, offet).OrderBy(sort).Find(&data) fmt.Println(err) fmt.Println(sess.LastSQL()) return data } func GetGuideOrderListTotal(args map[string]string) ([]model.GuideOrder, int64) { var data = make([]model.GuideOrder, 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>=?", utils.TimeStdParseUnix(args["start_time"])) } if args["end_time"] != "" { sess = sess.And("create_time<=?", utils.TimeStdParseUnix(args["end_time"])) } if args["type"] != "" { sess = sess.And("pvd=?", 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("station_uid=?", args["zuid"]) } if args["oid"] != "" { sess = sess.And("pvd_oid like ?", "%"+args["oid"]+"%") } 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 }