-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from feng99/main
提交订单创建功能
- Loading branch information
Showing
52 changed files
with
1,697 additions
and
348 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "订单管理" | ||
desc: "订单管理" | ||
author: "刘羽禅" | ||
email: "18500606035@163.com" | ||
version: "v1" | ||
) | ||
|
||
// 订单表 | ||
type Orders struct { | ||
Id string `json:"id"` //订单id | ||
Userid uint64 `json:"userid"` //用户id | ||
Shoppingid int64 `json:"shoppingid"` //收货信息表id | ||
Payment float64 `json:"payment"` //实际付款金额,单位是元,保留两位小数 | ||
Paymenttype int8 `json:"paymenttype"` //支付类型,1-在线支付 | ||
Postage int `json:"postage"` //运费,单位是元 | ||
Status int16 `json:"status"` //订单状态:0-已取消-10-未付款,20-已付款,30-待发货 40-待收货,50-交易成功,60-交易关闭 | ||
CreateTime int64 `json:"create_time"` //创建时间 | ||
UpdateTime int64 `json:"update_time"` //更新时间 | ||
} | ||
|
||
//创建订单 | ||
type ( | ||
OrderAddReq { | ||
receiveAddressId int64 `json:"receiveAddressId"` //用户收货地址表id | ||
Postage int64 `json:"postage"` //运费,单位是元 | ||
Productid int64 `json:"productid"` //商品id | ||
Quantity int64 `json:"quantity"` //商品数量 | ||
} | ||
OrderAddResp { | ||
Id string `json:"id"` //订单id | ||
} | ||
) | ||
//创建订单 | ||
|
||
//订单详情 | ||
type ( | ||
OrderInfoReq { | ||
} | ||
OrderInfoResp { | ||
OrderInfo Orders `json:"orderInfo"` | ||
} | ||
) | ||
//订单详情 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package order | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/zeromicro/go-zero/rest/httpx" | ||
"github.com/zhoushuguang/lebron/apps/app/api/internal/logic/order" | ||
"github.com/zhoushuguang/lebron/apps/app/api/internal/svc" | ||
"github.com/zhoushuguang/lebron/apps/app/api/internal/types" | ||
"github.com/zhoushuguang/lebron/pkg/result" | ||
) | ||
|
||
func AddOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.OrderAddReq | ||
if err := httpx.Parse(r, &req); err != nil { | ||
result.ParamErrorResult(r, w, err) | ||
return | ||
} | ||
|
||
l := order.NewAddOrderLogic(r.Context(), svcCtx) | ||
resp, err := l.AddOrder(&req) | ||
result.HttpResult(r, w, resp, err) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package order | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/zhoushuguang/lebron/apps/app/api/internal/svc" | ||
"github.com/zhoushuguang/lebron/apps/app/api/internal/types" | ||
"github.com/zhoushuguang/lebron/apps/order/rpc/order" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type AddOrderLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewAddOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddOrderLogic { | ||
return &AddOrderLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *AddOrderLogic) AddOrder(req *types.OrderAddReq) (resp *types.OrderAddResp, err error) { | ||
uid, err := l.ctx.Value("uid").(json.Number).Int64() | ||
if err != nil { | ||
return nil, err | ||
} | ||
addOrderReq := order.AddOrderReq{ | ||
Userid: uid, | ||
Productid: req.Productid, | ||
Quantity: req.Quantity, | ||
Postage: req.Postage, | ||
ReceiveAddressId: req.ReceiveAddressId, | ||
} | ||
addOrderResp, err := l.svcCtx.OrderRPC.CreateOrderDTM(l.ctx, &addOrderReq) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "req: %+v", req) | ||
} | ||
return &types.OrderAddResp{ | ||
Id: addOrderResp.Id, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.