package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetOrderGoodsByRecordId(eg *xorm.Engine, id string) *model.OrderGoodsDoing { var order model.OrderGoodsDoing get, err := eg.Where("record_id=?", id).Get(&order) if get == false || err != nil { return nil } return &order } func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsDoing, int64) { var order []model.OrderGoodsDoing sess := eg.Where("1=1") if param["admin_name"] != "" { var data []model.Admin eg.Where("memo like ?", "%"+param["admin_name"]+"%") 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"]+"%") ids := []int{-1} for _, v := range data { ids = append(ids, v.Id) } sess.In("enterprise_id", ids) } if param["oid"] != "" { sess.And("oid like ?", "%"+param["oid"]+"%") } 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 }