Browse Source

更新

master
huangjiajun 4 months ago
parent
commit
e0e6a1c847
3 changed files with 45 additions and 17 deletions
  1. +3
    -3
      app/bigData/hdl/hdl_making_data.go
  2. +40
    -12
      app/bigData/svc/svc_data.go
  3. +2
    -2
      app/router/big_data_router.go

+ 3
- 3
app/bigData/hdl/hdl_making_data.go View File

@@ -34,14 +34,14 @@ func SortingData(c *gin.Context) {
return return
} }
func NewSortingCate(c *gin.Context) { func NewSortingCate(c *gin.Context) {
result := svc.NewSortingCate()
result := svc.NewSortingCate(c)


e.OutSuc(c, result, nil) e.OutSuc(c, result, nil)
return return
} }
func NewSortingGoodsCate(c *gin.Context) { func NewSortingGoodsCate(c *gin.Context) {


result := svc.NewSortingGoodsCate()
result := svc.NewSortingGoodsCate(c)


e.OutSuc(c, result, nil) e.OutSuc(c, result, nil)
return return
@@ -52,7 +52,7 @@ func NewSortingGoodsData(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err) e.OutErr(c, e.ERR_INVALID_ARGS, err)
return return
} }
result := svc.NewSortingGoodsData(arg)
result := svc.NewSortingGoodsData(c, arg)


e.OutSuc(c, result, nil) e.OutSuc(c, result, nil)
return return


+ 40
- 12
app/bigData/svc/svc_data.go View File

@@ -408,23 +408,35 @@ func RightDataForSorting(req md.RightDataForMakeReq) (resp []md.RightDataForMake
return return
} }


