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

svc_making_data.go 2.3 KiB

6 月之前
6 月之前
6 月之前
6 月之前
6 月之前
6 月之前
6 月之前
6 月之前
6 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. }
  54. if args["state"] == "3" {
  55. tmp["num"] = utils.IntToStr(v.WaitSortingNum)
  56. tmp["state_str"] = "分拣中"
  57. tmp["state"] = "3"
  58. if v.WaitSortingNum == 0 {
  59. tmp["state"] = "4"
  60. tmp["state_str"] = "分拣完成"
  61. }
  62. }
  63. skuData := make([]md.Sku, 0)
  64. json.Unmarshal([]byte(v.Sku), &skuData)
  65. skuStr := ""
  66. for _, v1 := range skuData {
  67. if skuStr != "" {
  68. skuStr += ";"
  69. }
  70. skuStr += v1.Value
  71. }
  72. tmp["sku_str"] = skuStr
  73. list = append(list, tmp)
  74. }
  75. }
  76. e.OutSuc(c, list, nil)
  77. return
  78. }
  79. func CommDate() string {
  80. sysCfgDb := db.SysCfgDb{}
  81. sysCfgDb.Set()
  82. beforeHourShowOrder, _ := sysCfgDb.SysCfgGetOne("before_hour_show_order")
  83. today := utils.GetTimeRange("today")
  84. if utils.StrToInt(beforeHourShowOrder.Val) > time.Now().Hour() {
  85. today = utils.GetTimeRange("yesterday")
  86. }
  87. return time.Unix(today["start"], 0).Format("20060102")
  88. }