Ver código fonte

更新

master
huangjiajun 5 meses atrás
pai
commit
bee5d75278
6 arquivos alterados com 154 adições e 16 exclusões
  1. +3
    -0
      app/admin/hdl/order/hdl_order_list.go
  2. +125
    -0
      app/admin/svc/order/svc_order_list.go
  3. +9
    -0
      app/db/db_order_goods_list.go
  4. +1
    -1
      app/db/db_order_list.go
  5. +16
    -15
      app/router/admin_router.go
  6. BIN
     

+ 3
- 0
app/admin/hdl/order/hdl_order_list.go Ver arquivo

@@ -28,6 +28,9 @@ func OrderDetail(c *gin.Context) {
func OrderOutput(c *gin.Context) {
order.OrderOutput(c)
}
func OrderGoodsOutput(c *gin.Context) {
order.OrderGoodsOutput(c)
}
func OrderEdit(c *gin.Context) {
order.OrderEdit(c)
}


+ 125
- 0
app/admin/svc/order/svc_order_list.go Ver arquivo

@@ -640,6 +640,131 @@ func OrderOutput(c *gin.Context) {
_ = xlsx.Write(c.Writer)
return
}
func OrderGoodsOutput(c *gin.Context) {
var args map[string]string
if err := c.ShouldBindJSON(&args); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
eg := db.Db
list := db.GetOrderListOutput(eg, args)
xlsx, _ := excelize.OpenFile("./static/template/订单品类明细表.xlsx")

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

oids := make([]int64, 0)

if list != nil {
ordMap := make(map[int64]model.Order)
for _, v := range *list {
_, ok := ordMap[v.Oid]
if ok == false {
ordMap[v.Oid] = model.Order{}
}
ordMap[v.Oid] = v
oids = append(oids, v.Oid)
enterpriseIds = append(enterpriseIds, v.EnterpriseId)
}
enterpriseMap = db.GetEnterpriseMore(eg, enterpriseIds)

ord := db.GetOrderGoodsByOid(eg, oids)

for _, v := range *ord {
dateStr := ordMap[v.Oid].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[string]string)
}
gidStr := utils.Int64ToStr(v.GoodsId) + "_" + utils.Int64ToStr(v.SkuId)
if data[dateStr][gidStr] == nil {
data[dateStr][gidStr] = make([]map[string]string, 0)
}

tmp := make(map[string]string)
tmp["date"] = ordMap[v.Oid].CreateAt.Format("2006-01-02")
tmp["send_date"] = gjson.Get(ordMap[v.Oid].BuyInfo, "date").String()
tmp["goods_name"] = v.GoodsTitle
tmp["make_date"] = utils.TimeParseDateStd1(v.MakeDate)
if v.OrdNo == "" {
v.OrdNo = utils.Int64ToStr(v.Oid)
}
tmp["ord_no"] = v.OrdNo
tmp["goods_type"] = utils.IntToStr(v.GoodsType)
skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(v.Sku), &skuData)
skuStr := ""
for _, v1 := range skuData {
if skuStr != "" {
skuStr += ";"
}
skuStr += v1.Value
}
tmp["sku_str"] = skuStr
tmp["num"] = utils.IntToStr(v.Num)
inSideName := ""
_, ok := enterpriseMap[v.EnterpriseId]
if ok {
inSideName = enterpriseMap[v.EnterpriseId].InsideName
}
tmp["inSideName"] = inSideName
data[dateStr][gidStr] = append(data[dateStr][gidStr], tmp)
}
}

sheetIndex := 2 //第一个表是模板表
xlsx.NewSheet("Sheet1") //新建表格
xlsx.CopySheet(1, sheetIndex)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(2), &[]interface{}{
"日期:" + utils.TimeParseStd(args["start_at"]).Format("2006-01-02") + " ~ " + utils.TimeParseStd(args["end_at"]).Format("2006-01-02"),
})

