feat: product items info
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"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"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type ExistByStoreProductLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewExistByStoreProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExistByStoreProductLogic {
|
||||
return &ExistByStoreProductLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ExistByStoreProduct 门店是否存在指定产品的已支付/待支付/支付中订单(内部)
|
||||
func (l *ExistByStoreProductLogic) ExistByStoreProduct(in *order.ExistByStoreProductReq) (*order.ExistByStoreProductResp, error) {
|
||||
if in.StoreId < utils.NumberOne || in.ProductId < utils.NumberOne {
|
||||
return nil, status.Error(codes.InvalidArgument, utils.ErrorParams.Msg)
|
||||
}
|
||||
|
||||
var info dao.OrderInfo
|
||||
err := model.OrderModel{}.Init().GetOne(modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"product_ids": strconv.FormatInt(in.ProductId, utils.NumberTen),
|
||||
"store_id": strconv.FormatInt(in.StoreId, utils.NumberTen),
|
||||
},
|
||||
In: map[string][]string{
|
||||
"status": {
|
||||
utils.StringStatusOk,
|
||||
strconv.Itoa(dao.OrderPayStatusWait),
|
||||
strconv.Itoa(dao.OrderPayStatusIn),
|
||||
},
|
||||
},
|
||||
}, &info)
|
||||
if err != nil {
|
||||
l.Errorf("exist by store product: %v", err)
|
||||
return nil, status.Error(codes.Internal, utils.Fail.Msg)
|
||||
}
|
||||
|
||||
return &order.ExistByStoreProductResp{Exist: info.Id >= utils.NumberOne}, nil
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.2
|
||||
// goctl 1.10.1
|
||||
// Source: order.proto
|
||||
|
||||
package server
|
||||
@@ -95,6 +95,12 @@ func (s *OrderServer) UpdateOrderPayStatus(ctx context.Context, in *order.Update
|
||||
return l.UpdateOrderPayStatus(in)
|
||||
}
|
||||
|
||||
// 门店是否存在指定产品的有效/待支付订单(内部)
|
||||
func (s *OrderServer) ExistByStoreProduct(ctx context.Context, in *order.ExistByStoreProductReq) (*order.ExistByStoreProductResp, error) {
|
||||
l := logic.NewExistByStoreProductLogic(ctx, s.svcCtx)
|
||||
return l.ExistByStoreProduct(in)
|
||||
}
|
||||
|
||||
// API
|
||||
func (s *OrderServer) ApiSupply(ctx context.Context, in *order.ApiSupplyRequest) (*order.Response, error) {
|
||||
l := logic.NewApiSupplyLogic(ctx, s.svcCtx)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.2
|
||||
// goctl 1.10.1
|
||||
// Source: order.proto
|
||||
|
||||
package orderClient
|
||||
@@ -26,6 +26,8 @@ type (
|
||||
EditCartRequest = order.EditCartRequest
|
||||
EmptyRequest = order.EmptyRequest
|
||||
ExcelExportResponse = order.ExcelExportResponse
|
||||
ExistByStoreProductReq = order.ExistByStoreProductReq
|
||||
ExistByStoreProductResp = order.ExistByStoreProductResp
|
||||
GetOrderInfoRequest = order.GetOrderInfoRequest
|
||||
IdAndTypeRequest = order.IdAndTypeRequest
|
||||
IdRequest = order.IdRequest
|
||||
@@ -64,6 +66,8 @@ type (
|
||||
GetOrderInfo(ctx context.Context, in *GetOrderInfoRequest, opts ...grpc.CallOption) (*OrderInfoResponse, error)
|
||||
// status 1 为已支付 4 支付失败,其它的返回错误
|
||||
UpdateOrderPayStatus(ctx context.Context, in *UpdateOrderPayStatusRequest, opts ...grpc.CallOption) (*UpdateOrderPayStatusResponse, error)
|
||||
// 门店是否存在指定产品的有效/待支付订单(内部)
|
||||
ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error)
|
||||
// API
|
||||
ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
ApiSupplyInfo(ctx context.Context, in *ApiSupplyInfoRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
@@ -164,6 +168,12 @@ func (m *defaultOrder) UpdateOrderPayStatus(ctx context.Context, in *UpdateOrder
|
||||
return client.UpdateOrderPayStatus(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 门店是否存在指定产品的有效/待支付订单(内部)
|
||||
func (m *defaultOrder) ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error) {
|
||||
client := order.NewOrderClient(m.cli.Conn())
|
||||
return client.ExistByStoreProduct(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// API
|
||||
func (m *defaultOrder) ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := order.NewOrderClient(m.cli.Conn())
|
||||
|
||||
Reference in New Issue
Block a user