huangjiajun vor 6 Monaten
Ursprung
Commit
bebf7b0e4d
1 geänderte Dateien mit 112 neuen und 101 gelöschten Zeilen
  1. +112
    -101
      app/admin/svc/order/svc_order_list.go

+ 112
- 101
app/admin/svc/order/svc_order_list.go Datei anzeigen

@@ -87,9 +87,11 @@ func OrderExport(c *gin.Context) {
list, _ := db.GetOrderListExport(eg, args)
xlsx, _ := excelize.OpenFile("./static/template/商品销售明细表.xlsx")

var data = map[string]map[int64][]map[string]string{}
var data = map[string]map[string]map[int64][]map[string]string{}
enterpriseIds := make([]int, 0)
var enterpriseMap = make(map[int]model.Enterprise)
dateList := make([]string, 0)

if list != nil {
for _, v := range *list {
enterpriseIds = append(enterpriseIds, v.EnterpriseId)
@@ -97,18 +99,18 @@ func OrderExport(c *gin.Context) {
enterpriseMap = db.GetEnterpriseMore(eg, enterpriseIds)

for _, v := range *list {
enterpriseName := "-"
inSideName := "-"
_, ok := enterpriseMap[v.EnterpriseId]
if ok {
enterpriseName = enterpriseMap[v.EnterpriseId].Name
inSideName = enterpriseMap[v.EnterpriseId].InsideName
dateStr := v.CreateAt.Format("2006-01-02")
if utils.InArr(dateStr, dateList) == false {
dateList = append(dateList, dateStr)
}
if data[dateStr] == nil {
data[dateStr] = make(map[string]map[int64][]map[string]string)
}
if data[utils.IntToStr(v.EnterpriseId)] == nil {
data[utils.IntToStr(v.EnterpriseId)] = make(map[int64][]map[string]string)
if data[dateStr][utils.IntToStr(v.EnterpriseId)] == nil {
data[dateStr][utils.IntToStr(v.EnterpriseId)] = make(map[int64][]map[string]string)
}
if data[utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
if data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
@@ -122,8 +124,6 @@ func OrderExport(c *gin.Context) {
tmp["date"] = v.CreateAt.Format("2006-01-02")
tmp["send_date"] = gjson.Get(v.BuyInfo, "date").String()
tmp["goods_name"] = vv.GoodsTitle
tmp["inside_name"] = inSideName
tmp["enterprise_name"] = enterpriseName
tmp["ord_no"] = vv.OrdNo
tmp["goods_type"] = utils.IntToStr(vv.GoodsType)
skuData := make([]md.Sku, 0)
@@ -137,7 +137,7 @@ func OrderExport(c *gin.Context) {
}
tmp["sku_str"] = skuStr
tmp["num"] = utils.IntToStr(vv.Num)
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
}
}
}
@@ -150,50 +150,52 @@ func OrderExport(c *gin.Context) {
})

j := 4 //表头前三行被占用了,只能从第四行开始
for k, v := range data {
var total = 0
inSideName := ""
_, ok := enterpriseMap[utils.StrToInt(k)]
if ok {
inSideName = enterpriseMap[utils.StrToInt(k)].InsideName
}
for kk, vv := range v {
for _, v3 := range vv {
if v3["ord_no"] == "" {
v3["ord_no"] = utils.Int64ToStr(kk)
}
if utils.StrToInt(v3["goods_type"]) > 0 {
v3["goods_name"] = "数量不计入汇总-" + v3["goods_name"]
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
})
xlsx.SetRowHeight("Sheet1", j, 18)
if utils.StrToInt(v3["goods_type"]) == 0 {
total += utils.StrToInt(v3["num"])
for _, v0 := range dateList {
for k, v := range data[v0] {
var total = 0
inSideName := ""
_, ok := enterpriseMap[utils.StrToInt(k)]
if ok {
inSideName = enterpriseMap[utils.StrToInt(k)].InsideName
}
for kk, vv := range v {
for _, v3 := range vv {
if v3["ord_no"] == "" {
v3["ord_no"] = utils.Int64ToStr(kk)
}
if utils.StrToInt(v3["goods_type"]) > 0 {
v3["goods_name"] = "数量不计入汇总-" + v3["goods_name"]
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
})
xlsx.SetRowHeight("Sheet1", j, 18)
if utils.StrToInt(v3["goods_type"]) == 0 {
total += utils.StrToInt(v3["num"])
}
j++
}
j++
}
}

style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFFCC"],"pattern":1}, "alignment":{"horizontal":"center", "vertical": "center"}}`)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFFCC"],"pattern":1}, "alignment":{"horizontal":"center", "vertical": "center"}}`)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
}
xlsx.MergeCell("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j)) //合并单元格
xlsx.SetCellStyle("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j), style)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
}
xlsx.MergeCell("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j)) //合并单元格
xlsx.SetCellStyle("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j), style)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
}
xlsx.DeleteSheet("template") //删除模板表

@@ -502,21 +504,28 @@ func OrderOutput(c *gin.Context) {
list := db.GetOrderListOutput(eg, args)
xlsx, _ := excelize.OpenFile("./static/template/商品销售明细表.xlsx")

var data = map[string]map[int64][]map[string]string{}
var data = map[string]map[string]map[int64][]map[string]string{}
var enterpriseMap = make(map[int]model.Enterprise)
enterpriseIds := make([]int, 0)
dateList := make([]string, 0)
if list != nil {
for _, v := range *list {
enterpriseIds = append(enterpriseIds, v.EnterpriseId)
}
enterpriseMap = db.GetEnterpriseMore(eg, enterpriseIds)
for _, v := range *list {

if data[utils.IntToStr(v.EnterpriseId)] == nil {
data[utils.IntToStr(v.EnterpriseId)] = make(map[int64][]map[string]string)
dateStr := v.CreateAt.Format("2006-01-02")
if utils.InArr(dateStr, dateList) == false {
dateList = append(dateList, dateStr)
}
if data[dateStr] == nil {
data[dateStr] = make(map[string]map[int64][]map[string]string)
}
if data[utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
if data[dateStr][utils.IntToStr(v.EnterpriseId)] == nil {
data[dateStr][utils.IntToStr(v.EnterpriseId)] = make(map[int64][]map[string]string)
}
if data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
@@ -543,7 +552,7 @@ func OrderOutput(c *gin.Context) {
}
tmp["sku_str"] = skuStr
tmp["num"] = utils.IntToStr(vv.Num)
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[dateStr][utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
}
}
}
@@ -556,50 +565,52 @@ func OrderOutput(c *gin.Context) {
})

j := 4 //表头前三行被占用了,只能从第四行开始
for k, v := range data {
inSideName := ""
_, ok := enterpriseMap[utils.StrToInt(k)]
if ok {
inSideName = enterpriseMap[utils.StrToInt(k)].InsideName
}
var total = 0
for kk, vv := range v {
for _, v3 := range vv {
if v3["ord_no"] == "" {
v3["ord_no"] = utils.Int64ToStr(kk)
}
if utils.StrToInt(v3["goods_type"]) > 0 {
v3["goods_name"] = v3["goods_name"] + "-数量不计入汇总"
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
})
xlsx.SetRowHeight("Sheet1", j, 18)
if utils.StrToInt(v3["goods_type"]) == 0 {
total += utils.StrToInt(v3["num"])
for _, v0 := range dateList {
for k, v := range data[v0] {
inSideName := ""
_, ok := enterpriseMap[utils.StrToInt(k)]
if ok {
inSideName = enterpriseMap[utils.StrToInt(k)].InsideName
}
var total = 0
for kk, vv := range v {
for _, v3 := range vv {
if v3["ord_no"] == "" {
v3["ord_no"] = utils.Int64ToStr(kk)
}
if utils.StrToInt(v3["goods_type"]) > 0 {
v3["goods_name"] = v3["goods_name"] + "-数量不计入汇总"
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
})
xlsx.SetRowHeight("Sheet1", j, 18)
if utils.StrToInt(v3["goods_type"]) == 0 {
total += utils.StrToInt(v3["num"])
}
j++
}
j++
}
}

style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFFCC"],"pattern":1}, "alignment":{"horizontal":"center", "vertical": "center"}}`)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFFCC"],"pattern":1}, "alignment":{"horizontal":"center", "vertical": "center"}}`)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
}
xlsx.MergeCell("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j)) //合并单元格
xlsx.SetCellStyle("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j), style)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
}
xlsx.MergeCell("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j)) //合并单元格
xlsx.SetCellStyle("Sheet1", "A"+strconv.Itoa(j), "F"+strconv.Itoa(j), style)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
}
xlsx.DeleteSheet("template") //删除模板表



Laden…
Abbrechen
Speichern