j := 4 //表头前三行被占用了,只能从第四行开始
for _, v0 := range dateList {
for _, v := range data[v0] {
var total = 0
title := ""
for _, vv := range v {
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
vv["date"],
vv["ord_no"],
vv["inSideName"],
vv["num"],
vv["make_date"],
})
title = vv["goods_name"] + " " + vv["sku_st"]
xlsx.SetRowHeight("Sheet1", j, 18)
total += utils.StrToInt(vv["num"])
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)
}
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{}{
title + " 汇总: " + utils.IntToStr(total),
})
xlsx.SetRowHeight("Sheet1", j, 20)
j++
}
}
xlsx.DeleteSheet("template") //删除模板表

c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename="+"订单记录"+".xlsx")
c.Header("Content-Transfer-Encoding", "binary")
//回写到web 流媒体 形成下载
_ = xlsx.Write(c.Writer)
return
}
func OrderEdit(c *gin.Context) {
var args map[string]string
if err := c.ShouldBindJSON(&args); err != nil {


+ 9
- 0
app/db/db_order_goods_list.go Ver arquivo

@@ -75,3 +75,12 @@ func GetOrderGoodsAll(sess *xorm.Session, oid string) *[]model.OrderGoods {
}
return &order
}

func GetOrderGoodsByOid(eg *xorm.Engine, oid []int64) *[]model.OrderGoods {
var order []model.OrderGoods
err := eg.In("oid", oid).And("goods_type=0").Find(&order)
if err != nil {
return nil
}
return &order
}

+ 1
- 1
app/db/db_order_list.go Ver arquivo

@@ -175,7 +175,7 @@ func GetOrderListOutput(eg *xorm.Engine, param map[string]string) *[]model.Order
}
sess.In("enterprise_id", oids)
}
err := sess.OrderBy("id desc").Find(&order)
err := sess.OrderBy("id asc").Find(&order)
if err != nil {
return nil
}


+ 16
- 15
app/router/admin_router.go Ver arquivo

@@ -136,21 +136,22 @@ func rGoodsPay(r *gin.RouterGroup) {
r.POST("/create", orderHdl.GoodsPayCreate) //商品下单
}
func rOrder(r *gin.RouterGroup) {
r.POST("/list", orderHdl.OrderList) //用户订单
r.POST("/total", orderHdl.OrderTotal) //用户订单统计
r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消
r.POST("/detail", orderHdl.OrderDetail) //用户订单详情
r.POST("/output", orderHdl.OrderOutput) //用户订单导出
r.POST("/del", orderHdl.OrderDel) //用户订单商品删除
r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息
r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数
r.POST("/addSku", orderHdl.OrderAddSku) //用户订单修改订单数
r.POST("/addNum", orderHdl.OrderAddNum) //用户订单增加数量
r.POST("/deductNum", orderHdl.OrderDeductNum) //用户订单减少数量
r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
r.POST("/notice", orderHdl.NoticeList) //公告
r.POST("/notice_save", orderHdl.NoticeSave) //公告
r.POST("/notice_del", orderHdl.NoticeDel) //公告
r.POST("/list", orderHdl.OrderList) //用户订单
r.POST("/total", orderHdl.OrderTotal) //用户订单统计
r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消
r.POST("/detail", orderHdl.OrderDetail) //用户订单详情
r.POST("/output", orderHdl.OrderOutput) //用户订单导出
r.POST("/goods/output", orderHdl.OrderGoodsOutput) //用户订单导出
r.POST("/del", orderHdl.OrderDel) //用户订单商品删除
r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息
r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数
r.POST("/addSku", orderHdl.OrderAddSku) //用户订单修改订单数
r.POST("/addNum", orderHdl.OrderAddNum) //用户订单增加数量
r.POST("/deductNum", orderHdl.OrderDeductNum) //用户订单减少数量
r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
r.POST("/notice", orderHdl.NoticeList) //公告
r.POST("/notice_save", orderHdl.NoticeSave) //公告
r.POST("/notice_del", orderHdl.NoticeDel) //公告
}

func rDataStatistics(r *gin.RouterGroup) {



Carregando…
Cancelar
Salvar