面包店
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

95 řádky
2.4 KiB

  1. package svc
  2. import (
  3. "applet/app/admin/md"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. "applet/app/e"
  7. "applet/app/utils"
  8. "encoding/json"
  9. "github.com/gin-gonic/gin"
  10. "time"
  11. )
  12. func CommMakingData(c *gin.Context, args map[string]string) {
  13. eg := db.Db
  14. args["now"] = CommDate()
  15. data, _ := db.GetOrderGoodsMakeStockByBigData(eg, args)
  16. list := make([]map[string]string, 0)
  17. if data != nil {
  18. for _, v := range *data {
  19. var tmp = map[string]string{
  20. "num": "",
  21. "state_str": "",
  22. "goods_title": v.GoodsTitle,
  23. "state": "",
  24. }
  25. if args["state"] == "1" {
  26. tmp["num"] = utils.IntToStr(v.WaitMakeNum)
  27. tmp["state_str"] = "制作中"
  28. tmp["state"] = "1"
  29. if v.WaitMakeNum == 0 {
  30. tmp["state"] = "4"
  31. tmp["state_str"] = "制作完成"
  32. }
  33. if v.GoodsType == 2 {
  34. tmp["state"] = "4"
  35. tmp["state_str"] = "无需制作"
  36. }
  37. if v.GoodsType == 1 { //判断主单做完了就显示完成
  38. count, _ := eg.Where("gid=? and sku_id=? and goods_type=0 and make_date=?", v.Gid, v.SkuId, v.MakeDate).Sum(&model.OrderGoodsMakeStock{}, "wait_make_num")
  39. if count == 0 {
  40. tmp["state"] = "4"
  41. tmp["state_str"] = "制作完成"
  42. }
  43. }
  44. }
  45. if args["state"] == "2" {
  46. tmp["num"] = utils.IntToStr(v.WaitBakingNum)
  47. tmp["state_str"] = "烘焙中"
  48. tmp["state"] = "2"
  49. if v.WaitBakingNum == 0 {
  50. tmp["state"] = "4"
  51. tmp["state_str"] = "烘焙完成"
  52. }
  53. if v.GoodsType == 2 {
  54. tmp["state"] = "4"
  55. tmp["state_str"] = "无需烘焙"
  56. }
  57. }
  58. if args["state"] == "3" {
  59. tmp["num"] = utils.IntToStr(v.WaitSortingNum)
  60. tmp["state_str"] = "分拣中"
  61. tmp["state"] = "3"
  62. if v.WaitSortingNum == 0 {
  63. tmp["state"] = "4"
  64. tmp["state_str"] = "分拣完成"
  65. }
  66. }
  67. skuData := make([]md.Sku, 0)
  68. json.Unmarshal([]byte(v.Sku), &skuData)
  69. skuStr := ""
  70. for _, v1 := range skuData {
  71. if skuStr != "" {
  72. skuStr += ";"
  73. }
  74. skuStr += v1.Value
  75. }
  76. tmp["sku_str"] = skuStr
  77. list = append(list, tmp)
  78. }
  79. }
  80. e.OutSuc(c, list, nil)
  81. return
  82. }
  83. func CommDate() string {
  84. sysCfgDb := db.SysCfgDb{}
  85. sysCfgDb.Set()
  86. beforeHourShowOrder, _ := sysCfgDb.SysCfgGetOne("before_hour_show_order")
  87. today := utils.GetTimeRange("today")
  88. if utils.StrToInt(beforeHourShowOrder.Val) > time.Now().Hour() {
  89. today = utils.GetTimeRange("yesterday")
  90. }
  91. return time.Unix(today["start"], 0).Format("20060102")
  92. }