feat: product items info

This commit is contained in:
zzw
2026-10-08 09:25:41 +08:00
parent 5fdf23beed
commit cfe88e0f56
27 changed files with 1213 additions and 224 deletions
@@ -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
}