|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package svc
-
- import (
- "applet/app/admin/md"
- "applet/app/db"
- "applet/app/e"
- "applet/app/utils"
- "encoding/json"
- "github.com/gin-gonic/gin"
- )
-
- func MarkRecord(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
- list, total := db.GetOrderGoodsDoingList(eg, args)
- data := make([]map[string]string, 0)
- if list != nil {
- stateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
- enterpriseIds := make([]int, 0)
- adminIds := make([]int, 0)
- for _, v := range *list {
- enterpriseIds = append(enterpriseIds, v.EnterpriseId)
- adminIds = append(adminIds, v.AdminId)
- }
- enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds)
- adminMap := db.GetStaffMore(eg, adminIds)
-
- for _, v := range *list {
- enterpriseName := ""
- adminName := ""
- _, ok := enterpriseMap[v.EnterpriseId]
- if ok {
- enterpriseName = enterpriseMap[v.EnterpriseId].Name
- }
- _, ok1 := adminMap[v.AdminId]
- if ok1 {
- adminName = adminMap[v.AdminId].Name
- }
-
- var tmp = map[string]string{
- "oid": utils.Int64ToStr(v.Oid),
- "id": utils.IntToStr(v.Id),
- "state_str": stateArr[v.State],
- "state": utils.IntToStr(v.State),
- "time": v.Time.Format("2006-01-02 15:04:05"),
- "enterprise_name": enterpriseName,
- "sku_str": "",
- "goods_title": v.GoodsTitle,
- "memo": v.Memo,
- "admin_name": adminName,
- "num": utils.IntToStr(v.Num),
- "success_num": utils.IntToStr(v.SuccessNum),
- }
- skuData := make([]md.Sku, 0)
- json.Unmarshal([]byte(v.Sku), &skuData)
- skuStr := ""
- for _, v1 := range skuData {
- if skuStr != "" {
- skuStr += ";"
- }
- skuStr += v1.Value
- }
- tmp["sku_str"] = skuStr
- data = append(data, tmp)
- }
- }
- enterpriseList := db.GetEnterpriseList(eg)
- enterpriseData := make([]map[string]string, 0)
- if enterpriseList != nil {
- for _, v := range *enterpriseList {
- var tmp = map[string]string{
- "id": utils.IntToStr(v.Id),
- "name": v.Name,
- }
- enterpriseData = append(enterpriseData, tmp)
- }
- }
- res := map[string]interface{}{
- "total": total,
- "enterprise": enterpriseData,
- "list": data,
- }
- e.OutSuc(c, res, nil)
- return
- }
- func MarkRecordFlow(c *gin.Context) {
-
- }
|