面包店
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

hdl_making_data.go 2.2 KiB

pirms 7 mēnešiem
pirms 7 mēnešiem
pirms 7 mēnešiem
pirms 7 mēnešiem
pirms 7 mēnešiem
pirms 7 mēnešiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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[string]string, 0)
  60. for _, v := range data {
  61. _, ok := skuDatas[v.SkuId]
  62. if ok == false {
  63. skuDatas[v.SkuId] = make(map[string]string)
  64. }
  65. skuDatas[v.SkuId]["goods_title"] = v.GoodsTitle
  66. skuDatas[v.SkuId]["sku"] = v.Sku
  67. skuDatas[v.SkuId]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId]["count"]) + v.Num)
  68. }
  69. res := make([]map[string]string, 0)
  70. for _, v := range skuDatas {
  71. skuData := make([]md.Sku, 0)
  72. json.Unmarshal([]byte(v["sku"]), &skuData)
  73. skuStr := ""
  74. for _, v1 := range skuData {
  75. if skuStr != "" {
  76. skuStr += ";"
  77. }
  78. skuStr += v1.Value
  79. }
  80. tip := str
  81. tip = strings.ReplaceAll(tip, "[商品名称]", v["goods_title"])
  82. tip = strings.ReplaceAll(tip, "[规格]", skuStr)
  83. tip = strings.ReplaceAll(tip, "[数量]", v["count"])
  84. tmp := map[string]string{
  85. "str": tip,
  86. }
  87. res = append(res, tmp)
  88. }
  89. for _, v := range data {
  90. v.IsNew = 0
  91. db.Db.Where("id=?", v.Id).Cols("is_new").Update(&v)
  92. }
  93. e.OutSuc(c, res, nil)
  94. return
  95. }