Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): avoid acct-trans addition in free order #1049

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions deploy/build/charts/laf-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,8 @@ spec:
value: {{ .Values.default_region.apisix_api_url }}
- name: DEFAULT_REGION_APISIX_API_KEY
value: {{ .Values.default_region.apisix_api_key }}
- name: CASDOOR_ENDPOINT
value: {{ .Values.casdoor.endpoint }}
- name: CASDOOR_ORG_NAME
value: {{ .Values.casdoor.org_name | quote}}
- name: CASDOOR_APP_NAME
value: {{ .Values.casdoor.app_name | quote}}
- name: CASDOOR_CLIENT_ID
value: {{ .Values.casdoor.client_id | quote}}
- name: CASDOOR_CLIENT_SECRET
value: {{ .Values.casdoor.client_secret | quote}}
- name: CASDOOR_REDIRECT_URI
value : {{ .Values.casdoor.redirect_uri | quote}}
- name: SITE_NAME
value: {{ .Values.siteName | quote}}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
8 changes: 1 addition & 7 deletions deploy/build/charts/laf-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
apiServerHost: ""
databaseUrl: ""
apiServerUrl: ""
siteName: "laf"
# init default region conf
default_region:
# db conf
Expand All @@ -25,13 +26,6 @@ default_region:
jwt:
secret: laf_server_abc123
expires_in: 7d
casdoor:
endpoint: ""
client_id: a71f65e93723c436027e
client_secret: 0d7e157be08055867b81456df3c222ea7c68a097
org_name: laf
app_name: laf
redirect_uri: http://localhost:3001/login_callback

replicaCount: 1

Expand Down
1 change: 1 addition & 0 deletions deploy/build/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ helm install server -n ${NAMESPACE} \
--set jwt.secret=${SERVER_JWT_SECRET} \
--set apiServerHost=api.${DOMAIN} \
--set apiServerUrl=${HTTP_SCHEMA}://api.${DOMAIN} \
--set siteName=${DOMAIN} \
--set default_region.database_url=${DATABASE_URL} \
--set default_region.minio_domain=${MINIO_DOMAIN} \
--set default_region.minio_external_endpoint=${MINIO_EXTERNAL_ENDPOINT} \
Expand Down
27 changes: 0 additions & 27 deletions server/Dockerfile.alpine

This file was deleted.

5 changes: 3 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "laf-server",
"version": "1.0.0-beta.6",
"description": "",
"description": "laf server",
"author": "maslow(wangfugen@126.com)",
"private": true,
"license": "UNLICENSED",
"license": "Apache-2.0",
"scripts": {
"intercept": "telepresence intercept laf-server -n laf-system -p 3000:3000 -e $(pwd)/.env",
"leave": "telepresence leave laf-server-laf-system",
"prebuild": "npm run generate && rimraf dist",
"generate": "prisma generate",
"build": "nest build",
Expand Down
3 changes: 2 additions & 1 deletion server/src/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { WeChatPayOrderResponse, WeChatPayTradeState } from './payment/types'
import { WeChatPayService } from './payment/wechat-pay.service'
import { Response } from 'express'
import * as assert from 'assert'
import { ServerConfig } from 'src/constants'

@ApiTags('Account')
@Controller('accounts')
Expand Down Expand Up @@ -84,7 +85,7 @@ export class AccountController {
order.id,
amount,
currency,
'laf account charge',
`${ServerConfig.SITE_NAME} recharge`,
)

return ResponseUtil.ok({
Expand Down
6 changes: 5 additions & 1 deletion server/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ export class ServerConfig {
}
}

static get SITE_NAME() {
return process.env.SITE_NAME || 'laf'
}

static get API_SERVER_URL() {
return process.env.API_SERVER_URL || 'http://localhost:3000'
}

static get certManagerIssuerName() {
static get CertManagerIssuerName() {
return process.env.CERT_MANAGER_ISSUER_NAME || 'laf-issuer'
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/gateway/apisix-custom-cert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ApisixCustomCertService {
secretName: website.id,
dnsNames: [website.domain],
issuerRef: {
name: ServerConfig.certManagerIssuerName,
name: ServerConfig.CertManagerIssuerName,
kind: 'ClusterIssuer',
},
},
Expand Down
23 changes: 13 additions & 10 deletions server/src/subscription/renewal-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,20 @@ export class SubscriptionRenewalTaskService {
{ $inc: { balance: -priceAmount } },
{ session },
)
}

// Create account transaction
await db.collection('AccountTransaction').insertOne({
accountId: account._id,
amount: -priceAmount,
balance: account.balance - priceAmount,
message: `subscription renewal order ${renewal._id}`,
createdAt: new Date(),
updatedAt: new Date(),
})
// Create account transaction
await db.collection('AccountTransaction').insertOne(
{
accountId: account._id,
amount: -priceAmount,
balance: account.balance - priceAmount,
message: `subscription renewal order ${renewal._id}`,
createdAt: new Date(),
updatedAt: new Date(),
},
{ session },
)
}

// Update subscription 'expiredAt' time
await db.collection<Subscription>('Subscription').updateOne(
Expand Down