|
|
@@ -1,10 +1,15 @@ |
|
|
|
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) { |
|
|
@@ -43,3 +48,50 @@ func NewOrderNotice(c *gin.Context) { |
|
|
|
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[string]string, 0) |
|
|
|
for _, v := range data { |
|
|
|
_, ok := skuDatas[v.SkuId] |
|
|
|
if ok == false { |
|
|
|
skuDatas[v.SkuId] = make(map[string]string) |
|
|
|
} |
|
|
|
skuDatas[v.SkuId]["goods_title"] = v.GoodsTitle |
|
|
|
skuDatas[v.SkuId]["sku"] = v.Sku |
|
|
|
skuDatas[v.SkuId]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId]["count"]) + v.Num) |
|
|
|
} |
|
|
|
res := make([]map[string]string, 0) |
|
|
|
for _, v := range skuDatas { |
|
|
|
skuData := make([]md.Sku, 0) |
|
|
|
json.Unmarshal([]byte(v["sku"]), &skuData) |
|
|
|
skuStr := "" |
|
|
|
for _, v1 := range skuData { |
|
|
|
if skuStr != "" { |
|
|
|
skuStr += ";" |
|
|
|
} |
|
|
|
skuStr += v1.Value |
|
|
|
} |
|
|
|
tip := str |
|
|
|
tip = strings.ReplaceAll(tip, "[商品名称]", v["goods_title"]) |
|
|
|
tip = strings.ReplaceAll(tip, "[规格]", skuStr) |
|
|
|
tip = strings.ReplaceAll(tip, "[数量]", v["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 |
|
|
|
} |