func NewSortingCate() []map[string]string {
func NewSortingCate(c *gin.Context) []map[string]string {
engine := db.Db engine := db.Db
res := make([]map[string]string, 0) res := make([]map[string]string, 0)
var args = make(map[string]string)
c.ShouldBindJSON(&args)
var enterprise []model.Enterprise var enterprise []model.Enterprise
err := engine.Where("1=1").Find(&enterprise)
sess := engine.Where("1=1")
if args["name"] != "" {
sess.And("name like ? or inside_name like ?", "%"+args["name"]+"%", "%"+args["name"]+"%")
}
err := sess.Find(&enterprise)
if err != nil { if err != nil {
return res return res
} }
var enterpriseMap = map[int]model.Enterprise{} var enterpriseMap = map[int]model.Enterprise{}
enterpriseId := []int{-1}
for _, v := range enterprise { for _, v := range enterprise {
enterpriseMap[v.Id] = v enterpriseMap[v.Id] = v
enterpriseId = append(enterpriseId, v.Id)
} }


//1、查找不等于4 5 //1、查找不等于4 5
now := CommDate() now := CommDate()
var orders []model.Order var orders []model.Order
err = engine.Where(" state != 4 and state != 5 and make_date=?", now).Find(&orders)
sess1 := engine.Where(" state != 4 and state != 5 and make_date=?", now)
if args["name"] != "" {
sess1.In("enterprise_id", enterpriseId)
}
err = sess1.Find(&orders)
if err != nil { if err != nil {
return res return res
} }
@@ -477,8 +489,12 @@ func NewSortingData(c *gin.Context) []map[string]string {
} }
oIds = append(oIds, utils.Int64ToStr(v.Oid)) oIds = append(oIds, utils.Int64ToStr(v.Oid))
} }
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku FROM order_goods WHERE oid in (%s) and make_date=%s and goods_type=0 GROUP BY enterprise_id,goods_id,sku_id`
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), now)
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku FROM order_goods WHERE %s oid in (%s) and make_date=%s and goods_type=0 GROUP BY enterprise_id,goods_id,sku_id`
str := ""
if args["name"] != "" {
str = " goods_title like %" + args["name"] + "% and "
}
sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now)
nativeString, err := db.QueryNativeString(engine, sql) nativeString, err := db.QueryNativeString(engine, sql)
for _, v := range nativeString { for _, v := range nativeString {
skuData := make([]md2.Sku, 0) skuData := make([]md2.Sku, 0)
@@ -506,13 +522,16 @@ func NewSortingData(c *gin.Context) []map[string]string {
} }
return res return res
} }
func NewSortingGoodsCate() []map[string]string {
func NewSortingGoodsCate(c *gin.Context) []map[string]string {
res := make([]map[string]string, 0) res := make([]map[string]string, 0)


engine := db.Db engine := db.Db
//1、查找不等于4 5 //1、查找不等于4 5
now := CommDate() now := CommDate()
var orders []model.Order var orders []model.Order
var args = make(map[string]string)
c.ShouldBindJSON(&args)

err := engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) err := engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders)
if err != nil { if err != nil {
return res return res
@@ -525,8 +544,12 @@ func NewSortingGoodsCate() []map[string]string {
} }
oIds = append(oIds, utils.Int64ToStr(v.Oid)) oIds = append(oIds, utils.Int64ToStr(v.Oid))
} }
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id`
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), now)
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE %s oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id`
str := ""
if args["name"] != "" {
str = " goods_title like %" + args["name"] + "% and "
}
sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now)
nativeString, err := db.QueryNativeString(engine, sql) nativeString, err := db.QueryNativeString(engine, sql)
for _, v := range nativeString { for _, v := range nativeString {
skuData := make([]md2.Sku, 0) skuData := make([]md2.Sku, 0)
@@ -556,7 +579,7 @@ func NewSortingGoodsCate() []map[string]string {
} }
return res return res
} }
func NewSortingGoodsData(arg map[string]string) []map[string]string {
func NewSortingGoodsData(c *gin.Context, arg map[string]string) []map[string]string {


engine := db.Db engine := db.Db
res := make([]map[string]string, 0) res := make([]map[string]string, 0)
@@ -571,7 +594,8 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string {
} }
//1、查找不等于4 5 //1、查找不等于4 5
now := CommDate() now := CommDate()

var args = make(map[string]string)
c.ShouldBindJSON(&args)
var orders []model.Order var orders []model.Order
err = engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) err = engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders)
if err != nil { if err != nil {
@@ -585,8 +609,12 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string {
} }
oIds = append(oIds, utils.Int64ToStr(v.Oid)) oIds = append(oIds, utils.Int64ToStr(v.Oid))
} }
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id ORDER BY id asc`
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now)
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE %s oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id ORDER BY id asc`
str := ""
if args["name"] != "" {
str = " goods_title like %" + args["name"] + "% and "
}
sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now)
nativeString, err := db.QueryNativeString(engine, sql) nativeString, err := db.QueryNativeString(engine, sql)
for _, v := range nativeString { for _, v := range nativeString {
skuData := make([]md2.Sku, 0) skuData := make([]md2.Sku, 0)


+ 2
- 2
app/router/big_data_router.go View File

@@ -25,10 +25,10 @@ func rData(r *gin.RouterGroup) {
r.GET("/new_order_notice", hdl.NewOrderNotice) //新订单提醒 r.GET("/new_order_notice", hdl.NewOrderNotice) //新订单提醒
r.GET("/new_order_info_notice", hdl.NewOrderInfoNotice) //新订单提醒 r.GET("/new_order_info_notice", hdl.NewOrderInfoNotice) //新订单提醒


r.GET("/new_sorting_cate", hdl.NewSortingCate) //分拣区学校分类
r.Any("/new_sorting_cate", hdl.NewSortingCate) //分拣区学校分类
r.POST("/new_sorting_data", hdl.NewSortingData) //分拣区数据 r.POST("/new_sorting_data", hdl.NewSortingData) //分拣区数据


r.GET("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品
r.Any("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品
r.POST("/new_sorting_goods_data", hdl.NewSortingGoodsData) //分拣区 按商品 数据 r.POST("/new_sorting_goods_data", hdl.NewSortingGoodsData) //分拣区 按商品 数据
r.GET("/notice", hdl.Notice) r.GET("/notice", hdl.Notice)
} }

Loading…
Cancel
Save