feat(app): update
This commit is contained in:
153
pkg/dto/request/BaseOrerIdRequest.go
Normal file
153
pkg/dto/request/BaseOrerIdRequest.go
Normal file
@ -0,0 +1,153 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gitea.ddegame.cn/open/servicebase/pkg/tools"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type BaseOrderIdRequest struct {
|
||||
BaseRequest
|
||||
OrderId string
|
||||
OrderCountComplete string // 实际完成的订单量(局)
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *BaseOrderIdRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type PayOrderIdRequest struct {
|
||||
BaseRequest
|
||||
OrderId string
|
||||
BuyerUserId string
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *PayOrderIdRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type SellerOrderIdRequest struct {
|
||||
BaseRequest
|
||||
OrderId string
|
||||
SellerUserId string
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *SellerOrderIdRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 卖家提前完成订单
|
||||
type BuyerEarlyFinishOrderRequest struct {
|
||||
BaseOrderIdRequest
|
||||
OrderCountComplete string // 实际完成得订单量
|
||||
OrderAmountPaid string // 实际应支付的订单金额
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *BuyerEarlyFinishOrderRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type FreeOfChargeOrderRequest struct {
|
||||
BaseRequest
|
||||
OrderId string
|
||||
ChangeCount string // 完成单数
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *FreeOfChargeOrderRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
if len(request.ChangeCount) == 0 {
|
||||
err = errors.New("完成单数不能为空")
|
||||
return
|
||||
}
|
||||
var count decimal.Decimal
|
||||
if count, err = decimal.NewFromString(request.ChangeCount); err != nil {
|
||||
err = errors.New("完成单数不能为非数字")
|
||||
return
|
||||
}
|
||||
if !tools.IsHalfMultiple(count) {
|
||||
err = errors.New("完成单数必须为0.5的倍数")
|
||||
return
|
||||
}
|
||||
if count.LessThanOrEqual(decimal.NewFromInt(0)) {
|
||||
err = errors.New("完成单数不能小于等于零")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type ReduceOrderRequest struct {
|
||||
BaseRequest
|
||||
OrderId string
|
||||
ChangeCount string // 完成单数
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *ReduceOrderRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
if len(request.ChangeCount) == 0 {
|
||||
err = errors.New("减少单数不能为空")
|
||||
return
|
||||
}
|
||||
var count decimal.Decimal
|
||||
if count, err = decimal.NewFromString(request.ChangeCount); err != nil {
|
||||
err = errors.New("减少数不能为非数字")
|
||||
return
|
||||
}
|
||||
if !tools.IsHalfMultiple(count) {
|
||||
err = errors.New("减少单数必须为0.5的倍数")
|
||||
return
|
||||
}
|
||||
if count.LessThanOrEqual(decimal.NewFromInt(0)) {
|
||||
err = errors.New("减少单数不能小于等于零")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 卖家提前完成订单
|
||||
type SellerFinishOrderRequest struct {
|
||||
BaseOrderIdRequest
|
||||
OrderCountComplete string // 实际完成的订单量(局)
|
||||
}
|
||||
|
||||
// 参数合法性检验
|
||||
func (request *SellerFinishOrderRequest) CheckParameter() (err error) {
|
||||
if len(request.OrderId) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
if len(request.OrderCountComplete) == 0 {
|
||||
err = errors.New("OrderId不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user