60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package orderservicelogic
|
|
|
|
import (
|
|
"app-cloudep-trade-service/internal/domain/usecase"
|
|
"context"
|
|
|
|
ers "code.30cm.net/digimon/library-go/errs"
|
|
|
|
"app-cloudep-trade-service/gen_result/pb/trade"
|
|
"app-cloudep-trade-service/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ModifyOrderStatusLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewModifyOrderStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyOrderStatusLogic {
|
|
return &ModifyOrderStatusLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// ModifyOrderQuery
|
|
// 0.建立訂單 1.建單失敗 2.審核中 3.付款中 4.已付款
|
|
// 5.已付款待轉帳 6.申訴中 7.交易完成
|
|
// 8.交易失敗 9.交易取消 10.交易異常 11.交易超時
|
|
|
|
type ModifyOrderQuery struct {
|
|
BusinessID string `json:"business_id" validate:"required"`
|
|
Status int64 `json:"status" validate:"required,oneof=2 3 4 5 6 7 8 11"`
|
|
}
|
|
|
|
// ModifyOrderStatus 修改訂單狀態
|
|
func (l *ModifyOrderStatusLogic) ModifyOrderStatus(in *trade.ModifyOrderStatusReq) (*trade.OKResp, error) {
|
|
// 驗證資料
|
|
if err := l.svcCtx.Validate.ValidateAll(&ModifyOrderQuery{
|
|
BusinessID: in.GetBusinessId(),
|
|
Status: in.GetStatus(),
|
|
}); err != nil {
|
|
// 錯誤代碼 06-011-00
|
|
return nil, ers.InvalidFormat(err.Error())
|
|
}
|
|
|
|
err := l.svcCtx.OrderUseCase.ModifyOrderStatus(l.ctx, &usecase.ModifyOrderQuery{
|
|
Status: in.GetStatus(),
|
|
BusinessID: in.GetBusinessId(),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &trade.OKResp{}, nil
|
|
}
|