Ver a proveniência

更新

master
huangjiajun há 6 meses
ascendente
cometimento
c3ea72b3f2
1 ficheiros alterados com 31 adições e 28 eliminações
  1. +31
    -28
      app/admin/svc/order/svc_order_list.go

+ 31
- 28
app/admin/svc/order/svc_order_list.go Ver ficheiro

@@ -88,12 +88,13 @@ func OrderExport(c *gin.Context) {
xlsx, _ := excelize.OpenFile("./static/template/商品销售明细表.xlsx")

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

for _, v := range *list {
enterpriseName := "-"
@@ -103,11 +104,11 @@ func OrderExport(c *gin.Context) {
enterpriseName = enterpriseMap[v.EnterpriseId].Name
inSideName = enterpriseMap[v.EnterpriseId].InsideName
}
if data[enterpriseName] == nil {
data[enterpriseName] = make(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[enterpriseName][v.Oid] == nil {
data[enterpriseName][v.Oid] = make([]map[string]string, 0)
if data[utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
@@ -136,7 +137,7 @@ func OrderExport(c *gin.Context) {
}
tmp["sku_str"] = skuStr
tmp["num"] = utils.IntToStr(vv.Num)
data[enterpriseName][v.Oid] = append(data[enterpriseName][v.Oid], tmp)
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
}
}
}
@@ -151,6 +152,11 @@ 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"] == "" {
@@ -162,7 +168,7 @@ func OrderExport(c *gin.Context) {
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
v3["inside_name"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
@@ -184,7 +190,7 @@ func OrderExport(c *gin.Context) {
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{}{
k + " 汇总: " + utils.IntToStr(total),
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
@@ -497,26 +503,20 @@ func OrderOutput(c *gin.Context) {
xlsx, _ := excelize.OpenFile("./static/template/商品销售明细表.xlsx")

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

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
}
if data[enterpriseName] == nil {
data[enterpriseName] = make(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[enterpriseName][v.Oid] == nil {
data[enterpriseName][v.Oid] = make([]map[string]string, 0)
if data[utils.IntToStr(v.EnterpriseId)][v.Oid] == nil {
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = make([]map[string]string, 0)
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
@@ -530,8 +530,6 @@ func OrderOutput(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)
@@ -545,7 +543,7 @@ func OrderOutput(c *gin.Context) {
}
tmp["sku_str"] = skuStr
tmp["num"] = utils.IntToStr(vv.Num)
data[enterpriseName][v.Oid] = append(data[enterpriseName][v.Oid], tmp)
data[utils.IntToStr(v.EnterpriseId)][v.Oid] = append(data[utils.IntToStr(v.EnterpriseId)][v.Oid], tmp)
}
}
}
@@ -559,6 +557,11 @@ 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 {
@@ -571,7 +574,7 @@ func OrderOutput(c *gin.Context) {
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
v3["date"],
v3["ord_no"],
v3["inside_name"],
inSideName,
v3["goods_name"],
v3["sku_str"],
v3["num"],
@@ -593,7 +596,7 @@ func OrderOutput(c *gin.Context) {
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{}{
k + " 汇总: " + utils.IntToStr(total),
inSideName + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++


Carregando…
Cancelar
Guardar