|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package hdl
-
- 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 OrderGoodsCate(c *gin.Context) {
- var res = []map[string]string{
- {"name": "全部", "id": ""},
- {"name": "待制作", "id": "0"},
- {"name": "制作中", "id": "1"},
- {"name": "待烘焙", "id": "2"},
- {"name": "已完成", "id": "3"},
- }
- e.OutSuc(c, res, nil)
- return
- }
- func OrderGoods(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.GetOrderGoodsListByIpad(eg, args)
- list := make([]map[string]string, 0)
- if data != nil {
- gids := make([]int64, 0)
- for _, v := range *data {
- gids = append(gids, v.GoodsId)
- }
- goodsMap := db.GetGoodsMore(eg, gids)
- scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c)
- var tmpMap interface{}
- stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"}
- btnArr := []string{"开始制作", "制作完成", "烘焙完成", "已完成", "已完成", "已取消"}
- for _, v := range *data {
- var tmp = map[string]string{
- "oid": utils.Int64ToStr(v.Oid),
- "id": utils.IntToStr(v.Id),
- "num": utils.IntToStr(v.Num),
- "state_str": stateArr[v.State],
- "btn_str": btnArr[v.State],
- "goods_title": v.GoodsTitle,
- "goods_img": "",
- "state": utils.IntToStr(v.State),
- }
- // 商品主图
- if goodsMap[v.GoodsId].ImageList != "" {
- utils.Unserialize([]byte(goodsMap[v.GoodsId].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
- }
|