|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package hdl
-
- import (
- "applet/app/admin/md"
- "applet/app/bigData/svc"
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/e"
- "applet/app/utils"
- "encoding/json"
- "github.com/gin-gonic/gin"
- "strings"
- )
-
- func MakingData(c *gin.Context) {
- args := map[string]string{
- "state": "1",
- }
- svc.CommMakingData(c, args)
- }
- func BakingData(c *gin.Context) {
- args := map[string]string{
- "state": "2",
- }
- svc.CommMakingData(c, args)
- }
- func SortingData(c *gin.Context) {
- result, err := svc.LeftDataForSorting()
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, result, nil)
- return
- }
- func NewSortingCate(c *gin.Context) {
- result := svc.NewSortingCate()
-
- e.OutSuc(c, result, nil)
- return
- }
- func NewSortingData(c *gin.Context) {
- result := svc.NewSortingData(c)
-
- e.OutSuc(c, result, nil)
- return
- }
- func NewOrderNotice(c *gin.Context) {
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- cfg, _ := sysCfgDb.SysCfgGetOne("has_new_order")
- res := map[string]string{
- "has_new_order": "0",
- }
- if cfg != nil {
- res["has_new_order"] = cfg.Val
- cfg.Val = "0"
- db.Db.Where("`key`=?", "has_new_order").Update(cfg)
- }
- e.OutSuc(c, res, nil)
- return
- }
- func NewOrderInfoNotice(c *gin.Context) {
- var data []model.OrderGoods
- db.Db.Where("is_new=1").Find(&data)
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- cfg, _ := sysCfgDb.SysCfgGetOne("new_order_notice")
- str := ""
- if cfg != nil {
- str = cfg.Val
- }
- skuDatas := make(map[int64]map[int]map[string]string, 0)
- for _, v := range data {
- _, ok := skuDatas[v.SkuId]
- if ok == false {
- skuDatas[v.SkuId] = make(map[int]map[string]string)
- }
- _, ok1 := skuDatas[v.SkuId][v.GoodsType]
- if ok1 == false {
- skuDatas[v.SkuId][v.GoodsType] = make(map[string]string)
- }
- skuDatas[v.SkuId][v.GoodsType]["goods_title"] = v.GoodsTitle
- skuDatas[v.SkuId][v.GoodsType]["sku"] = v.Sku
- skuDatas[v.SkuId][v.GoodsType]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId][v.GoodsType]["count"]) + v.Num)
- }
- res := make([]map[string]string, 0)
- for _, v := range skuDatas {
- for _, v1 := range v {
- skuData := make([]md.Sku, 0)
- json.Unmarshal([]byte(v1["sku"]), &skuData)
- skuStr := ""
- for _, v2 := range skuData {
- if skuStr != "" {
- skuStr += ";"
- }
- skuStr += v2.Value
- }
- tip := str
- tip = strings.ReplaceAll(tip, "[商品名称]", v1["goods_title"])
- tip = strings.ReplaceAll(tip, "[规格]", skuStr)
- tip = strings.ReplaceAll(tip, "[数量]", v1["count"])
- tmp := map[string]string{
- "str": tip,
- }
- res = append(res, tmp)
- }
- }
- for _, v := range data {
- v.IsNew = 0
- db.Db.Where("id=?", v.Id).Cols("is_new").Update(&v)
- }
- e.OutSuc(c, res, nil)
- return
- }
|