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.

48 lines
1.3 KiB

package order
import (
"base/app/common"
"base/app/lib/bean"
"base/app/logic/customer/order"
"base/app/logic/customer/user"
"github.com/gin-gonic/gin"
)
type Reserve struct {
}
// Lists @Title 直卖预约
func (r *Reserve) Lists(c *gin.Context) {
args := bean.Page{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
lists, total := order.ReserveLogic.Lists(user.UserLogic.GetCustomerId(c), args)
bean.Response.ResultSuc(c, "操作成功", bean.ResultLists{
List: lists,
Total: total,
})
}
type argsReserveAdd struct {
PriceId uint `binding:"required" label:"价格"`
ReserveTime string `binding:"required" label:"预约时间"`
Address string `binding:"required" label:"地址"`
}
// Add @Title 预约卖车
func (r *Reserve) Add(c *gin.Context) {
args := argsReserveAdd{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
customerInfo := user.UserLogic.GetCustomerInfo(c)
if err := order.ReserveLogic.Add(customerInfo.Id, customerInfo.BrokerId, args.PriceId, args.ReserveTime, args.Address); err != nil {
bean.Response.ResultFail(c, 10002, err.Error())
return
}
bean.Response.ResultSuc(c, "操作成功", nil)
}