package analysisstorelogic import ( "context" "strconv" "strings" "lone-services/pkg/utils" analysis "lone-services/rpc/analysis/pb" storepb "lone-services/rpc/store/pb" "lone-services/services/analysis/internal/dao" "lone-services/services/analysis/internal/logic/common" "lone-services/services/analysis/internal/svc" "github.com/zeromicro/go-zero/core/logx" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) func loadPassedStore(ctx context.Context, storeId int64) (*storepb.InfoResponse, *analysis.Response) { if storeId < utils.NumberOne { return nil, common.OutResponse(utils.ErrorParams, "门店信息不存在") } svcName := utils.GetConfigString("services.store") if svcName == utils.StringEmpty { return nil, common.FailResponse(utils.Fail) } cli, err := svc.GetRpcClient(svcName) if err != nil { logx.WithContext(ctx).Errorf("store info rpc: %v", err) return nil, common.FailResponse(utils.Fail) } info, err := storepb.NewStoreClient(cli.Conn()).GetInfoById(ctx, &storepb.IdRequest{Id: storeId}) if err != nil { logx.WithContext(ctx).Errorf("store info get: %v", err) if st, ok := status.FromError(err); ok && (st.Code() == codes.NotFound || st.Message() == utils.ErrorNotFund.Msg) { return nil, common.FailResponse(utils.ErrorNotFund) } return nil, common.FailResponse(utils.Fail) } if info == nil || info.Id < utils.NumberOne || info.Status != int32(utils.StatusOk) { return nil, common.FailResponse(utils.ErrorNotFund) } return info, nil } func skinStore(info *storepb.InfoResponse) dao.StoreSkinInfo { return dao.StoreSkinInfo{ Id: info.Id, StoreName: info.Name, StoreUserName: info.UserName, StoreUserMobile: utils.DecryptPhoneReplace(info.UserMobile), District: info.DistrictIds, Address: regionAddress(info), StoreImg: info.Images, StoreContact: info.Contact, StoreContent: info.Content, OpenTime: info.OpenTime, LongitudeWgs84: info.LongitudeWgs84, LatitudeWgs84: info.LatitudeWgs84, LongitudeGcj02: info.LongitudeGcj02, LatitudeGcj02: info.LatitudeGcj02, CreateTime: info.CreateTime, } } func regionAddress(info *storepb.InfoResponse) string { parts := make([]string, 0, 3) for _, name := range []string{info.ProvinceName, info.CityName, info.CountyName} { if name != utils.StringEmpty { parts = append(parts, name) } } return strings.Join(parts, "") + info.Address } func dateOnly(value string) string { if len(value) >= len("2006-01-02") { return value[:len("2006-01-02")] } return value } func idStrings(ids []int64) []string { out := make([]string, 0, len(ids)) for _, id := range ids { if id < utils.NumberOne { continue } out = append(out, strconv.FormatInt(id, utils.NumberTen)) } return out }