package svc import ( "applet/app/admin/md" "applet/app/db" "applet/app/db/model" "applet/app/e" "applet/app/utils" "encoding/json" "github.com/gin-gonic/gin" "time" ) func CommMakingData(c *gin.Context, args map[string]string) { eg := db.Db args["now"] = CommDate() data, _ := db.GetOrderGoodsMakeStockByBigData(eg, args) list := make([]map[string]string, 0) if data != nil { for _, v := range *data { var tmp = map[string]string{ "num": "", "state_str": "", "goods_title": v.GoodsTitle, "state": "", } if args["state"] == "1" { tmp["num"] = utils.IntToStr(v.WaitMakeNum) tmp["state_str"] = "制作中" tmp["state"] = "1" if v.WaitMakeNum == 0 { tmp["state"] = "4" tmp["state_str"] = "制作完成" } if v.GoodsType == 2 { tmp["state"] = "4" tmp["state_str"] = "无需制作" } if v.GoodsType == 1 { //判断主单做完了就显示完成 count, _ := eg.Where("gid=? and sku_id=? and goods_type=0 and make_date=?", v.Gid, v.SkuId, v.MakeDate).Sum(&model.OrderGoodsMakeStock{}, "wait_make_num") if count == 0 { tmp["state"] = "4" tmp["state_str"] = "制作完成" } } } if args["state"] == "2" { tmp["num"] = utils.IntToStr(v.WaitBakingNum) tmp["state_str"] = "烘焙中" tmp["state"] = "2" if v.WaitBakingNum == 0 { tmp["state"] = "4" tmp["state_str"] = "烘焙完成" } } if args["state"] == "3" { tmp["num"] = utils.IntToStr(v.WaitSortingNum) tmp["state_str"] = "分拣中" tmp["state"] = "3" if v.WaitSortingNum == 0 { tmp["state"] = "4" tmp["state_str"] = "分拣完成" } } 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 list = append(list, tmp) } } e.OutSuc(c, list, nil) return } func CommDate() string { sysCfgDb := db.SysCfgDb{} sysCfgDb.Set() beforeHourShowOrder, _ := sysCfgDb.SysCfgGetOne("before_hour_show_order") today := utils.GetTimeRange("today") if utils.StrToInt(beforeHourShowOrder.Val) > time.Now().Hour() { today = utils.GetTimeRange("yesterday") } return time.Unix(today["start"], 0).Format("20060102") }