diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000000000000000000000000000000000..205163f2e5b72b00f5673edfe86422a42ae62a15 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 180 +} \ No newline at end of file diff --git a/Proto.lock b/Proto.lock index 3a7bbe5243433188fde841f9fa5c02c7cd4ef60d..b406193ffbacf4a4164571b3b5d884906598c700 100644 --- a/Proto.lock +++ b/Proto.lock @@ -9,6 +9,24 @@ version = "0.0.21" dependencies = [] dependants = 1 +[[packages]] +name = "pay-hera" +digest = "sha256:e8b4d70d38e206516d50e62805a23c9b74911cfe7cd7ecf9bd63dbce7a6f8767" +registry = "https://jfrog.downtown8.com/artifactory" +repository = "protobuf" +version = "0.1.7" +dependencies = [] +dependants = 1 + +[[packages]] +name = "rms-mobile-hera" +digest = "sha256:038c7551d49be8ec141748505e4e5c09bcfdc587b1524a574da9849314b4bb36" +registry = "https://jfrog.downtown8.com/artifactory" +repository = "protobuf" +version = "0.1.3" +dependencies = [] +dependants = 1 + [[packages]] name = "user-center-hera" digest = "sha256:dca5189f791f3d00a7c3e773b1143011c35e13c07f618a91d5fdda4493a321c9" diff --git a/Proto.toml b/Proto.toml index 87ac0b119f29c7a666a8d311796a013467222251..f79f7b789d32af99cecc86267c5602d85f67dbf9 100644 --- a/Proto.toml +++ b/Proto.toml @@ -1,7 +1,7 @@ edition = "0.9" -[dependencies.user-center-hera] -version = "=0.1.28" +[dependencies.pay-hera] +version = "=0.1.7" repository = "protobuf" registry = "https://jfrog.downtown8.com/artifactory" @@ -9,3 +9,13 @@ registry = "https://jfrog.downtown8.com/artifactory" version = "=0.0.21" repository = "protobuf" registry = "https://jfrog.downtown8.com/artifactory" + +[dependencies.rms-mobile-hera] +version = "=0.1.3" +repository = "protobuf" +registry = "https://jfrog.downtown8.com/artifactory" + +[dependencies.user-center-hera] +version = "=0.1.28" +repository = "protobuf" +registry = "https://jfrog.downtown8.com/artifactory" diff --git a/config-templates/config/.env b/config-templates/config/.env index 8cdcb66731d7f721a602ed0185e9e669ec06b667..759d0fe7ecde3976dbd48f9ad0f67d959450ce64 100644 --- a/config-templates/config/.env +++ b/config-templates/config/.env @@ -16,5 +16,11 @@ USER_CENTER_SERVICE_GRPC_PORT=9000 HQ_ORCHESTRATOR_SERVICE=g-hq-orchestrator HQ_ORCHESTRATOR_SERVICE_GRPC_PORT=9000 +PAY_CENTER_SERVICE=n-pay-center +PAY_CENTER_SERVICE_GRPC_PORT=9000 + +N_RMS_MOBILE_CENTER_SERVICE=n-rms-mobile-center +N_RMS_MOBILE_CENTER_SERVICE_GRPC_PORT=9000 + QYWX_BOT_KEY={{getv "/configuration/projects/pos-bff-service/QYWX_BOT_KEY"}} \ No newline at end of file diff --git a/config/.env b/config/.env index 934db097d9ca4fd8496f5d7aa0074bf24f8a8857..03309842f6632d4262a7f8de74c911030c870829 100644 --- a/config/.env +++ b/config/.env @@ -15,6 +15,11 @@ USER_CENTER_SERVICE_GRPC_PORT=8080 HQ_ORCHESTRATOR_SERVICE=127.0.0.1 HQ_ORCHESTRATOR_SERVICE_GRPC_PORT=9000 +PAY_CENTER_SERVICE=127.0.0.1 +PAY_CENTER_SERVICE_GRPC_PORT=9000 + +N_RMS_MOBILE_CENTER_SERVICE=127.0.0.1 +N_RMS_MOBILE_CENTER_SERVICE_GRPC_PORT=9000 RABBIT_VHOST=localv1 QYWX_BOT_KEY="d01614bc-dc2f-4e54-ad79-bedbfd9faeb6" \ No newline at end of file diff --git a/src/app.module.ts b/src/app.module.ts index aefde2f044fc849dff3c361f92d4e8ed0e7dfe61..038050706c7d91aa6f26ac1bbdf4c9282617f7f3 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,24 +1,26 @@ -import { Module, NestModule, MiddlewareConsumer } from "@nestjs/common"; -import { AppController } from "./app.controller"; -import { AppService } from "./app.service"; -import { LoggerModule } from "./logger/logger.module"; -import { ApolloDriver, ApolloDriverConfig } from "@nestjs/apollo"; -import { GraphQLModule } from "@nestjs/graphql"; -import { upperDirectiveTransformer } from "./lib/upper-case.directive"; -import { ClsModule } from "nestjs-cls"; -import LogHelp from "@dt/log-help"; -import { AllExceptionsFilter } from "./filter/all-exceptions.filter"; -import { LoggerService } from "./logger/logger.service"; -import { v4 as uuidv4 } from "uuid"; -import { LoggingInterceptor } from "./logger/logging.interceptor"; -import { ENV_NAME_ENUM } from "./lib/enum"; -import { QyWechatbotModule, QyWechatbotService } from "@dt/nestjs-qywechatbot"; -import { UserCenterModule } from "./user/user.module"; -import { grpcResolver } from "./common/grpcResolver"; -import { GrpcMetadataInterceptor } from "./interceptor/grpc-metadata.interceptor"; -import { UserLoginModule } from "./userLogin/userLogin.module"; +import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; +import { LoggerModule } from './logger/logger.module'; +import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; +import { GraphQLModule } from '@nestjs/graphql'; +import { upperDirectiveTransformer } from './lib/upper-case.directive'; +import { ClsModule } from 'nestjs-cls'; +import LogHelp from '@dt/log-help'; +import { AllExceptionsFilter } from './filter/all-exceptions.filter'; +import { LoggerService } from './logger/logger.service'; +import { v4 as uuidv4 } from 'uuid'; +import { LoggingInterceptor } from './logger/logging.interceptor'; +import { ENV_NAME_ENUM } from './lib/enum'; +import { QyWechatbotModule, QyWechatbotService } from '@dt/nestjs-qywechatbot'; +import { UserCenterModule } from './user/user.module'; +import { grpcResolver } from './common/grpcResolver'; +import { GrpcMetadataInterceptor } from './interceptor/grpc-metadata.interceptor'; +import { UserLoginModule } from './userLogin/userLogin.module'; import { PublicModule } from './public/public.module'; import { BrandStoreModule } from './brand-store/brand-store.module'; +import { PayModule } from './pay/pay.module'; +import { MobileConfigModule } from './mobileConfig/mobileConfig.module'; @Module({ imports: [ GraphQLModule.forRootAsync<ApolloDriverConfig>({ @@ -30,15 +32,11 @@ import { BrandStoreModule } from './brand-store/brand-store.module'; }), ], inject: [LoggerService, QyWechatbotService], - useFactory: async ( - logger: LoggerService, - qyWechatBot: QyWechatbotService - ) => { + useFactory: async (logger: LoggerService, qyWechatBot: QyWechatbotService) => { const isDebug = process.env.ENV_NAME !== ENV_NAME_ENUM.PORDUCT; return { - typePaths: ["./**/*.graphql"], - transformSchema: (schema) => - upperDirectiveTransformer(schema, "upper"), + typePaths: ['./**/*.graphql'], + transformSchema: (schema) => upperDirectiveTransformer(schema, 'upper'), installSubscriptionHandlers: true, formatError: (error) => { logger.log(error); @@ -49,9 +47,9 @@ import { BrandStoreModule } from './brand-store/brand-store.module'; ** 消æ¯**: ${error?.message} ** 路径**: ${error?.path} ** 错误ç **: ${error?.extensions?.code} - ** Trace Id**: ${logger.dtlog.get("trace_id")} + ** Trace Id**: ${logger.dtlog.get('trace_id')} ** 环境**: ${process.env?.RABBIT_VHOST} - ` + `, ); if (isDebug) { @@ -75,11 +73,7 @@ import { BrandStoreModule } from './brand-store/brand-store.module'; // logger.dtlog.setCategory(''); if (body?.variables && body?.query) { - body.variables = grpcResolver.formatVariables( - body.query, - body.variables, - headers - ); + body.variables = grpcResolver.formatVariables(body.query, body.variables, headers); } }, }; @@ -94,22 +88,22 @@ import { BrandStoreModule } from './brand-store/brand-store.module'; // and use the setup method to // provide default store values. setup: (cls, req) => { - cls.set("url", req.headers["url"]); + cls.set('url', req.headers['url']); const dtlog = new LogHelp(); - dtlog.set({ url: cls.get("url") }); - let traceId = req.headers["trace_id"]; + dtlog.set({ url: cls.get('url') }); + let traceId = req.headers['trace_id']; if (!traceId) { - traceId = uuidv4().replace(/-/g, ""); + traceId = uuidv4().replace(/-/g, ''); } traceId && dtlog.set({ trace_id: traceId }); - cls.set("pos-version", req.headers["pos-version"]); - cls.set("x-version", req.headers["x-version"]); - cls.set("x-b3-traceid", req.headers["x-b3-traceid"]); - cls.set("x-b3-spanid", req.headers["x-b3-spanid"]); - cls.set("x-b3-sampled", req.headers["x-b3-sampled"]); - cls.set("x-b3-flags", req.headers["x-b3-flags"]); - cls.set("dtlog", dtlog); + cls.set('pos-version', req.headers['pos-version']); + cls.set('x-version', req.headers['x-version']); + cls.set('x-b3-traceid', req.headers['x-b3-traceid']); + cls.set('x-b3-spanid', req.headers['x-b3-spanid']); + cls.set('x-b3-sampled', req.headers['x-b3-sampled']); + cls.set('x-b3-flags', req.headers['x-b3-flags']); + cls.set('dtlog', dtlog); }, }, }), @@ -121,6 +115,8 @@ import { BrandStoreModule } from './brand-store/brand-store.module'; UserLoginModule, PublicModule, BrandStoreModule, + PayModule, + MobileConfigModule, ], controllers: [AppController], providers: [ diff --git a/src/common/base.grpc.service.ts b/src/common/base.grpc.service.ts index 5822c4b03b99dd0436de717bae9254a06ce2a7e5..5ac3a7628190550b56aad3b76a17096668e20dee 100644 --- a/src/common/base.grpc.service.ts +++ b/src/common/base.grpc.service.ts @@ -1,7 +1,7 @@ -import { ClientGrpc } from "@nestjs/microservices"; -import { GraphQLError } from "graphql"; -import { lastValueFrom } from "rxjs"; -import { Metadata } from "@grpc/grpc-js"; +import { ClientGrpc } from '@nestjs/microservices'; +import { GraphQLError } from 'graphql'; +import { lastValueFrom } from 'rxjs'; +import { Metadata } from '@grpc/grpc-js'; interface GrpcResponse { code: number; @@ -15,12 +15,16 @@ export class BaseGrpcService { protected userAccessService: any; protected hqPublicOrchestratorService: any; protected hqBrandStoreService: any; + protected payService: any; + protected orderConfigService: any; protected get serviceMap() { return { hqUserPermit: this.userPermitService, hqUserAccess: this.userAccessService, hqPublicOrchestrator: this.hqPublicOrchestratorService, hqBrandStoreOrchestrator: this.hqBrandStoreService, + payService: this.payService, + orderConfigService: this.orderConfigService, }; } @@ -30,10 +34,10 @@ export class BaseGrpcService { const metadata: Metadata = request.grpcMetadata; // 获å–æ“作类型 - const isMutation = request.operationType === "mutation"; + const isMutation = request.operationType === 'mutation'; // 优先采用inputä¸çš„brandIdå’ŒstoreId - console.log("input", input); + console.log('input', input); if (!input?.brandId) { input.brandId = request.brandId; } @@ -43,9 +47,9 @@ export class BaseGrpcService { const result = await lastValueFrom<GrpcResponse>(service[methodName](input, metadata)); - console.log("result--------", result); + console.log('result--------', result); - if ("code" in result && result.code !== 0) { + if ('code' in result && result.code !== 0) { throw new GraphQLError(result.msg, { extensions: { code: result.code, diff --git a/src/mobileConfig/mobileConfig.module.ts b/src/mobileConfig/mobileConfig.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..5201110705c460b5571c58423abfd0db42f6e696 --- /dev/null +++ b/src/mobileConfig/mobileConfig.module.ts @@ -0,0 +1,24 @@ +import { join } from 'path'; +import { Module } from '@nestjs/common'; +import { StoreOrderConfigResolver } from './storeOrder/storeOrderConfig.resolver'; +import { StoreOrderConfigService } from './storeOrder/storeOrderConfig.service'; + +import { ClientsModule, Transport } from '@nestjs/microservices'; + +@Module({ + imports: [ + ClientsModule.register([ + { + name: 'MOBILE-CONFIG', + transport: Transport.GRPC, + options: { + url: `${process.env.N_RMS_MOBILE_CENTER_SERVICE}:${process.env.N_RMS_MOBILE_CENTER_SERVICE_GRPC_PORT}`, + package: ['rmsMobile'], + protoPath: [join(process.cwd(), 'proto/vendor/rms-mobile-hera/storeOrderConfig.proto')], + }, + }, + ]), + ], + providers: [StoreOrderConfigResolver, StoreOrderConfigService], +}) +export class MobileConfigModule {} diff --git a/src/mobileConfig/storeOrder/storeOrderConfig.graphql b/src/mobileConfig/storeOrder/storeOrderConfig.graphql new file mode 100644 index 0000000000000000000000000000000000000000..7eb2126b424fa9394baf70bf09b27b4eba21df50 --- /dev/null +++ b/src/mobileConfig/storeOrder/storeOrderConfig.graphql @@ -0,0 +1,256 @@ +# Code generated by protoc-gen-graphql. DO NOT EDIT. + +type rmsMobile_SuccesResponse { + code: Int + msg: String +} + +input Input_rmsMobile_StoreIdDto { + brandId: Int + storeId: Int +} + +input Input_rmsMobile_TimeHourStartAndEnd { + start: String + end: String +} + +type rmsMobile_TimeHourStartAndEnd { + start: String + end: String +} + +input Input_rmsMobile_StorePlacardData { + brandId: Int + storeId: Int + isStoreInfoShow: Boolean + isCostomShow: Boolean + costomShowValue: String + costomShowMode: String + costomShowTimeType: String + costomShowTimeValue: [Int] + costomShowTimeDateStart: String + costomShowTimeDateEnd: String + costomShowTimeHours: [Input_rmsMobile_TimeHourStartAndEnd] +} + +type rmsMobile_StorePlacardData { + brandId: Int + storeId: Int + isStoreInfoShow: Boolean + isCostomShow: Boolean + costomShowValue: String + costomShowMode: String + costomShowTimeType: String + costomShowTimeValue: [Int] + costomShowTimeDateStart: String + costomShowTimeDateEnd: String + costomShowTimeHours: [rmsMobile_TimeHourStartAndEnd] +} + +type rmsMobile_StorePlacardDataRes { + code: Int + msg: String + data: rmsMobile_StorePlacardData +} + +input Input_rmsMobile_StoreWaitInfoData { + brandId: Int + storeId: Int + isWaitInfoShow: Boolean + waitInfoShowType: String + waitTimeShowMoreThan: Int + waitTimeEveryProduct: Int +} + +type rmsMobile_StoreWaitInfoData { + brandId: Int + storeId: Int + isWaitInfoShow: Boolean + waitInfoShowType: String + waitTimeShowMoreThan: Int + waitTimeEveryProduct: Int +} + +type rmsMobile_StoreWaitInfoDataRes { + code: Int + msg: String + data: rmsMobile_StoreWaitInfoData +} + +type rmsMobile_StoreProductSaleStockData { + brandId: Int + storeId: Int + isSaleShow: Boolean + isStockShow: Boolean + saleShowTimeRange: String + saleShowMoreThan: Int + stockOverShowType: String +} + +input Input_rmsMobile_StoreProductSaleStockData { + brandId: Int + storeId: Int + isSaleShow: Boolean + isStockShow: Boolean + saleShowTimeRange: String + saleShowMoreThan: Int + stockOverShowType: String +} + +type rmsMobile_StoreProductSaleStockDataRes { + code: Int + msg: String + data: rmsMobile_StoreProductSaleStockData +} + +input Input_rmsMobile_StoreProductPushData { + brandId: Int + storeId: Int + isSmartPushShow: Boolean + smartPushShowType: String +} + +type rmsMobile_StoreProductPushData { + brandId: Int + storeId: Int + isSmartPushShow: Boolean + smartPushShowType: String +} + +type rmsMobile_StoreProductPushDataRes { + code: Int + msg: String + data: rmsMobile_StoreProductPushData +} + +input Input_rmsMobile_StoreProductSearchData { + brandId: Int + storeId: Int + isSearchShow: Boolean +} + +type rmsMobile_StoreProductSearchData { + brandId: Int + storeId: Int + isSearchShow: Boolean +} + +type rmsMobile_StoreProductSearchDataRes { + code: Int + msg: String + data: rmsMobile_StoreProductSearchData +} + +input Input_rmsMobile_EatTypeDto { + eatType: String + isOpen: Boolean + name: String +} + +type rmsMobile_EatTypeDto { + eatType: String + isOpen: Boolean + name: String +} + +input Input_rmsMobile_StoreEatTypeData { + brandId: Int + storeId: Int + brandCodeEatTypes: [Input_rmsMobile_EatTypeDto] + tableCodeEatTypes: [Input_rmsMobile_EatTypeDto] +} + +type rmsMobile_StoreEatTypeData { + brandId: Int + storeId: Int + brandCodeEatTypes: [rmsMobile_EatTypeDto] + tableCodeEatTypes: [rmsMobile_EatTypeDto] +} + +type rmsMobile_StoreEatTypeDataRes { + code: Int + msg: String + data: rmsMobile_StoreEatTypeData +} + +input Input_rmsMobile_StoreOrderMustMobileData { + brandId: Int + storeId: Int + isMobileMust: Boolean +} + +type rmsMobile_StoreOrderMustMobileData { + brandId: Int + storeId: Int + isMobileMust: Boolean +} + +type rmsMobile_StoreOrderMustMobileDataRes { + code: Int + msg: String + data: rmsMobile_StoreOrderMustMobileData +} + +input Input_rmsMobile_StoreOrderRemarkData { + brandId: Int + storeId: Int + isRemarkCommit: Boolean + remarkTemplates: [String] +} + +type rmsMobile_StoreOrderRemarkData { + brandId: Int + storeId: Int + isRemarkCommit: Boolean + remarkTemplates: [String] +} + +type rmsMobile_StoreOrderRemarkDataRes { + code: Int + msg: String + data: rmsMobile_StoreOrderRemarkData +} + +input Input_rmsMobile_StoreNoticeData { + brandId: Int + storeId: Int + isPickupNotice: Boolean +} + +type rmsMobile_StoreNoticeData { + brandId: Int + storeId: Int + isPickupNotice: Boolean +} + +type rmsMobile_StoreNoticeDataRes { + code: Int + msg: String + data: rmsMobile_StoreNoticeData +} + +type Query { + StorePlacardGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StorePlacardData! + StoreWaitInfoGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreWaitInfoData! + StoreProductSaleStockGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreProductSaleStockData! + StoreProductPushGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreProductPushData! + StoreProductSearchGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreProductSearchData! + StoreEatTypeGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreEatTypeData! + StoreOrderMustMobileGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreOrderMustMobileData! + StoreOrderRemarkGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreOrderRemarkData! + StoreNoticeGet(input: Input_rmsMobile_StoreIdDto!): rmsMobile_StoreNoticeData! +} + +type Mutation { + StorePlacardSet(input: Input_rmsMobile_StorePlacardData!): String! + StoreWaitInfoSet(input: Input_rmsMobile_StoreWaitInfoData!): String! + StoreProductSaleStockSet(input: Input_rmsMobile_StoreProductSaleStockData!): String! + StoreProductPushSet(input: Input_rmsMobile_StoreProductPushData!): String! + StoreProductSearchSet(input: Input_rmsMobile_StoreProductSearchData!): String! + StoreEatTypeSet(input: Input_rmsMobile_StoreEatTypeData!): String! + StoreOrderMustMobileSet(input: Input_rmsMobile_StoreOrderMustMobileData!): String! + StoreOrderRemarkSet(input: Input_rmsMobile_StoreOrderRemarkData!): String! + StoreNoticeSet(input: Input_rmsMobile_StoreNoticeData!): String! +} + diff --git a/src/mobileConfig/storeOrder/storeOrderConfig.resolver.ts b/src/mobileConfig/storeOrder/storeOrderConfig.resolver.ts new file mode 100644 index 0000000000000000000000000000000000000000..4159f88700fbdf0a5b18b9e1bc3d9d148601e8ff --- /dev/null +++ b/src/mobileConfig/storeOrder/storeOrderConfig.resolver.ts @@ -0,0 +1,103 @@ +import { UseInterceptors } from '@nestjs/common'; +import { Args, Query, Resolver, Context, Mutation } from '@nestjs/graphql'; +import { GrpcMetadataInterceptor } from '../../interceptor/grpc-metadata.interceptor'; +import { NullToZeroInterceptor } from '../../interceptor/null-to-zero.interceptor'; +import { OperationTypeInterceptor } from '../../interceptor/operation-type.interceptor'; + +import { StoreOrderConfigService } from './storeOrderConfig.service'; + +@Resolver() +@UseInterceptors(GrpcMetadataInterceptor, NullToZeroInterceptor, OperationTypeInterceptor) +export class StoreOrderConfigResolver { + constructor(private readonly storeOrderConfigService: StoreOrderConfigService) {} + + @Query('StorePlacardGet') + async StorePlacardGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StorePlacardGet(input, context); + } + + @Mutation('StorePlacardSet') + async StorePlacardSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StorePlacardSet(input, context); + } + + @Query('StoreWaitInfoGet') + async StoreWaitInfoGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreWaitInfoGet(input, context); + } + + @Mutation('StoreWaitInfoSet') + async StoreWaitInfoSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreWaitInfoSet(input, context); + } + + @Query('StoreProductSaleStockGet') + async StoreProductSaleStockGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductSaleStockGet(input, context); + } + + @Mutation('StoreProductSaleStockSet') + async StoreProductSaleStockSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductSaleStockSet(input, context); + } + + @Query('StoreProductPushGet') + async StoreProductPushGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductPushGet(input, context); + } + + @Mutation('StoreProductPushSet') + async StoreProductPushSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductPushSet(input, context); + } + + @Query('StoreProductSearchGet') + async StoreProductSearchGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductSearchGet(input, context); + } + + @Mutation('StoreProductSearchSet') + async StoreProductSearchSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreProductSearchSet(input, context); + } + + @Query('StoreEatTypeGet') + async StoreEatTypeGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreEatTypeGet(input, context); + } + + @Mutation('StoreEatTypeSet') + async StoreEatTypeSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreEatTypeSet(input, context); + } + + @Query('StoreOrderMustMobileGet') + async StoreOrderMustMobileGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreOrderMustMobileGet(input, context); + } + + @Mutation('StoreOrderMustMobileSet') + async StoreOrderMustMobileSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreOrderMustMobileSet(input, context); + } + + @Query('StoreOrderRemarkGet') + async StoreOrderRemarkGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreOrderRemarkGet(input, context); + } + + @Mutation('StoreOrderRemarkSet') + async StoreOrderRemarkSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreOrderRemarkSet(input, context); + } + + @Query('StoreNoticeGet') + async StoreNoticeGet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreNoticeGet(input, context); + } + + @Mutation('StoreNoticeSet') + async StoreNoticeSet(@Args('input') input: any, @Context() context: any) { + return this.storeOrderConfigService.StoreNoticeSet(input, context); + } +} diff --git a/src/mobileConfig/storeOrder/storeOrderConfig.service.ts b/src/mobileConfig/storeOrder/storeOrderConfig.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b04783bbda6e467caa35f366e3002f3141d0e6d5 --- /dev/null +++ b/src/mobileConfig/storeOrder/storeOrderConfig.service.ts @@ -0,0 +1,87 @@ +import { BaseGrpcService } from '@/common/base.grpc.service'; +import { Injectable, Inject } from '@nestjs/common'; +import { ClientGrpc } from '@nestjs/microservices'; + +@Injectable() +export class StoreOrderConfigService extends BaseGrpcService { + constructor(@Inject('MOBILE-CONFIG') private readonly client: ClientGrpc) { + super(); + } + + onModuleInit() { + this.orderConfigService = this.client.getService<any>('OrderConfigService'); + } + + async StorePlacardGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StorePlacardGet', input, context); + } + + async StorePlacardSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StorePlacardSet', input, context); + } + // + + async StoreWaitInfoGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreWaitInfoGet', input, context); + } + + async StoreWaitInfoSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreWaitInfoSet', input, context); + } + + async StoreProductSaleStockGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductSaleStockGet', input, context); + } + + async StoreProductSaleStockSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductSaleStockSet', input, context); + } + + async StoreProductPushGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductPushGet', input, context); + } + + async StoreProductPushSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductPushSet', input, context); + } + + async StoreProductSearchGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductSearchGet', input, context); + } + + async StoreProductSearchSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreProductSearchSet', input, context); + } + + async StoreEatTypeGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreEatTypeGet', input, context); + } + + async StoreEatTypeSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreEatTypeSet', input, context); + } + + async StoreOrderMustMobileGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreOrderMustMobileGet', input, context); + } + + async StoreOrderMustMobileSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreOrderMustMobileSet', input, context); + } + + async StoreOrderRemarkGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreOrderRemarkGet', input, context); + } + + async StoreOrderRemarkSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreOrderRemarkSet', input, context); + } + + async StoreNoticeGet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreNoticeGet', input, context); + } + + async StoreNoticeSet(input: any, context: any) { + return this.callGrpcMethod('orderConfigService', 'StoreNoticeSet', input, context); + } +} diff --git a/src/pay/pay.graphql b/src/pay/pay.graphql new file mode 100644 index 0000000000000000000000000000000000000000..290997ccb91b30cc9549f2be970a43b502e1f87d --- /dev/null +++ b/src/pay/pay.graphql @@ -0,0 +1,7 @@ +input BrandIdDto { + brandId: Int +} + +type Query { + WechatBankList(input: BrandIdDto!): [String] +} diff --git a/src/pay/pay.module.ts b/src/pay/pay.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee779917f477981d4e916702b58c230380517ac4 --- /dev/null +++ b/src/pay/pay.module.ts @@ -0,0 +1,24 @@ +import { join } from 'path'; +import { Module } from '@nestjs/common'; +import { PaymentResolver } from './payment.resolver'; +import { PaymentService } from './payment.service'; + +import { ClientsModule, Transport } from '@nestjs/microservices'; + +@Module({ + imports: [ + ClientsModule.register([ + { + name: 'PAY-CENTER', + transport: Transport.GRPC, + options: { + url: `${process.env.PAY_CENTER_SERVICE}:${process.env.PAY_CENTER_SERVICE_GRPC_PORT}`, + package: ['pay'], + protoPath: [join(process.cwd(), 'proto/vendor/pay-hera/payment.proto')], + }, + }, + ]), + ], + providers: [PaymentResolver, PaymentService], +}) +export class PayModule {} diff --git a/src/pay/payment.resolver.ts b/src/pay/payment.resolver.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8ab1de590c63c8cbf34fcfa35a5730f0ff01893 --- /dev/null +++ b/src/pay/payment.resolver.ts @@ -0,0 +1,19 @@ +import { UseInterceptors } from '@nestjs/common'; +import { Args, Query, Resolver, Context } from '@nestjs/graphql'; + +import { NullToZeroInterceptor } from '../interceptor/null-to-zero.interceptor'; +import { GrpcMetadataInterceptor } from '../interceptor/grpc-metadata.interceptor'; +import { OperationTypeInterceptor } from '../interceptor/operation-type.interceptor'; + +import { PaymentService } from './payment.service'; + +@Resolver() +@UseInterceptors(GrpcMetadataInterceptor, NullToZeroInterceptor, OperationTypeInterceptor) +export class PaymentResolver { + constructor(private readonly paymentService: PaymentService) {} + + @Query('WechatBankList') + async WechatBankList(@Args('input') input: any, @Context() context: any) { + return this.paymentService.WechatBankList(input, context); + } +} diff --git a/src/pay/payment.service.ts b/src/pay/payment.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..a05b8b5198b2edf9a0868195aa54cc54253709b3 --- /dev/null +++ b/src/pay/payment.service.ts @@ -0,0 +1,19 @@ +import { Injectable, Inject } from '@nestjs/common'; +import { ClientGrpc } from '@nestjs/microservices'; + +import { BaseGrpcService } from '@/common/base.grpc.service'; + +@Injectable() +export class PaymentService extends BaseGrpcService { + constructor(@Inject('PAY-CENTER') private readonly client: ClientGrpc) { + super(); + } + + onModuleInit() { + this.payService = this.client.getService<any>('PaymentService'); + } + + async WechatBankList(input: any, context: any) { + return this.callGrpcMethod('payService', 'WechatBankList', input, context); + } +}