|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package svc
-
- import (
- "applet/app/admin/md"
- "applet/app/db"
- "applet/app/e"
- "applet/app/svc"
- "applet/app/utils"
- "encoding/json"
- "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,
- "time": v.CreateAt.Format("2006-01-02 15:04:05"),
- }
-
- list = append(list, tmp)
- }
- }
- e.OutSuc(c, list, nil)
- return
- }
-
- func StateOrder(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.GetOrderGoodsMakeStockByIpad(eg, args)
- list := make([]map[string]string, 0)
- if data != nil {
- gids := make([]int64, 0)
- for _, v := range *data {
- gids = append(gids, v.Gid)
- }
- goodsMap := db.GetGoodsMore(eg, gids)
- scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
- var tmpMap interface{}
- for _, v := range *data {
- var tmp = map[string]string{
- "id": utils.IntToStr(v.Id),
- "gid": utils.Int64ToStr(v.Gid),
- "sku_id": utils.Int64ToStr(v.SkuId),
- "num": "",
- "state_str": "",
- "btn_str": "",
- "goods_title": v.GoodsTitle,
- "goods_img": "",
- "state": "",
- }
- if args["state"] == "1" {
- tmp["num"] = utils.IntToStr(v.WaitMakeNum)
- tmp["state_str"] = "制作中"
- tmp["btn_str"] = "制作完成"
- tmp["state"] = "1"
- }
- if args["state"] == "2" {
- tmp["num"] = utils.IntToStr(v.WaitBakingNum)
- tmp["state_str"] = "烘焙中"
- tmp["btn_str"] = "烘焙完成"
- tmp["state"] = "2"
- }
- if args["state"] == "3" {
- tmp["num"] = utils.IntToStr(v.WaitSortingNum)
- tmp["state_str"] = "分拣中"
- tmp["btn_str"] = "分拣完成"
- tmp["state"] = "3"
- }
- // 商品主图
- if goodsMap[v.Gid].ImageList != "" {
- utils.Unserialize([]byte(goodsMap[v.Gid].ImageList), &tmpMap)
- var imageListUrlTmp []string
- for _, v := range tmpMap.([]interface{}) {
- imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string)))
- }
- if imageListUrlTmp != nil {
- tmp["goods_img"] = imageListUrlTmp[0]
- }
- }
- 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
- }
|