面包店
Você não pode selecionar mais de 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.
 
 
 
 
 

134 linhas
3.7 KiB

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