面包店
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.

svc_order.go 3.4 KiB

9 mesi fa
9 mesi fa
9 mesi fa
9 mesi fa
9 mesi fa
8 mesi fa
9 mesi fa
9 mesi fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. "id": utils.IntToStr(v.Id),
  37. "state_str": stateArr[v.State],
  38. "btn_str": btnArr[v.State],
  39. "state": utils.IntToStr(v.State),
  40. "enterprise_name": enterpriseName,
  41. "time": v.CreateAt.Format("2006-01-02 15:04:05"),
  42. }
  43. list = append(list, tmp)
  44. }
  45. }
  46. e.OutSuc(c, list, nil)
  47. return
  48. }
  49. func StateOrder(c *gin.Context) {
  50. var args map[string]string
  51. if err := c.ShouldBindJSON(&args); err != nil {
  52. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  53. return
  54. }
  55. eg := db.Db
  56. data, _ := db.GetOrderGoodsMakeStockByIpad(eg, args)
  57. list := make([]map[string]string, 0)
  58. if data != nil {
  59. gids := make([]int64, 0)
  60. for _, v := range *data {
  61. gids = append(gids, v.Gid)
  62. }
  63. goodsMap := db.GetGoodsMore(eg, gids)
  64. scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
  65. var tmpMap interface{}
  66. for _, v := range *data {
  67. var tmp = map[string]string{
  68. "id": utils.IntToStr(v.Id),
  69. "gid": utils.Int64ToStr(v.Gid),
  70. "sku_id": utils.Int64ToStr(v.SkuId),
  71. "num": "",
  72. "state_str": "",
  73. "btn_str": "",
  74. "goods_title": v.GoodsTitle,
  75. "goods_img": "",
  76. "state": "",
  77. }
  78. if args["state"] == "1" {
  79. tmp["num"] = utils.IntToStr(v.WaitMakeNum)
  80. tmp["state_str"] = "制作中"
  81. tmp["btn_str"] = "制作完成"
  82. tmp["state"] = "1"
  83. }
  84. if args["state"] == "2" {
  85. tmp["num"] = utils.IntToStr(v.WaitBakingNum)
  86. tmp["state_str"] = "烘焙中"
  87. tmp["btn_str"] = "烘焙完成"
  88. tmp["state"] = "2"
  89. }
  90. if args["state"] == "3" {
  91. tmp["num"] = utils.IntToStr(v.WaitSortingNum)
  92. tmp["state_str"] = "分拣中"
  93. tmp["btn_str"] = "分拣完成"
  94. tmp["state"] = "3"
  95. }
  96. // 商品主图
  97. if goodsMap[v.Gid].ImageList != "" {
  98. utils.Unserialize([]byte(goodsMap[v.Gid].ImageList), &tmpMap)
  99. var imageListUrlTmp []string
  100. for _, v := range tmpMap.([]interface{}) {
  101. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
  102. }
  103. if imageListUrlTmp != nil {
  104. tmp["goods_img"] = imageListUrlTmp[0]
  105. }
  106. }
  107. skuData := make([]md.Sku, 0)
  108. json.Unmarshal([]byte(v.Sku), &skuData)
  109. skuStr := ""
  110. for _, v1 := range skuData {
  111. if skuStr != "" {
  112. skuStr += ";"
  113. }
  114. skuStr += v1.Value
  115. }
  116. tmp["sku_str"] = skuStr
  117. list = append(list, tmp)
  118. }
  119. }
  120. e.OutSuc(c, list, nil)
  121. return
  122. }