|
- 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),
- "success_num": utils.IntToStr(v.SuccessNum),
- "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
- }
- func SortingOrderGoods(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
- args["sorting"] = "1"
- data, _ := db.GetOrderGoodsListByIpad(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)
- gids := make([]int64, 0)
- for _, v := range *data {
- gids = append(gids, v.GoodsId)
- }
- 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),
- "num": utils.IntToStr(v.Num),
- "success_num": utils.IntToStr(v.SuccessNum),
- "need_num": utils.IntToStr(v.Num - v.SuccessNum),
- "enterprise_name": enterpriseName,
- }
- list = append(list, tmp)
- }
- }
-
- e.OutSuc(c, list, nil)
- return
- }
|