|
- 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 num!=success_num")
-
- 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("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
- }
|