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.

66 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package bill
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/order"
"recook/tools"
)
//获取发票列表
//2 :开票完成( 最终状 态),其他状态分别为: 20:开票中; 21:开票成功签章中;22:开票失败;24: 开票成功签章失败 ;3: 发票已作废 31:\n\n发票作废中 备注22、24 状态时,无需再查询, 请确认开票失败原因以及签章失败 原因3、31 只针对纸票
//2,24已开票
//20,21,开票中
//22,开票失败
type getBillListPem struct {
Page int `json:"page"`
}
type getBillListResult struct {
Result order.Bill `json:"result"`
StatusDec string `json:"statusDec"`
Color int `json:"color"`
}
func GetBillList(c *gin.Context) {
limit := 10
var p getBillListPem
err := tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return
}
if p.Page < 1 {
p.Page = 1
}
var billList []order.Bill
dbc.DB.Order("id desc").Limit(limit).Offset((p.Page) * limit).Find(&billList)
var mygetBillListResult []getBillListResult
myStatus := ""
myColor := 1
for _, item := range billList {
if item.Status == 2 || item.Status == 24 {
myStatus = "已开票"
myColor = 1
}
if item.Status == 20 || item.Status == 21 {
myStatus = "开票中"
myColor = 2
}
if item.Status == 22 {
myStatus = "开票失败"
myColor = 3
}
mygetBillListResult = append(mygetBillListResult, getBillListResult{
Result: item,
StatusDec: myStatus,
Color: myColor,
})
}
back.Suc(c, "", &mygetBillListResult)
return
}