面包店
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

hdl_making_data.go 3.0 KiB

há 6 meses
há 4 meses
há 6 meses
há 6 meses
há 4 meses
há 6 meses
há 4 meses
há 6 meses
há 6 meses
há 7 meses
há 6 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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(c)
  36. e.OutSuc(c, result, nil)
  37. return
  38. }
  39. func NewSortingGoodsCate(c *gin.Context) {
  40. result := svc.NewSortingGoodsCate(c)
  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(c, 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. now := svc.CommDate()
  77. db.Db.Where("is_new=1 and make_date=?", now).Find(&data)
  78. sysCfgDb := db.SysCfgDb{}
  79. sysCfgDb.Set()
  80. cfg, _ := sysCfgDb.SysCfgGetOne("new_order_notice")
  81. str := ""
  82. if cfg != nil {
  83. str = cfg.Val
  84. }
  85. skuDatas := make(map[int64]map[int]map[string]string, 0)
  86. for _, v := range data {
  87. _, ok := skuDatas[v.SkuId]
  88. if ok == false {
  89. skuDatas[v.SkuId] = make(map[int]map[string]string)
  90. }
  91. _, ok1 := skuDatas[v.SkuId][v.GoodsType]
  92. if ok1 == false {
  93. skuDatas[v.SkuId][v.GoodsType] = make(map[string]string)
  94. }
  95. skuDatas[v.SkuId][v.GoodsType]["goods_title"] = v.GoodsTitle
  96. skuDatas[v.SkuId][v.GoodsType]["sku"] = v.Sku
  97. skuDatas[v.SkuId][v.GoodsType]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId][v.GoodsType]["count"]) + v.Num)
  98. }
  99. res := make([]map[string]string, 0)
  100. for _, v := range skuDatas {
  101. for _, v1 := range v {
  102. skuData := make([]md.Sku, 0)
  103. json.Unmarshal([]byte(v1["sku"]), &skuData)
  104. skuStr := ""
  105. for _, v2 := range skuData {
  106. if skuStr != "" {
  107. skuStr += ";"
  108. }
  109. skuStr += v2.Value
  110. }
  111. tip := str
  112. tip = strings.ReplaceAll(tip, "[商品名称]", v1["goods_title"])
  113. tip = strings.ReplaceAll(tip, "[规格]", skuStr)
  114. tip = strings.ReplaceAll(tip, "[数量]", v1["count"])
  115. tmp := map[string]string{
  116. "str": tip,
  117. }
  118. res = append(res, tmp)
  119. }
  120. }
  121. for _, v := range data {
  122. v.IsNew = 0
  123. db.Db.Where("id=?", v.Id).Cols("is_new").Update(&v)
  124. }
  125. e.OutSuc(c, res, nil)
  126. return
  127. }