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

93 lines
2.4 KiB

  1. package svc
  2. import (
  3. "applet/app/admin/md"
  4. "applet/app/db"
  5. "applet/app/e"
  6. "applet/app/utils"
  7. "encoding/json"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func MarkRecord(c *gin.Context) {
  11. var args map[string]string
  12. if err := c.ShouldBindJSON(&args); err != nil {
  13. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  14. return
  15. }
  16. eg := db.Db
  17. list, total := db.GetOrderGoodsDoingList(eg, args)
  18. data := make([]map[string]string, 0)
  19. if list != nil {
  20. stateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  21. enterpriseIds := make([]int, 0)
  22. adminIds := make([]int, 0)
  23. for _, v := range *list {
  24. enterpriseIds = append(enterpriseIds, v.EnterpriseId)
  25. adminIds = append(adminIds, v.AdminId)
  26. }
  27. enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
  28. adminMap := db.GetStaffMore(eg, adminIds)
  29. for _, v := range *list {
  30. enterpriseName := ""
  31. adminName := ""
  32. _, ok := enterpriseMap[v.EnterpriseId]
  33. if ok {
  34. enterpriseName = enterpriseMap[v.EnterpriseId].Name
  35. }
  36. _, ok1 := adminMap[v.AdminId]
  37. if ok1 {
  38. adminName = adminMap[v.AdminId].Name
  39. }
  40. var tmp = map[string]string{
  41. "oid": utils.Int64ToStr(v.Oid),
  42. "id": utils.IntToStr(v.Id),
  43. "state_str": stateArr[v.State],
  44. "state": utils.IntToStr(v.State),
  45. "time": v.Time.Format("2006-01-02 15:04:05"),
  46. "enterprise_name": enterpriseName,
  47. "sku_str": "",
  48. "goods_title": v.GoodsTitle,
  49. "memo": v.Memo,
  50. "admin_name": adminName,
  51. "num": utils.IntToStr(v.Num),
  52. "success_num": utils.IntToStr(v.SuccessNum),
  53. }
  54. skuData := make([]md.Sku, 0)
  55. json.Unmarshal([]byte(v.Sku), &skuData)
  56. skuStr := ""
  57. for _, v1 := range skuData {
  58. if skuStr != "" {
  59. skuStr += ";"
  60. }
  61. skuStr += v1.Value
  62. }
  63. tmp["sku_str"] = skuStr
  64. data = append(data, tmp)
  65. }
  66. }
  67. enterpriseList := db.GetEnterpriseList(eg)
  68. enterpriseData := make([]map[string]string, 0)
  69. if enterpriseList != nil {
  70. for _, v := range *enterpriseList {
  71. var tmp = map[string]string{
  72. "id": utils.IntToStr(v.Id),
  73. "name": v.Name,
  74. }
  75. enterpriseData = append(enterpriseData, tmp)
  76. }
  77. }
  78. res := map[string]interface{}{
  79. "total": total,
  80. "enterprise": enterpriseData,
  81. "list": data,
  82. }
  83. e.OutSuc(c, res, nil)
  84. return
  85. }
  86. func MarkRecordFlow(c *gin.Context) {
  87. }