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.
46 lines
775 B
46 lines
775 B
package invoice
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/user"
|
|
"recook/tools"
|
|
)
|
|
|
|
type createParam struct {
|
|
UserID uint `json:"userId"`
|
|
Type uint `json:"type"`
|
|
Title string `json:"title"`
|
|
TaxNo string `json:"taxNo"`
|
|
}
|
|
|
|
func CreateInvoice(c *gin.Context) {
|
|
var p createParam
|
|
err := tools.ParseParams(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
one := user.Invoice{
|
|
UserID: p.UserID,
|
|
Type: p.Type,
|
|
Title: p.Title,
|
|
}
|
|
if p.Type == 1 {
|
|
if len(p.TaxNo) == 0 {
|
|
back.Fail(c, "企业开票必须填写税号")
|
|
return
|
|
}
|
|
one.TaxNo = p.TaxNo
|
|
}
|
|
err = dbc.DB.Create(&one).Error
|
|
if err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
|
|
back.Suc(c, "", &one)
|
|
}
|