|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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 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
- }
|