reseller : update

This commit is contained in:
2026-04-15 15:37:40 +03:30
parent 232d2ec072
commit 6e8e2cd527
8 changed files with 98 additions and 49 deletions
+41 -30
View File
@@ -9,13 +9,14 @@ import { AdminRoute } from '../../common/decorators/admin.decorator';
import { ResellerRoute } from '../../common/decorators/reseller.decorator';
import { UserDec } from '../../common/decorators/user.decorator';
import { CreateResellerAgentDto } from './dto/create-reseller-agent.dto';
import { SearchRewardsRequestQueryDto } from './dto/search-reward-requests.dto';
import { SearchWithdrawRequestQueryDto } from './dto/search-withdraw-requests.dto';
import { SearchCustomersDto } from '../users/DTO/search-customers.dto';
import { SearchResellerInvoicesQueryDto } from './dto/search-reseller-invoices.dto';
import { PaginationDto } from '../../common/DTO/pagination.dto';
import { WalletsService } from '../wallets/providers/wallets.service';
import { CreateWithdrawRequestDto } from './dto/create-withdraw-request.dto';
import { CreateUserBankAccountDto } from './dto/create-user-bank-account.dto';
import { ResellerType } from '../auth/DTO/verify-reseller-otp.dto';
@Controller('reseller')
@AuthGuards()
@@ -25,7 +26,7 @@ export class ResellerController {
private readonly walletsService: WalletsService,
) { }
//***************** DSC Endpoints **************** */
@ApiOperation({ summary: "create Reseller ==> admin route" })
@AdminRoute()
@PermissionsDec(PermissionEnum.RESELLER)
@@ -52,24 +53,26 @@ export class ResellerController {
return this.resellerService.findAll()
}
// ************** Reseller Panel Endpoints ***********
// =========== Reseller-->Agent =============
@ApiOperation({ summary: "get Reseller agents ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('agents')
getResellerAgents(@UserDec("id") userId: string) {
return this.resellerService.finResellerAgents(userId)
}
@ApiOperation({ summary: "Create Reseller agent ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.reseller])
@Post('agents')
createResellerAgent(@UserDec("id") userId: string, @Body() dto: CreateResellerAgentDto) {
return this.resellerService.createResellerAgent(userId, dto.phone)
}
@ApiOperation({ summary: "Remove Reseller agent ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.reseller])
@Delete('agents/:agentId')
deleteResellerAgent(@UserDec("id") userId: string, @Param('agentId') agentId: string) {
return this.resellerService.removeResellerAgent(userId, agentId)
@@ -77,31 +80,39 @@ export class ResellerController {
// ============ Customers =============
@ApiOperation({ summary: "get Reseller Customers ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.reseller])
@Get('customers')
getCustomers(@UserDec("id") userId: string, @Query() dto: SearchCustomersDto) {
return this.resellerService.findResellerCustomers(userId, dto)
}
// ============ Invoice =============
// ============ Invoice =============ok
@ApiOperation({ summary: "get Reseller Customers Invoices==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('invoices')
getCustomerInvoices(@UserDec("id") userId: string, @Query() query: SearchResellerInvoicesQueryDto) {
return this.resellerService.findResellerCustomersInvoices(userId, query)
getCustomerInvoices(
@UserDec("id") userId: string,
@Query() query: SearchResellerInvoicesQueryDto,
@UserDec("resellerType") type: ResellerType
) {
return this.resellerService.findInvoices(userId, type, query)
}
// ============ Rewards =============
@ApiOperation({ summary: "get Reseller Agents Rewards==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('rewards')
getResellerAgentsRewards(@UserDec("id") userId: string, @Query() query: SearchRewardsRequestQueryDto) {
return this.resellerService.findResellerAgentsRewards(userId, query)
getResellerAgentsRewards(
@UserDec("id") userId: string,
@Query() query: SearchWithdrawRequestQueryDto,
@UserDec("resellerType") type: ResellerType
) {
return this.resellerService.findRewards(userId, type, query)
}
// ============ Wallet Transactions =============
@ApiOperation({ summary: "get Reseller/Agent Wallet Transactions ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('wallet/transaction')
getWalletTransactionss(@UserDec("id") userId: string, @Query() query: PaginationDto) {
return this.walletsService.getTransaction(userId, query);
@@ -110,39 +121,39 @@ export class ResellerController {
// ============ Wallet Balance =============
@ApiOperation({ summary: "get Reseller/Agent Wallet Balance ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('wallet/balance')
getWalletBalance(@UserDec("id") userId: string) {
return this.walletsService.getBalance(userId)
}
// ============Payment WithDraw Request =============
// ============Create WithDraw Request =============
@ApiOperation({ summary: "Create Reseller/Agent withdraw request ==> reseller route" })
@ResellerRoute()
@Post('payment/withdraw')
@ResellerRoute([ResellerType.agent])
@Post('withdraw-request')
withdrawRequest(@UserDec("id") userId: string, @Body() dto: CreateWithdrawRequestDto) {
return this.resellerService.createWithdrawRequest(userId, dto.amount)
}
// ============ Remove payment WithDraw Request =============
// ============ Remove WithDraw Request =============
@ApiOperation({ summary: "remove Reseller/Agent withdraw request ==> reseller route" })
@ResellerRoute()
@Delete('paymant/withdraw/:id')
@ResellerRoute([ResellerType.agent])
@Delete('withdraw-request/:id')
removeWithdrawRequest(@UserDec("id") userId: string, @Param('id') id: string) {
return this.resellerService.removeWithdrawRequest(userId, id)
}
// ============ Payment list=============
@ApiOperation({ summary: "Get Payment list ==> reseller route" })
@ResellerRoute()
@Get('payment')
getPayments(@UserDec("id") userId: string, @Body() dto: SearchRewardsRequestQueryDto) {
// ============ withdraw list=============
@ApiOperation({ summary: "Get withdraw-request list ==> reseller route" })
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('withdraw-request')
getPayments(@UserDec("id") userId: string, @Body() dto: SearchWithdrawRequestQueryDto) {
return this.resellerService.getRewrdsRequests(userId, dto)
}
// ============ Bank Account =============
// ============ Create Bank Account =============
@ApiOperation({ summary: "Create Bank Account ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Post('bank-account')
createBankAccount(@UserDec("id") userId: string, @Body() dto: CreateUserBankAccountDto) {
return this.resellerService.createUserBankAccount(userId, dto)
@@ -151,7 +162,7 @@ export class ResellerController {
// ============ Get Bank Account =============
@ApiOperation({ summary: "Get Bank Account ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Get('bank-account')
getBankAccount(@UserDec("id") userId: string) {
return this.resellerService.getUserBankAccount(userId)
@@ -159,7 +170,7 @@ export class ResellerController {
// ============ Remove Bank Account =============
@ApiOperation({ summary: "remove User Bank account ==> reseller route" })
@ResellerRoute()
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
@Delete('bank-account/:id')
removeBankAccount(@UserDec("id") userId: string, @Param('id') id: string) {
return this.resellerService.deleteUserBankAccount(userId, id)