面包店
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.
 
 
 
 
 

123 lines
3.3 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetOrderGoodsMakeStockByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) {
  8. var order []model.OrderGoodsMakeStock
  9. sess := eg.Where("goods_type=0")
  10. if param["state"] == "1" {
  11. sess.And("wait_make_num >0")
  12. }
  13. if param["state"] == "2" {
  14. sess.And("wait_baking_num >0")
  15. }
  16. if param["state"] == "3" {
  17. sess.And("wait_sorting_num >0")
  18. }
  19. if param["keyword"] != "" {
  20. sess.And("goods_title like ?", "%"+param["keyword"]+"%")
  21. }
  22. size := utils.StrToInt(param["limit"])
  23. start := (utils.StrToInt(param["page"]) - 1) * size
  24. count, err := sess.Limit(size, start).OrderBy("make_date asc,id asc").FindAndCount(&order)
  25. if err != nil {
  26. return nil, count
  27. }
  28. return &order, count
  29. }
  30. func GetOrderGoodsMakeStockByBigData(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) {
  31. var order []model.OrderGoodsMakeStock
  32. sess := eg.Where("1=1")
  33. if param["now"] != "" {
  34. sess.And("make_date=?", param["now"])
  35. }
  36. if param["state"] == "1" {
  37. sess.And("wait_make_num >=0")
  38. } else {
  39. sess.And("goods_type =0")
  40. }
  41. if param["state"] == "2" {
  42. sess.And("wait_make_num =0 and wait_baking_num >=0")
  43. }
  44. if param["state"] == "3" {
  45. sess.And("wait_baking_num =0 and wait_sorting_num >=0")
  46. }
  47. if param["keyword"] != "" {
  48. sess.And("goods_title like ?", "%"+param["keyword"]+"%")
  49. }
  50. count, err := sess.OrderBy("id asc").FindAndCount(&order)
  51. if err != nil {
  52. return nil, count
  53. }
  54. return &order, count
  55. }
  56. func GetOrderGoodsMakeStock(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock {
  57. var data model.OrderGoodsMakeStock
  58. get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data)
  59. if err != nil {
  60. return nil
  61. }
  62. if get == false {
  63. data = model.OrderGoodsMakeStock{
  64. Gid: gid,
  65. SkuId: skuId,
  66. }
  67. insert, err := sess.Insert(&data)
  68. if insert == 0 || err != nil {
  69. return nil
  70. }
  71. }
  72. return &data
  73. }
  74. func GetOrderGoodsMakeStockById(sess *xorm.Session, id int64) *model.OrderGoodsMakeStock {
  75. var data model.OrderGoodsMakeStock
  76. get, err := sess.Where("id=? ", id).Get(&data)
  77. if err != nil || get == false {
  78. return nil
  79. }
  80. return &data
  81. }
  82. func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64, goodsType int) *model.OrderGoodsMakeStock {
  83. var data model.OrderGoodsMakeStock
  84. get, err := sess.Where("gid=? and sku_id=? and goods_type=?", gid, skuId, goodsType).Get(&data)
  85. if err != nil || get == false {
  86. return nil
  87. }
  88. return &data
  89. }
  90. func GetOrderGoodsMakeStockAllByDate(sess *xorm.Session, gid, skuId int64, goodsType int, date int) *model.OrderGoodsMakeStock {
  91. var data model.OrderGoodsMakeStock
  92. get, err := sess.Where("gid=? and sku_id=? and goods_type=? and make_date=?", gid, skuId, goodsType, date).Get(&data)
  93. if err != nil || get == false {
  94. return nil
  95. }
  96. return &data
  97. }
  98. func GetOrderGoodsMakeStockByDate(sess *xorm.Session, gid, skuId int64, date int) *model.OrderGoodsMakeStock {
  99. var data model.OrderGoodsMakeStock
  100. get, err := sess.Where("gid=? and sku_id=? and make_date=?", gid, skuId, date).Get(&data)
  101. if err != nil {
  102. return nil
  103. }
  104. if get == false {
  105. data = model.OrderGoodsMakeStock{
  106. Gid: gid,
  107. SkuId: skuId,
  108. MakeDate: date,
  109. }
  110. insert, err := sess.Insert(&data)
  111. if insert == 0 || err != nil {
  112. return nil
  113. }
  114. }
  115. return &data
  116. }