获取订单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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user