获取订单rpc
CI / changes (push) Successful in 38s
CI / ad (push) Successful in 29s
CI / admin (push) Successful in 20s
CI / bff (push) Successful in 15s
CI / chore (push) Successful in 17s
CI / equipment (push) Successful in 15s
CI / express (push) Successful in 16s
CI / product (push) Successful in 15s
CI / record (push) Successful in 15s
CI / sale (push) Successful in 16s
CI / task (push) Successful in 15s
CI / user (push) Successful in 16s
CI / wecom (push) Successful in 16s
CI / changes (push) Successful in 38s
CI / ad (push) Successful in 29s
CI / admin (push) Successful in 20s
CI / bff (push) Successful in 15s
CI / chore (push) Successful in 17s
CI / equipment (push) Successful in 15s
CI / express (push) Successful in 16s
CI / product (push) Successful in 15s
CI / record (push) Successful in 15s
CI / sale (push) Successful in 16s
CI / task (push) Successful in 15s
CI / user (push) Successful in 16s
CI / wecom (push) Successful in 16s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package dao
|
||||
|
||||
const CartTypeStore = 1
|
||||
const CartTypeSale = 2
|
||||
const CartTypeStore = 2
|
||||
const CartTypeSale = 1
|
||||
const CartTypeUser = 3
|
||||
|
||||
type Cart struct {
|
||||
|
||||
@@ -2,17 +2,24 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/rpc/order/pb"
|
||||
"lone-services/services/order/internal/dao"
|
||||
"lone-services/services/order/internal/model"
|
||||
"lone-services/services/order/internal/svc"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type GetOrderInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewGetOrderInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrderInfoLogic {
|
||||
@@ -24,7 +31,84 @@ func NewGetOrderInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetO
|
||||
}
|
||||
|
||||
func (l *GetOrderInfoLogic) GetOrderInfo(in *order.GetOrderInfoRequest) (*order.OrderInfoResponse, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var info dao.OrderInfo
|
||||
modelObj := model.OrderModel{}.Init()
|
||||
w := modelbase.Params{Eq: map[string]string{"order_sn": in.OrderSn}}
|
||||
|
||||
return &order.OrderInfoResponse{}, nil
|
||||
switch in.Type {
|
||||
case dao.OrderTypeSale:
|
||||
w.Eq["sale_id"] = strconv.FormatInt(in.UserId, utils.NumberTen)
|
||||
case dao.OrderTypePersonal:
|
||||
w.Eq["user_id"] = strconv.FormatInt(in.UserId, utils.NumberTen)
|
||||
case dao.OrderTypeStore:
|
||||
w.Eq["store_id"] = strconv.FormatInt(in.UserId, utils.NumberTen)
|
||||
default:
|
||||
return nil, status.Error(codes.Internal, utils.ErrorParams.Msg)
|
||||
}
|
||||
|
||||
err := modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return nil, status.Error(codes.Internal, utils.ErrorNotFund.Msg)
|
||||
}
|
||||
|
||||
if info.Id < utils.NumberOne {
|
||||
return nil, status.Error(codes.Internal, utils.ErrorNotFund.Msg)
|
||||
}
|
||||
|
||||
var productItems []dao.OrderProducts
|
||||
ww := modelbase.Params{
|
||||
Eq: map[string]string{"order_sn": in.OrderSn},
|
||||
}
|
||||
err = model.OrderProductModel{}.Init().Items(ww, &productItems)
|
||||
if err != nil {
|
||||
l.Logger.Error("product err:", err)
|
||||
return nil, status.Error(codes.Internal, utils.ErrorNotFund.Msg)
|
||||
}
|
||||
|
||||
info.ProductItems = productItems
|
||||
mobile, _ := utils.DecryptPhone(info.Mobile)
|
||||
info.AesMobile = info.Mobile
|
||||
info.Mobile = mobile
|
||||
|
||||
res := order.OrderInfoResponse{
|
||||
Id: info.Id,
|
||||
OrderSn: info.OrderSn,
|
||||
StoreId: int64(info.StoreId),
|
||||
StoreName: info.SaleName,
|
||||
SaleName: info.SaleName,
|
||||
SaleMobile: info.SaleMobile,
|
||||
UserId: int64(info.UserId),
|
||||
UserName: info.UserName,
|
||||
SaleId: int64(info.SaleId),
|
||||
Mobile: info.Mobile,
|
||||
Address: info.Address,
|
||||
Addressee: info.Addressee,
|
||||
DistrictIds: info.DistrictIds,
|
||||
TotalPrice: utils.RoundFloat(info.TotalPrice),
|
||||
PayPrice: utils.RoundFloat(info.PayPrice),
|
||||
PayType: int32(info.PayType),
|
||||
DeliverStatus: int32(info.DeliverStatus),
|
||||
Status: int32(info.Status),
|
||||
IsSupply: int32(info.IsSupply),
|
||||
Note: info.Note,
|
||||
ProductIds: info.ProductIds,
|
||||
OutTradeNo: info.OutTradeNo,
|
||||
Type: int32(info.Type),
|
||||
VerifyStatus: int32(info.VerifyStatus),
|
||||
CreateType: int32(info.CreateType),
|
||||
RefundStatus: int32(info.RefundStatus),
|
||||
}
|
||||
for _, v := range productItems {
|
||||
res.ProductItems = append(res.ProductItems, &order.ProductItemsResponse{
|
||||
Id: int64(v.Id),
|
||||
ProductId: int64(v.ProductId),
|
||||
ProductName: v.ProductName,
|
||||
Price: utils.RoundFloat(float64(v.Price)),
|
||||
Number: int32(v.Number),
|
||||
OrderSn: v.OrderSn,
|
||||
})
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
@@ -92,15 +92,13 @@ func (l *ItemsLogic) Items(in *order.OrderItemsRequest) (*order.Response, error)
|
||||
l.Logger.Error("order_sn:", v.OrderSn)
|
||||
ids = append(ids, v.OrderSn)
|
||||
}
|
||||
l.Logger.Error("ids:", ids)
|
||||
l.Logger.Error(len(ids), utils.NumberOne)
|
||||
var productItems []dao.OrderProducts
|
||||
ww := modelbase.Params{
|
||||
In: map[string][]string{"order_sn": ids},
|
||||
}
|
||||
err = model.OrderProductModel{}.Init().Items(ww, &productItems)
|
||||
if err != nil {
|
||||
utils.Logger.Error("product err:", err)
|
||||
l.Logger.Error("product err:", err)
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
"lone-services/services/order/internal/dao"
|
||||
"lone-services/services/order/internal/model"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"lone-services/rpc/order/pb"
|
||||
"lone-services/services/order/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type OrderInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewOrderInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderInfoLogic {
|
||||
return &OrderInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OrderInfoLogic) OrderInfo(in *order.IdRequest) (*order.Response, error) {
|
||||
var v validate.InfoValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
var info dao.OrderInfo
|
||||
modelObj := model.OrderModel{}.Init()
|
||||
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
||||
err := modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
var productItems []dao.OrderProducts
|
||||
ww := modelbase.Params{
|
||||
In: map[string][]string{"order_sn": strings.Split(info.ProductIds, utils.DecollatorComma)},
|
||||
}
|
||||
err = model.OrderProductModel{}.Init().Items(ww, &productItems)
|
||||
if err != nil {
|
||||
l.Logger.Error("product err:", err)
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
info.ProductItems = productItems
|
||||
mobile, _ := utils.DecryptPhone(info.Mobile)
|
||||
info.AesMobile = info.Mobile
|
||||
info.Mobile = utils.DecryptPhoneReplace(mobile)
|
||||
|
||||
return l.ok(info)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/rpc/order/pb"
|
||||
"lone-services/services/order/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateOrderDPayStatusLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewUpdateOrderDPayStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateOrderDPayStatusLogic {
|
||||
return &UpdateOrderDPayStatusLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateOrderDPayStatusLogic) UpdateOrderDPayStatus(in *order.UpdateOrderPayStatusRequest) (*order.UpdateOrderPayStatusResponse, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.UpdateOrderPayStatusResponse{}, nil
|
||||
}
|
||||
@@ -108,6 +108,11 @@ func (s *OrderServer) OrderDown(ctx context.Context, in *order.OrderItemsRequest
|
||||
return l.OrderDown(in)
|
||||
}
|
||||
|
||||
func (s *OrderServer) OrderInfo(ctx context.Context, in *order.IdRequest) (*order.Response, error) {
|
||||
l := logic.NewOrderInfoLogic(ctx, s.svcCtx)
|
||||
return l.OrderInfo(in)
|
||||
}
|
||||
|
||||
func (s *OrderServer) UpdateOrderDeliverStatus(ctx context.Context, in *order.UpdateOrderDeliverStatusRequest) (*order.UpdateOrderDeliverStatusResponse, error) {
|
||||
l := logic.NewUpdateOrderDeliverStatusLogic(ctx, s.svcCtx)
|
||||
return l.UpdateOrderDeliverStatus(in)
|
||||
@@ -117,3 +122,8 @@ func (s *OrderServer) GetOrderInfo(ctx context.Context, in *order.GetOrderInfoRe
|
||||
l := logic.NewGetOrderInfoLogic(ctx, s.svcCtx)
|
||||
return l.GetOrderInfo(in)
|
||||
}
|
||||
|
||||
func (s *OrderServer) UpdateOrderDPayStatus(ctx context.Context, in *order.UpdateOrderPayStatusRequest) (*order.UpdateOrderPayStatusResponse, error) {
|
||||
l := logic.NewUpdateOrderDPayStatusLogic(ctx, s.svcCtx)
|
||||
return l.UpdateOrderDPayStatus(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user