|
|
@@ -6,6 +6,8 @@ import { In } from 'typeorm'
|
|
|
import { UsersService } from '../users/users.service'
|
|
|
import { OperationLogService } from '../operation-log/operation-log.service'
|
|
|
import { OperationType } from '../operation-log/entities/operation-log.entity'
|
|
|
+import { SysConfigService } from '../sys-config/sys-config.service'
|
|
|
+import Decimal from 'decimal.js'
|
|
|
|
|
|
@Controller('payOrder')
|
|
|
export class PayOrderController {
|
|
|
@@ -13,7 +15,8 @@ export class PayOrderController {
|
|
|
constructor(
|
|
|
private readonly payOrderService: PayOrderService,
|
|
|
private readonly userService: UsersService,
|
|
|
- private readonly operationLogService: OperationLogService
|
|
|
+ private readonly operationLogService: OperationLogService,
|
|
|
+ private readonly sysConfigService: SysConfigService
|
|
|
) {
|
|
|
}
|
|
|
|
|
|
@@ -39,6 +42,10 @@ export class PayOrderController {
|
|
|
order.userName = req.user.username
|
|
|
const payOrder = await this.payOrderService.create(order)
|
|
|
await this.operationLogService.create(req, payOrder, 'PayOrder', OperationType.INSERT, '创建充值订单')
|
|
|
+ const rechargeRatio = await this.sysConfigService.getString('recharge_ratio', '')
|
|
|
+ const ratio = new Decimal(rechargeRatio)
|
|
|
+ const balanceDecimal = new Decimal(payOrder.amount).mul(ratio)
|
|
|
+ payOrder.rechargeBalance = balanceDecimal.toNumber()
|
|
|
return payOrder
|
|
|
} catch (e) {
|
|
|
console.log(e.message)
|