面包店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_order_goods_list.go 2.0 KiB

8 months ago
7 months ago
8 months ago
8 months ago
8 months ago
6 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) {
  8. var order []model.OrderGoods
  9. sess := eg.Where("state!=5 ")
  10. if param["sorting"] == "1" {
  11. sess.And("state!=4")
  12. }
  13. if param["oid"] != "" {
  14. sess.And("oid = ?", param["oid"])
  15. }
  16. if param["gid"] != "" {
  17. sess.And("goods_id = ?", param["gid"])
  18. }
  19. if param["sku_id"] != "" {
  20. sess.And("sku_id = ?", param["sku_id"])
  21. }
  22. if param["state"] != "" {
  23. sess.And("state =?", param["state"])
  24. }
  25. if param["keyword"] != "" {
  26. sess.And("goods_title like ?", "%"+param["keyword"]+"%")
  27. }
  28. size := utils.StrToInt(param["limit"])
  29. start := (utils.StrToInt(param["page"]) - 1) * size
  30. count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order)
  31. if err != nil {
  32. return nil, count
  33. }
  34. return &order, count
  35. }
  36. func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods {
  37. var order model.OrderGoods
  38. get, err := eg.Where("id=?", id).Get(&order)
  39. if get == false || err != nil {
  40. return nil
  41. }
  42. return &order
  43. }
  44. func GetOrderGoodsByIds(sess *xorm.Session, id string) *[]model.OrderGoods {
  45. var order []model.OrderGoods
  46. err := sess.Where("oid=?", id).Find(&order)
  47. if err != nil {
  48. return nil
  49. }
  50. return &order
  51. }
  52. func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods {
  53. var order model.OrderGoods
  54. get, err := sess.Where("id=?", id).Get(&order)
  55. if get == false || err != nil {
  56. return nil
  57. }
  58. return &order
  59. }
  60. func GetOrderGoods(sess *xorm.Session, oid, gid, skuId string) *model.OrderGoods {
  61. var data model.OrderGoods
  62. get, err := sess.Where("oid=? and goods_id=? and sku_id=?", oid, gid, skuId).Get(&data)
  63. if err != nil || get == false {
  64. return nil
  65. }
  66. return &data
  67. }
  68. func GetOrderGoodsAll(sess *xorm.Session, oid string) *[]model.OrderGoods {
  69. var order []model.OrderGoods
  70. err := sess.Where("oid=? and goods_type=0", oid).Find(&order)
  71. if err != nil {
  72. return nil
  73. }
  74. return &order
  75. }