面包店
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

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