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

82 lines
2.2 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. "state_str": stateArr[v.State],
  47. "btn_str": btnArr[v.State],
  48. "goods_title": v.GoodsTitle,
  49. "goods_img": "",
  50. "state": utils.IntToStr(v.State),
  51. }
  52. // 商品主图
  53. if goodsMap[v.GoodsId].ImageList != "" {
  54. utils.Unserialize([]byte(goodsMap[v.GoodsId].ImageList), &tmpMap)
  55. var imageListUrlTmp []string
  56. for _, v := range tmpMap.([]interface{}) {
  57. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
  58. }
  59. if imageListUrlTmp != nil {
  60. tmp["goods_img"] = imageListUrlTmp[0]
  61. }
  62. }
  63. skuData := make([]md.Sku, 0)
  64. json.Unmarshal([]byte(v.Sku), &skuData)
  65. skuStr := ""
  66. for _, v1 := range skuData {
  67. if skuStr != "" {
  68. skuStr += ";"
  69. }
  70. skuStr += v1.Value
  71. }
  72. tmp["sku_str"] = skuStr
  73. list = append(list, tmp)
  74. }
  75. }
  76. e.OutSuc(c, list, nil)
  77. return
  78. }