@@ -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)