|
- package svc
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- )
-
- func Order(c *gin.Context) {
- var args map[string]string
- if err := c.ShouldBindJSON(&args); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- eg := db.Db
- data, _ := db.GetOrderListByIpad(eg, args)
- list := make([]map[string]string, 0)
- if data != nil {
- enterpriseIds := make([]int, 0)
- for _, v := range *data {
- enterpriseIds = append(enterpriseIds, v.EnterpriseId)
- }
- enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
- stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
- btnArr := []string{"进入制作", "进入制作", "进入制作", "分拣完成", "查看详情", "已取消"}
- for _, v := range *data {
- enterpriseName := ""
- _, ok := enterpriseMap[v.EnterpriseId]
- if ok {
- enterpriseName = enterpriseMap[v.EnterpriseId].Name
- }
- var tmp = map[string]string{
- "oid": utils.Int64ToStr(v.Oid),
- "id": utils.IntToStr(v.Id),
- "state_str": stateArr[v.State],
- "btn_str": btnArr[v.State],
- "state": utils.IntToStr(v.State),
- "enterprise_name": enterpriseName,
- }
-
- list = append(list, tmp)
- }
- }
- e.OutSuc(c, list, nil)
- return
- }
|