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.
53 lines
1.1 KiB
53 lines
1.1 KiB
package invoice
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/order"
|
|
"recook/tools"
|
|
)
|
|
|
|
type updateInvoiceStatusParam struct {
|
|
InvoiceID uint `json:"invoiceId"`
|
|
ExpressCompName string `json:"expressCompName"`
|
|
ExpressNo string `json:"expressNo"`
|
|
}
|
|
|
|
func UpdateInvoice(c *gin.Context) {
|
|
var p updateInvoiceStatusParam
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
var one order.Invoice
|
|
if err := dbc.DB.First(&one, "id = ?", p.InvoiceID).Error; err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
|
|
tx := dbc.DB.Begin()
|
|
{
|
|
if err := tx.Model(&one).Updates(order.Invoice{
|
|
ExpressCompName: p.ExpressCompName,
|
|
ExpressNo: p.ExpressNo,
|
|
}).Error; err != nil {
|
|
back.Err(c, err.Error())
|
|
tx.Rollback()
|
|
return
|
|
}
|
|
|
|
if err := tx.Model(&order.Information{ID: one.OrderID}).Updates(order.Information{
|
|
InvoiceStatus: 2,
|
|
}).Error; err != nil {
|
|
back.Err(c, err.Error())
|
|
tx.Rollback()
|
|
return
|
|
}
|
|
}
|
|
tx.Commit()
|
|
|
|
back.Suc(c, "", nil)
|
|
}
|