package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetOrderGoodsMakeStockByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) { var order []model.OrderGoodsMakeStock sess := eg.Where("1=1") if param["state"] == "1" { sess.And("wait_make_num >0") } if param["state"] == "2" { sess.And("wait_baking_num >0") } if param["state"] == "3" { sess.And("wait_sorting_num >0") } 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 GetOrderGoodsMakeStockByBigData(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) { var order []model.OrderGoodsMakeStock sess := eg.Where("1=1") if param["state"] == "1" { sess.And("wait_make_num >0") } if param["state"] == "2" { sess.And("wait_baking_num >0") } if param["state"] == "3" { sess.And("wait_sorting_num >0") } if param["keyword"] != "" { sess.And("goods_title like ?", "%"+param["keyword"]+"%") } count, err := sess.OrderBy("id asc").FindAndCount(&order) if err != nil { return nil, count } return &order, count } func GetOrderGoodsMakeStock(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock { var data model.OrderGoodsMakeStock get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data) if err != nil { return nil } if get == false { data = model.OrderGoodsMakeStock{ Gid: gid, SkuId: skuId, } insert, err := sess.Insert(&data) if insert == 0 || err != nil { return nil } } return &data } func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock { var data model.OrderGoodsMakeStock get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data) if err != nil || get == false { return nil } return &data }