diff --git a/.env.test b/.env.test index 7ffe5e0..0e54242 100644 --- a/.env.test +++ b/.env.test @@ -3,8 +3,10 @@ JWT_ISSUER="pena-auth-service" JWT_AUDIENCE="pena" JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgHgnvr7O2tiApjJfid1orFnIGm69\n80fZp+Lpbjo+NC/0whMFga2Biw5b1G2Q/B2u0tpO1Fs/E8z7Lv1nYfr5jx2S8x6B\ndA4TS2kB9Kf0wn0+7wSlyikHoKhbtzwXHZl17GsyEi6wHnsqNBSauyIWhpha8i+Y\n+3GyaOY536H47qyXAgMBAAE=\n-----END PUBLIC KEY-----" -HTTP_HOST=0.0.0.0 -HTTP_PORT=8082 +EXTERNAL_HTTP_HOST=0.0.0.0 +EXTERNAL_HTTP_PORT=8082 +INTERNAL_HTTP_HOST=0.0.0.0 +INTERNAL_HTTP_PORT=8083 GRPC_HOST=0.0.0.0 GRPC_PORT=9001 diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..c8decfa --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: Deploy +run-name: ${{ gitea.actor }} build image and push to container registry + +on: + push: + branches: + - 'main' + - 'staging' + +jobs: + CreateImage: + runs-on: [hubstaging] + uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.0.1 + with: + runner: hubstaging + secrets: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + DeployService: + runs-on: [hubstaging] + needs: CreateImage + uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.0.3 + with: + runner: hubstaging + actionid: ${{ gitea.run_id }} + + diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml new file mode 100644 index 0000000..20e6298 --- /dev/null +++ b/.gitea/workflows/lint.yml @@ -0,0 +1,14 @@ +name: Lint +run-name: ${{ gitea.actor }} produce linting + +on: + push: + branches: + - 'dev' + +jobs: + Lint: + runs-on: [hubstaging] + uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.0 + with: + runner: hubstaging diff --git a/.gitignore b/.gitignore index a102894..7a482d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Dependency directories (remove the comment below to include it) +main vendor/ .idea/ .vscode diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5846c4..25166e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,18 @@ include: file: "/templates/docker/build-template.gitlab-ci.yml" - project: "devops/pena-continuous-integration" file: "/templates/docker/deploy-template.gitlab-ci.yml" + - project: "devops/pena-continuous-integration" + file: "/templates/docker/golint.gitlab-ci.yml" + - project: "devops/pena-continuous-integration" + file: "/templates/docker/service-discovery.gitlab-ci.yml" stages: + - lint - build - deploy + - service-discovery + +lint: + extends: .golint_template build-app: extends: .build_template @@ -21,3 +30,7 @@ deploy-to-prod: tags: - prod extends: .deploy_template + +service-discovery: + extends: .sd_artefacts_template + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bbd0125 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +#v1.0.1 + +INTERNAL: + +- Добавлено версионирование модели данных. На данный момент модель под версией 1 + + +FIX: + +- При пустой корзине во время оплаты(/cart/pay) больше не будет возвращаться 500, а будет возвращаться 406 + +#v1.0.0 diff --git a/Dockerfile b/Dockerfile index 7178ef6..a995215 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # BUILD -FROM golang:1.22.0-alpine AS build +FROM penahub.gitlab.yandexcloud.net:5050/devops/dockerhub-backup/golang:main.3862 AS build # Update packages and clear cache RUN apk add --no-cache curl @@ -21,7 +21,7 @@ RUN go mod download RUN GOOS=linux go build -o bin ./... # PRODUCTION -FROM alpine:3.18.3 AS production +FROM penahub.gitlab.yandexcloud.net:5050/devops/dockerhub-backup/alpine:main.3862 AS production # Install packages RUN apk --no-cache add ca-certificates diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml new file mode 100644 index 0000000..21178c5 --- /dev/null +++ b/Taskfile.dist.yml @@ -0,0 +1,24 @@ +version: "3" + +vars: + VERSION: + sh: head -n 1 ./CHANGELOG.md | cut -c 2- + + +tasks: + update-linter: + cmds: + - go get -u penahub.gitlab.yandexcloud.net/devops/linters/golang.git + lint: + cmds: + - task: update-linter + - cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m gitea.pena/PenaSide/linters-golang)/.golangci.yml + version: + cmds: + - echo "{{.VERSION}}" + tag-create: + cmds: + - git tag {{.VERSION}} + tag-remove: + cmds: + - git tag -d {{.VERSION}} diff --git a/api/openapi/v1/openapi.yaml b/api/openapi/v1/openapi.yaml index 05b40e7..58c552d 100644 --- a/api/openapi/v1/openapi.yaml +++ b/api/openapi/v1/openapi.yaml @@ -118,7 +118,7 @@ paths: schema: $ref: "#/components/schemas/Error" - /accounts: + /getList: get: tags: - account @@ -412,6 +412,12 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + "406": + description: корзина пустая + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /wallet: patch: diff --git a/api/proto/treasurer/payment.model.proto b/api/proto/treasurer/payment.model.proto index f64e166..c6af147 100644 --- a/api/proto/treasurer/payment.model.proto +++ b/api/proto/treasurer/payment.model.proto @@ -11,12 +11,21 @@ message MainPaymentSettings { string ReturnURL = 4; string UserID = 5; string ClientIP = 6; + Customer Customer = 7; + repeated Item Items = 8; } -message BankCardInformation { - string Number = 1; - string ExpiryYear = 2; - string ExpiryMonth = 3; - optional string CSC = 4; - optional string CardHolderName = 5; -} \ No newline at end of file +message Customer { + string FullName = 1; + string INN = 2; + string Email = 3; + string Phone = 4; +} + +message Item { + string Description = 1; + string Measure = 2; + string Quantity = 3; + string Money = 4; + string Currency = 5; + } diff --git a/api/proto/treasurer/service.proto b/api/proto/treasurer/service.proto index 9d2bfda..9fcaec1 100644 --- a/api/proto/treasurer/service.proto +++ b/api/proto/treasurer/service.proto @@ -8,33 +8,22 @@ import "treasurer/payment.model.proto"; option go_package = "./treasurer"; service TreasurerService { - rpc GetPaymentLinkBankCard(GetBankCardPaymentLinkRequest) returns (GetPaymentLinkResponse) {} - rpc GetPaymentLinkYooMoney(GetPaymentLinkBody) returns (GetPaymentLinkResponse) {} - rpc GetPaymentLinkSberPay(GetPaymentLinkBody) returns (GetPaymentLinkResponse) {} - rpc GetPaymentLinkTinkoff(GetPaymentLinkBody) returns (GetPaymentLinkResponse) {} - rpc GetPaymentLinkSberbankB2B(GetPaymentLinkBody) returns (GetPaymentLinkResponse) {} - rpc GetPaymentLinkSBP(GetPaymentLinkBody) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkBankCard(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkYooMoney(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkTinkoff(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkSberbankB2B(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkSBP(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkSberPay(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} } message GetBankCardPaymentLinkRequest { MainPaymentSettings MainSettings = 1; - BankCardInformation BankCard = 2; } -message GetPaymentLinkBody { +message GetPaymentLinkRequest { MainPaymentSettings MainSettings = 1; } -message GetPhonePaymentLinkRequest { - MainPaymentSettings MainSettings = 1; - string Phone = 2; -} - -message GetLoginPaymentLinkRequest { - MainPaymentSettings MainSettings = 1; - string Login = 2; -} - message GetB2BPaymentLinkRequest { MainPaymentSettings MainSettings = 1; string PaymentPurpose = 2; diff --git a/cmd/app/main.go b/cmd/app/main.go index 859e082..e61dd84 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -8,8 +8,10 @@ import ( "time" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/app" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/app" + "gitea.pena/PenaSide/customer/internal/initialize" + // import for automatically updating linter rules + _ "gitea.pena/PenaSide/linters-golang/pkg/dummy" ) var ( diff --git a/deployments/main/docker-compose.yaml b/deployments/main/docker-compose.yaml index fa24fca..6869eae 100644 --- a/deployments/main/docker-compose.yaml +++ b/deployments/main/docker-compose.yaml @@ -1,18 +1,20 @@ version: "3.3" services: - customer-app-staging: - hostname: customer-service-staging - container_name: customer-service-staging + customer-appv1.0.0: + hostname: customer-servicev1.0.0 + container_name: customer-servicev1.0.0 image: $CI_REGISTRY_IMAGE/main:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID tty: true environment: - - HTTP_HOST=0.0.0.0 - - HTTP_PORT=8065 + - CLIENT_HTTP_HOST=0.0.0.0 + - CLIENT_HTTP_PORT=8065 + - ADMIN_HTTP_HOST=0.0.0.0 + - ADMIN_HTTP_PORT=8066 - GRPC_HOST=0.0.0.0 - - GRPC_PORT=9085 - - GRPC_DOMEN=http://customer-service:9085 + - GRPC_PORT=9065 + - GRPC_DOMEN=10.8.0.8:9065 - MONGO_HOST=10.8.0.8 - MONGO_PORT=27017 @@ -20,6 +22,7 @@ services: - MONGO_PASSWORD=$MONGO_PASSWORD - MONGO_DB_NAME=customer - MONGO_AUTH=customer + - NOTIFICATION_RS_PAY_CHANNEL=-1002338593104 - KAFKA_BROKERS=10.8.0.8:9092 - KAFKA_TOPIC_TARIFF=tariffs @@ -31,13 +34,28 @@ services: - PAYMENT_MICROSERVICE_GRPC_HOST=10.8.0.8:9085 - VERIFICATION_MICROSERVICE_USER_URL=http://10.8.0.8:7035/verification - TEMPLATEGEN_MICROSERVICE_URL=10.6.0.17 + - CODEWORD_MICROSERVICE_GRPC_HOST=10.8.0.8:59665 + - API_URL=https://api.smtp.bz/v1/smtp/send + - MAIL_SENDER=noreply@noreply.pena.digital + - MAIL_API_KEY=8tv2xcsfCMBX3TCQxzgeeEwAEYyQrPUp0ggw + - MAIL_AUTH_USERNAME=team@pena.digital + - MAIL_AUTH_PASSWORD=AyMfwqA9LkQH + - MAIL_ADDRESS=sells@pena.digital - JWT_PUBLIC_KEY=$JWT_PUBLIC_KEY - JWT_ISSUER=pena-auth-service - JWT_AUDIENCE=pena + - PUBLIC_KEY=$USER_PKEY + - PRIVATE_KEY=$USER_PRIVATEKEY + - ADMIN_FRONT_URL=https://admin.pena + - TRASH_LOG_HOST=10.8.0.15:7113 + - MODULE_LOGGER=customer-main + - NOTIFICATION_CHANNEL=-1002017928045 + - NOTIFICATION_BOT_TOKEN=6112841016:AAH2nO1c6mqfMewBvHwdXCDp5PCclOuc99s ports: - - 10.8.0.8:8065:8065 - - 10.8.0.8:9065:9065 + - 10.8.0.8:8066:8065 + - 10.8.0.8:8031:8066 + - 10.8.0.8:9066:9065 networks: - default diff --git a/deployments/staging/docker-compose.yaml b/deployments/staging/docker-compose.yaml index 2038238..c5385f4 100644 --- a/deployments/staging/docker-compose.yaml +++ b/deployments/staging/docker-compose.yaml @@ -1,25 +1,30 @@ version: "3.3" services: - customer-app-stagingv1.0.0: - hostname: customer-service-stagingv1.0.0 - container_name: customer-service-stagingv1.0.0 + customer-app-stagingv1.0.1: + hostname: customerv1.0.1 + container_name: customerv1.0.1 image: $CI_REGISTRY_IMAGE/staging:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID tty: true + labels: + com.pena.allowed_headers: content-type,authorization,response-type environment: - - HTTP_HOST=0.0.0.0 - - HTTP_PORT=8065 + - CLIENT_HTTP_HOST=0.0.0.0 + - CLIENT_HTTP_PORT=8065 + - ADMIN_HTTP_HOST=0.0.0.0 + - ADMIN_HTTP_PORT=8066 - GRPC_HOST=0.0.0.0 - GRPC_PORT=9065 - - GRPC_DOMEN=10.8.0.6:9065 + - GRPC_DOMEN=10.8.0.6:9060 - - MONGO_HOST=10.8.0.6 + - MONGO_HOST=10.7.0.4 - MONGO_PORT=27017 - MONGO_USER=$MONGO_USER - MONGO_PASSWORD=$MONGO_PASSWORD - MONGO_DB_NAME=customer - MONGO_AUTH=customer + - NOTIFICATION_RS_PAY_CHANNEL=-1002338593104 - KAFKA_BROKERS=10.8.0.6:9092 - KAFKA_TOPIC_TARIFF=tariffs @@ -29,7 +34,7 @@ services: - CURRENCY_MICROSERVICE_TRANSLATE_URL=http://10.8.0.6:3131/change - DISCOUNT_MICROSERVICE_GRPC_HOST=10.8.0.6:9001 - PAYMENT_MICROSERVICE_GRPC_HOST=10.8.0.6:9085 - - VERIFICATION_MICROSERVICE_USER_URL=http://10.8.0.6:7035/verification + - VERIFICATION_MICROSERVICE_USER_URL=http://10.8.0.6:7036/verification - TEMPLATEGEN_MICROSERVICE_URL=http://10.6.0.17/generator/service - API_URL=https://api.smtp.bz/v1/smtp/send - CODEWORD_MICROSERVICE_GRPC_HOST=10.8.0.6:59665 @@ -44,10 +49,13 @@ services: - JWT_AUDIENCE=pena - PUBLIC_KEY=$USER_PKEY - PRIVATE_KEY=$USER_PRIVATEKEY + - ADMIN_FRONT_URL=https://sadmin.pena - TRASH_LOG_HOST=10.8.0.15:7113 - MODULE_LOGGER=customer-staging + - NOTIFICATION_BOT_TOKEN=6112841016:AAH2nO1c6mqfMewBvHwdXCDp5PCclOuc99s ports: - - 10.8.0.6:8066:8065 - - 10.8.0.6:9066:9065 + - 10.8.0.6:8067:8065 + - 10.8.0.6:8070:8066 + - 10.8.0.6:9060:9065 networks: - default diff --git a/go.mod b/go.mod index d461958..5999c97 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,9 @@ -module penahub.gitlab.yandexcloud.net/pena-services/customer +module gitea.pena/PenaSide/customer go 1.22.0 require ( + gitea.pena/PenaSide/linters-golang v0.0.0-20241114215743-9a8e7d58cf96 github.com/go-resty/resty/v2 v2.11.0 github.com/gofiber/fiber/v2 v2.52.1 github.com/golang-jwt/jwt/v5 v5.2.0 @@ -20,9 +21,10 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 google.golang.org/grpc v1.65.0 google.golang.org/protobuf v1.34.2 + gopkg.in/tucnak/telebot.v2 v2.5.0 penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881 - penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae + penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5 ) require ( @@ -59,13 +61,13 @@ require ( github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect go.etcd.io/bbolt v1.3.10 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.24.0 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/crypto v0.25.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/tucnak/telebot.v2 v2.5.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3 // indirect ) diff --git a/go.sum b/go.sum index 55f579c..39be10d 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +gitea.pena/PenaSide/linters-golang v0.0.0-20241114215743-9a8e7d58cf96 h1:m4EMXEhsA/glI6eJeZnRGUhYPSQdcWj3hzT2IDNlWS0= +gitea.pena/PenaSide/linters-golang v0.0.0-20241114215743-9a8e7d58cf96/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= @@ -184,8 +186,8 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -209,8 +211,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -236,8 +238,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -280,8 +282,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -316,5 +318,7 @@ penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5 penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881 h1:U1/WGQdwZsmrV/ta7Uqm13Dg07IPN/5omS8gzBJYZv4= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae h1:vlGInCsQSDA464q7OMv3EWGUviQWQdEcpLc8HIRo+rE= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4= +penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3 h1:sf6e2mp582L3i/FMDd2q6QuWm1njRXzYpIX0SipsvM4= +penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3/go.mod h1:i7M72RIpkSjcQtHID6KKj9RT/EYZ1rxS6tIPKWa/BSY= +penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5 h1:amsK0bkSJxBisk334aFo5ZmVPvN1dBT0Sv5j3V5IsT8= +penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5/go.mod h1:J8kQNEP4bL7ZNKHxuT4tfe6a3FHyovpAPkyytN4qllc= diff --git a/internal/app/app.go b/internal/app/app.go index 9a9104b..364da19 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -6,22 +6,23 @@ import ( "fmt" "github.com/themakers/hlog" "go.uber.org/zap/zapcore" + tb "gopkg.in/tucnak/telebot.v2" "os/signal" "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/external/trashlog.git/app" - "penahub.gitlab.yandexcloud.net/external/trashlog.git/wrappers/zaptrashlog" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" + "penahub.gitlab.yandexcloud.net/external/trashlog/app" + "penahub.gitlab.yandexcloud.net/external/trashlog/wrappers/zaptrashlog" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" "syscall" "time" "github.com/twmb/franz-go/pkg/kgo" "go.uber.org/zap" qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/server" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/closer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/kafka" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/server" + "gitea.pena/PenaSide/customer/pkg/closer" + "gitea.pena/PenaSide/customer/pkg/kafka" ) const ( @@ -52,18 +53,6 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) panic(err) } - //telegrammLogger, err := zaptg.NewCore(ctx, - // zap.InfoLevel, - // "1408111289:AAHfWZRiBQRncb2gl2LtU8OeASjfJi4e8YE", - // build.Version, - // build.Commit, - // build.BuildTime, - // -1001256687920, - //) - //if err != nil { - // panic(err) - //} - loggerForHlog := logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core { return zapcore.NewTee(core, clickHouseLogger) }), zap.AddCallerSkip(2)) @@ -72,7 +61,7 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) loggerHlog.With(models.AllFields{}) loggerHlog.Emit(app.InfoSvcStarted{}) - if err := kafka.Initialize(ctx, config.Service.Kafka.Brokers, []string{ + if err = kafka.Initialize(ctx, config.Service.Kafka.Brokers, []string{ config.Service.Kafka.Tariff.Topic, }); err != nil { return fmt.Errorf("failed initialize kafka: %w", err) @@ -106,6 +95,19 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) return err } + notificationBot, err := tb.NewBot(tb.Settings{ + Token: config.Service.NotificationBotToken, + Verbose: false, + ParseMode: tb.ModeHTML, + Poller: &tb.LongPoller{ + Timeout: time.Second, + }, + }) + if err != nil { + //logger.Emit(json.Token(err)) + return err + } + clients := initialize.NewClients(initialize.ClientsDeps{ Logger: logger, AuthURL: &config.Service.AuthMicroservice.URL, @@ -117,6 +119,8 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) TemplategenURL: &config.Service.TemplategenMicroserviceURL.URL, MailClient: &config.Service.Mail, CodewordServiceHost: &config.Service.CodewordMicroservice, + Notifier: notificationBot, + NotificationRsPayChannel: config.Service.NotificationRsPayChannel, }) repositories := initialize.NewRepositories(initialize.RepositoriesDeps{ @@ -125,11 +129,14 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) }) services := initialize.NewServices(initialize.ServicesDeps{ - Logger: logger, - Repositories: repositories, - Clients: clients, - ConfigurationGRPC: &config.GRPC, - Brokers: brokers, + Logger: logger, + Repositories: repositories, + Clients: clients, + ConfigurationGRPC: &config.GRPC, + Brokers: brokers, + Notifier: notificationBot, + NotificationChannel: config.Service.NotificationChannel, + AdminURL: config.Service.AdminURL, }) rpcControllers := initialize.NewRpcControllers(initialize.RpcControllersDeps{ @@ -152,14 +159,22 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) MiddleWare: middleWare, }) - serverHTTP := server.NewServer(server.ServerConfig{ + serverClientHTTP := server.NewServer(server.ServerConfig{ Logger: logger, Hlog: loggerHlog, - Controllers: []server.Controller{httpControllers.CurrencyController, httpControllers.HistoryController, httpControllers.CartController, httpControllers.WalletController, httpControllers.AccountController}, + Controllers: []server.Controller{httpControllers.CurrencyClientController, httpControllers.HistoryClientController, httpControllers.CartClientController, httpControllers.WalletClientController, httpControllers.AccountClientController}, JWTConfig: &config.Service.JWT, }) - serverHTTP.ListRoutes() + serverAdminHTTP := server.NewServer(server.ServerConfig{ + Logger: logger, + Hlog: loggerHlog, + Controllers: []server.Controller{httpControllers.AccountAdminController, httpControllers.CurrencyAdminController, httpControllers.HistoryAdminController}, + JWTConfig: &config.Service.JWT, + }) + + serverClientHTTP.ListRoutes() + serverAdminHTTP.ListRoutes() serverGRPC, grpcErr := server.NewGRPC(server.DepsGRPC{Logger: logger}) if grpcErr != nil { @@ -169,8 +184,15 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) serverGRPC.Register(rpcControllers) go func() { - if err := serverHTTP.Start(config.HTTP.Host + ":" + config.HTTP.Port); err != nil { - logger.Error("Server startup error", zap.Error(err)) + if err := serverClientHTTP.Start(config.HTTP.ClientHost + ":" + config.HTTP.ClientPort); err != nil { + logger.Error("Server external startup error", zap.Error(err)) + cancel() + } + }() + + go func() { + if err := serverAdminHTTP.Start(config.HTTP.AdminHost + ":" + config.HTTP.AdminPort); err != nil { + logger.Error("Server internal startup error", zap.Error(err)) cancel() } }() @@ -178,7 +200,8 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error) go serverGRPC.Run(&config.GRPC) closer.Add(mongoDB.Client().Disconnect) - closer.Add(serverHTTP.Shutdown) + closer.Add(serverClientHTTP.Shutdown) + closer.Add(serverAdminHTTP.Shutdown) closer.Add(serverGRPC.Stop) closer.Add(closer.Wrap(kafkaTariffClient.Close)) diff --git a/internal/errors/http.go b/internal/errors/http.go index f2f8fde..50c5f6e 100644 --- a/internal/errors/http.go +++ b/internal/errors/http.go @@ -4,7 +4,7 @@ import ( "net/http" "github.com/labstack/echo/v4" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/models" ) var httpStatuses = map[ErrorType]int{ diff --git a/internal/initialize/brokers.go b/internal/initialize/brokers.go index d041459..b0d5f35 100644 --- a/internal/initialize/brokers.go +++ b/internal/initialize/brokers.go @@ -3,7 +3,7 @@ package initialize import ( "github.com/twmb/franz-go/pkg/kgo" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/broker/tariff" + "gitea.pena/PenaSide/customer/internal/interface/broker/tariff" ) type BrokersDeps struct { diff --git a/internal/initialize/brokers_test.go b/internal/initialize/brokers_test.go index d6ca211..48ae315 100644 --- a/internal/initialize/brokers_test.go +++ b/internal/initialize/brokers_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/twmb/franz-go/pkg/kgo" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/initialize" ) func TestNewBrokers(t *testing.T) { diff --git a/internal/initialize/clients.go b/internal/initialize/clients.go index b3de905..cb57d42 100644 --- a/internal/initialize/clients.go +++ b/internal/initialize/clients.go @@ -3,8 +3,9 @@ package initialize import ( "github.com/gofiber/fiber/v2" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gopkg.in/tucnak/telebot.v2" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/models" ) type ClientsDeps struct { @@ -18,6 +19,8 @@ type ClientsDeps struct { TemplategenURL *models.TemplategenMicroserviceURL MailClient *models.MailConfiguration CodewordServiceHost *models.CodewordMicroserviceConfiguration + NotificationRsPayChannel int64 + Notifier *telebot.Bot } type Clients struct { @@ -30,6 +33,7 @@ type Clients struct { TemplateClient *client.TemplateClient MailClient *client.MailClient CodewordClient *client.CodewordClient + TelegramClient *client.TelegramClient } func NewClients(deps ClientsDeps) *Clients { @@ -79,5 +83,9 @@ func NewClients(deps ClientsDeps) *Clients { Logger: deps.Logger, CodewordServiceHost: deps.CodewordServiceHost.HostGRPC, }), + TelegramClient: client.NewTelegramClient(client.TelegramClientDeps{ + Notifier: deps.Notifier, + NotifierPayChannel: deps.NotificationRsPayChannel, + }), } } diff --git a/internal/initialize/clients_test.go b/internal/initialize/clients_test.go index 352a70b..28ef9f4 100644 --- a/internal/initialize/clients_test.go +++ b/internal/initialize/clients_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/assert" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" ) func TestNewClients(t *testing.T) { diff --git a/internal/initialize/config.go b/internal/initialize/config.go index d36cecf..e4990cc 100644 --- a/internal/initialize/config.go +++ b/internal/initialize/config.go @@ -4,9 +4,9 @@ import ( "time" "github.com/golang-jwt/jwt/v5" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/env" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/pkg/env" ) // TODO: обработать возможность читать конфиги ещё по json diff --git a/internal/initialize/config_test.go b/internal/initialize/config_test.go index 36f6fe8..b0780fd 100644 --- a/internal/initialize/config_test.go +++ b/internal/initialize/config_test.go @@ -7,8 +7,8 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/stretchr/testify/assert" "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" ) func TestConfiguration(t *testing.T) { @@ -62,8 +62,10 @@ func setDefaultTestingENV(t *testing.T) *models.Config { defaultConfiguration := models.Config{ HTTP: models.ConfigurationHTTP{ - Host: "localhost", - Port: "8080", + ClientHost: "localhost", + ClientPort: "8080", + AdminHost: "localhost", + AdminPort: "8081", }, GRPC: models.ConfigurationGRPC{ Host: "localhost", diff --git a/internal/initialize/controllers.go b/internal/initialize/controllers.go index a53e108..eb1de4e 100644 --- a/internal/initialize/controllers.go +++ b/internal/initialize/controllers.go @@ -4,16 +4,19 @@ import ( "github.com/themakers/hlog" "go.uber.org/zap" qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/broker/tariff" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/grpc/customer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/grpc/payment" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http/account" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http/cart" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http/currency" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http/history" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http/wallet" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/interface/broker/tariff" + "gitea.pena/PenaSide/customer/internal/interface/controller/grpc/customer" + "gitea.pena/PenaSide/customer/internal/interface/controller/grpc/payment" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/account_admin" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/account_client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/cart_client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/currency_admin" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/currency_client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/history_admin" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/history_client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http/wallet_client" + "gitea.pena/PenaSide/customer/internal/models" ) type RpcControllersDeps struct { @@ -54,23 +57,32 @@ type HttpControllersDeps struct { } type HttpController struct { - AccountController *account.AccountController - CartController *cart.CartController - HistoryController *history.HistoryController - WalletController *wallet.WalletController - CurrencyController *currency.CurrencyController + AccountClientController *account_client.AccountController + AccountAdminController *account_admin.AccountInternalController + CartClientController *cart_client.CartController + CurrencyClientController *currency_client.CurrencyController + CurrencyAdminController *currency_admin.CurrencyController + HistoryAdminController *history_admin.HistoryController + HistoryClientController *history_client.HistoryController + WalletClientController *wallet_client.WalletController } func NewHttpControllers(deps HttpControllersDeps) *HttpController { return &HttpController{ - AccountController: account.NewAccountController(account.Deps{ + AccountClientController: account_client.NewAccountController(account_client.Deps{ MiddleWare: deps.MiddleWare, AccountRepo: deps.Repositories.AccountRepository, Logger: deps.Logger, Encrypt: deps.Encrypt, AuthClient: deps.Clients.AuthClient, }), - CartController: cart.NewCartController(cart.Deps{ + AccountAdminController: account_admin.NewAccountInternalController( + account_admin.Deps{ + MiddleWare: deps.MiddleWare, + AccountRepo: deps.Repositories.AccountRepository, + Logger: deps.Logger, + }), + CartClientController: cart_client.NewCartController(cart_client.Deps{ MiddleWare: deps.MiddleWare, Logger: deps.Logger, AccountRepo: deps.Repositories.AccountRepository, @@ -80,7 +92,17 @@ func NewHttpControllers(deps HttpControllersDeps) *HttpController { CurrencyClient: deps.Clients.CurrencyClient, Producer: deps.Producer, }), - HistoryController: history.NewHistoryController(history.Deps{ + CurrencyClientController: currency_client.NewCurrencyController(currency_client.Deps{ + CurrencyRepo: deps.Repositories.CurrencyRepository, + MiddleWare: deps.MiddleWare, + Logger: deps.Logger, + }), + CurrencyAdminController: currency_admin.NewCurrencyController(currency_admin.Deps{ + CurrencyRepo: deps.Repositories.CurrencyRepository, + MiddleWare: deps.MiddleWare, + Logger: deps.Logger, + }), + HistoryAdminController: history_admin.NewHistoryController(history_admin.Deps{ MiddleWare: deps.MiddleWare, HistoryRepo: deps.Repositories.HistoryRepository, AccountRepo: deps.Repositories.AccountRepository, @@ -90,7 +112,17 @@ func NewHttpControllers(deps HttpControllersDeps) *HttpController { CodewordClient: deps.Clients.CodewordClient, Logger: deps.Logger, }), - WalletController: wallet.NewWalletController(wallet.Deps{ + HistoryClientController: history_client.NewHistoryController(history_client.Deps{ + MiddleWare: deps.MiddleWare, + HistoryRepo: deps.Repositories.HistoryRepository, + AccountRepo: deps.Repositories.AccountRepository, + VerifyClient: deps.Clients.VerificationClient, + AuthClient: deps.Clients.AuthClient, + TemplateClient: deps.Clients.TemplateClient, + CodewordClient: deps.Clients.CodewordClient, + Logger: deps.Logger, + }), + WalletClientController: wallet_client.NewWalletController(wallet_client.Deps{ MiddleWare: deps.MiddleWare, AuthClient: deps.Clients.AuthClient, PaymentClient: deps.Clients.PaymentClient, @@ -100,11 +132,7 @@ func NewHttpControllers(deps HttpControllersDeps) *HttpController { VerifyClient: deps.Clients.VerificationClient, MailClient: deps.Clients.MailClient, Logger: deps.Logger, - }), - CurrencyController: currency.NewCurrencyController(currency.Deps{ - CurrencyRepo: deps.Repositories.CurrencyRepository, - MiddleWare: deps.MiddleWare, - Logger: deps.Logger, + TelegramClient: deps.Clients.TelegramClient, }), } } diff --git a/internal/initialize/controllers_test.go b/internal/initialize/controllers_test.go index 93f8f79..e1c56f8 100644 --- a/internal/initialize/controllers_test.go +++ b/internal/initialize/controllers_test.go @@ -4,11 +4,10 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/twmb/franz-go/pkg/kgo" "go.mongodb.org/mongo-driver/mongo/integration/mtest" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" ) func TestNewControllers(t *testing.T) { @@ -34,22 +33,10 @@ func TestNewControllers(t *testing.T) { MongoDB: t.Client.Database("test"), }) - brokers := initialize.NewBrokers(initialize.BrokersDeps{ + controllers := initialize.NewHttpControllers(initialize.HttpControllersDeps{ Logger: logger, - TariffClient: &kgo.Client{}, - }) - - services := initialize.NewServices(initialize.ServicesDeps{ - Logger: logger, - Clients: clients, - Repositories: repositories, - Brokers: brokers, - ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"}, - }) - - controllers := initialize.NewControllers(initialize.ControllersDeps{ - Logger: logger, - Services: services, + Repositories: repositories, + Clients: clients, }) assert.NotNil(t, controllers) diff --git a/internal/initialize/repositories.go b/internal/initialize/repositories.go index 01b0810..78e2952 100644 --- a/internal/initialize/repositories.go +++ b/internal/initialize/repositories.go @@ -3,7 +3,7 @@ package initialize import ( "go.mongodb.org/mongo-driver/mongo" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/interface/repository" ) type RepositoriesDeps struct { diff --git a/internal/initialize/repositories_test.go b/internal/initialize/repositories_test.go index a57e31e..3641959 100644 --- a/internal/initialize/repositories_test.go +++ b/internal/initialize/repositories_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "go.mongodb.org/mongo-driver/mongo/integration/mtest" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/initialize" ) func TestNewRepositories(t *testing.T) { diff --git a/internal/initialize/services.go b/internal/initialize/services.go index 560e2d3..99f5c34 100644 --- a/internal/initialize/services.go +++ b/internal/initialize/services.go @@ -2,19 +2,23 @@ package initialize import ( "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/broker/tariff" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/callback" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/history" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/wallet" + tb "gopkg.in/tucnak/telebot.v2" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/service/broker/tariff" + "gitea.pena/PenaSide/customer/internal/service/callback" + "gitea.pena/PenaSide/customer/internal/service/history" + "gitea.pena/PenaSide/customer/internal/service/wallet" ) type ServicesDeps struct { - Logger *zap.Logger - Repositories *Repositories - Clients *Clients - Brokers *Brokers - ConfigurationGRPC *models.ConfigurationGRPC + Logger *zap.Logger + Repositories *Repositories + Clients *Clients + Brokers *Brokers + ConfigurationGRPC *models.ConfigurationGRPC + Notifier *tb.Bot + NotificationChannel int64 + AdminURL string } type Services struct { @@ -55,6 +59,9 @@ func NewServices(deps ServicesDeps) *Services { AccountRepository: deps.Repositories.AccountRepository, WalletService: walletService, HistoryService: historyService, + Notifier: deps.Notifier, + NotifyChannel: deps.NotificationChannel, + AdminURL: deps.AdminURL, }), TariffBrokerService: tariffBrokerService, } diff --git a/internal/initialize/services_test.go b/internal/initialize/services_test.go index 3a58c85..12a9f26 100644 --- a/internal/initialize/services_test.go +++ b/internal/initialize/services_test.go @@ -7,8 +7,8 @@ import ( "github.com/twmb/franz-go/pkg/kgo" "go.mongodb.org/mongo-driver/mongo/integration/mtest" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" ) func TestNewServices(t *testing.T) { diff --git a/internal/interface/broker/tariff/consumer.go b/internal/interface/broker/tariff/consumer.go index ab16351..1c0eda2 100644 --- a/internal/interface/broker/tariff/consumer.go +++ b/internal/interface/broker/tariff/consumer.go @@ -8,9 +8,9 @@ import ( "github.com/twmb/franz-go/pkg/kgo" "go.uber.org/zap" "google.golang.org/protobuf/proto" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/transfer" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/utils/transfer" ) type ConsumerDeps struct { diff --git a/internal/interface/broker/tariff/producer.go b/internal/interface/broker/tariff/producer.go index 0a9ea21..191e8b1 100644 --- a/internal/interface/broker/tariff/producer.go +++ b/internal/interface/broker/tariff/producer.go @@ -8,9 +8,9 @@ import ( "github.com/twmb/franz-go/pkg/kgo" "go.uber.org/zap" "google.golang.org/protobuf/proto" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/transfer" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils/transfer" ) type ProducerDeps struct { diff --git a/internal/interface/client/auth.go b/internal/interface/client/auth.go index 854798f..313fccf 100644 --- a/internal/interface/client/auth.go +++ b/internal/interface/client/auth.go @@ -7,10 +7,10 @@ import ( "net/url" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/pkg/client" ) type AuthClientDeps struct { diff --git a/internal/interface/client/codeword.go b/internal/interface/client/codeword.go index d6f1abd..5e19780 100644 --- a/internal/interface/client/codeword.go +++ b/internal/interface/client/codeword.go @@ -8,9 +8,9 @@ import ( "google.golang.org/grpc/credentials/insecure" "io" "log" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - codeword_rpc "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/codeword" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" + "gitea.pena/PenaSide/customer/pkg/validate" ) type CodewordClientDeps struct { diff --git a/internal/interface/client/currency.go b/internal/interface/client/currency.go index 14a1292..27a9282 100644 --- a/internal/interface/client/currency.go +++ b/internal/interface/client/currency.go @@ -7,10 +7,10 @@ import ( "strconv" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/pkg/client" ) type CurrencyClientDeps struct { diff --git a/internal/interface/client/discount.go b/internal/interface/client/discount.go index 1d52c70..112601d 100644 --- a/internal/interface/client/discount.go +++ b/internal/interface/client/discount.go @@ -8,9 +8,9 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/proto/discount" + "gitea.pena/PenaSide/customer/pkg/validate" ) type DiscountClientDeps struct { diff --git a/internal/interface/client/hubadmin.go b/internal/interface/client/hubadmin.go index 1da6d31..03ff7e1 100644 --- a/internal/interface/client/hubadmin.go +++ b/internal/interface/client/hubadmin.go @@ -7,10 +7,10 @@ import ( "net/url" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/pkg/client" ) type HubadminClientDeps struct { diff --git a/internal/interface/client/mail.go b/internal/interface/client/mail.go index ffcb23d..20b06ed 100644 --- a/internal/interface/client/mail.go +++ b/internal/interface/client/mail.go @@ -6,8 +6,8 @@ import ( "github.com/gofiber/fiber/v2" "go.uber.org/zap" "mime/multipart" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" ) type MailClientDeps struct { @@ -36,7 +36,7 @@ func NewMailClient(deps MailClientDeps) *MailClient { func (receiver *MailClient) SendMessage(userEmail string, verification *models.Verification, money float32) errors.Error { body := fmt.Sprintf("

