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

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