面包店
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_make_stock.go 4.0 KiB

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