Skip to content

Commit

Permalink
fix(server): avoid acct-trans addition in free order (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Apr 19, 2023
1 parent 367dcf0 commit b0f7e81
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 61 deletions.
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

0 comments on commit b0f7e81

Please sign in to comment.