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

134 lignes
3.0 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 NewSortingCate(c *gin.Context) {
  35. result := svc.NewSortingCate()
  36. e.OutSuc(c, result, nil)
  37. return
  38. }
  39. func NewSortingGoodsCate(c *gin.Context) {
  40. result := svc.NewSortingGoodsCate()
  41. e.OutSuc(c, result, nil)
  42. return
  43. }
  44. func NewSortingGoodsData(c *gin.Context) {
  45. var arg map[string]string
  46. if err := c.ShouldBindJSON(&arg); err != nil {
  47. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  48. return
  49. }
  50. result := svc.NewSortingGoodsData(arg)
  51. e.OutSuc(c, result, nil)
  52. return
  53. }
  54. func NewSortingData(c *gin.Context) {
  55. result := svc.NewSortingData(c)
  56. e.OutSuc(c, result, nil)
  57. return
  58. }
  59. func NewOrderNotice(c *gin.Context) {
  60. sysCfgDb := db.SysCfgDb{}
  61. sysCfgDb.Set()
  62. cfg, _ := sysCfgDb.SysCfgGetOne("has_new_order")
  63. res := map[string]string{
  64. "has_new_order": "0",
  65. }
  66. if cfg != nil {
  67. res["has_new_order"] = cfg.Val
  68. cfg.Val = "0"
  69. db.Db.Where("`key`=?", "has_new_order").Update(cfg)
  70. }
  71. e.OutSuc(c, res, nil)
  72. return
  73. }
  74. func NewOrderInfoNotice(c *gin.Context) {
  75. var data []model.OrderGoods
  76. db.Db.Where("is_new=1").Find(&data)
  77. sysCfgDb := db.SysCfgDb{}
  78. sysCfgDb.Set()
  79. cfg, _ := sysCfgDb.SysCfgGetOne("new_order_notice")
  80. str := ""
  81. if cfg != nil {
  82. str = cfg.Val
  83. }
  84. skuDatas := make(map[int64]map[int]map[string]string, 0)
  85. for _, v := range data {
  86. _, ok := skuDatas[v.SkuId]
  87. if ok == false {
  88. skuDatas[v.SkuId] = make(map[int]map[string]string)
  89. }
  90. _, ok1 := skuDatas[v.SkuId][v.GoodsType]
  91. if ok1 == false {
  92. skuDatas[v.SkuId][v.GoodsType] = make(map[string]string)
  93. }
  94. skuDatas[v.SkuId][v.GoodsType]["goods_title"] = v.GoodsTitle
  95. skuDatas[v.SkuId][v.GoodsType]["sku"] = v.Sku
  96. skuDatas[v.SkuId][v.GoodsType]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId][v.GoodsType]["count"]) + v.Num)
  97. }
  98. res := make([]map[string]string, 0)
  99. for _, v := range skuDatas {
  100. for _, v1 := range v {
  101. skuData := make([]md.Sku, 0)
  102. json.Unmarshal([]byte(v1["sku"]), &skuData)
  103. skuStr := ""
  104. for _, v2 := range skuData {
  105. if skuStr != "" {
  106. skuStr += ";"
  107. }
  108. skuStr += v2.Value
  109. }
  110. tip := str
  111. tip = strings.ReplaceAll(tip, "[商品名称]", v1["goods_title"])
  112. tip = strings.ReplaceAll(tip, "[规格]", skuStr)
  113. tip = strings.ReplaceAll(tip, "[数量]", v1["count"])
  114. tmp := map[string]string{
  115. "str": tip,
  116. }
  117. res = append(res, tmp)
  118. }
  119. }
  120. for _, v := range data {
  121. v.IsNew = 0
  122. db.Db.Where("id=?", v.Id).Cols("is_new").Update(&v)
  123. }
  124. e.OutSuc(c, res, nil)
  125. return
  126. }