面包店
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

104 lignes
2.4 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/md"
  4. "applet/app/bigData/svc"
  5. "applet/app/db"
  6. "applet/app/db/model"
  7. "applet/app/e"
  8. "applet/app/utils"
  9. "encoding/json"
  10. "github.com/gin-gonic/gin"
  11. "strings"
  12. )
  13. func MakingData(c *gin.Context) {
  14. args := map[string]string{
  15. "state": "1",
  16. }
  17. svc.CommMakingData(c, args)
  18. }
  19. func BakingData(c *gin.Context) {
  20. args := map[string]string{
  21. "state": "2",
  22. }
  23. svc.CommMakingData(c, args)
  24. }
  25. func SortingData(c *gin.Context) {
  26. result, err := svc.LeftDataForSorting()
  27. if err != nil {
  28. e.OutErr(c, e.ERR, err.Error())
  29. return
  30. }
  31. e.OutSuc(c, result, nil)
  32. return
  33. }
  34. func NewOrderNotice(c *gin.Context) {
  35. sysCfgDb := db.SysCfgDb{}
  36. sysCfgDb.Set()
  37. cfg, _ := sysCfgDb.SysCfgGetOne("has_new_order")
  38. res := map[string]string{
  39. "has_new_order": "0",
  40. }
  41. if cfg != nil {
  42. res["has_new_order"] = cfg.Val
  43. cfg.Val = "0"
  44. db.Db.Where("`key`=?", "has_new_order").Update(cfg)
  45. }
  46. e.OutSuc(c, res, nil)
  47. return
  48. }
  49. func NewOrderInfoNotice(c *gin.Context) {
  50. var data []model.OrderGoods
  51. db.Db.Where("is_new=1").Find(&data)
  52. sysCfgDb := db.SysCfgDb{}
  53. sysCfgDb.Set()
  54. cfg, _ := sysCfgDb.SysCfgGetOne("new_order_notice")
  55. str := ""
  56. if cfg != nil {
  57. str = cfg.Val
  58. }
  59. skuDatas := make(map[int64]map[int]map[string]string, 0)
  60. for _, v := range data {
  61. _, ok := skuDatas[v.SkuId]
  62. if ok == false {
  63. skuDatas[v.SkuId] = make(map[int]map[string]string)
  64. }
  65. _, ok1 := skuDatas[v.SkuId][v.GoodsType]
  66. if ok1 == false {
  67. skuDatas[v.SkuId][v.GoodsType] = make(map[string]string)
  68. }
  69. skuDatas[v.SkuId][v.GoodsType]["goods_title"] = v.GoodsTitle
  70. skuDatas[v.SkuId][v.GoodsType]["sku"] = v.Sku
  71. skuDatas[v.SkuId][v.GoodsType]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId][v.GoodsType]["count"]) + v.Num)
  72. }
  73. res := make([]map[string]string, 0)
  74. for _, v := range skuDatas {
  75. for _, v1 := range v {
  76. skuData := make([]md.Sku, 0)
  77. json.Unmarshal([]byte(v1["sku"]), &skuData)
  78. skuStr := ""
  79. for _, v2 := range skuData {
  80. if skuStr != "" {
  81. skuStr += ";"
  82. }
  83. skuStr += v2.Value
  84. }
  85. tip := str
  86. tip = strings.ReplaceAll(tip, "[商品名称]", v1["goods_title"])
  87. tip = strings.ReplaceAll(tip, "[规格]", skuStr)
  88. tip = strings.ReplaceAll(tip, "[数量]", v1["count"])
  89. tmp := map[string]string{
  90. "str": tip,
  91. }
  92. res = append(res, tmp)
  93. }
  94. }
  95. for _, v := range data {
  96. v.IsNew = 0
  97. db.Db.Where("id=?", v.Id).Cols("is_new").Update(&v)
  98. }
  99. e.OutSuc(c, res, nil)
  100. return
  101. }