面包店
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

128 wiersze
3.6 KiB

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