|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- func GetStoreAmount(sess *xorm.Session, storeId int, agentUid int) *model.CommunityTeamStoreAmount {
- var data model.CommunityTeamStoreAmount
- get, err := sess.Where("uid=? and parent_uid=?", storeId, agentUid).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func GetStoreAmountEg(eg *xorm.Engine, storeId int, agentUid int) *model.CommunityTeamStoreAmount {
- var data model.CommunityTeamStoreAmount
- get, err := eg.Where("uid=? and parent_uid=?", storeId, agentUid).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func GetStoreAmountFlowList(eg *xorm.Engine, arg map[string]string) (*[]model.CommunityTeamStoreAmountFlow, int64) {
- var data []model.CommunityTeamStoreAmountFlow
- sess := eg.Where("1=1")
- if arg["store_uid"] != "" {
- sess.And("uid=?", arg["store_uid"])
- }
- if arg["parent_uid"] != "" {
- sess.And("parent_uid=?", arg["parent_uid"])
- }
- if arg["title"] != "" {
- sess.And("title like ?", "%"+arg["title"]+"%")
- }
- if arg["oid"] != "" {
- sess.And("oid like ?", "%"+arg["oid"]+"%")
- }
- if arg["start_time"] != "" {
- sess.And("create_at>=?", arg["start_time"])
- }
- if arg["end_time"] != "" {
- sess.And("create_at<=?", arg["end_time"])
- }
- limit := utils.StrToInt(arg["size"])
- start := (utils.StrToInt(arg["p"]) - 1) * limit
- count, err := sess.Desc("id").Limit(limit, start).FindAndCount(&data)
- if err != nil {
- return nil, count
- }
- return &data, count
- }
|