package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsDoingFlow, int64) { var order []model.OrderGoodsDoingFlow sess := eg.Where("1=1") if param["admin_name"] != "" { var data []model.Admin eg.Where("memo like ?", "%"+param["admin_name"]+"%").Find(&data) ids := []int{-1} for _, v := range data { ids = append(ids, v.AdmId) } sess.In("admin_id", ids) } if param["enterprise_name"] != "" { var data []model.Enterprise eg.Where("name like ?", "%"+param["enterprise_name"]+"%").Find(&data) ids := []int{-1} for _, v := range data { ids = append(ids, v.Id) } sess.In("enterprise_id", ids) } if param["state"] != "" { sess.And("state =?", param["state"]) } if param["enterprise_id"] != "" { sess.And("enterprise_id =?", param["enterprise_id"]) } if param["goods_title"] != "" { sess.And("goods_title like ?", "%"+param["goods_title"]+"%") } if param["start_time"] != "" { sess.And("time>=?", param["start_time"]) } if param["end_time"] != "" { sess.And("time<=?", param["end_time"]) } size := utils.StrToInt(param["limit"]) start := (utils.StrToInt(param["page"]) - 1) * size count, err := sess.Limit(size, start).OrderBy("time desc,id desc").FindAndCount(&order) if err != nil { return nil, count } return &order, count }