Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming
2023-09-21 14:31:32 +08:00
12 changed files with 201 additions and 43 deletions

View File

@@ -11,22 +11,22 @@ import (
"fusenapi/server/order/internal/types"
)
func CreatePrePaymentDepositHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func CreatePrePaymentByBalanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreatePrePaymentDepositReq
var req types.CreatePrePaymentByBalanceReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewCreatePrePaymentDepositLogic(r.Context(), svcCtx)
l := logic.NewCreatePrePaymentByBalanceLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.CreatePrePaymentDeposit(&req, userinfo)
resp := l.CreatePrePaymentByBalance(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)

View File

@@ -0,0 +1,35 @@
package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/order/internal/logic"
"fusenapi/server/order/internal/svc"
"fusenapi/server/order/internal/types"
)
func CreatePrePaymentByDepositHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreatePrePaymentByDepositReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewCreatePrePaymentByDepositLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.CreatePrePaymentByDeposit(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -20,7 +20,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
{
Method: http.MethodPost,
Path: "/api/order/create-prepayment-deposit",
Handler: CreatePrePaymentDepositHandler(serverCtx),
Handler: CreatePrePaymentByDepositHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/order/create-prepayment-balance",
Handler: CreatePrePaymentByBalanceHandler(serverCtx),
},
{
Method: http.MethodGet,

View File

@@ -12,14 +12,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type CreatePrePaymentDepositLogic struct {
type CreatePrePaymentByBalanceLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreatePrePaymentDepositLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePrePaymentDepositLogic {
return &CreatePrePaymentDepositLogic{
func NewCreatePrePaymentByBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePrePaymentByBalanceLogic {
return &CreatePrePaymentByBalanceLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -27,10 +27,10 @@ func NewCreatePrePaymentDepositLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
// 处理进入前逻辑w,r
// func (l *CreatePrePaymentDepositLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *CreatePrePaymentByBalanceLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *CreatePrePaymentDepositLogic) CreatePrePaymentDeposit(req *types.CreatePrePaymentDepositReq, userinfo *auth.UserInfo) (resp *basic.Response) {
func (l *CreatePrePaymentByBalanceLogic) CreatePrePaymentByBalance(req *types.CreatePrePaymentByBalanceReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
@@ -38,6 +38,6 @@ func (l *CreatePrePaymentDepositLogic) CreatePrePaymentDeposit(req *types.Create
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *CreatePrePaymentDepositLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *CreatePrePaymentByBalanceLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -0,0 +1,43 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/order/internal/svc"
"fusenapi/server/order/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CreatePrePaymentByDepositLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreatePrePaymentByDepositLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePrePaymentByDepositLogic {
return &CreatePrePaymentByDepositLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *CreatePrePaymentByDepositLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *CreatePrePaymentByDepositLogic) CreatePrePaymentByDeposit(req *types.CreatePrePaymentByDepositReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
return resp.SetStatus(basic.CodeOK)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *CreatePrePaymentByDepositLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -47,7 +47,7 @@ func (l *OrderDetailLogic) OrderDetail(req *types.OrderDetailReq, userinfo *auth
}
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"order_detail": res,
"order_detail": res.OrderDetail,
})
}

View File

@@ -14,9 +14,9 @@ type CreateOrderReq struct {
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
}
type CreatePrePaymentDepositReq struct {
type CreatePrePaymentByDepositReq struct {
OrderSn string `json:"order_sn"`
DeliveryMethod int64 `json:"delivery_method"`
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
DeliveryAddres DeliveryAddres `json:"delivery_addres,optional"`
}
@@ -26,7 +26,15 @@ type DeliveryAddres struct {
Mobile string `json:"mobile,optional"`
}
type CreatePrePaymentByBalanceReq struct {
OrderSn string `json:"order_sn"`
}
type OrderListReq struct {
DeliveryMethod int64 `json:"delivery_method,options=[0,1,2],optional"`
OrderCycle string `json:"order_cycle,optional"`
Current_page int64 `json:"current_page,optional,default=1"`
Page_size int64 `json:"page_size,optional,default=10"`
}
type Request struct {