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

71 lines
1.9 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 OrderGoods(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.GetOrderGoodsListByIpad(eg, args)
  19. list := make([]map[string]string, 0)
  20. if data != nil {
  21. gids := make([]int64, 0)
  22. for _, v := range *data {
  23. gids = append(gids, v.GoodsId)
  24. }
  25. goodsMap := db.GetGoodsMore(eg, gids)
  26. scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
  27. var tmpMap interface{}
  28. stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
  29. btnArr := []string{"开始制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  30. for _, v := range *data {
  31. var tmp = map[string]string{
  32. "oid": utils.Int64ToStr(v.Oid),
  33. "id": utils.IntToStr(v.Id),
  34. "num": utils.IntToStr(v.Num),
  35. "state_str": stateArr[v.State],
  36. "btn_str": btnArr[v.State],
  37. "goods_title": v.GoodsTitle,
  38. "goods_img": "",
  39. "state": utils.IntToStr(v.State),
  40. }
  41. // 商品主图
  42. if goodsMap[v.GoodsId].ImageList != "" {
  43. utils.Unserialize([]byte(goodsMap[v.GoodsId].ImageList), &tmpMap)
  44. var imageListUrlTmp []string
  45. for _, v := range tmpMap.([]interface{}) {
  46. imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
  47. }
  48. if imageListUrlTmp != nil {
  49. tmp["goods_img"] = imageListUrlTmp[0]
  50. }
  51. }
  52. skuData := make([]md.Sku, 0)
  53. json.Unmarshal([]byte(v.Sku), &skuData)
  54. skuStr := ""
  55. for _, v1 := range skuData {
  56. if skuStr != "" {
  57. skuStr += ";"
  58. }
  59. skuStr += v1.Value
  60. }
  61. tmp["sku_str"] = skuStr
  62. list = append(list, tmp)
  63. }
  64. }
  65. e.OutSuc(c, list, nil)
  66. return
  67. }