|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- type MasterWithdrawalFlowDb struct {
- Db *xorm.Engine `json:"db"`
- }
-
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) Set() { // set方法
- masterWithdrawalFlowDb.Db = ZhimengDb
- }
-
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) GetWithdrawalFlowListWithTotal(id string, args map[string]string) (*[]model.MasterWithdrawalFlow, int64) {
- var data []model.MasterWithdrawalFlow
- sess := masterWithdrawalFlowDb.Db.Where("uid=?", id)
- if args["start_time"] != "" {
- sess = sess.And("time>=?", args["start_time"])
- }
- if args["end_time"] != "" {
- sess = sess.And("time<=?", args["end_time"])
- }
- if args["check_start_time"] != "" {
- sess = sess.And("check_time>=?", args["check_start_time"])
- }
- if args["check_end_time"] != "" {
- sess = sess.And("check_time<=?", args["check_end_time"])
- }
- if args["status"] != "" {
- sess = sess.And("status=?", args["status"])
- }
- if args["alipay"] != "" {
- sess = sess.And("alipay LIKE ?", "%"+args["alipay"]+"%")
- }
- p := utils.StrToInt(args["p"])
- size := utils.StrToInt(args["size"])
- offet := (p - 1) * size
- total, err := sess.Limit(size, offet).OrderBy("time desc,id desc").FindAndCount(&data)
- if err != nil {
- return nil, total
- }
- return &data, total
- }
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) GetWithdrawalFlowList(id string, args map[string]string) *[]model.MasterWithdrawalFlow {
- var data []model.MasterWithdrawalFlow
- sess := masterWithdrawalFlowDb.Db.Where("uid=?", id)
- if args["start_time"] != "" {
- sess = sess.And("time>=?", args["start_time"])
- }
- if args["end_time"] != "" {
- sess = sess.And("time<=?", args["end_time"])
- }
- if args["check_start_time"] != "" {
- sess = sess.And("check_time>=?", args["check_start_time"])
- }
- if args["check_end_time"] != "" {
- sess = sess.And("check_time<=?", args["check_end_time"])
- }
- if args["status"] != "" {
- sess = sess.And("status=?", args["status"])
- }
- if args["alipay"] != "" {
- sess = sess.And("alipay LIKE ?", "%"+args["alipay"]+"%")
- }
- p := utils.StrToInt(args["p"])
- size := utils.StrToInt(args["size"])
- offet := (p - 1) * size
- err := sess.Limit(size, offet).OrderBy("time desc,id desc").Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
-
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowInsert(data *model.MasterWithdrawalFlow) bool {
- get, err := masterWithdrawalFlowDb.Db.InsertOne(data)
- if get == 0 || err != nil {
- return false
- }
- return true
- }
-
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowInsertUpdate(data *model.MasterWithdrawalFlow) bool {
- get, err := masterWithdrawalFlowDb.Db.Where("id=?", data.Id).Update(data)
- if get == 0 || err != nil {
- return false
- }
- return true
- }
- func MasterWithdrawalFlowInsertWithSess(sess *xorm.Session, data *model.MasterWithdrawalFlow) bool {
- get, err := sess.InsertOne(data)
- if get == 0 || err != nil {
- return false
- }
- return true
- }
- func (masterWithdrawalFlowDb *MasterWithdrawalFlowDb) MasterWithdrawalFlowById(id string) *model.MasterWithdrawalFlow {
- var data model.MasterWithdrawalFlow
- get, err := masterWithdrawalFlowDb.Db.Where("id=?", id).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
-
- }
|