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

83 lines
2.0 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("1=1")
  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("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["state"] == "1" {
  34. sess.And("wait_make_num >0")
  35. }
  36. if param["state"] == "2" {
  37. sess.And("wait_baking_num >0")
  38. }
  39. if param["state"] == "3" {
  40. sess.And("wait_sorting_num >0")
  41. }
  42. if param["keyword"] != "" {
  43. sess.And("goods_title like ?", "%"+param["keyword"]+"%")
  44. }
  45. count, err := sess.OrderBy("id asc").FindAndCount(&order)
  46. if err != nil {
  47. return nil, count
  48. }
  49. return &order, count
  50. }
  51. func GetOrderGoodsMakeStock(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock {
  52. var data model.OrderGoodsMakeStock
  53. get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data)
  54. if err != nil {
  55. return nil
  56. }
  57. if get == false {
  58. data = model.OrderGoodsMakeStock{
  59. Gid: gid,
  60. SkuId: skuId,
  61. }
  62. insert, err := sess.Insert(&data)
  63. if insert == 0 || err != nil {
  64. return nil
  65. }
  66. }
  67. return &data
  68. }
  69. func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock {
  70. var data model.OrderGoodsMakeStock
  71. get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data)
  72. if err != nil || get == false {
  73. return nil
  74. }
  75. return &data
  76. }