package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) { var order []model.OrderGoods sess := eg.Where("state!=5 and goods_type=0") if param["sorting"] == "1" { sess.And("state!=4") } if param["oid"] != "" { sess.And("oid = ?", param["oid"]) } if param["gid"] != "" { sess.And("goods_id = ?", param["gid"]) } if param["sku_id"] != "" { sess.And("sku_id = ?", param["sku_id"]) } if param["state"] != "" { sess.And("state =?", param["state"]) } if param["keyword"] != "" { sess.And("goods_title like ?", "%"+param["keyword"]+"%") } size := utils.StrToInt(param["limit"]) start := (utils.StrToInt(param["page"]) - 1) * size count, err := sess.Limit(size, start).OrderBy("make_date asc,id asc").FindAndCount(&order) if err != nil { return nil, count } return &order, count } func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods { var order model.OrderGoods get, err := eg.Where("id=?", id).Get(&order) if get == false || err != nil { return nil } return &order } func GetOrderGoodsByIds(sess *xorm.Session, id string) *[]model.OrderGoods { var order []model.OrderGoods err := sess.Where("oid=?", id).Find(&order) if err != nil { return nil } return &order } func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods { var order model.OrderGoods get, err := sess.Where("id=?", id).Get(&order) if get == false || err != nil { return nil } return &order } func GetOrderGoods(sess *xorm.Session, oid, gid, skuId string) *model.OrderGoods { var data model.OrderGoods get, err := sess.Where("oid=? and goods_id=? and sku_id=?", oid, gid, skuId).Get(&data) if err != nil || get == false { return nil } return &data } func GetOrderGoodsAll(sess *xorm.Session, oid string) *[]model.OrderGoods { var order []model.OrderGoods err := sess.Where("oid=? and goods_type=0", oid).Find(&order) if err != nil { return nil } return &order } func GetOrderGoodsByOid(eg *xorm.Engine, oid []int64) *[]model.OrderGoods { var order []model.OrderGoods err := eg.In("oid", oid).And("goods_type=0").Find(&order) if err != nil { return nil } return &order }