面包店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_order_goods.go 3.4 KiB

9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. "success_num": utils.IntToStr(v.SuccessNum),
  47. "state_str": stateArr[v.State],
  48. "btn_str": btnArr[v.State],
  49. "goods_title": v.GoodsTitle,
  50. "goods_img": "",
  51. "state": utils.IntToStr(v.State),
  52. }
  53. // 商品主图
  54. if goodsMap[v.GoodsId].ImageList != "" {
  55. utils.Unserialize([]byte(goodsMap[v.GoodsId].ImageList), &tmpMap)
  56. var imageListUrlTmp []string
  57. for _, v := range tmpMap.([]interface{}) {
  58. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
  59. }
  60. if imageListUrlTmp != nil {
  61. tmp["goods_img"] = imageListUrlTmp[0]
  62. }
  63. }
  64. skuData := make([]md.Sku, 0)
  65. json.Unmarshal([]byte(v.Sku), &skuData)
  66. skuStr := ""
  67. for _, v1 := range skuData {
  68. if skuStr != "" {
  69. skuStr += ";"
  70. }
  71. skuStr += v1.Value
  72. }
  73. tmp["sku_str"] = skuStr
  74. list = append(list, tmp)
  75. }
  76. }
  77. e.OutSuc(c, list, nil)
  78. return
  79. }
  80. func SortingOrderGoods(c *gin.Context) {
  81. var args map[string]string
  82. if err := c.ShouldBindJSON(&args); err != nil {
  83. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  84. return
  85. }
  86. eg := db.Db
  87. args["sorting"] = "1"
  88. data, _ := db.GetOrderGoodsListByIpad(eg, args)
  89. list := make([]map[string]string, 0)
  90. if data != nil {
  91. enterpriseIds := make([]int, 0)
  92. for _, v := range *data {
  93. enterpriseIds = append(enterpriseIds, v.EnterpriseId)
  94. }
  95. enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
  96. gids := make([]int64, 0)
  97. for _, v := range *data {
  98. gids = append(gids, v.GoodsId)
  99. }
  100. for _, v := range *data {
  101. enterpriseName := ""
  102. _, ok := enterpriseMap[v.EnterpriseId]
  103. if ok {
  104. enterpriseName = enterpriseMap[v.EnterpriseId].Name
  105. }
  106. var tmp = map[string]string{
  107. "oid": utils.Int64ToStr(v.Oid),
  108. "id": utils.IntToStr(v.Id),
  109. "num": utils.IntToStr(v.Num),
  110. "success_num": utils.IntToStr(v.SuccessNum),
  111. "need_num": utils.IntToStr(v.Num - v.SuccessNum),
  112. "enterprise_name": enterpriseName,
  113. }
  114. list = append(list, tmp)
  115. }
  116. }
  117. e.OutSuc(c, list, nil)
  118. return
  119. }