Поступила заявка на оплату через Р/С от пользователя с почтой %s (%s)

"+ "

Вот файлы его верификации:

"+ - "

Запрос на оплату: %d рублей

", userEmail, verification.UserID, money) + "

Запрос на оплату: %f рублей

", userEmail, verification.UserID, money) for _, file := range verification.Files { body += fmt.Sprintf("

%s: %s

", file.Name, file.URL, file.URL) @@ -75,7 +75,7 @@ func (receiver *MailClient) SendMessage(userEmail string, verification *models.V } if statusCode != fiber.StatusOK { - err := fmt.Errorf("the SMTP service returned an error: %s", statusCode) + err := fmt.Errorf("the SMTP service returned an error: %d", statusCode) return handleError(receiver.deps.Logger, "Error sending email", err) } diff --git a/internal/interface/client/payment.go b/internal/interface/client/payment.go index 06387e6..ca0ece5 100644 --- a/internal/interface/client/payment.go +++ b/internal/interface/client/payment.go @@ -8,9 +8,9 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/treasurer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/proto/treasurer" + "gitea.pena/PenaSide/customer/pkg/validate" ) type PaymentClientDeps struct { @@ -38,7 +38,7 @@ func NewPaymentClient(deps PaymentClientDeps) *PaymentClient { } } -func (receiver *PaymentClient) GetPaymentLinkBankCard(ctx context.Context, request *treasurer.GetBankCardPaymentLinkRequest) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkBankCard(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) @@ -59,7 +59,7 @@ func (receiver *PaymentClient) GetPaymentLinkBankCard(ctx context.Context, reque return response.RedirectURL, nil } -func (receiver *PaymentClient) GetPaymentLinkYooMoney(ctx context.Context, request *treasurer.GetPaymentLinkBody) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkYooMoney(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) @@ -80,7 +80,7 @@ func (receiver *PaymentClient) GetPaymentLinkYooMoney(ctx context.Context, reque return response.RedirectURL, nil } -func (receiver *PaymentClient) GetPaymentLinkSberPay(ctx context.Context, request *treasurer.GetPaymentLinkBody) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkSberPay(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) @@ -101,7 +101,7 @@ func (receiver *PaymentClient) GetPaymentLinkSberPay(ctx context.Context, reques return response.RedirectURL, nil } -func (receiver *PaymentClient) GetPaymentLinkSBP(ctx context.Context, request *treasurer.GetPaymentLinkBody) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkSBP(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) @@ -122,7 +122,7 @@ func (receiver *PaymentClient) GetPaymentLinkSBP(ctx context.Context, request *t return response.RedirectURL, nil } -func (receiver *PaymentClient) GetPaymentLinkTinkoff(ctx context.Context, request *treasurer.GetPaymentLinkBody) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkTinkoff(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) @@ -143,7 +143,7 @@ func (receiver *PaymentClient) GetPaymentLinkTinkoff(ctx context.Context, reques return response.RedirectURL, nil } -func (receiver *PaymentClient) GetPaymentLinkSberbankB2B(ctx context.Context, request *treasurer.GetPaymentLinkBody) (string, errors.Error) { +func (receiver *PaymentClient) GetPaymentLinkSberbankB2B(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) { client, closeConnection, connectErr := receiver.connect(ctx) if connectErr != nil { receiver.logger.Error("failed to connect on of ", zap.Error(connectErr)) diff --git a/internal/interface/client/telegram.go b/internal/interface/client/telegram.go new file mode 100644 index 0000000..8d65abe --- /dev/null +++ b/internal/interface/client/telegram.go @@ -0,0 +1,49 @@ +package client + +import ( + "fmt" + tb "gopkg.in/tucnak/telebot.v2" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" +) + +type TelegramClient struct { + notifier *tb.Bot + notifierPayChannel int64 +} + +type TelegramClientDeps struct { + Notifier *tb.Bot + NotifierPayChannel int64 +} + +func NewTelegramClient(deps TelegramClientDeps) *TelegramClient { + return &TelegramClient{ + notifier: deps.Notifier, + notifierPayChannel: deps.NotifierPayChannel, + } +} + +func (t *TelegramClient) NotifyRsPay(userEmail string, verification *models.Verification, money float32) errors.Error { + message := fmt.Sprintf( + "Поступила заявка на оплату через Р/С от пользователя с почтой %s (%s)\n"+ + "Вот файлы его верификации:\n"+ + "Запрос на оплату: %f рублей\n", + userEmail, verification.UserID, money, + ) + + for _, file := range verification.Files { + message += fmt.Sprintf("%s: %s\n", file.Name, file.URL) + } + fmt.Println("RSP", t.notifierPayChannel) + + _, err := t.notifier.Send( + &tb.Chat{ID: t.notifierPayChannel}, + message, + ) + if err != nil { + return errors.New(fmt.Errorf("failed to send tg RS PAY message: %v", err), errors.ErrInternalError) + } + + return nil +} diff --git a/internal/interface/client/telegram_test.go b/internal/interface/client/telegram_test.go new file mode 100644 index 0000000..7f81338 --- /dev/null +++ b/internal/interface/client/telegram_test.go @@ -0,0 +1,37 @@ +package client + +import ( + "fmt" + tb "gopkg.in/tucnak/telebot.v2" + "gitea.pena/PenaSide/customer/internal/models" + "testing" + "time" +) + +func Test_Telegram(t *testing.T) { + tbBot, err := tb.NewBot(tb.Settings{ + Token: "6712573453:AAFqTOsgwe_j48ZQ1GzWKQDT5Nwr-SAWjz8", + Verbose: false, + ParseMode: tb.ModeHTML, + Poller: &tb.LongPoller{ + Timeout: time.Second, + }, + }) + + if err != nil { + fmt.Println(err) + return + } + + tgClient := NewTelegramClient(TelegramClientDeps{ + Notifier: tbBot, + NotifierPayChannel: -1002217604546, + }) + + err = tgClient.NotifyRsPay("test@email", &models.Verification{UserID: "test"}, 100.11111) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("good") +} diff --git a/internal/interface/client/templategen.go b/internal/interface/client/templategen.go index 3fa8095..0a5cde8 100644 --- a/internal/interface/client/templategen.go +++ b/internal/interface/client/templategen.go @@ -9,8 +9,8 @@ import ( "net/http" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" ) type TemplateClientDeps struct { diff --git a/internal/interface/client/verification.go b/internal/interface/client/verification.go index 2cef4fc..a68e4e7 100644 --- a/internal/interface/client/verification.go +++ b/internal/interface/client/verification.go @@ -7,9 +7,9 @@ import ( "net/url" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" ) type VerificationClientDeps struct { @@ -47,16 +47,17 @@ func (receiver *VerificationClient) GetVerification(ctx context.Context, token, } response, err := client.Get[models.Verification, models.FastifyError](ctx, &client.RequestSettings{ - URL: verifURL, + URL: verifURL, Headers: map[string]string{ - "Content-Type": "application/json", - "Authorization": token, - }, + "Content-Type": "application/json", + "Authorization": token, + }, }) if err != nil { - fmt.Println("AAAAAAAAAAAa", err, verifURL, response) - if response.StatusCode == 404 { - return nil, errors.New(err, errors.ErrNotFound) + if response != nil { + if response.StatusCode == 404 { + return &models.Verification{}, nil + } } return nil, errors.New(err, errors.ErrInternalError) } diff --git a/internal/interface/controller/grpc/customer/customer.go b/internal/interface/controller/grpc/customer/customer.go index 3ad5e52..a6960ee 100644 --- a/internal/interface/controller/grpc/customer/customer.go +++ b/internal/interface/controller/grpc/customer/customer.go @@ -4,14 +4,14 @@ import ( "context" "google.golang.org/protobuf/types/known/timestamppb" "log" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/interface/repository" "go.uber.org/zap" "google.golang.org/protobuf/types/known/emptypb" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/customer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/history" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/customer" + "gitea.pena/PenaSide/customer/internal/service/history" ) type Deps struct { diff --git a/internal/interface/controller/grpc/payment/payment.go b/internal/interface/controller/grpc/payment/payment.go index 233e5f9..710e57a 100644 --- a/internal/interface/controller/grpc/payment/payment.go +++ b/internal/interface/controller/grpc/payment/payment.go @@ -7,10 +7,10 @@ import ( "go.uber.org/zap" "google.golang.org/protobuf/types/known/emptypb" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/payment_callback" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/callback" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/payment_callback" + "gitea.pena/PenaSide/customer/internal/service/callback" ) type Deps struct { diff --git a/internal/interface/controller/http/account_admin/controllers.go b/internal/interface/controller/http/account_admin/controllers.go new file mode 100644 index 0000000..5258dc9 --- /dev/null +++ b/internal/interface/controller/http/account_admin/controllers.go @@ -0,0 +1,99 @@ +package account_admin + +import ( + "github.com/gofiber/fiber/v2" + "go.uber.org/zap" + "math" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" + "strconv" +) + +type Deps struct { + MiddleWare *http.MiddleWare + AccountRepo *repository.AccountRepository + Logger *zap.Logger +} + +type AccountInternalController struct { + middleWare *http.MiddleWare + accountRepo *repository.AccountRepository + logger *zap.Logger +} + +func NewAccountInternalController(deps Deps) *AccountInternalController { + return &AccountInternalController{ + middleWare: deps.MiddleWare, + accountRepo: deps.AccountRepo, + logger: deps.Logger, + } +} + +func (receiver *AccountInternalController) DeleteCurrent(ctx *fiber.Ctx) error { + userID := ctx.Params("userId") + if userID == "" { + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId") + } + + account, err := receiver.accountRepo.Remove(ctx.Context(), userID) + if err != nil { + return receiver.middleWare.ErrorOld(ctx, err) + } + + return ctx.Status(fiber.StatusOK).JSON(account) +} + +func (receiver *AccountInternalController) GetCurrent(ctx *fiber.Ctx) error { + userID := ctx.Params("userId") + if userID == "" { + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId") + } + + account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID) + if err != nil { + return receiver.middleWare.ErrorOld(ctx, err) + } + + return ctx.Status(fiber.StatusOK).JSON(account) +} + +func (receiver *AccountInternalController) Pagination(ctx *fiber.Ctx) error { + pageStr := ctx.Query("page", "1") + limitStr := ctx.Query("limit", "100") + + page, err := strconv.ParseInt(pageStr, 10, 64) + if err != nil || page < 1 { + page = 1 + } + limit, err := strconv.ParseInt(limitStr, 10, 64) + if err != nil || limit < 1 { + limit = models.DefaultLimit + } else { + limit = int64(math.Min(float64(limit), float64(models.DefaultLimit))) + } + + count, err := receiver.accountRepo.CountAll(ctx.Context()) + if err != nil { + return receiver.middleWare.ErrorOld(ctx, err) + } + + if count == 0 { + response := models.PaginationResponse[models.Account]{TotalPages: 0, Records: []models.Account{}} + return ctx.Status(fiber.StatusOK).JSON(response) + } + + totalPages := int64(math.Ceil(float64(count) / float64(limit))) + + accounts, err := receiver.accountRepo.FindMany(ctx.Context(), page, limit) + if err != nil { + return receiver.middleWare.ErrorOld(ctx, err) + } + + response := models.PaginationResponse[models.Account]{ + TotalPages: totalPages, + Records: accounts, + } + + return ctx.Status(fiber.StatusOK).JSON(response) +} diff --git a/internal/interface/controller/http/account_admin/route.go b/internal/interface/controller/http/account_admin/route.go new file mode 100644 index 0000000..81e91a7 --- /dev/null +++ b/internal/interface/controller/http/account_admin/route.go @@ -0,0 +1,13 @@ +package account_admin + +import "github.com/gofiber/fiber/v2" + +func (receiver *AccountInternalController) Register(router fiber.Router) { + router.Delete("/account/:userId", receiver.DeleteCurrent) + router.Get("/account/:userId", receiver.GetCurrent) + router.Get("/getList", receiver.Pagination) +} + +func (receiver *AccountInternalController) Name() string { + return "" +} diff --git a/internal/interface/controller/http/account/controllers.go b/internal/interface/controller/http/account_client/controllers.go similarity index 72% rename from internal/interface/controller/http/account/controllers.go rename to internal/interface/controller/http/account_client/controllers.go index 9433287..2553167 100644 --- a/internal/interface/controller/http/account/controllers.go +++ b/internal/interface/controller/http/account_client/controllers.go @@ -1,20 +1,19 @@ -package account +package account_client import ( "bufio" "context" "encoding/json" "fmt" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" + "github.com/gofiber/fiber/v2" "go.uber.org/zap" - "math" "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "strconv" "time" ) @@ -180,74 +179,6 @@ func (receiver *AccountController) Create(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(account) } -func (receiver *AccountController) DeleteCurrent(ctx *fiber.Ctx) error { - userID := ctx.Params("userId") - if userID == "" { - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId") - } - - account, err := receiver.accountRepo.Remove(ctx.Context(), userID) - if err != nil { - return receiver.middleWare.ErrorOld(ctx, err) - } - - return ctx.Status(fiber.StatusOK).JSON(account) -} - -func (receiver *AccountController) GetCurrent(ctx *fiber.Ctx) error { - userID := ctx.Params("userId") - if userID == "" { - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId") - } - - account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID) - if err != nil { - return receiver.middleWare.ErrorOld(ctx, err) - } - - return ctx.Status(fiber.StatusOK).JSON(account) -} - -func (receiver *AccountController) Pagination(ctx *fiber.Ctx) error { - pageStr := ctx.Query("page", "1") - limitStr := ctx.Query("limit", "100") - - page, err := strconv.ParseInt(pageStr, 10, 64) - if err != nil || page < 1 { - page = 1 - } - limit, err := strconv.ParseInt(limitStr, 10, 64) - if err != nil || limit < 1 { - limit = models.DefaultLimit - } else { - limit = int64(math.Min(float64(limit), float64(models.DefaultLimit))) - } - - count, err := receiver.accountRepo.CountAll(ctx.Context()) - if err != nil { - return receiver.middleWare.ErrorOld(ctx, err) - } - - if count == 0 { - response := models.PaginationResponse[models.Account]{TotalPages: 0, Records: []models.Account{}} - return ctx.Status(fiber.StatusOK).JSON(response) - } - - totalPages := int64(math.Ceil(float64(count) / float64(limit))) - - accounts, err := receiver.accountRepo.FindMany(ctx.Context(), page, limit) - if err != nil { - return receiver.middleWare.ErrorOld(ctx, err) - } - - response := models.PaginationResponse[models.Account]{ - TotalPages: totalPages, - Records: accounts, - } - - return ctx.Status(fiber.StatusOK).JSON(response) -} - func (receiver *AccountController) AccountPipe(ctx *fiber.Ctx) error { userID, ok := receiver.middleWare.ExtractUserID(ctx) if !ok || userID == "" { diff --git a/internal/interface/controller/http/account/route.go b/internal/interface/controller/http/account_client/route.go similarity index 72% rename from internal/interface/controller/http/account/route.go rename to internal/interface/controller/http/account_client/route.go index b0d37f2..271d0b7 100644 --- a/internal/interface/controller/http/account/route.go +++ b/internal/interface/controller/http/account_client/route.go @@ -1,4 +1,4 @@ -package account +package account_client import "github.com/gofiber/fiber/v2" @@ -8,10 +8,7 @@ func (receiver *AccountController) Register(router fiber.Router) { router.Patch("/account", receiver.Update) router.Post("/account", receiver.Create) router.Get("/account/pipe", receiver.AccountPipe) - router.Delete("/account/:userId", receiver.DeleteCurrent) - router.Get("/account/:userId", receiver.GetCurrent) router.Patch("/account/:userId", receiver.SetVerificationStatus) - router.Get("/accounts", receiver.Pagination) } func (receiver *AccountController) Name() string { diff --git a/internal/interface/controller/http/cart/controllers.go b/internal/interface/controller/http/cart_client/controllers.go similarity index 91% rename from internal/interface/controller/http/cart/controllers.go rename to internal/interface/controller/http/cart_client/controllers.go index 8370ecf..2951370 100644 --- a/internal/interface/controller/http/cart/controllers.go +++ b/internal/interface/controller/http/cart_client/controllers.go @@ -1,20 +1,20 @@ -package cart +package cart_client import ( "github.com/gofiber/fiber/v2" "go.uber.org/zap" "google.golang.org/protobuf/types/known/timestamppb" "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/broker/tariff" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/transfer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/broker/tariff" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/discount" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/utils/transfer" + "gitea.pena/PenaSide/customer/pkg/validate" "strings" "sync" "time" @@ -135,6 +135,10 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error { receiver.logger.Info("account for pay", zap.Any("acc", account)) + if len(account.Cart) == 0 { + return ctx.Status(fiber.StatusNotAcceptable).SendString("cart is empty") + } + tariffs, err := receiver.hubAdminClient.GetTariffs(ctx.Context(), accessToken, account.Cart) if err != nil { return receiver.middleWare.ErrorOld(ctx, err) @@ -173,7 +177,7 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error { hlogger.Emit(models.InfoPayCart{ CtxUserID: userID, CtxAccountID: account.ID, - KeySuccess: false, + KeySuccess: uint8(0), CtxPrice: int64(discountResponse.Price - uint64(account.Wallet.Money)), CtxTariff: strings.Join(account.Cart, ","), CtxDiscount: strings.Join(utils.GetAppliedDiscountsIDs(discountResponse.AppliedDiscounts), ","), @@ -294,7 +298,7 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error { hlogger.Emit(models.InfoPayCart{ CtxUserID: userID, CtxAccountID: updatedAccount.ID, - KeySuccess: true, + KeySuccess: uint8(1), CtxPrice: int64(discountResponse.Price), CtxTariff: strings.Join(account.Cart, ","), CtxDiscount: strings.Join(utils.GetAppliedDiscountsIDs(discountResponse.AppliedDiscounts), ","), diff --git a/internal/interface/controller/http/cart/route.go b/internal/interface/controller/http/cart_client/route.go similarity index 93% rename from internal/interface/controller/http/cart/route.go rename to internal/interface/controller/http/cart_client/route.go index d993b6a..5230d3f 100644 --- a/internal/interface/controller/http/cart/route.go +++ b/internal/interface/controller/http/cart_client/route.go @@ -1,4 +1,4 @@ -package cart +package cart_client import "github.com/gofiber/fiber/v2" diff --git a/internal/interface/controller/http/currency/controllers.go b/internal/interface/controller/http/currency_admin/controllers.go similarity index 66% rename from internal/interface/controller/http/currency/controllers.go rename to internal/interface/controller/http/currency_admin/controllers.go index 9714f6f..56871e5 100644 --- a/internal/interface/controller/http/currency/controllers.go +++ b/internal/interface/controller/http/currency_admin/controllers.go @@ -1,12 +1,12 @@ -package currency +package currency_admin import ( "github.com/gofiber/fiber/v2" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" ) type Deps struct { @@ -29,19 +29,6 @@ func NewCurrencyController(deps Deps) *CurrencyController { } } -func (receiver *CurrencyController) Get(ctx *fiber.Ctx) error { - currencyList, err := receiver.currencyRepo.FindCurrenciesList(ctx.Context(), models.DefaultCurrencyListName) - if err != nil && err.Type() != errors.ErrNotFound { - return receiver.middleWare.ErrorOld(ctx, err) - } - - if err != nil && err.Type() == errors.ErrNotFound { - return ctx.Status(fiber.StatusOK).JSON([]string{}) - } - - return ctx.Status(fiber.StatusOK).JSON(currencyList) -} - func (receiver *CurrencyController) Update(ctx *fiber.Ctx) error { var req struct { items []string diff --git a/internal/interface/controller/http/currency/route.go b/internal/interface/controller/http/currency_admin/route.go similarity index 79% rename from internal/interface/controller/http/currency/route.go rename to internal/interface/controller/http/currency_admin/route.go index 2902a2c..a853b94 100644 --- a/internal/interface/controller/http/currency/route.go +++ b/internal/interface/controller/http/currency_admin/route.go @@ -1,9 +1,8 @@ -package currency +package currency_admin import "github.com/gofiber/fiber/v2" func (receiver *CurrencyController) Register(router fiber.Router) { - router.Get("/currencies", receiver.Get) router.Put("/currencies", receiver.Update) } diff --git a/internal/interface/controller/http/currency_client/controllers.go b/internal/interface/controller/http/currency_client/controllers.go new file mode 100644 index 0000000..15ee695 --- /dev/null +++ b/internal/interface/controller/http/currency_client/controllers.go @@ -0,0 +1,43 @@ +package currency_client + +import ( + "github.com/gofiber/fiber/v2" + "go.uber.org/zap" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" +) + +type Deps struct { + CurrencyRepo *repository.CurrencyRepository + MiddleWare *http.MiddleWare + Logger *zap.Logger +} + +type CurrencyController struct { + currencyRepo *repository.CurrencyRepository + middleWare *http.MiddleWare + logger *zap.Logger +} + +func NewCurrencyController(deps Deps) *CurrencyController { + return &CurrencyController{ + currencyRepo: deps.CurrencyRepo, + middleWare: deps.MiddleWare, + logger: deps.Logger, + } +} + +func (receiver *CurrencyController) Get(ctx *fiber.Ctx) error { + currencyList, err := receiver.currencyRepo.FindCurrenciesList(ctx.Context(), models.DefaultCurrencyListName) + if err != nil && err.Type() != errors.ErrNotFound { + return receiver.middleWare.ErrorOld(ctx, err) + } + + if err != nil && err.Type() == errors.ErrNotFound { + return ctx.Status(fiber.StatusOK).JSON([]string{}) + } + + return ctx.Status(fiber.StatusOK).JSON(currencyList) +} diff --git a/internal/interface/controller/http/currency_client/route.go b/internal/interface/controller/http/currency_client/route.go new file mode 100644 index 0000000..df44dd1 --- /dev/null +++ b/internal/interface/controller/http/currency_client/route.go @@ -0,0 +1,11 @@ +package currency_client + +import "github.com/gofiber/fiber/v2" + +func (receiver *CurrencyController) Register(router fiber.Router) { + router.Get("/currencies", receiver.Get) +} + +func (receiver *CurrencyController) Name() string { + return "" +} diff --git a/internal/interface/controller/http/history_admin/controllers.go b/internal/interface/controller/http/history_admin/controllers.go new file mode 100644 index 0000000..f401b19 --- /dev/null +++ b/internal/interface/controller/http/history_admin/controllers.go @@ -0,0 +1,166 @@ +package history_admin + +import ( + "fmt" + "github.com/gofiber/fiber/v2" + "go.uber.org/zap" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" +) + +type Deps struct { + MiddleWare *http.MiddleWare + HistoryRepo *repository.HistoryRepository + AccountRepo *repository.AccountRepository + VerifyClient *client.VerificationClient + AuthClient *client.AuthClient + TemplateClient *client.TemplateClient + CodewordClient *client.CodewordClient + Logger *zap.Logger +} + +type HistoryController struct { + middleWare *http.MiddleWare + historyRepo *repository.HistoryRepository + accountRepo *repository.AccountRepository + verifyClient *client.VerificationClient + authClient *client.AuthClient + templateClient *client.TemplateClient + codewordClient *client.CodewordClient + logger *zap.Logger +} + +func NewHistoryController(deps Deps) *HistoryController { + return &HistoryController{ + middleWare: deps.MiddleWare, + historyRepo: deps.HistoryRepo, + authClient: deps.AuthClient, + accountRepo: deps.AccountRepo, + verifyClient: deps.VerifyClient, + templateClient: deps.TemplateClient, + codewordClient: deps.CodewordClient, + logger: deps.Logger, + } +} + +func (receiver *HistoryController) CalculateLTV(ctx *fiber.Ctx) error { + var req struct { + From int64 `json:"from"` + To int64 `json:"to"` + } + + if err := ctx.BodyParser(&req); err != nil { + receiver.logger.Error("failed to bind request", zap.Error(err)) + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") + } + + if req.From > req.To && req.To != 0 { + receiver.logger.Error("From timestamp must be less than To timestamp unless To is 0") + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "From timestamp must be less than To timestamp unless To is 0") + } + + ltv, err := receiver.historyRepo.CalculateCustomerLTV(ctx.Context(), req.From, req.To) + if err != nil { + receiver.logger.Error("failed to calculate LTV", zap.Error(err)) + return receiver.middleWare.ErrorOld(ctx, err) + } + + response := struct { + LTV int64 `json:"LTV"` + }{ + LTV: ltv, + } + + return ctx.Status(fiber.StatusOK).JSON(response) +} + +func (receiver *HistoryController) QuizLogoStat(ctx *fiber.Ctx) error { + var req struct { + From *int `json:"from,omitempty"` + Limit *int `json:"limit,omitempty"` + Page *int `json:"page,omitempty"` + To *int `json:"to,omitempty"` + } + + if err := ctx.BodyParser(&req); err != nil { + receiver.logger.Error("failed to bind request", zap.Error(err)) + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") + } + + result, err := receiver.accountRepo.QuizLogoStat(ctx.Context(), repository.QuizLogoStatDeps{ + Page: req.Page, + Limit: req.Limit, + From: req.From, + To: req.To, + }) + if err != nil { + return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed getting quiz logo stat", err.Error())) + } + + return ctx.Status(fiber.StatusOK).JSON(result) +} + +func (receiver *HistoryController) PromocodeLTV(ctx *fiber.Ctx) error { + var req struct { + From int `json:"from"` + To int `json:"to"` + } + + if err := ctx.BodyParser(&req); err != nil { + receiver.logger.Error("failed to bind request", zap.Error(err)) + return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") + } + + // получаем мапу вида [promoID] = []{userid,timeActivate} + // отдаются только первые использованые на аккаунте промокоды, соответсвенно подсчет идет сугубо по ним + // если в запросе время различается с временем активации - если меньше, то учитывается только после применения + // если больше, то учитывается только с начала переданного from + codewordData, err := receiver.codewordClient.GetAllPromoActivations(ctx.Context(), &codeword_rpc.Time{ + To: int64(req.To), + From: int64(req.From), + }) + + if err != nil { + return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed getting codeword data", err.Error())) + } + + userSumMap, er := receiver.historyRepo.GetPayUsersPromoHistory(ctx.Context(), codewordData, int64(req.From), int64(req.To)) + if er != nil { + return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed calculate promo users paid sum", er.Error())) + } + + resp := make(map[string]struct { + Regs int + Money int64 + }) + + for promoID, data := range codewordData { + fmt.Println("PROTOMOTO", promoID, data) + for _, value := range data { + + paids, ok := userSumMap[value.UserID] + if !ok { + paids = 0 + } + fmt.Println("PROTOMOTO1", paids, value) + + if value.Time >= int64(req.From) && value.Time <= int64(req.To) { + if _, ok := resp[promoID]; !ok { + resp[promoID] = struct { + Regs int + Money int64 + }{Regs: 1, Money: paids} + continue + } + current := resp[promoID] + current.Regs += 1 + current.Money += paids + resp[promoID] = current + } + } + } + + return ctx.Status(fiber.StatusOK).JSON(resp) +} diff --git a/internal/interface/controller/http/history/route.go b/internal/interface/controller/http/history_admin/route.go similarity index 68% rename from internal/interface/controller/http/history/route.go rename to internal/interface/controller/http/history_admin/route.go index 0d5eee4..8755e7f 100644 --- a/internal/interface/controller/http/history/route.go +++ b/internal/interface/controller/http/history_admin/route.go @@ -1,14 +1,11 @@ -package history +package history_admin import "github.com/gofiber/fiber/v2" func (receiver *HistoryController) Register(router fiber.Router) { - router.Get("/history", receiver.Get) router.Post("/history/ltv", receiver.CalculateLTV) router.Post("/promocode/ltv", receiver.PromocodeLTV) router.Post("/quizlogo/stat", receiver.QuizLogoStat) - router.Get("/recent", receiver.GetRecentTariffs) - router.Post("/sendReport", receiver.SendReport) } func (receiver *HistoryController) Name() string { diff --git a/internal/interface/controller/http/history/controllers.go b/internal/interface/controller/http/history_client/controllers.go similarity index 62% rename from internal/interface/controller/http/history/controllers.go rename to internal/interface/controller/http/history_client/controllers.go index b6216c2..26dbef1 100644 --- a/internal/interface/controller/http/history/controllers.go +++ b/internal/interface/controller/http/history_client/controllers.go @@ -1,4 +1,4 @@ -package history +package history_client import ( "fmt" @@ -7,13 +7,12 @@ import ( "math" "os" "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - codeword_rpc "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/codeword" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/history" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/service/history" + "gitea.pena/PenaSide/customer/internal/utils" "strconv" "strings" "time" @@ -117,37 +116,6 @@ func (receiver *HistoryController) Get(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(returnHistories) } -func (receiver *HistoryController) CalculateLTV(ctx *fiber.Ctx) error { - var req struct { - From int64 `json:"from"` - To int64 `json:"to"` - } - - if err := ctx.BodyParser(&req); err != nil { - receiver.logger.Error("failed to bind request", zap.Error(err)) - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") - } - - if req.From > req.To && req.To != 0 { - receiver.logger.Error("From timestamp must be less than To timestamp unless To is 0") - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "From timestamp must be less than To timestamp unless To is 0") - } - - ltv, err := receiver.historyRepo.CalculateCustomerLTV(ctx.Context(), req.From, req.To) - if err != nil { - receiver.logger.Error("failed to calculate LTV", zap.Error(err)) - return receiver.middleWare.ErrorOld(ctx, err) - } - - response := struct { - LTV int64 `json:"LTV"` - }{ - LTV: ltv, - } - - return ctx.Status(fiber.StatusOK).JSON(response) -} - func (receiver *HistoryController) GetRecentTariffs(ctx *fiber.Ctx) error { userID, ok := receiver.middleWare.ExtractUserID(ctx) if !ok || userID == "" { @@ -294,92 +262,3 @@ func (receiver *HistoryController) SendReport(ctx *fiber.Ctx) error { return ctx.SendStatus(fiber.StatusOK) } - -func (receiver *HistoryController) QuizLogoStat(ctx *fiber.Ctx) error { - var req struct { - From *int `json:"from,omitempty"` - Limit *int `json:"limit,omitempty"` - Page *int `json:"page,omitempty"` - To *int `json:"to,omitempty"` - } - - if err := ctx.BodyParser(&req); err != nil { - receiver.logger.Error("failed to bind request", zap.Error(err)) - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") - } - - result, err := receiver.accountRepo.QuizLogoStat(ctx.Context(), repository.QuizLogoStatDeps{ - Page: req.Page, - Limit: req.Limit, - From: req.From, - To: req.To, - }) - if err != nil { - return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed getting quiz logo stat", err.Error())) - } - - return ctx.Status(fiber.StatusOK).JSON(result) -} - -func (receiver *HistoryController) PromocodeLTV(ctx *fiber.Ctx) error { - var req struct { - From int `json:"from"` - To int `json:"to"` - } - - if err := ctx.BodyParser(&req); err != nil { - receiver.logger.Error("failed to bind request", zap.Error(err)) - return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "failed to bind request") - } - - // получаем мапу вида [promoID] = []{userid,timeActivate} - // отдаются только первые использованые на аккаунте промокоды, соответсвенно подсчет идет сугубо по ним - // если в запросе время различается с временем активации - если меньше, то учитывается только после применения - // если больше, то учитывается только с начала переданного from - codewordData, err := receiver.codewordClient.GetAllPromoActivations(ctx.Context(), &codeword_rpc.Time{ - To: int64(req.To), - From: int64(req.From), - }) - - if err != nil { - return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed getting codeword data", err.Error())) - } - - userSumMap, er := receiver.historyRepo.GetPayUsersPromoHistory(ctx.Context(), codewordData, int64(req.From), int64(req.To)) - if er != nil { - return receiver.middleWare.Error(ctx, fiber.StatusInternalServerError, fmt.Sprint("failed calculate promo users paid sum", er.Error())) - } - - resp := make(map[string]struct { - Regs int - Money int64 - }) - - for promoID, data := range codewordData { - fmt.Println("PROTOMOTO", promoID, data) - for _, value := range data { - - paids, ok := userSumMap[value.UserID] - if !ok { - paids = 0 - } - fmt.Println("PROTOMOTO1", paids, value) - - if value.Time >= int64(req.From) && value.Time <= int64(req.To) { - if _, ok := resp[promoID]; !ok { - resp[promoID] = struct { - Regs int - Money int64 - }{Regs: 1, Money: paids} - continue - } - current := resp[promoID] - current.Regs += 1 - current.Money += paids - resp[promoID] = current - } - } - } - - return ctx.Status(fiber.StatusOK).JSON(resp) -} diff --git a/internal/interface/controller/http/history_client/route.go b/internal/interface/controller/http/history_client/route.go new file mode 100644 index 0000000..7b61f2d --- /dev/null +++ b/internal/interface/controller/http/history_client/route.go @@ -0,0 +1,13 @@ +package history_client + +import "github.com/gofiber/fiber/v2" + +func (receiver *HistoryController) Register(router fiber.Router) { + router.Get("/history", receiver.Get) + router.Get("/recent", receiver.GetRecentTariffs) + router.Post("/sendReport", receiver.SendReport) +} + +func (receiver *HistoryController) Name() string { + return "" +} diff --git a/internal/interface/controller/http/middleware.go b/internal/interface/controller/http/middleware.go index 53f686d..f5c8432 100644 --- a/internal/interface/controller/http/middleware.go +++ b/internal/interface/controller/http/middleware.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/gofiber/fiber/v2" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/models" ) type MiddleWare struct { diff --git a/internal/interface/controller/http/wallet/controllers.go b/internal/interface/controller/http/wallet_client/controllers.go similarity index 61% rename from internal/interface/controller/http/wallet/controllers.go rename to internal/interface/controller/http/wallet_client/controllers.go index 0e9ffd1..6774cbe 100644 --- a/internal/interface/controller/http/wallet/controllers.go +++ b/internal/interface/controller/http/wallet_client/controllers.go @@ -1,19 +1,19 @@ -package wallet +package wallet_client import ( "context" - "fmt" "github.com/gofiber/fiber/v2" "go.uber.org/zap" + "fmt" "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/treasurer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/controller/http" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/treasurer" + "gitea.pena/PenaSide/customer/internal/utils" + "gitea.pena/PenaSide/customer/pkg/validate" ) type Deps struct { @@ -26,6 +26,7 @@ type Deps struct { VerifyClient *client.VerificationClient MailClient *client.MailClient Logger *zap.Logger + TelegramClient *client.TelegramClient } type WalletController struct { @@ -38,6 +39,7 @@ type WalletController struct { verifyClient *client.VerificationClient mailClient *client.MailClient logger *zap.Logger + telegramClient *client.TelegramClient } func NewWalletController(deps Deps) *WalletController { @@ -51,6 +53,7 @@ func NewWalletController(deps Deps) *WalletController { verifyClient: deps.VerifyClient, mailClient: deps.MailClient, logger: deps.Logger, + telegramClient: deps.TelegramClient, } } @@ -59,6 +62,7 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error { if !ok || userID == "" { return receiver.middleWare.NoAuth(ctx) } + token, _ := receiver.middleWare.ExtractToken(ctx) hlogger := log_mw.ExtractLogger(ctx) @@ -80,7 +84,7 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error { Body: &request, UserID: userID, ClientIP: ctx.IP(), - }) + }, account, token) if err != nil { return receiver.middleWare.ErrorOld(ctx, err) } @@ -97,8 +101,9 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(&models.GetPaymentLinkResponse{Link: link}) } -func (receiver *WalletController) GetPaymentLink(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - if _, userErr := receiver.authClient.GetUser(ctx, request.UserID); userErr != nil { +func (receiver *WalletController) GetPaymentLink(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, token string) (string, errors.Error) { + auth, userErr := receiver.authClient.GetUser(ctx, request.UserID) + if userErr != nil { receiver.logger.Error("failed to get user on on ", zap.Error(userErr), zap.String("userID", request.UserID), @@ -107,26 +112,37 @@ func (receiver *WalletController) GetPaymentLink(ctx context.Context, request *m return "", userErr } + if auth.PhoneNumber == "+7" { + auth.PhoneNumber = "" + } + + verification, err := receiver.verifyClient.GetVerification(ctx, token, request.UserID) + if err != nil { + verification = &models.Verification{ + TaxNumber: "", + } + } + switch request.Body.Type { case models.PaymentTypeBankCard: - return receiver.GetPaymentLinkBankCard(ctx, request) + return receiver.GetPaymentLinkBankCard(ctx, request, account, auth, verification) case models.PaymentTypeYoomoney: - return receiver.GetPaymentLinkYooMoney(ctx, request) + return receiver.GetPaymentLinkYooMoney(ctx, request, account, auth, verification) case models.PaymentTypeSberPay: - return receiver.GetPaymentLinkSberPay(ctx, request) + return receiver.GetPaymentLinkSberPay(ctx, request, account, auth, verification) case models.PaymentTypeTinkoff: - return receiver.GetPaymentLinkTinkoff(ctx, request) + return receiver.GetPaymentLinkTinkoff(ctx, request, account, auth, verification) case models.PaymentTypeSBP: - return receiver.GetPaymentLinkSBP(ctx, request) + return receiver.GetPaymentLinkSBP(ctx, request, account, auth, verification) case models.PaymentTypeSberB2B: - return receiver.GetPaymentLinkB2B(ctx, request) + return receiver.GetPaymentLinkB2B(ctx, request, account, auth, verification) } return "", errors.NewWithMessage("invalid payment method type", errors.ErrInvalidArgs) } -func (receiver *WalletController) GetPaymentLinkBankCard(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkBankCard(ctx, &treasurer.GetBankCardPaymentLinkRequest{ +func (receiver *WalletController) GetPaymentLinkBankCard(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkBankCard(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -134,6 +150,17 @@ func (receiver *WalletController) GetPaymentLinkBankCard(ctx context.Context, re ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ". " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -144,8 +171,8 @@ func (receiver *WalletController) GetPaymentLinkBankCard(ctx context.Context, re return link, nil } -func (receiver *WalletController) GetPaymentLinkYooMoney(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkYooMoney(ctx, &treasurer.GetPaymentLinkBody{ +func (receiver *WalletController) GetPaymentLinkYooMoney(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkYooMoney(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -153,6 +180,17 @@ func (receiver *WalletController) GetPaymentLinkYooMoney(ctx context.Context, re ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -163,8 +201,8 @@ func (receiver *WalletController) GetPaymentLinkYooMoney(ctx context.Context, re return link, nil } -func (receiver *WalletController) GetPaymentLinkSberPay(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkSberPay(ctx, &treasurer.GetPaymentLinkBody{ +func (receiver *WalletController) GetPaymentLinkSberPay(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkSberPay(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -172,6 +210,17 @@ func (receiver *WalletController) GetPaymentLinkSberPay(ctx context.Context, req ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -182,8 +231,8 @@ func (receiver *WalletController) GetPaymentLinkSberPay(ctx context.Context, req return link, nil } -func (receiver *WalletController) GetPaymentLinkTinkoff(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkTinkoff(ctx, &treasurer.GetPaymentLinkBody{ +func (receiver *WalletController) GetPaymentLinkTinkoff(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkTinkoff(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -191,6 +240,17 @@ func (receiver *WalletController) GetPaymentLinkTinkoff(ctx context.Context, req ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -201,8 +261,8 @@ func (receiver *WalletController) GetPaymentLinkTinkoff(ctx context.Context, req return link, nil } -func (receiver *WalletController) GetPaymentLinkSBP(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkSBP(ctx, &treasurer.GetPaymentLinkBody{ +func (receiver *WalletController) GetPaymentLinkSBP(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkSBP(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -210,6 +270,17 @@ func (receiver *WalletController) GetPaymentLinkSBP(ctx context.Context, request ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -220,8 +291,8 @@ func (receiver *WalletController) GetPaymentLinkSBP(ctx context.Context, request return link, nil } -func (receiver *WalletController) GetPaymentLinkB2B(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { - link, err := receiver.paymentClient.GetPaymentLinkSberbankB2B(ctx, &treasurer.GetPaymentLinkBody{ +func (receiver *WalletController) GetPaymentLinkB2B(ctx context.Context, request *models.GetPaymentLinkRequest, account *models.Account, auth *models.User, ver *models.Verification) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkSberbankB2B(ctx, &treasurer.GetPaymentLinkRequest{ MainSettings: &treasurer.MainPaymentSettings{ Currency: request.Body.Currency, Amount: request.Body.Amount, @@ -229,6 +300,17 @@ func (receiver *WalletController) GetPaymentLinkB2B(ctx context.Context, request ClientIP: request.ClientIP, CallbackHostGRPC: []string{receiver.grpc.Domen}, ReturnURL: request.Body.ReturnURL, + Customer: &treasurer.Customer{ + FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname, + Email: auth.Login, + Phone: auth.PhoneNumber, + }, + Items: []*treasurer.Item{&treasurer.Item{ + Description: "Пополнение пользовательского баланса платформы Pena Hub", + Quantity: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + Currency: "RUB", + Money: fmt.Sprintf("%.2f", float64(request.Body.Amount)/100), + }}, }, }) if err != nil { @@ -307,18 +389,12 @@ func (receiver *WalletController) PostWalletRspay(ctx *fiber.Ctx) error { return receiver.middleWare.Error(ctx, fiber.StatusForbidden, "not allowed for non organizations") } token := ctx.Get("Authorization") - fmt.Println("HEADERS", ctx.Request().Header) verification, err := receiver.verifyClient.GetVerification(ctx.Context(), token, userID) if err == errors.ErrNotFound { return receiver.middleWare.Error(ctx, fiber.StatusForbidden, "no verification data found") } - if (user.Status == models.AccountStatusOrg && len(verification.Files) != 3) || - (user.Status == models.AccountStatusNko && len(verification.Files) != 4) { - return receiver.middleWare.Error(ctx, fiber.StatusForbidden, "not enough verification files") - } - authData, err := receiver.authClient.GetUser(ctx.Context(), userID) if err != nil { return receiver.middleWare.ErrorOld(ctx, err) @@ -329,6 +405,11 @@ func (receiver *WalletController) PostWalletRspay(ctx *fiber.Ctx) error { return receiver.middleWare.ErrorOld(ctx, err) } + err = receiver.telegramClient.NotifyRsPay(authData.Login, verification, *req.Money) + if err != nil { + return receiver.middleWare.ErrorOld(ctx, err) + } + hlogger.Emit(models.InfoRSPay{ CtxUserID: userID, CtxAccountID: user.ID, diff --git a/internal/interface/controller/http/wallet/route.go b/internal/interface/controller/http/wallet_client/route.go similarity index 93% rename from internal/interface/controller/http/wallet/route.go rename to internal/interface/controller/http/wallet_client/route.go index c679993..8d19fee 100644 --- a/internal/interface/controller/http/wallet/route.go +++ b/internal/interface/controller/http/wallet_client/route.go @@ -1,4 +1,4 @@ -package wallet +package wallet_client import "github.com/gofiber/fiber/v2" diff --git a/internal/interface/repository/account.go b/internal/interface/repository/account.go index b7a1a85..365df01 100644 --- a/internal/interface/repository/account.go +++ b/internal/interface/repository/account.go @@ -6,15 +6,15 @@ import ( "log" "time" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/fields" + "gitea.pena/PenaSide/customer/internal/models" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.uber.org/zap" mongoWrapper "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" ) type AccountRepositoryDeps struct { diff --git a/internal/interface/repository/currency.go b/internal/interface/repository/currency.go index e68b302..5a883e3 100644 --- a/internal/interface/repository/currency.go +++ b/internal/interface/repository/currency.go @@ -11,9 +11,9 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.uber.org/zap" mongoWrapper "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/fields" + "gitea.pena/PenaSide/customer/internal/models" ) type CurrencyRepositoryDeps struct { diff --git a/internal/interface/repository/history.go b/internal/interface/repository/history.go index 282875b..b815fb8 100644 --- a/internal/interface/repository/history.go +++ b/internal/interface/repository/history.go @@ -4,8 +4,8 @@ import ( "context" "fmt" "log" - codeword_rpc "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/codeword" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" + "gitea.pena/PenaSide/customer/internal/utils" "time" "go.mongodb.org/mongo-driver/bson" @@ -14,10 +14,10 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "go.uber.org/zap" mongoWrapper "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/history" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/fields" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/service/history" ) type HistoryRepositoryDeps struct { diff --git a/internal/models/account.go b/internal/models/account.go index d1ffe9a..bca4e23 100644 --- a/internal/models/account.go +++ b/internal/models/account.go @@ -15,6 +15,7 @@ type Account struct { DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"` From string `json:"from" bson:"from"` Partner string `json:"partner" bson:"partner"` + Version uint32 `json:"version" bson:"version"` } func (receiver *Account) Sanitize() *Account { @@ -32,6 +33,7 @@ func (receiver *Account) Sanitize() *Account { //receiver.Partner = "" receiver.DeletedAt = nil receiver.Deleted = false + receiver.Version = mongoVersion return receiver } diff --git a/internal/models/config.go b/internal/models/config.go index 0c98b94..ecbce7d 100644 --- a/internal/models/config.go +++ b/internal/models/config.go @@ -15,8 +15,10 @@ type Config struct { } type ConfigurationHTTP struct { - Host string `env:"HTTP_HOST,default=localhost"` - Port string `env:"HTTP_PORT,default=8080"` + ClientHost string `env:"CLIENT_HTTP_HOST,default=localhost"` + ClientPort string `env:"CLIENT_HTTP_PORT,default=8080"` + AdminHost string `env:"ADMIN_HTTP_HOST,default=localhost"` + AdminPort string `env:"ADMIN_HTTP_PORT,default=8081"` } type ConfigurationGRPC struct { @@ -41,6 +43,10 @@ type ServiceConfiguration struct { PubKey string `env:"PUBLIC_KEY"` PrivKey string `env:"PRIVATE_KEY"` ModuleLogger string `env:"MODULE_LOGGER"` + NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"` + NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"` + AdminURL string `env:"ADMIN_FRONT_URL"` + NotificationRsPayChannel int64 `env:"NOTIFICATION_RS_PAY_CHANNEL"` } type KafkaConfiguration struct { @@ -126,3 +132,5 @@ type PlainAuth struct { Username string `env:"MAIL_AUTH_USERNAME,required"` Password string `env:"MAIL_AUTH_PASSWORD,required"` } + +const mongoVersion uint32 = 1 diff --git a/internal/models/currency.go b/internal/models/currency.go index 082c84b..86595ce 100644 --- a/internal/models/currency.go +++ b/internal/models/currency.go @@ -12,6 +12,7 @@ type CurrencyList struct { CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"` + Version uint32 `json:"version" bson:"version"` } func (receiver *CurrencyList) Sanitize() *CurrencyList { @@ -22,6 +23,7 @@ func (receiver *CurrencyList) Sanitize() *CurrencyList { receiver.UpdatedAt = now receiver.DeletedAt = nil receiver.Deleted = false + receiver.Version = mongoVersion return receiver } diff --git a/internal/models/history.go b/internal/models/history.go index 57f8628..37a502e 100644 --- a/internal/models/history.go +++ b/internal/models/history.go @@ -7,11 +7,12 @@ type History struct { UserID string `json:"userId" bson:"userId"` Comment string `json:"comment" bson:"comment"` Key string `json:"key" bson:"key"` - RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"` + RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"` Deleted bool `json:"isDeleted" bson:"isDeleted"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"` + Version uint32 `json:"version" bson:"version"` } type TariffID struct { @@ -33,7 +34,7 @@ type ReportHistory struct { type RawDetails struct { Tariffs []Tariff `json:"tariffs" bson:"tariffs"` Price int64 `json:"price" bson:"price"` - Comment string `json:"comment" bson:"comment"` + Comment string `json:"comment" bson:"comment"` } func (receiver *History) Sanitize() *History { @@ -44,6 +45,7 @@ func (receiver *History) Sanitize() *History { receiver.UpdatedAt = now receiver.DeletedAt = nil receiver.Deleted = false + receiver.Version = mongoVersion return receiver } diff --git a/internal/models/payment.go b/internal/models/payment.go index 18ce9fe..2193c65 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -5,29 +5,28 @@ type GetPaymentLinkBody struct { Currency string `json:"currency"` Amount int64 `json:"amount"` ReturnURL string `json:"returnUrl,omitempty"` - PhoneNumber string `json:"phoneNumber,omitempty"` - Login string `json:"login,omitempty"` - BankCard *BankCard `json:"bankCard,omitempty"` } type GetPaymentLinkRequest struct { Body *GetPaymentLinkBody ClientIP string UserID string + Customer Customer + Items []Item +} + +type Customer struct { + FullName, INN, Email, Phone string +} + +type Item struct { + Description, Measure, Quantity, Money, Currency string } type GetPaymentLinkResponse struct { Link string `json:"link"` } -type BankCard struct { - Number string `json:"number"` - ExpiryYear string `json:"expiryYear"` - ExpiryMonth string `json:"expiryMonth"` - CSC *string `json:"csc,omitempty"` - CardHolderName *string `json:"cardholder,omitempty"` -} - type PaymentType string const ( diff --git a/internal/models/tariff.go b/internal/models/tariff.go index 7d8e754..665dac5 100644 --- a/internal/models/tariff.go +++ b/internal/models/tariff.go @@ -3,7 +3,7 @@ package models import ( "time" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/proto/broker" ) type Tariff struct { diff --git a/internal/models/templategen.go b/internal/models/templategen.go index 4d293db..a0b793a 100644 --- a/internal/models/templategen.go +++ b/internal/models/templategen.go @@ -1,13 +1,13 @@ package models type RespGeneratorService struct { - DocNumber string `json:"docnumber"` + DocNumber string `json:"docnumber"` Date string `json:"date"` OrgTaxNum string `json:"orgtaxnum"` - OrgName string `json:"orgname"` + OrgName string `json:"orgname"` Name string `json:"name"` Amount string `json:"amount"` - Price string `json:"price"` - Sum string `json:"sum"` - Unit string `json:"unit"` + Price string `json:"price"` + Sum string `json:"sum"` + Unit string `json:"unit"` } diff --git a/internal/models/trashLog.go b/internal/models/trashLog.go index f01ea98..d5905f0 100644 --- a/internal/models/trashLog.go +++ b/internal/models/trashLog.go @@ -15,7 +15,7 @@ type AllFields struct { CtxPhone string KeyCurrency string CtxTariffID string - KeySuccess bool + KeySuccess uint8 CtxPrice int64 CtxTariff string @@ -53,7 +53,7 @@ type InfoAddToCart struct { type InfoPayCart struct { CtxUserID string //айдишник юзера из токена CtxAccountID string // айдишник аккаунта - KeySuccess bool // получилось оплатить или не хватило денег + KeySuccess uint8 // получилось оплатить или не хватило денег CtxPrice int64 // сумма в копейках. если не удалось оплатить - записать сколько денег не хватило CtxTariff string // через запятую список покупаемых тарифов CtxDiscount string // через запятую список применённых скидок diff --git a/internal/proto/broker/models.pb.go b/internal/proto/broker/models.pb.go index da6684e..3b555e3 100644 --- a/internal/proto/broker/models.pb.go +++ b/internal/proto/broker/models.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: broker/models.proto diff --git a/internal/proto/codeword_rpc/promo.pb.go b/internal/proto/codeword_rpc/promo.pb.go new file mode 100644 index 0000000..4e623c9 --- /dev/null +++ b/internal/proto/codeword_rpc/promo.pb.go @@ -0,0 +1,306 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc (unknown) +// source: codeword/promo.proto + +package codeword_rpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Time struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + From int64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` + To int64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (x *Time) Reset() { + *x = Time{} + if protoimpl.UnsafeEnabled { + mi := &file_codeword_promo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Time) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Time) ProtoMessage() {} + +func (x *Time) ProtoReflect() protoreflect.Message { + mi := &file_codeword_promo_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Time.ProtoReflect.Descriptor instead. +func (*Time) Descriptor() ([]byte, []int) { + return file_codeword_promo_proto_rawDescGZIP(), []int{0} +} + +func (x *Time) GetFrom() int64 { + if x != nil { + return x.From + } + return 0 +} + +func (x *Time) GetTo() int64 { + if x != nil { + return x.To + } + return 0 +} + +type PromoActivationResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + Users []*PromoActivationResp_UserTime `protobuf:"bytes,2,rep,name=Users,proto3" json:"Users,omitempty"` +} + +func (x *PromoActivationResp) Reset() { + *x = PromoActivationResp{} + if protoimpl.UnsafeEnabled { + mi := &file_codeword_promo_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PromoActivationResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PromoActivationResp) ProtoMessage() {} + +func (x *PromoActivationResp) ProtoReflect() protoreflect.Message { + mi := &file_codeword_promo_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PromoActivationResp.ProtoReflect.Descriptor instead. +func (*PromoActivationResp) Descriptor() ([]byte, []int) { + return file_codeword_promo_proto_rawDescGZIP(), []int{1} +} + +func (x *PromoActivationResp) GetID() string { + if x != nil { + return x.ID + } + return "" +} + +func (x *PromoActivationResp) GetUsers() []*PromoActivationResp_UserTime { + if x != nil { + return x.Users + } + return nil +} + +type PromoActivationResp_UserTime struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserID string `protobuf:"bytes,1,opt,name=UserID,proto3" json:"UserID,omitempty"` + Time int64 `protobuf:"varint,2,opt,name=Time,proto3" json:"Time,omitempty"` +} + +func (x *PromoActivationResp_UserTime) Reset() { + *x = PromoActivationResp_UserTime{} + if protoimpl.UnsafeEnabled { + mi := &file_codeword_promo_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PromoActivationResp_UserTime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PromoActivationResp_UserTime) ProtoMessage() {} + +func (x *PromoActivationResp_UserTime) ProtoReflect() protoreflect.Message { + mi := &file_codeword_promo_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PromoActivationResp_UserTime.ProtoReflect.Descriptor instead. +func (*PromoActivationResp_UserTime) Descriptor() ([]byte, []int) { + return file_codeword_promo_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *PromoActivationResp_UserTime) GetUserID() string { + if x != nil { + return x.UserID + } + return "" +} + +func (x *PromoActivationResp_UserTime) GetTime() int64 { + if x != nil { + return x.Time + } + return 0 +} + +var File_codeword_promo_proto protoreflect.FileDescriptor + +var file_codeword_promo_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, + 0x22, 0x2a, 0x0a, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, + 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x9b, 0x01, 0x0a, + 0x13, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x49, 0x44, 0x12, 0x3c, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2e, 0x50, + 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x05, 0x55, 0x73, 0x65, + 0x72, 0x73, 0x1a, 0x36, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x32, 0x5d, 0x0a, 0x10, 0x50, 0x72, + 0x6f, 0x6d, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x49, + 0x0a, 0x16, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x0e, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x77, + 0x6f, 0x72, 0x64, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x1a, 0x1d, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x77, + 0x6f, 0x72, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x30, 0x01, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x63, + 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_codeword_promo_proto_rawDescOnce sync.Once + file_codeword_promo_proto_rawDescData = file_codeword_promo_proto_rawDesc +) + +func file_codeword_promo_proto_rawDescGZIP() []byte { + file_codeword_promo_proto_rawDescOnce.Do(func() { + file_codeword_promo_proto_rawDescData = protoimpl.X.CompressGZIP(file_codeword_promo_proto_rawDescData) + }) + return file_codeword_promo_proto_rawDescData +} + +var file_codeword_promo_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_codeword_promo_proto_goTypes = []interface{}{ + (*Time)(nil), // 0: codeword.Time + (*PromoActivationResp)(nil), // 1: codeword.PromoActivationResp + (*PromoActivationResp_UserTime)(nil), // 2: codeword.PromoActivationResp.UserTime +} +var file_codeword_promo_proto_depIdxs = []int32{ + 2, // 0: codeword.PromoActivationResp.Users:type_name -> codeword.PromoActivationResp.UserTime + 0, // 1: codeword.PromoCodeService.GetAllPromoActivations:input_type -> codeword.Time + 1, // 2: codeword.PromoCodeService.GetAllPromoActivations:output_type -> codeword.PromoActivationResp + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_codeword_promo_proto_init() } +func file_codeword_promo_proto_init() { + if File_codeword_promo_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_codeword_promo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Time); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_codeword_promo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PromoActivationResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_codeword_promo_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PromoActivationResp_UserTime); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_codeword_promo_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_codeword_promo_proto_goTypes, + DependencyIndexes: file_codeword_promo_proto_depIdxs, + MessageInfos: file_codeword_promo_proto_msgTypes, + }.Build() + File_codeword_promo_proto = out.File + file_codeword_promo_proto_rawDesc = nil + file_codeword_promo_proto_goTypes = nil + file_codeword_promo_proto_depIdxs = nil +} diff --git a/internal/proto/codeword_rpc/promo_grpc.pb.go b/internal/proto/codeword_rpc/promo_grpc.pb.go new file mode 100644 index 0000000..f00092a --- /dev/null +++ b/internal/proto/codeword_rpc/promo_grpc.pb.go @@ -0,0 +1,134 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: codeword/promo.proto + +package codeword_rpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + PromoCodeService_GetAllPromoActivations_FullMethodName = "/codeword.PromoCodeService/GetAllPromoActivations" +) + +// PromoCodeServiceClient is the client API for PromoCodeService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type PromoCodeServiceClient interface { + GetAllPromoActivations(ctx context.Context, in *Time, opts ...grpc.CallOption) (PromoCodeService_GetAllPromoActivationsClient, error) +} + +type promoCodeServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPromoCodeServiceClient(cc grpc.ClientConnInterface) PromoCodeServiceClient { + return &promoCodeServiceClient{cc} +} + +func (c *promoCodeServiceClient) GetAllPromoActivations(ctx context.Context, in *Time, opts ...grpc.CallOption) (PromoCodeService_GetAllPromoActivationsClient, error) { + stream, err := c.cc.NewStream(ctx, &PromoCodeService_ServiceDesc.Streams[0], PromoCodeService_GetAllPromoActivations_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &promoCodeServiceGetAllPromoActivationsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type PromoCodeService_GetAllPromoActivationsClient interface { + Recv() (*PromoActivationResp, error) + grpc.ClientStream +} + +type promoCodeServiceGetAllPromoActivationsClient struct { + grpc.ClientStream +} + +func (x *promoCodeServiceGetAllPromoActivationsClient) Recv() (*PromoActivationResp, error) { + m := new(PromoActivationResp) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// PromoCodeServiceServer is the server API for PromoCodeService service. +// All implementations should embed UnimplementedPromoCodeServiceServer +// for forward compatibility +type PromoCodeServiceServer interface { + GetAllPromoActivations(*Time, PromoCodeService_GetAllPromoActivationsServer) error +} + +// UnimplementedPromoCodeServiceServer should be embedded to have forward compatible implementations. +type UnimplementedPromoCodeServiceServer struct { +} + +func (UnimplementedPromoCodeServiceServer) GetAllPromoActivations(*Time, PromoCodeService_GetAllPromoActivationsServer) error { + return status.Errorf(codes.Unimplemented, "method GetAllPromoActivations not implemented") +} + +// UnsafePromoCodeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PromoCodeServiceServer will +// result in compilation errors. +type UnsafePromoCodeServiceServer interface { + mustEmbedUnimplementedPromoCodeServiceServer() +} + +func RegisterPromoCodeServiceServer(s grpc.ServiceRegistrar, srv PromoCodeServiceServer) { + s.RegisterService(&PromoCodeService_ServiceDesc, srv) +} + +func _PromoCodeService_GetAllPromoActivations_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Time) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(PromoCodeServiceServer).GetAllPromoActivations(m, &promoCodeServiceGetAllPromoActivationsServer{stream}) +} + +type PromoCodeService_GetAllPromoActivationsServer interface { + Send(*PromoActivationResp) error + grpc.ServerStream +} + +type promoCodeServiceGetAllPromoActivationsServer struct { + grpc.ServerStream +} + +func (x *promoCodeServiceGetAllPromoActivationsServer) Send(m *PromoActivationResp) error { + return x.ServerStream.SendMsg(m) +} + +// PromoCodeService_ServiceDesc is the grpc.ServiceDesc for PromoCodeService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PromoCodeService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "codeword.PromoCodeService", + HandlerType: (*PromoCodeServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetAllPromoActivations", + Handler: _PromoCodeService_GetAllPromoActivations_Handler, + ServerStreams: true, + }, + }, + Metadata: "codeword/promo.proto", +} diff --git a/internal/proto/customer/service_grpc.pb.go b/internal/proto/customer/service_grpc.pb.go index 7645bda..194577e 100644 --- a/internal/proto/customer/service_grpc.pb.go +++ b/internal/proto/customer/service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: customer/service.proto package customer @@ -15,6 +19,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + CustomerService_InsertHistory_FullMethodName = "/customer.CustomerService/InsertHistory" +) + // CustomerServiceClient is the client API for CustomerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -33,7 +41,7 @@ func NewCustomerServiceClient(cc grpc.ClientConnInterface) CustomerServiceClient func (c *customerServiceClient) InsertHistory(ctx context.Context, in *History, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/customer.CustomerService/InsertHistory", in, out, opts...) + err := c.cc.Invoke(ctx, CustomerService_InsertHistory_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -91,7 +99,7 @@ func _CustomerService_InsertHistory_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/customer.CustomerService/InsertHistory", + FullMethod: CustomerService_InsertHistory_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CustomerServiceServer).InsertHistory(ctx, req.(*History)) diff --git a/internal/proto/discount/audit.model.pb.go b/internal/proto/discount/audit.model.pb.go index 14fe4a8..81a5a3c 100644 --- a/internal/proto/discount/audit.model.pb.go +++ b/internal/proto/discount/audit.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: discount/audit.model.proto diff --git a/internal/proto/discount/discount.model.pb.go b/internal/proto/discount/discount.model.pb.go index 53d45f2..1477d7c 100644 --- a/internal/proto/discount/discount.model.pb.go +++ b/internal/proto/discount/discount.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: discount/discount.model.proto diff --git a/internal/proto/discount/service.pb.go b/internal/proto/discount/service.pb.go index 5945037..4196e0c 100644 --- a/internal/proto/discount/service.pb.go +++ b/internal/proto/discount/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: discount/service.proto diff --git a/internal/proto/discount/service_grpc.pb.go b/internal/proto/discount/service_grpc.pb.go index 81f1efd..e9161fb 100644 --- a/internal/proto/discount/service_grpc.pb.go +++ b/internal/proto/discount/service_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 +// - protoc-gen-go-grpc v1.3.0 // - protoc (unknown) // source: discount/service.proto @@ -19,6 +19,18 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + DiscountService_GetAllDiscounts_FullMethodName = "/discount.DiscountService/GetAllDiscounts" + DiscountService_GetUserDiscounts_FullMethodName = "/discount.DiscountService/GetUserDiscounts" + DiscountService_DetermineDiscounts_FullMethodName = "/discount.DiscountService/DetermineDiscounts" + DiscountService_ApplyDiscounts_FullMethodName = "/discount.DiscountService/ApplyDiscounts" + DiscountService_GetDiscountByID_FullMethodName = "/discount.DiscountService/GetDiscountByID" + DiscountService_CreateDiscount_FullMethodName = "/discount.DiscountService/CreateDiscount" + DiscountService_ReplaceDiscount_FullMethodName = "/discount.DiscountService/ReplaceDiscount" + DiscountService_UpdateDiscount_FullMethodName = "/discount.DiscountService/UpdateDiscount" + DiscountService_DeleteDiscount_FullMethodName = "/discount.DiscountService/DeleteDiscount" +) + // DiscountServiceClient is the client API for DiscountService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -44,7 +56,7 @@ func NewDiscountServiceClient(cc grpc.ClientConnInterface) DiscountServiceClient func (c *discountServiceClient) GetAllDiscounts(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetAllDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetAllDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -53,7 +65,7 @@ func (c *discountServiceClient) GetAllDiscounts(ctx context.Context, in *emptypb func (c *discountServiceClient) GetUserDiscounts(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetUserDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetUserDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -62,7 +74,7 @@ func (c *discountServiceClient) GetUserDiscounts(ctx context.Context, in *GetDis func (c *discountServiceClient) DetermineDiscounts(ctx context.Context, in *ApplyDiscountRequest, opts ...grpc.CallOption) (*Discounts, error) { out := new(Discounts) - err := c.cc.Invoke(ctx, "/discount.DiscountService/DetermineDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_DetermineDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -71,7 +83,7 @@ func (c *discountServiceClient) DetermineDiscounts(ctx context.Context, in *Appl func (c *discountServiceClient) ApplyDiscounts(ctx context.Context, in *ApplyDiscountRequest, opts ...grpc.CallOption) (*ApplyDiscountResponse, error) { out := new(ApplyDiscountResponse) - err := c.cc.Invoke(ctx, "/discount.DiscountService/ApplyDiscounts", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_ApplyDiscounts_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -80,7 +92,7 @@ func (c *discountServiceClient) ApplyDiscounts(ctx context.Context, in *ApplyDis func (c *discountServiceClient) GetDiscountByID(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/GetDiscountByID", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_GetDiscountByID_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -89,7 +101,7 @@ func (c *discountServiceClient) GetDiscountByID(ctx context.Context, in *GetDisc func (c *discountServiceClient) CreateDiscount(ctx context.Context, in *CreateDiscountRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/CreateDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_CreateDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -98,7 +110,7 @@ func (c *discountServiceClient) CreateDiscount(ctx context.Context, in *CreateDi func (c *discountServiceClient) ReplaceDiscount(ctx context.Context, in *DiscountOptional, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/ReplaceDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_ReplaceDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -107,7 +119,7 @@ func (c *discountServiceClient) ReplaceDiscount(ctx context.Context, in *Discoun func (c *discountServiceClient) UpdateDiscount(ctx context.Context, in *DiscountOptional, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/UpdateDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_UpdateDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -116,7 +128,7 @@ func (c *discountServiceClient) UpdateDiscount(ctx context.Context, in *Discount func (c *discountServiceClient) DeleteDiscount(ctx context.Context, in *GetDiscountByIDRequest, opts ...grpc.CallOption) (*Discount, error) { out := new(Discount) - err := c.cc.Invoke(ctx, "/discount.DiscountService/DeleteDiscount", in, out, opts...) + err := c.cc.Invoke(ctx, DiscountService_DeleteDiscount_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -191,7 +203,7 @@ func _DiscountService_GetAllDiscounts_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetAllDiscounts", + FullMethod: DiscountService_GetAllDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetAllDiscounts(ctx, req.(*emptypb.Empty)) @@ -209,7 +221,7 @@ func _DiscountService_GetUserDiscounts_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetUserDiscounts", + FullMethod: DiscountService_GetUserDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetUserDiscounts(ctx, req.(*GetDiscountByIDRequest)) @@ -227,7 +239,7 @@ func _DiscountService_DetermineDiscounts_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/DetermineDiscounts", + FullMethod: DiscountService_DetermineDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).DetermineDiscounts(ctx, req.(*ApplyDiscountRequest)) @@ -245,7 +257,7 @@ func _DiscountService_ApplyDiscounts_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/ApplyDiscounts", + FullMethod: DiscountService_ApplyDiscounts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).ApplyDiscounts(ctx, req.(*ApplyDiscountRequest)) @@ -263,7 +275,7 @@ func _DiscountService_GetDiscountByID_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/GetDiscountByID", + FullMethod: DiscountService_GetDiscountByID_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).GetDiscountByID(ctx, req.(*GetDiscountByIDRequest)) @@ -281,7 +293,7 @@ func _DiscountService_CreateDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/CreateDiscount", + FullMethod: DiscountService_CreateDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).CreateDiscount(ctx, req.(*CreateDiscountRequest)) @@ -299,7 +311,7 @@ func _DiscountService_ReplaceDiscount_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/ReplaceDiscount", + FullMethod: DiscountService_ReplaceDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).ReplaceDiscount(ctx, req.(*DiscountOptional)) @@ -317,7 +329,7 @@ func _DiscountService_UpdateDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/UpdateDiscount", + FullMethod: DiscountService_UpdateDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).UpdateDiscount(ctx, req.(*DiscountOptional)) @@ -335,7 +347,7 @@ func _DiscountService_DeleteDiscount_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/discount.DiscountService/DeleteDiscount", + FullMethod: DiscountService_DeleteDiscount_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DiscountServiceServer).DeleteDiscount(ctx, req.(*GetDiscountByIDRequest)) diff --git a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go index 5f6751c..3812e49 100644 --- a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go +++ b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/annotations.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: google/api/annotations.proto diff --git a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go index 83d2d11..d2eaea7 100644 --- a/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go +++ b/internal/proto/google.golang.org/genproto/googleapis/api/annotations/http.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: google/api/http.proto diff --git a/internal/proto/payment_callback/service.pb.go b/internal/proto/payment_callback/service.pb.go index 6accf03..8f02a6f 100644 --- a/internal/proto/payment_callback/service.pb.go +++ b/internal/proto/payment_callback/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: callback/service.proto diff --git a/internal/proto/payment_callback/service_grpc.pb.go b/internal/proto/payment_callback/service_grpc.pb.go index 26cdd95..c4291fd 100644 --- a/internal/proto/payment_callback/service_grpc.pb.go +++ b/internal/proto/payment_callback/service_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 +// - protoc-gen-go-grpc v1.3.0 // - protoc (unknown) // source: callback/service.proto @@ -19,6 +19,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + PaymentCallbackService_OnSuccess_FullMethodName = "/payment_callback.PaymentCallbackService/OnSuccess" + PaymentCallbackService_OnFailure_FullMethodName = "/payment_callback.PaymentCallbackService/OnFailure" +) + // PaymentCallbackServiceClient is the client API for PaymentCallbackService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -37,7 +42,7 @@ func NewPaymentCallbackServiceClient(cc grpc.ClientConnInterface) PaymentCallbac func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnSuccess", in, out, opts...) + err := c.cc.Invoke(ctx, PaymentCallbackService_OnSuccess_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -46,7 +51,7 @@ func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, func (c *paymentCallbackServiceClient) OnFailure(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnFailure", in, out, opts...) + err := c.cc.Invoke(ctx, PaymentCallbackService_OnFailure_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -93,7 +98,7 @@ func _PaymentCallbackService_OnSuccess_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/payment_callback.PaymentCallbackService/OnSuccess", + FullMethod: PaymentCallbackService_OnSuccess_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnSuccess(ctx, req.(*Event)) @@ -111,7 +116,7 @@ func _PaymentCallbackService_OnFailure_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/payment_callback.PaymentCallbackService/OnFailure", + FullMethod: PaymentCallbackService_OnFailure_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnFailure(ctx, req.(*Event)) diff --git a/internal/proto/treasurer/payment.model.pb.go b/internal/proto/treasurer/payment.model.pb.go index 53c14ec..266a504 100644 --- a/internal/proto/treasurer/payment.model.pb.go +++ b/internal/proto/treasurer/payment.model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: treasurer/payment.model.proto @@ -25,12 +25,14 @@ type MainPaymentSettings struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Currency string `protobuf:"bytes,1,opt,name=Currency,proto3" json:"Currency,omitempty"` - Amount int64 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"` - CallbackHostGRPC []string `protobuf:"bytes,3,rep,name=CallbackHostGRPC,proto3" json:"CallbackHostGRPC,omitempty"` - ReturnURL string `protobuf:"bytes,4,opt,name=ReturnURL,proto3" json:"ReturnURL,omitempty"` - UserID string `protobuf:"bytes,5,opt,name=UserID,proto3" json:"UserID,omitempty"` - ClientIP string `protobuf:"bytes,6,opt,name=ClientIP,proto3" json:"ClientIP,omitempty"` + Currency string `protobuf:"bytes,1,opt,name=Currency,proto3" json:"Currency,omitempty"` + Amount int64 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"` + CallbackHostGRPC []string `protobuf:"bytes,3,rep,name=CallbackHostGRPC,proto3" json:"CallbackHostGRPC,omitempty"` + ReturnURL string `protobuf:"bytes,4,opt,name=ReturnURL,proto3" json:"ReturnURL,omitempty"` + UserID string `protobuf:"bytes,5,opt,name=UserID,proto3" json:"UserID,omitempty"` + ClientIP string `protobuf:"bytes,6,opt,name=ClientIP,proto3" json:"ClientIP,omitempty"` + Customer *Customer `protobuf:"bytes,7,opt,name=Customer,proto3" json:"Customer,omitempty"` + Items []*Item `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` } func (x *MainPaymentSettings) Reset() { @@ -107,20 +109,33 @@ func (x *MainPaymentSettings) GetClientIP() string { return "" } -type BankCardInformation struct { +func (x *MainPaymentSettings) GetCustomer() *Customer { + if x != nil { + return x.Customer + } + return nil +} + +func (x *MainPaymentSettings) GetItems() []*Item { + if x != nil { + return x.Items + } + return nil +} + +type Customer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` - ExpiryYear string `protobuf:"bytes,2,opt,name=ExpiryYear,proto3" json:"ExpiryYear,omitempty"` - ExpiryMonth string `protobuf:"bytes,3,opt,name=ExpiryMonth,proto3" json:"ExpiryMonth,omitempty"` - CSC *string `protobuf:"bytes,4,opt,name=CSC,proto3,oneof" json:"CSC,omitempty"` - CardHolderName *string `protobuf:"bytes,5,opt,name=CardHolderName,proto3,oneof" json:"CardHolderName,omitempty"` + FullName string `protobuf:"bytes,1,opt,name=FullName,proto3" json:"FullName,omitempty"` + INN string `protobuf:"bytes,2,opt,name=INN,proto3" json:"INN,omitempty"` + Email string `protobuf:"bytes,3,opt,name=Email,proto3" json:"Email,omitempty"` + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` } -func (x *BankCardInformation) Reset() { - *x = BankCardInformation{} +func (x *Customer) Reset() { + *x = Customer{} if protoimpl.UnsafeEnabled { mi := &file_treasurer_payment_model_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -128,13 +143,13 @@ func (x *BankCardInformation) Reset() { } } -func (x *BankCardInformation) String() string { +func (x *Customer) String() string { return protoimpl.X.MessageStringOf(x) } -func (*BankCardInformation) ProtoMessage() {} +func (*Customer) ProtoMessage() {} -func (x *BankCardInformation) ProtoReflect() protoreflect.Message { +func (x *Customer) ProtoReflect() protoreflect.Message { mi := &file_treasurer_payment_model_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -146,42 +161,114 @@ func (x *BankCardInformation) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use BankCardInformation.ProtoReflect.Descriptor instead. -func (*BankCardInformation) Descriptor() ([]byte, []int) { +// Deprecated: Use Customer.ProtoReflect.Descriptor instead. +func (*Customer) Descriptor() ([]byte, []int) { return file_treasurer_payment_model_proto_rawDescGZIP(), []int{1} } -func (x *BankCardInformation) GetNumber() string { +func (x *Customer) GetFullName() string { if x != nil { - return x.Number + return x.FullName } return "" } -func (x *BankCardInformation) GetExpiryYear() string { +func (x *Customer) GetINN() string { if x != nil { - return x.ExpiryYear + return x.INN } return "" } -func (x *BankCardInformation) GetExpiryMonth() string { +func (x *Customer) GetEmail() string { if x != nil { - return x.ExpiryMonth + return x.Email } return "" } -func (x *BankCardInformation) GetCSC() string { - if x != nil && x.CSC != nil { - return *x.CSC +func (x *Customer) GetPhone() string { + if x != nil { + return x.Phone } return "" } -func (x *BankCardInformation) GetCardHolderName() string { - if x != nil && x.CardHolderName != nil { - return *x.CardHolderName +type Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=Description,proto3" json:"Description,omitempty"` + Measure string `protobuf:"bytes,2,opt,name=Measure,proto3" json:"Measure,omitempty"` + Quantity string `protobuf:"bytes,3,opt,name=Quantity,proto3" json:"Quantity,omitempty"` + Money string `protobuf:"bytes,4,opt,name=Money,proto3" json:"Money,omitempty"` + Currency string `protobuf:"bytes,5,opt,name=Currency,proto3" json:"Currency,omitempty"` +} + +func (x *Item) Reset() { + *x = Item{} + if protoimpl.UnsafeEnabled { + mi := &file_treasurer_payment_model_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Item) ProtoMessage() {} + +func (x *Item) ProtoReflect() protoreflect.Message { + mi := &file_treasurer_payment_model_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Item.ProtoReflect.Descriptor instead. +func (*Item) Descriptor() ([]byte, []int) { + return file_treasurer_payment_model_proto_rawDescGZIP(), []int{2} +} + +func (x *Item) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Item) GetMeasure() string { + if x != nil { + return x.Measure + } + return "" +} + +func (x *Item) GetQuantity() string { + if x != nil { + return x.Quantity + } + return "" +} + +func (x *Item) GetMoney() string { + if x != nil { + return x.Money + } + return "" +} + +func (x *Item) GetCurrency() string { + if x != nil { + return x.Currency } return "" } @@ -191,7 +278,7 @@ var File_treasurer_payment_model_proto protoreflect.FileDescriptor var file_treasurer_payment_model_proto_rawDesc = []byte{ 0x0a, 0x1d, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x22, 0xc7, 0x01, 0x0a, 0x13, 0x4d, + 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x22, 0x9f, 0x02, 0x0a, 0x13, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x16, @@ -204,20 +291,28 @@ var file_treasurer_payment_model_proto_rawDesc = []byte{ 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x50, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x49, 0x50, 0x22, 0xce, 0x01, 0x0a, 0x13, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, - 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, - 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x45, 0x78, 0x70, 0x69, 0x72, 0x79, 0x59, 0x65, - 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x45, 0x78, 0x70, 0x69, 0x72, 0x79, - 0x59, 0x65, 0x61, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x69, 0x72, 0x79, 0x4d, 0x6f, - 0x6e, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x78, 0x70, 0x69, 0x72, - 0x79, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x15, 0x0a, 0x03, 0x43, 0x53, 0x43, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x43, 0x53, 0x43, 0x88, 0x01, 0x01, 0x12, 0x2b, 0x0a, - 0x0e, 0x43, 0x61, 0x72, 0x64, 0x48, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x0e, 0x43, 0x61, 0x72, 0x64, 0x48, 0x6f, 0x6c, - 0x64, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x43, - 0x53, 0x43, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x43, 0x61, 0x72, 0x64, 0x48, 0x6f, 0x6c, 0x64, 0x65, - 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, + 0x6e, 0x74, 0x49, 0x50, 0x12, 0x2f, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x72, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x52, 0x08, 0x43, 0x75, 0x73, + 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x08, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, + 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x64, 0x0a, 0x08, + 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x46, 0x75, 0x6c, 0x6c, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x4e, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x49, 0x4e, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, + 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x50, 0x68, 0x6f, + 0x6e, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, + 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -233,17 +328,20 @@ func file_treasurer_payment_model_proto_rawDescGZIP() []byte { return file_treasurer_payment_model_proto_rawDescData } -var file_treasurer_payment_model_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_treasurer_payment_model_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_treasurer_payment_model_proto_goTypes = []interface{}{ (*MainPaymentSettings)(nil), // 0: treasurer.MainPaymentSettings - (*BankCardInformation)(nil), // 1: treasurer.BankCardInformation + (*Customer)(nil), // 1: treasurer.Customer + (*Item)(nil), // 2: treasurer.Item } var file_treasurer_payment_model_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: treasurer.MainPaymentSettings.Customer:type_name -> treasurer.Customer + 2, // 1: treasurer.MainPaymentSettings.Items:type_name -> treasurer.Item + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_treasurer_payment_model_proto_init() } @@ -265,7 +363,19 @@ func file_treasurer_payment_model_proto_init() { } } file_treasurer_payment_model_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BankCardInformation); i { + switch v := v.(*Customer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_treasurer_payment_model_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Item); i { case 0: return &v.state case 1: @@ -277,14 +387,13 @@ func file_treasurer_payment_model_proto_init() { } } } - file_treasurer_payment_model_proto_msgTypes[1].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_treasurer_payment_model_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/proto/treasurer/service.pb.go b/internal/proto/treasurer/service.pb.go index 2487a4a..a6c2742 100644 --- a/internal/proto/treasurer/service.pb.go +++ b/internal/proto/treasurer/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: treasurer/service.proto @@ -27,7 +27,6 @@ type GetBankCardPaymentLinkRequest struct { unknownFields protoimpl.UnknownFields MainSettings *MainPaymentSettings `protobuf:"bytes,1,opt,name=MainSettings,proto3" json:"MainSettings,omitempty"` - BankCard *BankCardInformation `protobuf:"bytes,2,opt,name=BankCard,proto3" json:"BankCard,omitempty"` } func (x *GetBankCardPaymentLinkRequest) Reset() { @@ -69,14 +68,7 @@ func (x *GetBankCardPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { return nil } -func (x *GetBankCardPaymentLinkRequest) GetBankCard() *BankCardInformation { - if x != nil { - return x.BankCard - } - return nil -} - -type GetPaymentLinkBody struct { +type GetPaymentLinkRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -84,8 +76,8 @@ type GetPaymentLinkBody struct { MainSettings *MainPaymentSettings `protobuf:"bytes,1,opt,name=MainSettings,proto3" json:"MainSettings,omitempty"` } -func (x *GetPaymentLinkBody) Reset() { - *x = GetPaymentLinkBody{} +func (x *GetPaymentLinkRequest) Reset() { + *x = GetPaymentLinkRequest{} if protoimpl.UnsafeEnabled { mi := &file_treasurer_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -93,13 +85,13 @@ func (x *GetPaymentLinkBody) Reset() { } } -func (x *GetPaymentLinkBody) String() string { +func (x *GetPaymentLinkRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPaymentLinkBody) ProtoMessage() {} +func (*GetPaymentLinkRequest) ProtoMessage() {} -func (x *GetPaymentLinkBody) ProtoReflect() protoreflect.Message { +func (x *GetPaymentLinkRequest) ProtoReflect() protoreflect.Message { mi := &file_treasurer_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -111,128 +103,18 @@ func (x *GetPaymentLinkBody) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPaymentLinkBody.ProtoReflect.Descriptor instead. -func (*GetPaymentLinkBody) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPaymentLinkRequest.ProtoReflect.Descriptor instead. +func (*GetPaymentLinkRequest) Descriptor() ([]byte, []int) { return file_treasurer_service_proto_rawDescGZIP(), []int{1} } -func (x *GetPaymentLinkBody) GetMainSettings() *MainPaymentSettings { +func (x *GetPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { if x != nil { return x.MainSettings } return nil } -type GetPhonePaymentLinkRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MainSettings *MainPaymentSettings `protobuf:"bytes,1,opt,name=MainSettings,proto3" json:"MainSettings,omitempty"` - Phone string `protobuf:"bytes,2,opt,name=Phone,proto3" json:"Phone,omitempty"` -} - -func (x *GetPhonePaymentLinkRequest) Reset() { - *x = GetPhonePaymentLinkRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetPhonePaymentLinkRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPhonePaymentLinkRequest) ProtoMessage() {} - -func (x *GetPhonePaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetPhonePaymentLinkRequest.ProtoReflect.Descriptor instead. -func (*GetPhonePaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{2} -} - -func (x *GetPhonePaymentLinkRequest) GetMainSettings() *MainPaymentSettings { - if x != nil { - return x.MainSettings - } - return nil -} - -func (x *GetPhonePaymentLinkRequest) GetPhone() string { - if x != nil { - return x.Phone - } - return "" -} - -type GetLoginPaymentLinkRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MainSettings *MainPaymentSettings `protobuf:"bytes,1,opt,name=MainSettings,proto3" json:"MainSettings,omitempty"` - Login string `protobuf:"bytes,2,opt,name=Login,proto3" json:"Login,omitempty"` -} - -func (x *GetLoginPaymentLinkRequest) Reset() { - *x = GetLoginPaymentLinkRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetLoginPaymentLinkRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLoginPaymentLinkRequest) ProtoMessage() {} - -func (x *GetLoginPaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetLoginPaymentLinkRequest.ProtoReflect.Descriptor instead. -func (*GetLoginPaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{3} -} - -func (x *GetLoginPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { - if x != nil { - return x.MainSettings - } - return nil -} - -func (x *GetLoginPaymentLinkRequest) GetLogin() string { - if x != nil { - return x.Login - } - return "" -} - type GetB2BPaymentLinkRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -246,7 +128,7 @@ type GetB2BPaymentLinkRequest struct { func (x *GetB2BPaymentLinkRequest) Reset() { *x = GetB2BPaymentLinkRequest{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[4] + mi := &file_treasurer_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -259,7 +141,7 @@ func (x *GetB2BPaymentLinkRequest) String() string { func (*GetB2BPaymentLinkRequest) ProtoMessage() {} func (x *GetB2BPaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[4] + mi := &file_treasurer_service_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -272,7 +154,7 @@ func (x *GetB2BPaymentLinkRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetB2BPaymentLinkRequest.ProtoReflect.Descriptor instead. func (*GetB2BPaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{4} + return file_treasurer_service_proto_rawDescGZIP(), []int{2} } func (x *GetB2BPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { @@ -307,7 +189,7 @@ type GetPaymentLinkResponse struct { func (x *GetPaymentLinkResponse) Reset() { *x = GetPaymentLinkResponse{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[5] + mi := &file_treasurer_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -320,7 +202,7 @@ func (x *GetPaymentLinkResponse) String() string { func (*GetPaymentLinkResponse) ProtoMessage() {} func (x *GetPaymentLinkResponse) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[5] + mi := &file_treasurer_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -333,7 +215,7 @@ func (x *GetPaymentLinkResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPaymentLinkResponse.ProtoReflect.Descriptor instead. func (*GetPaymentLinkResponse) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{5} + return file_treasurer_service_proto_rawDescGZIP(), []int{3} } func (x *GetPaymentLinkResponse) GetRedirectURL() string { @@ -352,91 +234,73 @@ var file_treasurer_service_proto_rawDesc = []byte{ 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x9f, 0x01, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, - 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3a, 0x0a, 0x08, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, - 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x49, 0x6e, 0x66, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, - 0x72, 0x64, 0x22, 0x58, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, - 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, - 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x76, 0x0a, 0x1a, - 0x47, 0x65, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, - 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, - 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, - 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x50, - 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x76, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x22, 0xb8, 0x01, 0x0a, - 0x18, 0x47, 0x65, 0x74, 0x42, 0x32, 0x42, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, - 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, - 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, - 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x26, 0x0a, - 0x0e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, 0x72, 0x70, 0x6f, 0x73, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, - 0x72, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x56, 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x07, - 0x56, 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, - 0x55, 0x52, 0x4c, 0x32, 0xcd, 0x04, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, - 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, - 0x72, 0x64, 0x12, 0x28, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, - 0x65, 0x74, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, - 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, - 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x5c, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, - 0x69, 0x6e, 0x6b, 0x59, 0x6f, 0x6f, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1d, 0x2e, 0x74, 0x72, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, + 0x22, 0x63, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, + 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, + 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, + 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x22, 0xb8, 0x01, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x42, 0x32, 0x42, 0x50, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, + 0x72, 0x70, 0x6f, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, 0x72, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x56, + 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x52, 0x07, 0x56, 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, + 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, + 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, + 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, 0x32, 0xd4, 0x04, 0x0a, 0x10, 0x54, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, + 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, + 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, + 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, - 0x6b, 0x53, 0x62, 0x65, 0x72, 0x50, 0x61, 0x79, 0x12, 0x1d, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, - 0x69, 0x6e, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, - 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, - 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x15, - 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x54, 0x69, - 0x6e, 0x6b, 0x6f, 0x66, 0x66, 0x12, 0x1d, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, - 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, - 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, - 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5f, 0x0a, 0x19, 0x47, 0x65, 0x74, - 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x62, - 0x61, 0x6e, 0x6b, 0x42, 0x32, 0x42, 0x12, 0x1d, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, - 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, - 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, - 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x11, 0x47, 0x65, - 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x42, 0x50, 0x12, - 0x1d, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x21, - 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, - 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, + 0x6b, 0x59, 0x6f, 0x6f, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, + 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, + 0x6e, 0x6b, 0x54, 0x69, 0x6e, 0x6b, 0x6f, 0x66, 0x66, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, + 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x62, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, + 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x62, 0x61, 0x6e, 0x6b, 0x42, 0x32, 0x42, 0x12, 0x20, 0x2e, + 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x42, 0x50, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, + 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, + 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x50, 0x61, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, + 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -451,43 +315,37 @@ func file_treasurer_service_proto_rawDescGZIP() []byte { return file_treasurer_service_proto_rawDescData } -var file_treasurer_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_treasurer_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_treasurer_service_proto_goTypes = []interface{}{ (*GetBankCardPaymentLinkRequest)(nil), // 0: treasurer.GetBankCardPaymentLinkRequest - (*GetPaymentLinkBody)(nil), // 1: treasurer.GetPaymentLinkBody - (*GetPhonePaymentLinkRequest)(nil), // 2: treasurer.GetPhonePaymentLinkRequest - (*GetLoginPaymentLinkRequest)(nil), // 3: treasurer.GetLoginPaymentLinkRequest - (*GetB2BPaymentLinkRequest)(nil), // 4: treasurer.GetB2BPaymentLinkRequest - (*GetPaymentLinkResponse)(nil), // 5: treasurer.GetPaymentLinkResponse - (*MainPaymentSettings)(nil), // 6: treasurer.MainPaymentSettings - (*BankCardInformation)(nil), // 7: treasurer.BankCardInformation - (*emptypb.Empty)(nil), // 8: google.protobuf.Empty + (*GetPaymentLinkRequest)(nil), // 1: treasurer.GetPaymentLinkRequest + (*GetB2BPaymentLinkRequest)(nil), // 2: treasurer.GetB2BPaymentLinkRequest + (*GetPaymentLinkResponse)(nil), // 3: treasurer.GetPaymentLinkResponse + (*MainPaymentSettings)(nil), // 4: treasurer.MainPaymentSettings + (*emptypb.Empty)(nil), // 5: google.protobuf.Empty } var file_treasurer_service_proto_depIdxs = []int32{ - 6, // 0: treasurer.GetBankCardPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 7, // 1: treasurer.GetBankCardPaymentLinkRequest.BankCard:type_name -> treasurer.BankCardInformation - 6, // 2: treasurer.GetPaymentLinkBody.MainSettings:type_name -> treasurer.MainPaymentSettings - 6, // 3: treasurer.GetPhonePaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 6, // 4: treasurer.GetLoginPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 6, // 5: treasurer.GetB2BPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 8, // 6: treasurer.GetB2BPaymentLinkRequest.VatData:type_name -> google.protobuf.Empty - 0, // 7: treasurer.TreasurerService.GetPaymentLinkBankCard:input_type -> treasurer.GetBankCardPaymentLinkRequest - 1, // 8: treasurer.TreasurerService.GetPaymentLinkYooMoney:input_type -> treasurer.GetPaymentLinkBody - 1, // 9: treasurer.TreasurerService.GetPaymentLinkSberPay:input_type -> treasurer.GetPaymentLinkBody - 1, // 10: treasurer.TreasurerService.GetPaymentLinkTinkoff:input_type -> treasurer.GetPaymentLinkBody - 1, // 11: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:input_type -> treasurer.GetPaymentLinkBody - 1, // 12: treasurer.TreasurerService.GetPaymentLinkSBP:input_type -> treasurer.GetPaymentLinkBody - 5, // 13: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse - 5, // 14: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse - 5, // 15: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse - 5, // 16: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse - 5, // 17: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse - 5, // 18: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse - 13, // [13:19] is the sub-list for method output_type - 7, // [7:13] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 4, // 0: treasurer.GetBankCardPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 4, // 1: treasurer.GetPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 4, // 2: treasurer.GetB2BPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 5, // 3: treasurer.GetB2BPaymentLinkRequest.VatData:type_name -> google.protobuf.Empty + 1, // 4: treasurer.TreasurerService.GetPaymentLinkBankCard:input_type -> treasurer.GetPaymentLinkRequest + 1, // 5: treasurer.TreasurerService.GetPaymentLinkYooMoney:input_type -> treasurer.GetPaymentLinkRequest + 1, // 6: treasurer.TreasurerService.GetPaymentLinkTinkoff:input_type -> treasurer.GetPaymentLinkRequest + 1, // 7: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:input_type -> treasurer.GetPaymentLinkRequest + 1, // 8: treasurer.TreasurerService.GetPaymentLinkSBP:input_type -> treasurer.GetPaymentLinkRequest + 1, // 9: treasurer.TreasurerService.GetPaymentLinkSberPay:input_type -> treasurer.GetPaymentLinkRequest + 3, // 10: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse + 3, // 11: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse + 3, // 12: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse + 3, // 13: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse + 3, // 14: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse + 3, // 15: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse + 10, // [10:16] is the sub-list for method output_type + 4, // [4:10] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_treasurer_service_proto_init() } @@ -510,7 +368,7 @@ func file_treasurer_service_proto_init() { } } file_treasurer_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPaymentLinkBody); i { + switch v := v.(*GetPaymentLinkRequest); i { case 0: return &v.state case 1: @@ -522,30 +380,6 @@ func file_treasurer_service_proto_init() { } } file_treasurer_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPhonePaymentLinkRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_treasurer_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetLoginPaymentLinkRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_treasurer_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetB2BPaymentLinkRequest); i { case 0: return &v.state @@ -557,7 +391,7 @@ func file_treasurer_service_proto_init() { return nil } } - file_treasurer_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_treasurer_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPaymentLinkResponse); i { case 0: return &v.state @@ -576,7 +410,7 @@ func file_treasurer_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_treasurer_service_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/proto/treasurer/service_grpc.pb.go b/internal/proto/treasurer/service_grpc.pb.go index 73b39e7..699b0e5 100644 --- a/internal/proto/treasurer/service_grpc.pb.go +++ b/internal/proto/treasurer/service_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 +// - protoc-gen-go-grpc v1.3.0 // - protoc (unknown) // source: treasurer/service.proto @@ -18,16 +18,25 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + TreasurerService_GetPaymentLinkBankCard_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkBankCard" + TreasurerService_GetPaymentLinkYooMoney_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkYooMoney" + TreasurerService_GetPaymentLinkTinkoff_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkTinkoff" + TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B" + TreasurerService_GetPaymentLinkSBP_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSBP" + TreasurerService_GetPaymentLinkSberPay_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberPay" +) + // TreasurerServiceClient is the client API for TreasurerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type TreasurerServiceClient interface { - GetPaymentLinkBankCard(ctx context.Context, in *GetBankCardPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) - GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) - GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) - GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) - GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) - GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkBankCard(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) } type treasurerServiceClient struct { @@ -38,54 +47,54 @@ func NewTreasurerServiceClient(cc grpc.ClientConnInterface) TreasurerServiceClie return &treasurerServiceClient{cc} } -func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in *GetBankCardPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkBankCard", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkBankCard_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkYooMoney", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkYooMoney_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberPay", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkTinkoff_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkTinkoff", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSBP_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkBody, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { +func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSBP", in, out, opts...) + err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberPay_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -96,36 +105,36 @@ func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetP // All implementations should embed UnimplementedTreasurerServiceServer // for forward compatibility type TreasurerServiceServer interface { - GetPaymentLinkBankCard(context.Context, *GetBankCardPaymentLinkRequest) (*GetPaymentLinkResponse, error) - GetPaymentLinkYooMoney(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) - GetPaymentLinkSberPay(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) - GetPaymentLinkTinkoff(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) - GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) - GetPaymentLinkSBP(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) + GetPaymentLinkBankCard(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkYooMoney(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkTinkoff(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkSBP(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) } // UnimplementedTreasurerServiceServer should be embedded to have forward compatible implementations. type UnimplementedTreasurerServiceServer struct { } -func (UnimplementedTreasurerServiceServer) GetPaymentLinkBankCard(context.Context, *GetBankCardPaymentLinkRequest) (*GetPaymentLinkResponse, error) { +func (UnimplementedTreasurerServiceServer) GetPaymentLinkBankCard(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkBankCard not implemented") } -func (UnimplementedTreasurerServiceServer) GetPaymentLinkYooMoney(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) { +func (UnimplementedTreasurerServiceServer) GetPaymentLinkYooMoney(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkYooMoney not implemented") } -func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSberPay not implemented") -} -func (UnimplementedTreasurerServiceServer) GetPaymentLinkTinkoff(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) { +func (UnimplementedTreasurerServiceServer) GetPaymentLinkTinkoff(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkTinkoff not implemented") } -func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) { +func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSberbankB2B not implemented") } -func (UnimplementedTreasurerServiceServer) GetPaymentLinkSBP(context.Context, *GetPaymentLinkBody) (*GetPaymentLinkResponse, error) { +func (UnimplementedTreasurerServiceServer) GetPaymentLinkSBP(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSBP not implemented") } +func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSberPay not implemented") +} // UnsafeTreasurerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TreasurerServiceServer will @@ -139,7 +148,7 @@ func RegisterTreasurerServiceServer(s grpc.ServiceRegistrar, srv TreasurerServic } func _TreasurerService_GetPaymentLinkBankCard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBankCardPaymentLinkRequest) + in := new(GetPaymentLinkRequest) if err := dec(in); err != nil { return nil, err } @@ -148,16 +157,16 @@ func _TreasurerService_GetPaymentLinkBankCard_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkBankCard", + FullMethod: TreasurerService_GetPaymentLinkBankCard_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkBankCard(ctx, req.(*GetBankCardPaymentLinkRequest)) + return srv.(TreasurerServiceServer).GetPaymentLinkBankCard(ctx, req.(*GetPaymentLinkRequest)) } return interceptor(ctx, in, info, handler) } func _TreasurerService_GetPaymentLinkYooMoney_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPaymentLinkBody) + in := new(GetPaymentLinkRequest) if err := dec(in); err != nil { return nil, err } @@ -166,34 +175,16 @@ func _TreasurerService_GetPaymentLinkYooMoney_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkYooMoney", + FullMethod: TreasurerService_GetPaymentLinkYooMoney_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkYooMoney(ctx, req.(*GetPaymentLinkBody)) - } - return interceptor(ctx, in, info, handler) -} - -func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPaymentLinkBody) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberPay", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, req.(*GetPaymentLinkBody)) + return srv.(TreasurerServiceServer).GetPaymentLinkYooMoney(ctx, req.(*GetPaymentLinkRequest)) } return interceptor(ctx, in, info, handler) } func _TreasurerService_GetPaymentLinkTinkoff_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPaymentLinkBody) + in := new(GetPaymentLinkRequest) if err := dec(in); err != nil { return nil, err } @@ -202,16 +193,16 @@ func _TreasurerService_GetPaymentLinkTinkoff_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkTinkoff", + FullMethod: TreasurerService_GetPaymentLinkTinkoff_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkTinkoff(ctx, req.(*GetPaymentLinkBody)) + return srv.(TreasurerServiceServer).GetPaymentLinkTinkoff(ctx, req.(*GetPaymentLinkRequest)) } return interceptor(ctx, in, info, handler) } func _TreasurerService_GetPaymentLinkSberbankB2B_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPaymentLinkBody) + in := new(GetPaymentLinkRequest) if err := dec(in); err != nil { return nil, err } @@ -220,16 +211,16 @@ func _TreasurerService_GetPaymentLinkSberbankB2B_Handler(srv interface{}, ctx co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", + FullMethod: TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkSberbankB2B(ctx, req.(*GetPaymentLinkBody)) + return srv.(TreasurerServiceServer).GetPaymentLinkSberbankB2B(ctx, req.(*GetPaymentLinkRequest)) } return interceptor(ctx, in, info, handler) } func _TreasurerService_GetPaymentLinkSBP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPaymentLinkBody) + in := new(GetPaymentLinkRequest) if err := dec(in); err != nil { return nil, err } @@ -238,10 +229,28 @@ func _TreasurerService_GetPaymentLinkSBP_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSBP", + FullMethod: TreasurerService_GetPaymentLinkSBP_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TreasurerServiceServer).GetPaymentLinkSBP(ctx, req.(*GetPaymentLinkBody)) + return srv.(TreasurerServiceServer).GetPaymentLinkSBP(ctx, req.(*GetPaymentLinkRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaymentLinkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreasurerService_GetPaymentLinkSberPay_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, req.(*GetPaymentLinkRequest)) } return interceptor(ctx, in, info, handler) } @@ -261,10 +270,6 @@ var TreasurerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetPaymentLinkYooMoney", Handler: _TreasurerService_GetPaymentLinkYooMoney_Handler, }, - { - MethodName: "GetPaymentLinkSberPay", - Handler: _TreasurerService_GetPaymentLinkSberPay_Handler, - }, { MethodName: "GetPaymentLinkTinkoff", Handler: _TreasurerService_GetPaymentLinkTinkoff_Handler, @@ -277,6 +282,10 @@ var TreasurerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetPaymentLinkSBP", Handler: _TreasurerService_GetPaymentLinkSBP_Handler, }, + { + MethodName: "GetPaymentLinkSberPay", + Handler: _TreasurerService_GetPaymentLinkSberPay_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "treasurer/service.proto", diff --git a/internal/server/grpc.go b/internal/server/grpc.go index 81943a5..777db6c 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -11,11 +11,11 @@ import ( grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" "go.uber.org/zap" "google.golang.org/grpc" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/customer" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/payment_callback" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/initialize" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/customer" + "gitea.pena/PenaSide/customer/internal/proto/payment_callback" ) type DepsGRPC struct { diff --git a/internal/server/http.go b/internal/server/http.go index 9a65976..834a276 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -7,8 +7,8 @@ import ( "github.com/themakers/hlog" "go.uber.org/zap" "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" ) type ServerConfig struct { diff --git a/internal/service/broker/tariff/tariff.go b/internal/service/broker/tariff/tariff.go index c4bf330..65f68f3 100644 --- a/internal/service/broker/tariff/tariff.go +++ b/internal/service/broker/tariff/tariff.go @@ -6,8 +6,8 @@ import ( "sync" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" ) type consumer interface { diff --git a/internal/service/callback/payment.go b/internal/service/callback/payment.go index c91878b..75db8ea 100644 --- a/internal/service/callback/payment.go +++ b/internal/service/callback/payment.go @@ -3,10 +3,12 @@ package callback import ( "context" "log" + "fmt" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + tb "gopkg.in/tucnak/telebot.v2" ) type accountRepository interface { @@ -26,6 +28,9 @@ type PaymentCallbackServiceDeps struct { AccountRepository accountRepository WalletService walletService HistoryService historyService + Notifier *tb.Bot + NotifyChannel int64 + AdminURL string } type PaymentCallbackService struct { @@ -33,6 +38,9 @@ type PaymentCallbackService struct { accountRepository accountRepository walletService walletService historyService historyService + notifier *tb.Bot + notifyChannel int64 + adminURL string } func NewPaymentCallbackService(deps PaymentCallbackServiceDeps) *PaymentCallbackService { @@ -57,6 +65,9 @@ func NewPaymentCallbackService(deps PaymentCallbackServiceDeps) *PaymentCallback accountRepository: deps.AccountRepository, walletService: deps.WalletService, historyService: deps.HistoryService, + notifier: deps.Notifier, + notifyChannel: deps.NotifyChannel, + adminURL: deps.AdminURL, } } @@ -83,29 +94,33 @@ func (receiver *PaymentCallbackService) SuccessEvent(ctx context.Context, event } //go func() { - if _, err := receiver.historyService.CreateHistory(ctx, &models.History{ - UserID: account.UserID, - Comment: event.Message, - Key: event.Key, - RawDetails: models.RawDetails{ - Price: event.Amount, - Comment: event.Type + ":" + event.Currency, - }, - }); err != nil { - receiver.logger.Error("failed to create history on of ", zap.Error(err)) - return err - } + if _, err := receiver.historyService.CreateHistory(ctx, &models.History{ + UserID: account.UserID, + Comment: event.Message, + Key: event.Key, + RawDetails: models.RawDetails{ + Price: event.Amount, + Comment: event.Type + ":" + event.Currency, + }, + }); err != nil { + receiver.logger.Error("failed to create history on of ", zap.Error(err)) + return err + } //}() - +go func () { + if _, err := receiver.notifier.Send(tb.ChatID(receiver.notifyChannel), fmt.Sprintf(`Внесены деньги %.2f, пользователем %s`,float64(event.Amount/100), receiver.adminURL + "/users/" + account.UserID)); err != nil { + fmt.Println("TBOER", err) + } +}() return nil } func (receiver *PaymentCallbackService) FailureEvent(ctx context.Context, event *models.PaymentEvent) errors.Error { if _, err := receiver.historyService.CreateHistory(ctx, &models.History{ - UserID: event.UserID, - Comment: event.Message, - Key: event.Key, - // RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency), + UserID: event.UserID, + Comment: event.Message, + Key: event.Key, + // RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency), }); err != nil { receiver.logger.Error("failed to create history on of ", zap.Error(err)) return err diff --git a/internal/service/history/history.go b/internal/service/history/history.go index 2e97503..4739ac0 100644 --- a/internal/service/history/history.go +++ b/internal/service/history/history.go @@ -5,9 +5,9 @@ import ( "go.mongodb.org/mongo-driver/bson" "go.uber.org/zap" "log" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/fields" + "gitea.pena/PenaSide/customer/internal/models" ) type GetHistories struct { diff --git a/internal/service/payment/payment.go b/internal/service/payment/payment.go new file mode 100644 index 0000000..abb9c60 --- /dev/null +++ b/internal/service/payment/payment.go @@ -0,0 +1,162 @@ +package payment + +import ( + "context" + "log" + + "go.uber.org/zap" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/treasurer" +) + +type paymentClient interface { + GetPaymentLinkBankCard(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) + GetPaymentLinkYooMoney(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) + GetPaymentLinkSberPay(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) + GetPaymentLinkTinkoff(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) + GetPaymentLinkSberbankB2B(ctx context.Context, request *treasurer.GetPaymentLinkRequest) (string, errors.Error) +} + +type authClient interface { + GetUser(ctx context.Context, userID string) (*models.User, errors.Error) +} + +type Deps struct { + Logger *zap.Logger + ConfigurationGRPC *models.ConfigurationGRPC + PaymentClient paymentClient + AuthClient authClient +} + +type Service struct { + logger *zap.Logger + configurationGRPC *models.ConfigurationGRPC + paymentClient paymentClient + authClient authClient +} + +func New(deps Deps) *Service { + if deps.Logger == nil { + log.Panicln("logger is nil on ") + } + + if deps.ConfigurationGRPC == nil { + log.Panicln("ConfigurationGRPC is nil on ") + } + + if deps.PaymentClient == nil { + log.Panicln("PaymentClient is nil on ") + } + + if deps.AuthClient == nil { + log.Panicln("AuthClient is nil on ") + } + + return &Service{ + logger: deps.Logger, + paymentClient: deps.PaymentClient, + authClient: deps.AuthClient, + configurationGRPC: deps.ConfigurationGRPC, + } +} + +func (receiver *Service) GetPaymentLink(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { + if _, userErr := receiver.authClient.GetUser(ctx, request.UserID); userErr != nil { + receiver.logger.Error("failed to get user on on ", + zap.Error(userErr), + zap.String("userID", request.UserID), + ) + + return "", userErr + } + + switch request.Body.Type { + case models.PaymentTypeBankCard: + return receiver.GetPaymentLinkBankCard(ctx, request) + case models.PaymentTypeYoomoney: + return receiver.GetPaymentLinkYooMoney(ctx, request) + case models.PaymentTypeSberPay: + return receiver.GetPaymentLinkSberPay(ctx, request) + case models.PaymentTypeTinkoff: + return receiver.GetPaymentLinkTinkoff(ctx, request) + } + + return "", errors.NewWithMessage("invalid payment method type", errors.ErrInvalidArgs) +} + +func (receiver *Service) GetPaymentLinkBankCard(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkBankCard(ctx, &treasurer.GetPaymentLinkRequest{ + MainSettings: &treasurer.MainPaymentSettings{ + Currency: request.Body.Currency, + Amount: request.Body.Amount, + UserID: request.UserID, + ClientIP: request.ClientIP, + CallbackHostGRPC: []string{receiver.configurationGRPC.Domen}, + ReturnURL: request.Body.ReturnURL, + }, + }) + if err != nil { + receiver.logger.Error("failed to get bankcard payment link on of ", zap.Error(err)) + return "", err + } + + return link, nil +} + +func (receiver *Service) GetPaymentLinkYooMoney(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkYooMoney(ctx, &treasurer.GetPaymentLinkRequest{ + MainSettings: &treasurer.MainPaymentSettings{ + Currency: request.Body.Currency, + Amount: request.Body.Amount, + UserID: request.UserID, + ClientIP: request.ClientIP, + CallbackHostGRPC: []string{receiver.configurationGRPC.Domen}, + ReturnURL: request.Body.ReturnURL, + }, + }) + if err != nil { + receiver.logger.Error("failed to get yoomoney payment link on of ", zap.Error(err)) + return "", err + } + + return link, nil +} + +func (receiver *Service) GetPaymentLinkSberPay(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkSberPay(ctx, &treasurer.GetPaymentLinkRequest{ + MainSettings: &treasurer.MainPaymentSettings{ + Currency: request.Body.Currency, + Amount: request.Body.Amount, + UserID: request.UserID, + ClientIP: request.ClientIP, + CallbackHostGRPC: []string{receiver.configurationGRPC.Domen}, + ReturnURL: request.Body.ReturnURL, + }, + }) + if err != nil { + receiver.logger.Error("failed to get sberpay payment link on of ", zap.Error(err)) + return "", err + } + + return link, nil +} + +func (receiver *Service) GetPaymentLinkTinkoff(ctx context.Context, request *models.GetPaymentLinkRequest) (string, errors.Error) { + link, err := receiver.paymentClient.GetPaymentLinkTinkoff(ctx, &treasurer.GetPaymentLinkRequest{ + MainSettings: &treasurer.MainPaymentSettings{ + Currency: request.Body.Currency, + Amount: request.Body.Amount, + UserID: request.UserID, + ClientIP: request.ClientIP, + CallbackHostGRPC: []string{receiver.configurationGRPC.Domen}, + ReturnURL: request.Body.ReturnURL, + }, + }) + if err != nil { + receiver.logger.Error("failed to get tinkoff payment link on of ", zap.Error(err)) + return "", err + } + + return link, nil +} diff --git a/internal/service/wallet/wallet.go b/internal/service/wallet/wallet.go index f7950fb..3658834 100644 --- a/internal/service/wallet/wallet.go +++ b/internal/service/wallet/wallet.go @@ -4,10 +4,10 @@ import ( "context" "go.uber.org/zap" "log" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/validate" ) type accountRepository interface { @@ -116,7 +116,7 @@ func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *mo updatedAccount, changeErr := receiver.repository.ChangeWallet(ctx, request.Account.UserID, &models.Wallet{ Cash: request.Account.Wallet.Cash + cash, Money: request.Account.Wallet.Money + request.Cash, - Spent: request.Account.Wallet.Spent, + Spent: request.Account.Wallet.Spent, PurchasesAmount: request.Account.Wallet.PurchasesAmount, Currency: request.Account.Wallet.Currency, LastPaymentID: request.PaymentID, diff --git a/internal/utils/authenticator.go b/internal/utils/authenticator.go index 8242850..8b1a05d 100644 --- a/internal/utils/authenticator.go +++ b/internal/utils/authenticator.go @@ -5,8 +5,8 @@ import ( "github.com/gofiber/fiber/v2" "strings" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" ) const ( diff --git a/internal/utils/client_response.go b/internal/utils/client_response.go index fb318a5..de18c7f 100644 --- a/internal/utils/client_response.go +++ b/internal/utils/client_response.go @@ -3,7 +3,7 @@ package utils import ( "net/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/errors" ) var clientErrors = map[int]error{ diff --git a/internal/utils/hlog_helpers.go b/internal/utils/hlog_helpers.go index 9f26749..4515cb1 100644 --- a/internal/utils/hlog_helpers.go +++ b/internal/utils/hlog_helpers.go @@ -2,8 +2,8 @@ package utils import ( "encoding/json" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/discount" ) func GetAppliedDiscountsIDs(appliedDiscounts []*discount.Discount) []string { diff --git a/internal/utils/jwt.go b/internal/utils/jwt.go index 93829ee..2bd8b4d 100644 --- a/internal/utils/jwt.go +++ b/internal/utils/jwt.go @@ -6,7 +6,7 @@ import ( "time" "github.com/golang-jwt/jwt/v5" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/models" ) type JWT struct { diff --git a/internal/utils/jwt_test.go b/internal/utils/jwt_test.go index e931d02..5f42cfb 100644 --- a/internal/utils/jwt_test.go +++ b/internal/utils/jwt_test.go @@ -7,8 +7,8 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" ) func TestJWT(t *testing.T) { diff --git a/internal/utils/pagination.go b/internal/utils/pagination.go index ccb63c8..5ba92ee 100644 --- a/internal/utils/pagination.go +++ b/internal/utils/pagination.go @@ -1,6 +1,6 @@ package utils -import "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" +import "gitea.pena/PenaSide/customer/internal/models" func DeterminePagination(page, limit interface{}) *models.Pagination { determinePage := func() int64 { diff --git a/internal/utils/payment.go b/internal/utils/payment.go index 158fc97..d84c580 100644 --- a/internal/utils/payment.go +++ b/internal/utils/payment.go @@ -1,8 +1,8 @@ package utils import ( - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/errors" + "gitea.pena/PenaSide/customer/internal/models" ) func ValidateGetPaymentLinkBody(request *models.GetPaymentLinkBody) errors.Error { @@ -10,5 +10,22 @@ func ValidateGetPaymentLinkBody(request *models.GetPaymentLinkBody) errors.Error return errors.NewWithMessage("request body is empty", errors.ErrInvalidArgs) } - return nil + switch request.Type { + case models.PaymentTypeBankCard: + return validateBankcardPayment(request) + default: + return nil + } +} + +func validateMobilePayment(request *models.GetPaymentLinkBody) errors.Error { + return nil +} + +func validateLoginPayment(request *models.GetPaymentLinkBody) errors.Error { + return nil +} + +func validateBankcardPayment(request *models.GetPaymentLinkBody) errors.Error { + return nil } diff --git a/internal/utils/payment_test.go b/internal/utils/payment_test.go index e70017a..e2627df 100644 --- a/internal/utils/payment_test.go +++ b/internal/utils/payment_test.go @@ -1,192 +1,184 @@ package utils_test -import ( - "testing" - - "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" -) - -func TestValidateGetPaymentLinkBody(t *testing.T) { - t.Run("Валидация объекта запроса для получения платёжной ссылки по банковской карточке (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeBankCard, - Currency: "RUB", - Amount: 10050, - BankCard: &models.BankCard{ - Number: "5315 5310 5310 5011", - ExpiryYear: "2021", - ExpiryMonth: "05", - }, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки по банковской карточке (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeBankCard, - Currency: "RUB", - Amount: 10050, - })) - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeBankCard, - Currency: "RUB", - Amount: 10050, - BankCard: &models.BankCard{ - Number: "5315 5310 5310 5011", - ExpiryYear: "2021", - }, - })) - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeBankCard, - Currency: "RUB", - Amount: 10050, - BankCard: &models.BankCard{ - Number: "5315 5310 5310 5011", - ExpiryMonth: "05", - }, - })) - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeBankCard, - Currency: "RUB", - Amount: 10050, - BankCard: &models.BankCard{ - ExpiryYear: "2021", - ExpiryMonth: "05", - }, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через yoomoney (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeYoomoney, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через yoomoney (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeYoomoney, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через qiwi (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeQiwi, - Currency: "USD", - Amount: 10050, - PhoneNumber: "79000000000", - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через qiwi (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeQiwi, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через sberpay (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeSberPay, - Currency: "USD", - Amount: 10050, - PhoneNumber: "79000000000", - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через sberpay (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeSberPay, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через alfaclick (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeAlfabank, - Currency: "USD", - Amount: 10050, - Login: "login_test", - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через alfaclick (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeAlfabank, - Currency: "BYN", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через sbp (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeSBP, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через tinkoff (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeTinkoff, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через мобильный (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeMobile, - Currency: "USD", - Amount: 10050, - PhoneNumber: "79000000000", - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через мобильный (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeMobile, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через наличные (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeCash, - Currency: "USD", - Amount: 10050, - PhoneNumber: "79000000000", - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через наличные (Не успешно)", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeCash, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Валидация объекта запроса для получения платёжной ссылки через оплату по частям (Успешно)", func(t *testing.T) { - assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: models.PaymentTypeInstallments, - Currency: "USD", - Amount: 10050, - })) - }) - - t.Run("Не успешная валидация из-за неопределённого типа оплаты", func(t *testing.T) { - assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ - Type: "some_radmon_payment_type", - Currency: "USD", - Amount: 10050, - })) - }) -} +//func TestValidateGetPaymentLinkBody(t *testing.T) { +// t.Run("Валидация объекта запроса для получения платёжной ссылки по банковской карточке (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeBankCard, +// Currency: "RUB", +// Amount: 10050, +// BankCard: &models.BankCard{ +// Number: "5315 5310 5310 5011", +// ExpiryYear: "2021", +// ExpiryMonth: "05", +// }, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки по банковской карточке (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeBankCard, +// Currency: "RUB", +// Amount: 10050, +// })) +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeBankCard, +// Currency: "RUB", +// Amount: 10050, +// BankCard: &models.BankCard{ +// Number: "5315 5310 5310 5011", +// ExpiryYear: "2021", +// }, +// })) +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeBankCard, +// Currency: "RUB", +// Amount: 10050, +// BankCard: &models.BankCard{ +// Number: "5315 5310 5310 5011", +// ExpiryMonth: "05", +// }, +// })) +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeBankCard, +// Currency: "RUB", +// Amount: 10050, +// BankCard: &models.BankCard{ +// ExpiryYear: "2021", +// ExpiryMonth: "05", +// }, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через yoomoney (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeYoomoney, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через yoomoney (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeYoomoney, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через qiwi (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeQiwi, +// Currency: "USD", +// Amount: 10050, +// PhoneNumber: "79000000000", +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через qiwi (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeQiwi, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через sberpay (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeSberPay, +// Currency: "USD", +// Amount: 10050, +// PhoneNumber: "79000000000", +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через sberpay (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeSberPay, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через alfaclick (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeAlfabank, +// Currency: "USD", +// Amount: 10050, +// Login: "login_test", +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через alfaclick (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeAlfabank, +// Currency: "BYN", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через sbp (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeSBP, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через tinkoff (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeTinkoff, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через мобильный (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeMobile, +// Currency: "USD", +// Amount: 10050, +// PhoneNumber: "79000000000", +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через мобильный (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeMobile, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через наличные (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeCash, +// Currency: "USD", +// Amount: 10050, +// PhoneNumber: "79000000000", +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через наличные (Не успешно)", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeCash, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Валидация объекта запроса для получения платёжной ссылки через оплату по частям (Успешно)", func(t *testing.T) { +// assert.NoError(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: models.PaymentTypeInstallments, +// Currency: "USD", +// Amount: 10050, +// })) +// }) +// +// t.Run("Не успешная валидация из-за неопределённого типа оплаты", func(t *testing.T) { +// assert.Error(t, utils.ValidateGetPaymentLinkBody(&models.GetPaymentLinkBody{ +// Type: "some_radmon_payment_type", +// Currency: "USD", +// Amount: 10050, +// })) +// }) +//} diff --git a/internal/utils/promo_LTV.go b/internal/utils/promo_LTV.go index 41e98dc..314392c 100644 --- a/internal/utils/promo_LTV.go +++ b/internal/utils/promo_LTV.go @@ -2,7 +2,7 @@ package utils import ( "go.mongodb.org/mongo-driver/bson" - codeword_rpc "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/codeword" + codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" "time" ) diff --git a/internal/utils/tariff.go b/internal/utils/tariff.go index b937096..c1e9811 100644 --- a/internal/utils/tariff.go +++ b/internal/utils/tariff.go @@ -1,6 +1,6 @@ package utils -import "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" +import "gitea.pena/PenaSide/customer/internal/models" func CalculateCartPurchasesAmount(tariffs []models.Tariff) uint64 { sum := uint64(0) diff --git a/internal/utils/tariff_test.go b/internal/utils/tariff_test.go index 9a74d65..57c2d6e 100644 --- a/internal/utils/tariff_test.go +++ b/internal/utils/tariff_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" ) func TestCalculateCartPurchasesAmount(t *testing.T) { diff --git a/internal/utils/transfer/payment.go b/internal/utils/transfer/payment.go new file mode 100644 index 0000000..772062f --- /dev/null +++ b/internal/utils/transfer/payment.go @@ -0,0 +1,22 @@ +package transfer +import( + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/treasurer" +) +func ReceiptItemToProto(in models.Item) *treasurer.Item { + return &treasurer.Item{ + Description: in.Description, + Measure: in.Measure, + Quantity: in.Quantity, + Money: in.Money, + Currency: in.Currency, + } +} + +func ReceiptItemsToProto(in []models.Item) []*treasurer.Item { + result := make([]*treasurer.Item, len(in), len(in)) + for i, item := range in { + result[i] = ReceiptItemToProto(item) + } + return result +} diff --git a/internal/utils/transfer/privilege.go b/internal/utils/transfer/privilege.go index 9abdca1..924a5aa 100644 --- a/internal/utils/transfer/privilege.go +++ b/internal/utils/transfer/privilege.go @@ -1,8 +1,8 @@ package transfer import ( - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/broker" ) func PrivilegeProtoToModel(privilege *broker.PrivilegeMessage) *models.Privilege { diff --git a/internal/utils/transfer/privilege_test.go b/internal/utils/transfer/privilege_test.go index db9a5aa..3661cb4 100644 --- a/internal/utils/transfer/privilege_test.go +++ b/internal/utils/transfer/privilege_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/transfer" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/utils/transfer" ) func TestPrivilegeModelToProto(t *testing.T) { diff --git a/internal/utils/transfer/tariff.go b/internal/utils/transfer/tariff.go index b30ddc8..014d295 100644 --- a/internal/utils/transfer/tariff.go +++ b/internal/utils/transfer/tariff.go @@ -1,9 +1,9 @@ package transfer import ( - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/proto/discount" ) func TariffsToProductInformations(tarrifs []models.Tariff) []*discount.ProductInformation { diff --git a/internal/utils/transfer/tariff_test.go b/internal/utils/transfer/tariff_test.go index e541c5e..b1fb9a4 100644 --- a/internal/utils/transfer/tariff_test.go +++ b/internal/utils/transfer/tariff_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/transfer" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/proto/broker" + "gitea.pena/PenaSide/customer/internal/utils/transfer" ) func TestTariffMessageProtoToTariffModel(t *testing.T) { diff --git a/internal/utils/validate_configuration_urls.go b/internal/utils/validate_configuration_urls.go index e94f0d4..7761de2 100644 --- a/internal/utils/validate_configuration_urls.go +++ b/internal/utils/validate_configuration_urls.go @@ -3,8 +3,8 @@ package utils import ( "fmt" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/validate" ) func ValidateConfigurationURLs(config *models.ServiceConfiguration) error { diff --git a/pkg/client/request.go b/pkg/client/request.go index 0799b0f..b4f62f0 100644 --- a/pkg/client/request.go +++ b/pkg/client/request.go @@ -2,7 +2,6 @@ package client import ( "context" - "fmt" "github.com/go-resty/resty/v2" ) @@ -36,7 +35,9 @@ func makeRequest[T any, R any](url string, requestMethod func(url string) (*rest if responseInstance.IsError() { responseBody, parseErr := parseResponse[R](responseInstance.Body(), responseInstance.RawResponse) if parseErr != nil { - return nil, parseErr + return &Response[T,R]{ + StatusCode: responseInstance.StatusCode(), + },parseErr } return &Response[T, R]{ @@ -44,11 +45,12 @@ func makeRequest[T any, R any](url string, requestMethod func(url string) (*rest Error: responseBody, }, nil } - fmt.Println("OOOOO", responseInstance.RawResponse) responseBody, parseErr := parseResponse[T](responseInstance.Body(), responseInstance.RawResponse) if parseErr != nil { - return nil, parseErr + return &Response[T,R]{ + StatusCode: responseInstance.StatusCode(), + },parseErr } return &Response[T, R]{ diff --git a/pkg/client/response.go b/pkg/client/response.go index b7098cf..b1e32c1 100644 --- a/pkg/client/response.go +++ b/pkg/client/response.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/json" + "gitea.pena/PenaSide/customer/pkg/json" ) func parseResponse[T any](body []byte, response *http.Response) (*T, error) { diff --git a/pkg/customer_clients/rpc.go b/pkg/customer_clients/rpc.go index 647bf92..3f7e047 100644 --- a/pkg/customer_clients/rpc.go +++ b/pkg/customer_clients/rpc.go @@ -5,7 +5,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/customer" + "gitea.pena/PenaSide/customer/internal/proto/customer" ) type CustomersClientDeps struct { diff --git a/pkg/validate/string_test.go b/pkg/validate/string_test.go index a3c8e4a..dceb5c7 100644 --- a/pkg/validate/string_test.go +++ b/pkg/validate/string_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/pkg/validate" ) func TestIsStringEmpty(t *testing.T) { diff --git a/pkg/validate/url_test.go b/pkg/validate/url_test.go index 7d910c7..0d26bf5 100644 --- a/pkg/validate/url_test.go +++ b/pkg/validate/url_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" + "gitea.pena/PenaSide/customer/pkg/validate" ) func TestValidateURL(t *testing.T) { diff --git a/tests/e2e/accountPipe_test.go b/tests/e2e/accountPipe_test.go index 9b8e065..48c9b85 100644 --- a/tests/e2e/accountPipe_test.go +++ b/tests/e2e/accountPipe_test.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/stretchr/testify/assert" "net/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" "time" ) diff --git a/tests/e2e/addAccount_test.go b/tests/e2e/addAccount_test.go index 013919a..8314aa7 100644 --- a/tests/e2e/addAccount_test.go +++ b/tests/e2e/addAccount_test.go @@ -3,9 +3,9 @@ package e2e_test import ( "context" "fmt" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" "github.com/stretchr/testify/assert" diff --git a/tests/e2e/buy_tariff_test.go b/tests/e2e/buy_tariff_test.go index 42f2e2f..8f5cd36 100644 --- a/tests/e2e/buy_tariff_test.go +++ b/tests/e2e/buy_tariff_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) func TestBuyTariff(t *testing.T) { diff --git a/tests/e2e/calculateLTV_test.go b/tests/e2e/calculateLTV_test.go index 4f4e103..4853603 100644 --- a/tests/e2e/calculateLTV_test.go +++ b/tests/e2e/calculateLTV_test.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" "time" ) diff --git a/tests/e2e/changeAccount_test.go b/tests/e2e/changeAccount_test.go index e084173..6b4f8ec 100644 --- a/tests/e2e/changeAccount_test.go +++ b/tests/e2e/changeAccount_test.go @@ -3,9 +3,9 @@ package e2e_test import ( "context" "fmt" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" "github.com/stretchr/testify/assert" @@ -19,7 +19,7 @@ func TestChangeAccount(t *testing.T) { defer cancel() assert.NotPanics(t, func() { - token, tokenErr := jwtUtil.Create("64e5d9830fcca0596d82c0c7") + token, tokenErr := jwtUtil.Create("64ebda4387392e122e5d411f") if isNoError := assert.NoError(t, tokenErr); !isNoError { return } @@ -43,7 +43,7 @@ func TestChangeAccount(t *testing.T) { return } - assert.Equal(t, "64e5d9830fcca0596d82c0c7", responseChangeAccount.Body.UserID) + assert.Equal(t, "64ebda4387392e122e5d411f", responseChangeAccount.Body.UserID) assert.Equal(t, "Aloha", responseChangeAccount.Body.Name.Middlename) assert.Equal(t, "Holla", responseChangeAccount.Body.Name.FirstName) assert.Equal(t, "Adios payasos", responseChangeAccount.Body.Name.Orgname) @@ -54,7 +54,7 @@ func TestChangeAccount(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() assert.NotPanics(t, func() { - token, tokenErr := jwtUtil.Create("64e5d9830fcca0596d82c0c7") + token, tokenErr := jwtUtil.Create("64ebda4387392e122e5d411f") if isNoError := assert.NoError(t, tokenErr); !isNoError { return } @@ -64,7 +64,7 @@ func TestChangeAccount(t *testing.T) { } responseStatusAccount, errStatusAccount := client.Patch[models.Account, models.ResponseErrorHTTP](ctx, &client.RequestSettings{ - URL: "http://localhost:8082/account/64e5d9830fcca0596d82c0c7", + URL: "http://localhost:8083/account/64ebda4387392e122e5d411f", Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)}, Body: statusRequest, }) diff --git a/tests/e2e/getAccount_test.go b/tests/e2e/getAccount_test.go index 52ae66d..a0b6e96 100644 --- a/tests/e2e/getAccount_test.go +++ b/tests/e2e/getAccount_test.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" ) @@ -47,7 +47,7 @@ func TestGetAccount(t *testing.T) { } responseGetAccount, errGetAccount := client.Get[models.Account, models.ResponseErrorHTTP](ctx, &client.RequestSettings{ - URL: "http://localhost:8082/account/64e5e1ca87392e122e5d3de7", + URL: "http://localhost:8083/account/64e5e1ca87392e122e5d3de7", Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)}, }) if isNoError := assert.NoError(t, errGetAccount); !isNoError { @@ -61,6 +61,10 @@ func TestGetAccount(t *testing.T) { }) }) t.Run("Получение аккаунтов с пагинацией", func(t *testing.T) { + token, tokenErr := jwtUtil.Create("64e5e1ca87392e122e5d3de7") + if isNoError := assert.NoError(t, tokenErr); !isNoError { + return + } ctx, cancel := context.WithCancel(context.Background()) defer cancel() assert.NotPanics(t, func() { @@ -77,8 +81,9 @@ func TestGetAccount(t *testing.T) { } responseGetAccount, errGetAccount := client.Get[models.PaginationResponse[models.Account], models.ResponseErrorHTTP](ctx, &client.RequestSettings{ - URL: "http://localhost:8082/accounts", - Body: params, + URL: "http://localhost:8083/accounts", + Body: params, + Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)}, }) if isNoError := assert.NoError(t, errGetAccount); !isNoError { return diff --git a/tests/e2e/recentTariffs_test.go b/tests/e2e/recentTariffs_test.go index ea3a116..2b38ee1 100644 --- a/tests/e2e/recentTariffs_test.go +++ b/tests/e2e/recentTariffs_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) func TestGetRecentTariffs(t *testing.T) { diff --git a/tests/e2e/rspay_test.go b/tests/e2e/rspay_test.go index d39ae7b..5c75e3e 100644 --- a/tests/e2e/rspay_test.go +++ b/tests/e2e/rspay_test.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" ) diff --git a/tests/e2e/sendReport_test.go b/tests/e2e/sendReport_test.go index ca6c2f0..f01143f 100644 --- a/tests/e2e/sendReport_test.go +++ b/tests/e2e/sendReport_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) // todo thinking diff --git a/tests/e2e/сurrencies_test.go b/tests/e2e/сurrencies_test.go index 840849c..2774cde 100644 --- a/tests/e2e/сurrencies_test.go +++ b/tests/e2e/сurrencies_test.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/stretchr/testify/assert" "net/http" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" "testing" ) diff --git a/tests/helpers/jwt.go b/tests/helpers/jwt.go index d2c12dc..f6d29a0 100644 --- a/tests/helpers/jwt.go +++ b/tests/helpers/jwt.go @@ -5,8 +5,8 @@ import ( "time" "github.com/golang-jwt/jwt/v5" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/utils" ) func InitializeJWT() *utils.JWT { diff --git a/tests/integration/history_report_test.go b/tests/integration/history_report_test.go index 7d7ca95..399c195 100644 --- a/tests/integration/history_report_test.go +++ b/tests/integration/history_report_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) func TestHistoryReport(t *testing.T) { diff --git a/tests/integration/logostat_test.go b/tests/integration/logostat_test.go index 5884dd8..4aae9fc 100644 --- a/tests/integration/logostat_test.go +++ b/tests/integration/logostat_test.go @@ -2,9 +2,10 @@ package integration import ( "context" + "fmt" "github.com/pioz/faker" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/interface/repository" + "gitea.pena/PenaSide/customer/internal/models" "strconv" "time" ) @@ -59,16 +60,25 @@ func InsertToDB(ctx context.Context, acc repository.AccountRepository, history r partner2 := "partner2" qid1 := "qid1" qid2 := "qid2" - acc.Insert(ctx, &models.Account{ + _, err := acc.Insert(ctx, &models.Account{ ID: "1", UserID: partner1, CreatedAt: time.Now(), }) - acc.Insert(ctx, &models.Account{ + if err != nil { + fmt.Println(err) + return + } + + _, err = acc.Insert(ctx, &models.Account{ ID: "2", UserID: partner2, CreatedAt: time.Now(), }) + if err != nil { + fmt.Println(err) + return + } for i := 1; i < 101; i++ { var partnerID string @@ -81,21 +91,29 @@ func InsertToDB(ctx context.Context, acc repository.AccountRepository, history r qid = qid1 } - acc.Insert(ctx, &models.Account{ + _, err = acc.Insert(ctx, &models.Account{ ID: "IDUSER" + strconv.Itoa(i), UserID: strconv.Itoa(i), CreatedAt: time.Now(), From: qid, Partner: partnerID, }) + if err != nil { + fmt.Println(err) + return + } - history.Insert(ctx, &models.History{ + _, err = history.Insert(ctx, &models.History{ ID: "IDHISTORY" + strconv.Itoa(i), UserID: strconv.Itoa(i), RawDetails: models.RawDetails{ Price: int64(faker.Uint64()), }, }) + if err != nil { + fmt.Println(err) + return + } } diff --git a/tests/integration/mail_test.go b/tests/integration/mail_test.go index e301466..a96fd68 100644 --- a/tests/integration/mail_test.go +++ b/tests/integration/mail_test.go @@ -4,8 +4,8 @@ import ( "github.com/gofiber/fiber/v2" "github.com/stretchr/testify/assert" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/models" "testing" ) diff --git a/tests/integration/promo_ltv_test.go b/tests/integration/promo_ltv_test.go index e919c2a..dfa0358 100644 --- a/tests/integration/promo_ltv_test.go +++ b/tests/integration/promo_ltv_test.go @@ -7,9 +7,9 @@ import ( "go.uber.org/zap" "log" "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" - codeword_rpc "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/codeword" + "gitea.pena/PenaSide/customer/internal/interface/client" + "gitea.pena/PenaSide/customer/internal/interface/repository" + codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" "testing" "time" ) diff --git a/tests/integration/rpc_clients_test.go b/tests/integration/rpc_clients_test.go index 4a6ac1b..44d747c 100644 --- a/tests/integration/rpc_clients_test.go +++ b/tests/integration/rpc_clients_test.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/stretchr/testify/assert" "go.uber.org/zap" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/customer_clients" + "gitea.pena/PenaSide/customer/pkg/customer_clients" "testing" ) diff --git a/tests/integration/set_account_verification_status_test.go b/tests/integration/set_account_verification_status_test.go index 6d26c29..8949d4d 100644 --- a/tests/integration/set_account_verification_status_test.go +++ b/tests/integration/set_account_verification_status_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) var customerServiceBase = os.Getenv("CUSTOMER_SERVICE") diff --git a/tests/integration/trashLogger_test.go b/tests/integration/trashLogger_test.go index 7501e63..8f206bd 100644 --- a/tests/integration/trashLogger_test.go +++ b/tests/integration/trashLogger_test.go @@ -9,9 +9,9 @@ import ( "go.uber.org/zap/zapcore" "log" "os" - "penahub.gitlab.yandexcloud.net/external/trashlog.git/app" - "penahub.gitlab.yandexcloud.net/external/trashlog.git/wrappers/zaptrashlog" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" + "penahub.gitlab.yandexcloud.net/external/trashlog/app" + "penahub.gitlab.yandexcloud.net/external/trashlog/wrappers/zaptrashlog" + "gitea.pena/PenaSide/customer/internal/models" "testing" "time" ) diff --git a/tests/integration/update_account_name_test.go b/tests/integration/update_account_name_test.go index 0251c21..c45ee7a 100644 --- a/tests/integration/update_account_name_test.go +++ b/tests/integration/update_account_name_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" - "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" - "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" + "gitea.pena/PenaSide/customer/internal/models" + "gitea.pena/PenaSide/customer/pkg/client" + "gitea.pena/PenaSide/customer/tests/helpers" ) func TestUpdateAccountName(t *testing.T) {