面包店
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

130 righe
3.6 KiB

  1. package svc
  2. import (
  3. "applet/app/admin/md"
  4. svc2 "applet/app/bigData/svc"
  5. "applet/app/db"
  6. "applet/app/e"
  7. "applet/app/svc"
  8. "applet/app/utils"
  9. "encoding/json"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func Order(c *gin.Context) {
  13. var args map[string]string
  14. if err := c.ShouldBindJSON(&args); err != nil {
  15. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  16. return
  17. }
  18. eg := db.Db
  19. args["now"] = svc2.CommDate()
  20. data, _ := db.GetOrderListByIpad(eg, args)
  21. list := make([]map[string]string, 0)
  22. if data != nil {
  23. enterpriseIds := make([]int, 0)
  24. for _, v := range *data {
  25. enterpriseIds = append(enterpriseIds, v.EnterpriseId)
  26. }
  27. enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
  28. stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
  29. btnArr := []string{"进入制作", "进入制作", "进入制作", "分拣完成", "查看详情", "已取消"}
  30. for _, v := range *data {
  31. enterpriseName := ""
  32. _, ok := enterpriseMap[v.EnterpriseId]
  33. if ok {
  34. enterpriseName = enterpriseMap[v.EnterpriseId].Name
  35. }
  36. var tmp = map[string]string{
  37. "oid": utils.Int64ToStr(v.Oid),
  38. "make_date": utils.TimeParseDateStd1(v.MakeDate),
  39. "id": utils.IntToStr(v.Id),
  40. "state_str": stateArr[v.State],
  41. "btn_str": btnArr[v.State],
  42. "state": utils.IntToStr(v.State),
  43. "enterprise_name": enterpriseName,
  44. "time": v.CreateAt.Format("2006-01-02 15:04:05"),
  45. }
  46. list = append(list, tmp)
  47. }
  48. }
  49. e.OutSuc(c, list, nil)
  50. return
  51. }
  52. func StateOrder(c *gin.Context) {
  53. var args map[string]string
  54. if err := c.ShouldBindJSON(&args); err != nil {
  55. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  56. return
  57. }
  58. eg := db.Db
  59. data, _ := db.GetOrderGoodsMakeStockByIpad(eg, args)
  60. list := make([]map[string]string, 0)
  61. if data != nil {
  62. gids := make([]int64, 0)
  63. for _, v := range *data {
  64. gids = append(gids, v.Gid)
  65. }
  66. goodsMap := db.GetGoodsMore(eg, gids)
  67. scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
  68. var tmpMap interface{}
  69. for _, v := range *data {
  70. var tmp = map[string]string{
  71. "id": utils.IntToStr(v.Id),
  72. "gid": utils.Int64ToStr(v.Gid),
  73. "sku_id": utils.Int64ToStr(v.SkuId),
  74. "make_date": utils.TimeParseDateStd1(v.MakeDate),
  75. "num": "",
  76. "state_str": "",
  77. "btn_str": "",
  78. "goods_title": v.GoodsTitle,
  79. "goods_img": "",
  80. "state": "",
  81. }
  82. if args["state"] == "1" {
  83. tmp["num"] = utils.IntToStr(v.WaitMakeNum)
  84. tmp["state_str"] = "制作中"
  85. tmp["btn_str"] = "制作完成"
  86. tmp["state"] = "1"
  87. }
  88. if args["state"] == "2" {
  89. tmp["num"] = utils.IntToStr(v.WaitBakingNum)
  90. tmp["state_str"] = "烘焙中"
  91. tmp["btn_str"] = "烘焙完成"
  92. tmp["state"] = "2"
  93. }
  94. if args["state"] == "3" {
  95. tmp["num"] = utils.IntToStr(v.WaitSortingNum)
  96. tmp["state_str"] = "分拣中"
  97. tmp["btn_str"] = "分拣完成"
  98. tmp["state"] = "3"
  99. }
  100. // 商品主图
  101. if goodsMap[v.Gid].ImageList != "" {
  102. utils.Unserialize([]byte(goodsMap[v.Gid].ImageList), &tmpMap)
  103. var imageListUrlTmp []string
  104. for _, v1 := range tmpMap.([]interface{}) {
  105. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v1.(string)))
  106. }
  107. if imageListUrlTmp != nil {
  108. tmp["goods_img"] = imageListUrlTmp[0]
  109. }
  110. }
  111. skuData := make([]md.Sku, 0)
  112. json.Unmarshal([]byte(v.Sku), &skuData)
  113. skuStr := ""
  114. for _, v1 := range skuData {
  115. if skuStr != "" {
  116. skuStr += ";"
  117. }
  118. skuStr += v1.Value
  119. }
  120. tmp["sku_str"] = skuStr
  121. list = append(list, tmp)
  122. }
  123. }
  124. e.OutSuc(c, list, nil)
  125. return
  126. }