Merge branch 'development' into 'devops-staging'
add: history-deposit-profile See merge request empatnusabangsa/ppob/ppob-backend!115
This commit is contained in:
commit
91bcac77cc
|
@ -159,6 +159,29 @@ export class TransactionController {
|
|||
page,
|
||||
req.user.userId,
|
||||
userDestination,
|
||||
'detail',
|
||||
pageSize,
|
||||
);
|
||||
|
||||
return {
|
||||
...data,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
@Get('history-deposit-profile')
|
||||
async getHistoryDepositUserProfile(
|
||||
@Query('page') page: number,
|
||||
@Query('pageSize') pageSize: number,
|
||||
@Query('user-destination') userDestination: string,
|
||||
@Request() req,
|
||||
) {
|
||||
const data = await this.transactionService.topUpHistoryByUser(
|
||||
page,
|
||||
req.user.userId,
|
||||
userDestination,
|
||||
'profile',
|
||||
pageSize,
|
||||
);
|
||||
|
||||
|
|
|
@ -1041,18 +1041,48 @@ export class TransactionService {
|
|||
page: number,
|
||||
user: string,
|
||||
destinationUser: string,
|
||||
type: string,
|
||||
pageSize?: number,
|
||||
) {
|
||||
const userData = await this.userService.findExist(user);
|
||||
|
||||
const baseQuery = this.transactionRepository
|
||||
.createQueryBuilder('transaction')
|
||||
.where(
|
||||
.leftJoinAndMapOne(
|
||||
'transaction.userData',
|
||||
UserDetail,
|
||||
'userData',
|
||||
'userData.user = transaction.user',
|
||||
);
|
||||
|
||||
if (
|
||||
userData.roles.name == 'Admin' ||
|
||||
userData.roles.name == 'Customer Service' ||
|
||||
type == 'profile'
|
||||
) {
|
||||
baseQuery.where(
|
||||
'transaction.type = 0 and transaction.user_destination = :destinationId',
|
||||
{
|
||||
destinationId: destinationUser,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
baseQuery.where(
|
||||
'transaction.user = :id and transaction.type = 0 and transaction.user_destination = :destinationId',
|
||||
{
|
||||
id: user,
|
||||
destinationId: destinationUser,
|
||||
},
|
||||
)
|
||||
.select(['id', 'created_at as transaction_date', 'amount'])
|
||||
);
|
||||
}
|
||||
|
||||
baseQuery
|
||||
.select([
|
||||
'transaction.id',
|
||||
'transaction.created_at as transaction_date',
|
||||
'amount',
|
||||
'userData.name as sender_name',
|
||||
])
|
||||
.orderBy('transaction.created_at', 'DESC');
|
||||
|
||||
const data = await baseQuery
|
||||
|
|
Loading…
Reference in New Issue
Block a user