YouChuKoffee/app/http/entities/front/Order.go

100 lines
3.0 KiB
Go

package front
import (
"qteam/app/models/ordersmodel"
"qteam/app/utils"
"qteam/app/utils/encrypt"
"qteam/config"
"time"
)
type OrderCreateRequest struct {
ProductId int `form:"product_id" validate:"required"`
}
type OrderQueryRequest struct {
OrderId string `form:"order_id"`
OrderNo string `form:"order_no"`
}
type OrderListRequest struct {
PageRequest
State int `form:"state"`
}
type OrderListResponse struct {
Id int `json:"id"`
OrderNo string `json:"order_no"`
MainImage string `json:"main_image"`
UserId int `json:"user_id"`
CustNo string `json:"custNo"`
Price string `json:"price"`
ProductId int `json:"product_id"`
ProductName string `json:"product_name"`
State int `json:"state"`
VoucherLink string `json:"voucher_link"`
CreateTime string `json:"create_time"`
NotifyUrl string `json:"notify_url"`
ExchangeTime string `json:"exchange_time"`
}
func (p *OrderListResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) {
p.Id = l.Id
p.OrderNo = l.OrderNo
p.MainImage = l.MainImage
p.ExchangeTime = l.ExchangeTime.Format(time.DateTime)
p.UserId = l.UserId
p.CustNo = l.CustNo
p.Price = l.Price
p.ProductId = l.ProductId
p.ProductName = l.ProductName
p.State = l.State
p.NotifyUrl = config.GetConf().YouChu.NotifyUrl
if l.VoucherLink != "" {
p.VoucherLink = string(encrypt.AesDecryptCBC(l.VoucherLink, []byte(config.GetConf().OpenApiMarketConfig.SecretKey)))
}
p.CreateTime = l.CreateTime.Format("2006-01-02 15:04:05")
return
}
type OrderStateResponse struct {
Id int `json:"id"`
State int `json:"state"`
VoucherLink string `json:"voucher_link"`
}
type OrderQueryResponse struct {
Id int `json:"id"`
OrderNo string `json:"order_no"`
UserId int `json:"user_id"`
UserName string `json:"user_name"`
Price string `json:"price"`
MainImage string `json:"main_image"`
Mobile string `json:"mobile"`
ProductId int `json:"product_id"`
ProductName string `json:"product_name"`
State int `json:"state"`
VoucherLink string `json:"voucher_link"`
CreateTime string `json:"create_time"`
NotifyUrl string `json:"notify_url"`
ExchangeTime string `json:"exchange_time"`
}
func (p *OrderQueryResponse) ResponseFromDb(l ordersmodel.Orders) {
utils.EntityCopy(p, &l)
p.NotifyUrl = config.GetConf().YouChu.NotifyUrl
p.CreateTime = l.CreateTime.Format("2006-01-02 15:04:05")
p.ExchangeTime = l.ExchangeTime.Format(time.DateTime)
if l.VoucherLink != "" {
p.VoucherLink = string(encrypt.AesDecryptCBC(l.VoucherLink, []byte(config.GetConf().OpenApiMarketConfig.SecretKey)))
}
return
}
type OrdersUpdateRequest struct {
Id int `json:"id" validate:"required" form:"id" validate:"required" example:"1"`
Status int `json:"status" form:"status" validate:"oneof=1 2 3 4" example:"1"` // '状态(1/待支付,2/已支付,3/已完成4/取消5作废)'
VoucherLink string `json:"voucher_link"`
OrgTxnSeq string `json:"orgTxnSeq"`
}