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

126 righe
3.5 KiB

  1. package hdl
  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 OrderGoodsCate(c *gin.Context) {
  12. var res = []map[string]string{
  13. {"name": "全部", "id": ""},
  14. //{"name": "待制作", "id": "0"},
  15. {"name": "制作中", "id": "1"},
  16. {"name": "待烘焙", "id": "2"},
  17. {"name": "已完成", "id": "3"},
  18. }
  19. e.OutSuc(c, res, nil)
  20. return
  21. }
  22. func OrderGoods(c *gin.Context) {
  23. var args map[string]string
  24. if err := c.ShouldBindJSON(&args); err != nil {
  25. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  26. return
  27. }
  28. eg := db.Db
  29. data, _ := db.GetOrderGoodsListByIpad(eg, args)
  30. list := make([]map[string]string, 0)
  31. if data != nil {
  32. gids := make([]int64, 0)
  33. for _, v := range *data {
  34. gids = append(gids, v.GoodsId)
  35. }
  36. goodsMap := db.GetGoodsMore(eg, gids)
  37. scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
  38. var tmpMap interface{}
  39. stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
  40. btnArr := []string{"开始制作", "制作完成", "烘焙完成", "已完成", "已完成", "已取消"}
  41. for _, v := range *data {
  42. var tmp = map[string]string{
  43. "oid": utils.Int64ToStr(v.Oid),
  44. "id": utils.IntToStr(v.Id),
  45. "num": utils.IntToStr(v.Num),
  46. "make_date": utils.TimeParseDateStd1(v.MakeDate),
  47. "success_num": utils.IntToStr(v.SuccessNum),
  48. "state_str": stateArr[v.State],
  49. "btn_str": btnArr[v.State],
  50. "goods_title": v.GoodsTitle,
  51. "goods_img": "",
  52. "state": utils.IntToStr(v.State),
  53. }
  54. // 商品主图
  55. if goodsMap[v.GoodsId].ImageList != "" {
  56. utils.Unserialize([]byte(goodsMap[v.GoodsId].ImageList), &tmpMap)
  57. var imageListUrlTmp []string
  58. for _, v := range tmpMap.([]interface{}) {
  59. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
  60. }
  61. if imageListUrlTmp != nil {
  62. tmp["goods_img"] = imageListUrlTmp[0]
  63. }
  64. }
  65. skuData := make([]md.Sku, 0)
  66. json.Unmarshal([]byte(v.Sku), &skuData)
  67. skuStr := ""
  68. for _, v1 := range skuData {
  69. if skuStr != "" {
  70. skuStr += ";"
  71. }
  72. skuStr += v1.Value
  73. }
  74. tmp["sku_str"] = skuStr
  75. list = append(list, tmp)
  76. }
  77. }
  78. e.OutSuc(c, list, nil)
  79. return
  80. }
  81. func SortingOrderGoods(c *gin.Context) {
  82. var args map[string]string
  83. if err := c.ShouldBindJSON(&args); err != nil {
  84. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  85. return
  86. }
  87. eg := db.Db
  88. args["sorting"] = "1"
  89. data, _ := db.GetOrderGoodsListByIpad(eg, args)
  90. list := make([]map[string]string, 0)
  91. if data != nil {
  92. enterpriseIds := make([]int, 0)
  93. for _, v := range *data {
  94. enterpriseIds = append(enterpriseIds, v.EnterpriseId)
  95. }
  96. enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
  97. gids := make([]int64, 0)
  98. for _, v := range *data {
  99. gids = append(gids, v.GoodsId)
  100. }
  101. for _, v := range *data {
  102. enterpriseName := ""
  103. _, ok := enterpriseMap[v.EnterpriseId]
  104. if ok {
  105. enterpriseName = enterpriseMap[v.EnterpriseId].Name
  106. }
  107. var tmp = map[string]string{
  108. "oid": utils.Int64ToStr(v.Oid),
  109. "id": utils.IntToStr(v.Id),
  110. "num": utils.IntToStr(v.Num),
  111. "success_num": utils.IntToStr(v.SuccessNum),
  112. "need_num": utils.IntToStr(v.Num - v.SuccessNum),
  113. "enterprise_name": enterpriseName,
  114. "make_date": utils.TimeParseDateStd1(v.MakeDate),
  115. }
  116. list = append(list, tmp)
  117. }
  118. }
  119. e.OutSuc(c, list, nil)
  120. return
  121. }