You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.7 KiB
78 lines
1.7 KiB
package invoice
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/shopspring/decimal"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/order"
|
|
"recook/tools"
|
|
)
|
|
|
|
type queryParam struct {
|
|
UserID uint `json:"userId"`
|
|
Page uint `json:"page"`
|
|
}
|
|
|
|
type queryResp struct {
|
|
order.Information
|
|
Detail []detail `json:"detail"`
|
|
Invoice order.Invoice `json:"invoice"`
|
|
}
|
|
|
|
type detail struct {
|
|
Name string `json:"name"`
|
|
SkuName string `json:"skuName"`
|
|
Quantity uint `json:"quantity"`
|
|
ActualAmount decimal.Decimal `json:"actualAmount"`
|
|
}
|
|
|
|
/*
|
|
查询未开票订单
|
|
*/
|
|
func QueryNotOpenInvoiceList(c *gin.Context) {
|
|
var p queryParam
|
|
err := tools.Params(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
var total uint
|
|
dbc.DB.Table((&order.Information{}).TableName()).Where("invoice_status = 1").Count(&total)
|
|
|
|
var unfinishInvoiceOrderList []order.Information
|
|
dbc.DB.Limit(20).Offset(p.Page*20).Order("id desc").Find(&unfinishInvoiceOrderList, "invoice_status = 1")
|
|
|
|
list := make([]queryResp, 0, 0)
|
|
|
|
for i, v := range unfinishInvoiceOrderList {
|
|
var ds []order.GoodsDetail
|
|
dbc.DB.Select("goods_name, sku_name, quantity, actual_amount").Find(&ds, "order_id = ? AND ", v.ID)
|
|
|
|
var details []detail
|
|
for j := range ds {
|
|
d := detail{
|
|
Name: ds[j].GoodsName,
|
|
SkuName: ds[j].SkuName,
|
|
Quantity: ds[j].Quantity,
|
|
ActualAmount: ds[j].ActualAmount,
|
|
}
|
|
details = append(details, d)
|
|
}
|
|
|
|
var invoice order.Invoice
|
|
dbc.DB.First(&invoice, "order_id = ?", v.ID)
|
|
|
|
list = append(list, queryResp{
|
|
Information: unfinishInvoiceOrderList[i],
|
|
Detail: details,
|
|
Invoice: invoice,
|
|
})
|
|
}
|
|
back.Suc(c, "", gin.H{
|
|
"total": total,
|
|
"list": list,
|
|
})
|
|
}
|