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.

98 lines
2.7 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 Consignment struct {
}
type argsConsignmentLists struct {
order.ConsignmentListsSearch
bean.Page
}
// Lists @Title 寄卖订单
func (*Consignment) Lists(c *gin.Context) {
args := argsConsignmentLists{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
lists, total := order.ConsignmentLogic.Lists(user.UserLogic.GetCustomerId(c), args.ConsignmentListsSearch, args.Page)
bean.Response.ResultSuc(c, "操作成功", bean.ResultLists{
List: lists,
Total: total,
})
}
type argsConsignmentSign struct {
OrderId uint `binding:"required" label:"订单"`
Sign string `binding:"required" label:"签名"`
}
// Sign @Title 签订订单合同(已废弃:交由腾讯电子签完成该流程)
func (*Consignment) Sign(c *gin.Context) {
args := argsConsignmentSign{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
if err := order.ConsignmentLogic.Sign(user.UserLogic.GetCustomerId(c), args.OrderId, args.Sign); err != nil {
bean.Response.ResultFail(c, 10002, err.Error())
return
}
bean.Response.ResultSuc(c, "操作成功", nil)
}
// SignUrl @Title 签订合同地址
func (*Consignment) SignUrl(c *gin.Context) {
args := argsConsignmentInfo{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
result, err := order.ConsignmentLogic.SignUrl(user.UserLogic.GetCustomerId(c), args.OrderId)
if err != nil {
bean.Response.ResultFail(c, 10002, err.Error())
return
}
bean.Response.ResultSuc(c, "操作成功", result)
}
type argsConsignmentInfo struct {
OrderId uint `binding:"required" label:"订单"`
}
// Info @Title 订单详情
func (*Consignment) Info(c *gin.Context) {
args := argsConsignmentInfo{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
result, err := order.ConsignmentLogic.Info(user.UserLogic.GetCustomerId(c), args.OrderId)
if err != nil {
bean.Response.ResultFail(c, 10002, err.Error())
return
}
bean.Response.ResultSuc(c, "操作成功", result)
}
// AdjustPrice @Title 调价
func (*Consignment) AdjustPrice(c *gin.Context) {
args := order.AdjustPriceData{}
if err := c.ShouldBind(&args); err != nil {
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
return
}
if err := order.ConsignmentLogic.AdjustPrice(user.UserLogic.GetCustomerId(c), args.ConsignmentId, args.Price); err != nil {
bean.Response.ResultFail(c, 10001, err.Error())
return
}
bean.Response.ResultSuc(c, "操作成功", nil)
}