|
@@ -513,3 +513,116 @@ func NewSortingData(c *gin.Context) []map[string]string { |
|
|
} |
|
|
} |
|
|
return res |
|
|
return res |
|
|
} |
|
|
} |
|
|
|
|
|
func NewSortingGoodsCate() []map[string]string { |
|
|
|
|
|
res := make([]map[string]string, 0) |
|
|
|
|
|
|
|
|
|
|
|
engine := db.Db |
|
|
|
|
|
//1、查找不等于4 5 |
|
|
|
|
|
today := utils.GetTimeRange("today") |
|
|
|
|
|
if time.Now().Hour() < 2 { |
|
|
|
|
|
today = utils.GetTimeRange("yesterday") |
|
|
|
|
|
} |
|
|
|
|
|
var orders []model.Order |
|
|
|
|
|
err := engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return res |
|
|
|
|
|
} |
|
|
|
|
|
var oIds []string |
|
|
|
|
|
for _, v := range orders { |
|
|
|
|
|
v1 := order.JudgePackageOrdOrdState(&v) |
|
|
|
|
|
if v1.State == 4 || v1.State == 5 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
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) GROUP BY goods_id,sku_id` |
|
|
|
|
|
sql = fmt.Sprintf(sql, strings.Join(oIds, ",")) |
|
|
|
|
|
nativeString, err := db.QueryNativeString(engine, sql) |
|
|
|
|
|
for _, v := range nativeString { |
|
|
|
|
|
skuData := make([]md2.Sku, 0) |
|
|
|
|
|
json.Unmarshal([]byte(v["sku"]), &skuData) |
|
|
|
|
|
skuStr := "" |
|
|
|
|
|
for _, v1 := range skuData { |
|
|
|
|
|
if skuStr != "" { |
|
|
|
|
|
skuStr += ";" |
|
|
|
|
|
} |
|
|
|
|
|
skuStr += v1.Value |
|
|
|
|
|
} |
|
|
|
|
|
tmp := map[string]string{ |
|
|
|
|
|
"goods_id": v["goods_id"], |
|
|
|
|
|
"sku_id": v["sku_id"], |
|
|
|
|
|
"goods_name": v["goods_title"], |
|
|
|
|
|
"sku": skuStr, |
|
|
|
|
|
"num": v["num"], |
|
|
|
|
|
"success_num": v["success_num"], |
|
|
|
|
|
"state": "1", |
|
|
|
|
|
"state_str": "待分拣", |
|
|
|
|
|
} |
|
|
|
|
|
if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) { |
|
|
|
|
|
tmp["state"] = "4" |
|
|
|
|
|
tmp["stare_str"] = "分拣完成" |
|
|
|
|
|
} |
|
|
|
|
|
res = append(res, tmp) |
|
|
|
|
|
} |
|
|
|
|
|
return res |
|
|
|
|
|
} |
|
|
|
|
|
func NewSortingGoodsData(arg map[string]string) []map[string]string { |
|
|
|
|
|
|
|
|
|
|
|
engine := db.Db |
|
|
|
|
|
res := make([]map[string]string, 0) |
|
|
|
|
|
var enterprise []model.Enterprise |
|
|
|
|
|
err := engine.Where("1=1").Find(&enterprise) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return res |
|
|
|
|
|
} |
|
|
|
|
|
var enterpriseMap = map[int]model.Enterprise{} |
|
|
|
|
|
for _, v := range enterprise { |
|
|
|
|
|
enterpriseMap[v.Id] = v |
|
|
|
|
|
} |
|
|
|
|
|
//1、查找不等于4 5 |
|
|
|
|
|
today := utils.GetTimeRange("today") |
|
|
|
|
|
if time.Now().Hour() < 2 { |
|
|
|
|
|
today = utils.GetTimeRange("yesterday") |
|
|
|
|
|
} |
|
|
|
|
|
var orders []model.Order |
|
|
|
|
|
err = engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return res |
|
|
|
|
|
} |
|
|
|
|
|
var oIds []string |
|
|
|
|
|
for _, v := range orders { |
|
|
|
|
|
v1 := order.JudgePackageOrdOrdState(&v) |
|
|
|
|
|
if v1.State == 4 || v1.State == 5 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
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 sku_id=%s GROUP BY enterprise_id` |
|
|
|
|
|
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"]) |
|
|
|
|
|
nativeString, err := db.QueryNativeString(engine, sql) |
|
|
|
|
|
for _, v := range nativeString { |
|
|
|
|
|
skuData := make([]md2.Sku, 0) |
|
|
|
|
|
json.Unmarshal([]byte(v["sku"]), &skuData) |
|
|
|
|
|
skuStr := "" |
|
|
|
|
|
for _, v1 := range skuData { |
|
|
|
|
|
if skuStr != "" { |
|
|
|
|
|
skuStr += ";" |
|
|
|
|
|
} |
|
|
|
|
|
skuStr += v1.Value |
|
|
|
|
|
} |
|
|
|
|
|
tmp := map[string]string{ |
|
|
|
|
|
"enterprise_name": enterpriseMap[utils.StrToInt(v["enterprise_id"])].Name, |
|
|
|
|
|
"num": v["num"], |
|
|
|
|
|
"success_num": v["success_num"], |
|
|
|
|
|
"state": "1", |
|
|
|
|
|
"state_str": "待分拣", |
|
|
|
|
|
} |
|
|
|
|
|
if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) { |
|
|
|
|
|
tmp["state"] = "4" |
|
|
|
|
|
tmp["stare_str"] = "分拣完成" |
|
|
|
|
|
} |
|
|
|
|
|
res = append(res, tmp) |
|
|
|
|
|
} |
|
|
|
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
} |