@@ -7,4 +7,5 @@ import ( | |||||
type UserWalletFlowDao interface { | type UserWalletFlowDao interface { | ||||
UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error) | UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error) | ||||
UserWalletFlowFindByParams(params map[string]interface{}, page, limit int) (*[]model.UserWalletFlow, int64, error) | |||||
} | } |
@@ -24,7 +24,10 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm. | |||||
func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) { | func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) { | ||||
var m []model.UserVirtualCoinFlow | var m []model.UserVirtualCoinFlow | ||||
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at >= ?", startAt).And("create_at <= ?", endAt) | |||||
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID) | |||||
if startAt != "" && endAt != "" { | |||||
session = session.And("create_at >= ?", startAt).And("create_at <= ?", endAt) | |||||
} | |||||
if direction != 0 { | if direction != 0 { | ||||
session = session.And("direction = ?", direction) | session = session.And("direction = ?", direction) | ||||
} | } | ||||
@@ -3,6 +3,10 @@ | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" | |||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | |||||
"fmt" | |||||
"reflect" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -21,3 +25,26 @@ func (u UserWalletFlowDb) UserWalletFlowInsertBySession(session *xorm.Session, u | |||||
} | } | ||||
return userWalletFlow.Id, nil | return userWalletFlow.Id, nil | ||||
} | } | ||||
func (u UserWalletFlowDb) UserWalletFlowFindByParams(params map[string]interface{}, page, limit int) (*[]model.UserWalletFlow, int64, error) { | |||||
var m []model.UserWalletFlow | |||||
if page == 0 || limit == 0 { | |||||
page = 1 | |||||
limit = 10 | |||||
} | |||||
var total int64 | |||||
var err error | |||||
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { | |||||
//指定In查询 | |||||
if total, err = u.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Limit(limit, (page-1)*limit).FindAndCount(&m); err != nil { | |||||
return nil, 0, zhios_order_relate_logx.Warn(err) | |||||
} | |||||
} else { | |||||
var query = fmt.Sprintf("%s =?", params["key"]) | |||||
total, err = u.Db.Where(query, params["value"]).Limit(limit, (page-1)*limit).FindAndCount(&m) | |||||
if err != nil { | |||||
return nil, 0, zhios_order_relate_logx.Error(err) | |||||
} | |||||
} | |||||
return &m, total, nil | |||||
} |