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

48 rivejä
1.3 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/utils"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func Order(c *gin.Context) {
  9. var args map[string]string
  10. if err := c.ShouldBindJSON(&args); err != nil {
  11. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  12. return
  13. }
  14. eg := db.Db
  15. data, _ := db.GetOrderListByIpad(eg, args)
  16. list := make([]map[string]string, 0)
  17. if data != nil {
  18. enterpriseIds := make([]int, 0)
  19. for _, v := range *data {
  20. enterpriseIds = append(enterpriseIds, v.EnterpriseId)
  21. }
  22. enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
  23. stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
  24. btnArr := []string{"进入制作", "进入制作", "进入制作", "分拣完成", "查看详情", "已取消"}
  25. for _, v := range *data {
  26. enterpriseName := ""
  27. _, ok := enterpriseMap[v.EnterpriseId]
  28. if ok {
  29. enterpriseName = enterpriseMap[v.EnterpriseId].Name
  30. }
  31. var tmp = map[string]string{
  32. "oid": utils.Int64ToStr(v.Oid),
  33. "id": utils.IntToStr(v.Id),
  34. "state_str": stateArr[v.State],
  35. "btn_str": btnArr[v.State],
  36. "state": utils.IntToStr(v.State),
  37. "enterprise_name": enterpriseName,
  38. }
  39. list = append(list, tmp)
  40. }
  41. }
  42. e.OutSuc(c, list, nil)
  43. return
  44. }