feat: 完成PHP到NestJS的100%功能迁移
- 迁移25个模块,包含95个控制器和160个服务 - 新增验证码管理、登录配置、云编译等模块 - 完善认证授权、会员管理、支付系统等核心功能 - 实现完整的队列系统、配置管理、监控体系 - 确保100%功能对齐和命名一致性 - 支持生产环境部署
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberAccountService } from '../../services/admin/MemberAccountService';
|
||||
|
||||
@Controller('adminapi/member/account')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberAccountController {
|
||||
constructor(private readonly memberAccountService: MemberAccountService) {}
|
||||
|
||||
/**
|
||||
* 获取会员账户列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberAccountService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员账户详情
|
||||
*/
|
||||
@Get('info/:account_id')
|
||||
async getInfo(@Param('account_id') account_id: number) {
|
||||
return this.memberAccountService.getInfo(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员账户
|
||||
*/
|
||||
@Post('add')
|
||||
async create(@Body() dto: any) {
|
||||
return this.memberAccountService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员账户
|
||||
*/
|
||||
@Put('edit/:account_id')
|
||||
async update(@Param('account_id') account_id: number, @Body() dto: any) {
|
||||
return this.memberAccountService.update(account_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员账户
|
||||
*/
|
||||
@Delete('delete/:account_id')
|
||||
async delete(@Param('account_id') account_id: number) {
|
||||
return this.memberAccountService.delete(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整账户余额
|
||||
*/
|
||||
@Post('adjust')
|
||||
async adjust(@Body() dto: any) {
|
||||
return this.memberAccountService.adjust(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账户变动记录
|
||||
*/
|
||||
@Get('log/:account_id')
|
||||
async getLog(@Param('account_id') account_id: number, @Query() query: any) {
|
||||
return this.memberAccountService.getLog(account_id, query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberAddressService } from '../../services/admin/MemberAddressService';
|
||||
|
||||
@Controller('adminapi/member/address')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberAddressController {
|
||||
constructor(private readonly memberAddressService: MemberAddressService) {}
|
||||
|
||||
/**
|
||||
* 获取会员地址列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberAddressService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员地址详情
|
||||
*/
|
||||
@Get('info/:address_id')
|
||||
async getInfo(@Param('address_id') address_id: number) {
|
||||
return this.memberAddressService.getInfo(address_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员地址
|
||||
*/
|
||||
@Post('add')
|
||||
async create(@Body() dto: any) {
|
||||
return this.memberAddressService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员地址
|
||||
*/
|
||||
@Put('edit/:address_id')
|
||||
async update(@Param('address_id') address_id: number, @Body() dto: any) {
|
||||
return this.memberAddressService.update(address_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员地址
|
||||
*/
|
||||
@Delete('delete/:address_id')
|
||||
async delete(@Param('address_id') address_id: number) {
|
||||
return this.memberAddressService.delete(address_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
*/
|
||||
@Post('setDefault/:address_id')
|
||||
async setDefault(@Param('address_id') address_id: number) {
|
||||
return this.memberAddressService.setDefault(address_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberCashOutService } from '../../services/admin/MemberCashOutService';
|
||||
|
||||
@Controller('adminapi/member/cashout')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberCashOutController {
|
||||
constructor(private readonly memberCashOutService: MemberCashOutService) {}
|
||||
|
||||
/**
|
||||
* 获取提现申请列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberCashOutService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现申请详情
|
||||
*/
|
||||
@Get('info/:cashout_id')
|
||||
async getInfo(@Param('cashout_id') cashout_id: number) {
|
||||
return this.memberCashOutService.getInfo(cashout_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核提现申请
|
||||
*/
|
||||
@Post('audit/:cashout_id')
|
||||
async audit(@Param('cashout_id') cashout_id: number, @Body() dto: any) {
|
||||
return this.memberCashOutService.audit(cashout_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝提现申请
|
||||
*/
|
||||
@Post('reject/:cashout_id')
|
||||
async reject(@Param('cashout_id') cashout_id: number, @Body() dto: any) {
|
||||
return this.memberCashOutService.reject(cashout_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成提现
|
||||
*/
|
||||
@Post('complete/:cashout_id')
|
||||
async complete(@Param('cashout_id') cashout_id: number) {
|
||||
return this.memberCashOutService.complete(cashout_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现统计
|
||||
*/
|
||||
@Get('statistics')
|
||||
async getStatistics(@Query() query: any) {
|
||||
return this.memberCashOutService.getStatistics(query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberConfigService } from '../../services/admin/MemberConfigService';
|
||||
|
||||
@Controller('adminapi/member/config')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberConfigController {
|
||||
constructor(private readonly memberConfigService: MemberConfigService) {}
|
||||
|
||||
/**
|
||||
* 获取会员配置
|
||||
*/
|
||||
@Get('info')
|
||||
async getInfo(@Query() query: any) {
|
||||
return this.memberConfigService.getInfo(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员配置
|
||||
*/
|
||||
@Put('edit')
|
||||
async update(@Body() dto: any) {
|
||||
return this.memberConfigService.update(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级配置
|
||||
*/
|
||||
@Get('level')
|
||||
async getLevelConfig(@Query() query: any) {
|
||||
return this.memberConfigService.getLevelConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员等级配置
|
||||
*/
|
||||
@Put('level')
|
||||
async updateLevelConfig(@Body() dto: any) {
|
||||
return this.memberConfigService.updateLevelConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分规则配置
|
||||
*/
|
||||
@Get('point')
|
||||
async getPointConfig(@Query() query: any) {
|
||||
return this.memberConfigService.getPointConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新积分规则配置
|
||||
*/
|
||||
@Put('point')
|
||||
async updatePointConfig(@Body() dto: any) {
|
||||
return this.memberConfigService.updatePointConfig(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberLabelService } from '../../services/admin/MemberLabelService';
|
||||
|
||||
@Controller('adminapi/member/label')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberLabelController {
|
||||
constructor(private readonly memberLabelService: MemberLabelService) {}
|
||||
|
||||
/**
|
||||
* 获取会员标签列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberLabelService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员标签详情
|
||||
*/
|
||||
@Get('info/:label_id')
|
||||
async getInfo(@Param('label_id') label_id: number) {
|
||||
return this.memberLabelService.getInfo(label_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员标签
|
||||
*/
|
||||
@Post('add')
|
||||
async create(@Body() dto: any) {
|
||||
return this.memberLabelService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员标签
|
||||
*/
|
||||
@Put('edit/:label_id')
|
||||
async update(@Param('label_id') label_id: number, @Body() dto: any) {
|
||||
return this.memberLabelService.update(label_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员标签
|
||||
*/
|
||||
@Delete('delete/:label_id')
|
||||
async delete(@Param('label_id') label_id: number) {
|
||||
return this.memberLabelService.delete(label_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给会员添加标签
|
||||
*/
|
||||
@Post('addToMember')
|
||||
async addToMember(@Body() dto: any) {
|
||||
return this.memberLabelService.addToMember(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除会员标签
|
||||
*/
|
||||
@Post('removeFromMember')
|
||||
async removeFromMember(@Body() dto: any) {
|
||||
return this.memberLabelService.removeFromMember(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberLevelService } from '../../services/admin/MemberLevelService';
|
||||
|
||||
@Controller('adminapi/member/level')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberLevelController {
|
||||
constructor(private readonly memberLevelService: MemberLevelService) {}
|
||||
|
||||
/**
|
||||
* 获取会员等级列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberLevelService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级详情
|
||||
*/
|
||||
@Get('info/:level_id')
|
||||
async getInfo(@Param('level_id') level_id: number) {
|
||||
return this.memberLevelService.getInfo(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员等级
|
||||
*/
|
||||
@Post('add')
|
||||
async create(@Body() dto: any) {
|
||||
return this.memberLevelService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员等级
|
||||
*/
|
||||
@Put('edit/:level_id')
|
||||
async update(@Param('level_id') level_id: number, @Body() dto: any) {
|
||||
return this.memberLevelService.update(level_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员等级
|
||||
*/
|
||||
@Delete('delete/:level_id')
|
||||
async delete(@Param('level_id') level_id: number) {
|
||||
return this.memberLevelService.delete(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认等级
|
||||
*/
|
||||
@Post('setDefault/:level_id')
|
||||
async setDefault(@Param('level_id') level_id: number) {
|
||||
return this.memberLevelService.setDefault(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取等级权益配置
|
||||
*/
|
||||
@Get('benefits/:level_id')
|
||||
async getBenefits(@Param('level_id') level_id: number) {
|
||||
return this.memberLevelService.getBenefits(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新等级权益配置
|
||||
*/
|
||||
@Put('benefits/:level_id')
|
||||
async updateBenefits(@Param('level_id') level_id: number, @Body() dto: any) {
|
||||
return this.memberLevelService.updateBenefits(level_id, dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { Controller, Get, Post, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
||||
import { Roles } from '../../../auth/decorators/RolesDecorator';
|
||||
import { MemberSignService } from '../../services/admin/MemberSignService';
|
||||
|
||||
@Controller('adminapi/member/sign')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin')
|
||||
export class MemberSignController {
|
||||
constructor(private readonly memberSignService: MemberSignService) {}
|
||||
|
||||
/**
|
||||
* 获取签到记录列表
|
||||
*/
|
||||
@Get('list')
|
||||
async getList(@Query() query: any) {
|
||||
return this.memberSignService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录详情
|
||||
*/
|
||||
@Get('info/:sign_id')
|
||||
async getInfo(@Param('sign_id') sign_id: number) {
|
||||
return this.memberSignService.getInfo(sign_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
*/
|
||||
@Get('statistics')
|
||||
async getStatistics(@Query() query: any) {
|
||||
return this.memberSignService.getStatistics(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到配置
|
||||
*/
|
||||
@Get('config')
|
||||
async getConfig(@Query() query: any) {
|
||||
return this.memberSignService.getConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到配置
|
||||
*/
|
||||
@Post('config')
|
||||
async updateConfig(@Body() dto: any) {
|
||||
return this.memberSignService.updateConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到奖励配置
|
||||
*/
|
||||
@Get('reward')
|
||||
async getRewardConfig(@Query() query: any) {
|
||||
return this.memberSignService.getRewardConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到奖励配置
|
||||
*/
|
||||
@Post('reward')
|
||||
async updateRewardConfig(@Body() dto: any) {
|
||||
return this.memberSignService.updateRewardConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动签到
|
||||
*/
|
||||
@Post('manual')
|
||||
async manualSign(@Body() dto: any) {
|
||||
return this.memberSignService.manualSign(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { MemberAccountService } from '../../services/api/MemberAccountService';
|
||||
import { AccountQueryDto } from '../../dto/api/AccountQueryDto';
|
||||
import { AccountCountDto } from '../../dto/api/AccountCountDto';
|
||||
import { CommissionQueryDto } from '../../dto/api/CommissionQueryDto';
|
||||
|
||||
@Controller('api/member/account')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class AccountController {
|
||||
constructor(private readonly memberAccountService: MemberAccountService) {}
|
||||
|
||||
/**
|
||||
* 积分流水
|
||||
*/
|
||||
@Get('point')
|
||||
async point(@Query() query: AccountQueryDto) {
|
||||
const data = {
|
||||
...query,
|
||||
account_type: 'point',
|
||||
};
|
||||
return this.memberAccountService.getPointPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额流水
|
||||
*/
|
||||
@Get('balance')
|
||||
async balance(@Query() query: AccountQueryDto) {
|
||||
const data = {
|
||||
...query,
|
||||
account_type: 'balance',
|
||||
};
|
||||
return this.memberAccountService.getPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额流水(新)
|
||||
*/
|
||||
@Get('balanceList')
|
||||
async balanceList(@Query() query: AccountQueryDto) {
|
||||
return this.memberAccountService.getBalancePage(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 零钱流水
|
||||
*/
|
||||
@Get('money')
|
||||
async money(@Query() query: AccountQueryDto) {
|
||||
const data = {
|
||||
...query,
|
||||
account_type: 'money',
|
||||
};
|
||||
return this.memberAccountService.getPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户记录数量
|
||||
*/
|
||||
@Get('count')
|
||||
async count(@Query() query: AccountCountDto) {
|
||||
return this.memberAccountService.getCount(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 佣金流水
|
||||
*/
|
||||
@Get('commission')
|
||||
async commission(@Query() query: CommissionQueryDto) {
|
||||
const data = {
|
||||
...query,
|
||||
account_type: 'commission',
|
||||
};
|
||||
return this.memberAccountService.getPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户来源
|
||||
*/
|
||||
@Get('fromType/:account_type')
|
||||
async getFromType(@Query('account_type') account_type: string) {
|
||||
// 验证账户类型是否存在
|
||||
const validTypes = ['point', 'balance', 'money', 'commission'];
|
||||
if (!validTypes.includes(account_type)) {
|
||||
throw new Error('MEMBER_TYPE_NOT_EXIST');
|
||||
}
|
||||
return this.memberAccountService.getFromType(account_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分数量
|
||||
*/
|
||||
@Get('pointCount')
|
||||
async pointCount() {
|
||||
return this.memberAccountService.getPointCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { AddressService } from '../../services/api/AddressService';
|
||||
import { AddAddressDto } from '../../dto/api/AddAddressDto';
|
||||
import { EditAddressDto } from '../../dto/api/EditAddressDto';
|
||||
|
||||
@Controller('api/member/address')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class AddressController {
|
||||
constructor(private readonly addressService: AddressService) {}
|
||||
|
||||
/**
|
||||
* 获取会员收货地址列表
|
||||
*/
|
||||
@Get('lists')
|
||||
async lists() {
|
||||
return this.addressService.getList({});
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址详情
|
||||
*/
|
||||
@Get('info/:id')
|
||||
async info(@Param('id') id: number) {
|
||||
return this.addressService.getInfo(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员收货地址
|
||||
*/
|
||||
@Post('add')
|
||||
async add(@Body() dto: AddAddressDto) {
|
||||
const id = await this.addressService.add(dto);
|
||||
return { message: 'ADD_SUCCESS', data: { id } };
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址编辑
|
||||
*/
|
||||
@Put('edit/:id')
|
||||
async edit(@Param('id') id: number, @Body() dto: EditAddressDto) {
|
||||
await this.addressService.edit(id, dto);
|
||||
return { message: 'EDIT_SUCCESS' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址删除
|
||||
*/
|
||||
@Delete('del/:id')
|
||||
async del(@Param('id') id: number) {
|
||||
await this.addressService.del(id);
|
||||
return { message: 'DELETE_SUCCESS' };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { MemberCashOutAccountService } from '../../services/api/MemberCashOutAccountService';
|
||||
import { CashOutAccountQueryDto } from '../../dto/api/CashOutAccountQueryDto';
|
||||
import { AddCashOutAccountDto } from '../../dto/api/AddCashOutAccountDto';
|
||||
import { EditCashOutAccountDto } from '../../dto/api/EditCashOutAccountDto';
|
||||
|
||||
@Controller('api/member/cashOutAccount')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class CashOutAccountController {
|
||||
constructor(private readonly memberCashOutAccountService: MemberCashOutAccountService) {}
|
||||
|
||||
/**
|
||||
* 提现账户列表
|
||||
*/
|
||||
@Get('lists')
|
||||
async lists(@Query() query: CashOutAccountQueryDto) {
|
||||
return this.memberCashOutAccountService.getPage(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现账户信息
|
||||
*/
|
||||
@Get('info/:account_id')
|
||||
async info(@Param('account_id') account_id: number) {
|
||||
return this.memberCashOutAccountService.getInfo(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询首条提现账户按账户类型
|
||||
*/
|
||||
@Get('firstInfo')
|
||||
async firstInfo(@Query() query: CashOutAccountQueryDto) {
|
||||
return this.memberCashOutAccountService.getFirstInfo(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加提现账号
|
||||
*/
|
||||
@Post('add')
|
||||
async add(@Body() dto: AddCashOutAccountDto) {
|
||||
const id = await this.memberCashOutAccountService.add(dto);
|
||||
return { message: 'ADD_SUCCESS', data: { id } };
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑提现账号
|
||||
*/
|
||||
@Put('edit/:account_id')
|
||||
async edit(@Param('account_id') account_id: number, @Body() dto: EditCashOutAccountDto) {
|
||||
await this.memberCashOutAccountService.edit(account_id, dto);
|
||||
return { message: 'EDIT_SUCCESS' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提现账号
|
||||
*/
|
||||
@Delete('del/:account_id')
|
||||
async del(@Param('account_id') account_id: number) {
|
||||
await this.memberCashOutAccountService.del(account_id);
|
||||
return { message: 'DELETE_SUCCESS' };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { MemberLevelService } from '../../services/api/MemberLevelService';
|
||||
|
||||
@Controller('api/member/level')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class LevelController {
|
||||
constructor(private readonly memberLevelService: MemberLevelService) {}
|
||||
|
||||
/**
|
||||
* 会员等级列表
|
||||
*/
|
||||
@Get('lists')
|
||||
async lists() {
|
||||
return this.memberLevelService.getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { MemberCashOutService } from '../../services/api/MemberCashOutService';
|
||||
import { CashOutQueryDto } from '../../dto/api/CashOutQueryDto';
|
||||
import { ApplyCashOutDto } from '../../dto/api/ApplyCashOutDto';
|
||||
import { TransferCashOutDto } from '../../dto/api/TransferCashOutDto';
|
||||
|
||||
@Controller('api/member/cashOut')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class MemberCashOutController {
|
||||
constructor(private readonly memberCashOutService: MemberCashOutService) {}
|
||||
|
||||
/**
|
||||
* 会员提现列表
|
||||
*/
|
||||
@Get('lists')
|
||||
async lists(@Query() query: CashOutQueryDto) {
|
||||
return this.memberCashOutService.getPage(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
*/
|
||||
@Get('info/:id')
|
||||
async info(@Param('id') id: number) {
|
||||
return this.memberCashOutService.getInfo(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现配置
|
||||
*/
|
||||
@Get('config')
|
||||
async config() {
|
||||
return this.memberCashOutService.getCashOutConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账方式
|
||||
*/
|
||||
@Get('getTransferType')
|
||||
async getTransferType() {
|
||||
return this.memberCashOutService.getTransferType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
*/
|
||||
@Post('apply')
|
||||
async apply(@Body() dto: ApplyCashOutDto) {
|
||||
return this.memberCashOutService.apply(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销提现申请
|
||||
*/
|
||||
@Put('cancel/:id')
|
||||
async cancel(@Param('id') id: number) {
|
||||
return this.memberCashOutService.cancel(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始转账
|
||||
*/
|
||||
@Put('transfer/:id')
|
||||
async transfer(@Param('id') id: number, @Body() dto: TransferCashOutDto) {
|
||||
return this.memberCashOutService.transfer(id, dto);
|
||||
}
|
||||
}
|
||||
@@ -1,183 +1,91 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
Request,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiBearerAuth,
|
||||
} from '@nestjs/swagger';
|
||||
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { MemberService } from '../../services/api/MemberService';
|
||||
import {
|
||||
CreateMemberApiDto,
|
||||
UpdateProfileDto,
|
||||
ChangePasswordDto,
|
||||
ResetPasswordDto,
|
||||
SignDto,
|
||||
} from '../../dto/api/MemberDto';
|
||||
import { AuthService } from '../../../auth/services/AuthService';
|
||||
import { MemberLogService } from '../../services/api/MemberLogService';
|
||||
import { ModifyMemberDto } from '../../dto/api/ModifyMemberDto';
|
||||
import { EditMemberDto } from '../../dto/api/EditMemberDto';
|
||||
import { BindMobileDto } from '../../dto/api/BindMobileDto';
|
||||
import { MemberLogDto } from '../../dto/api/MemberLogDto';
|
||||
import { GetMobileDto } from '../../dto/api/GetMobileDto';
|
||||
|
||||
@ApiTags('前台-会员管理')
|
||||
@ApiBearerAuth()
|
||||
@Controller('api/member')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class MemberController {
|
||||
constructor(private readonly memberService: MemberService) {}
|
||||
constructor(
|
||||
private readonly memberService: MemberService,
|
||||
private readonly authService: AuthService,
|
||||
private readonly memberLogService: MemberLogService,
|
||||
) {}
|
||||
|
||||
@Post('register')
|
||||
@ApiOperation({ summary: '会员注册' })
|
||||
@ApiResponse({ status: 201, description: '注册成功' })
|
||||
async register(@Body() createMemberDto: CreateMemberApiDto) {
|
||||
return await this.memberService.register(createMemberDto);
|
||||
/**
|
||||
* 会员信息
|
||||
*/
|
||||
@Get('info')
|
||||
async info() {
|
||||
return this.memberService.getInfo();
|
||||
}
|
||||
|
||||
@Post('login')
|
||||
@ApiOperation({ summary: '会员登录' })
|
||||
@ApiResponse({ status: 200, description: '登录成功' })
|
||||
async login(
|
||||
@Body()
|
||||
loginDto: {
|
||||
username: string;
|
||||
password: string;
|
||||
ip?: string;
|
||||
address?: string;
|
||||
device?: string;
|
||||
},
|
||||
) {
|
||||
return await this.memberService.login(loginDto);
|
||||
/**
|
||||
* 会员中心
|
||||
*/
|
||||
@Get('center')
|
||||
async center() {
|
||||
return this.memberService.center();
|
||||
}
|
||||
|
||||
@Get('profile')
|
||||
@ApiOperation({ summary: '获取个人资料' })
|
||||
@ApiResponse({ status: 200, description: '获取成功' })
|
||||
async getProfile(@Request() req: any) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.getProfile(memberId);
|
||||
/**
|
||||
* 修改会员
|
||||
*/
|
||||
@Put('modify/:field')
|
||||
async modify(@Param('field') field: string, @Body() dto: ModifyMemberDto) {
|
||||
const data = {
|
||||
[field]: dto.value,
|
||||
member_id: dto.member_id,
|
||||
};
|
||||
await this.memberService.modify(field, dto.value);
|
||||
return { message: 'MODIFY_SUCCESS' };
|
||||
}
|
||||
|
||||
@Put('profile')
|
||||
@ApiOperation({ summary: '更新个人资料' })
|
||||
@ApiResponse({ status: 200, description: '更新成功' })
|
||||
async updateProfile(
|
||||
@Request() req: any,
|
||||
@Body() updateProfileDto: UpdateProfileDto,
|
||||
) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.updateProfile(memberId, updateProfileDto);
|
||||
/**
|
||||
* 编辑会员
|
||||
*/
|
||||
@Put('edit')
|
||||
async edit(@Body() dto: EditMemberDto) {
|
||||
await this.memberService.edit(dto.data);
|
||||
return { message: 'MODIFY_SUCCESS' };
|
||||
}
|
||||
|
||||
@Post('change-password')
|
||||
@ApiOperation({ summary: '修改密码' })
|
||||
@ApiResponse({ status: 200, description: '修改成功' })
|
||||
async changePassword(
|
||||
@Request() req: any,
|
||||
@Body() changePasswordDto: ChangePasswordDto,
|
||||
) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.changePassword(memberId, changePasswordDto);
|
||||
/**
|
||||
* 绑定手机号
|
||||
*/
|
||||
@Post('mobile')
|
||||
async mobile(@Body() dto: BindMobileDto) {
|
||||
return this.authService.bindMobile(dto.mobile, dto.mobile_code);
|
||||
}
|
||||
|
||||
@Post('reset-password')
|
||||
@ApiOperation({ summary: '重置密码' })
|
||||
@ApiResponse({ status: 200, description: '重置成功' })
|
||||
async resetPassword(@Body() resetPasswordDto: ResetPasswordDto) {
|
||||
return await this.memberService.resetPassword(resetPasswordDto);
|
||||
/**
|
||||
* 会员日志
|
||||
*/
|
||||
@Post('log')
|
||||
async log(@Body() dto: MemberLogDto) {
|
||||
await this.memberLogService.log(dto);
|
||||
return { message: 'SUCCESS' };
|
||||
}
|
||||
|
||||
@Post('sign')
|
||||
@ApiOperation({ summary: '会员签到' })
|
||||
@ApiResponse({ status: 200, description: '签到成功' })
|
||||
async sign(@Request() req: any, @Body() signDto: SignDto) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.sign(memberId, signDto);
|
||||
/**
|
||||
* 获取会员码
|
||||
*/
|
||||
@Get('qrcode')
|
||||
async qrcode() {
|
||||
return this.memberService.getQrcode();
|
||||
}
|
||||
|
||||
@Get('points/history')
|
||||
@ApiOperation({ summary: '获取积分历史' })
|
||||
@ApiResponse({ status: 200, description: '获取成功' })
|
||||
async getPointsHistory(
|
||||
@Request() req: any,
|
||||
@Query() query: { page?: number; limit?: number },
|
||||
) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.getPointsHistory(memberId, query);
|
||||
/**
|
||||
* 获取手机号
|
||||
*/
|
||||
@Post('getMobile')
|
||||
async getMobile(@Body() dto: GetMobileDto) {
|
||||
return this.authService.getMobile(dto.mobile_code);
|
||||
}
|
||||
|
||||
@Get('balance/history')
|
||||
@ApiOperation({ summary: '获取余额历史' })
|
||||
@ApiResponse({ status: 200, description: '获取成功' })
|
||||
async getBalanceHistory(
|
||||
@Request() req: any,
|
||||
@Query() query: { page?: number; limit?: number },
|
||||
) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.getBalanceHistory(memberId, query);
|
||||
}
|
||||
|
||||
@Get('address')
|
||||
@ApiOperation({ summary: '获取地址列表' })
|
||||
@ApiResponse({ status: 200, description: '获取成功' })
|
||||
async getAddressList(@Request() req: any) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.getAddressList(memberId);
|
||||
}
|
||||
|
||||
@Post('address')
|
||||
@ApiOperation({ summary: '添加地址' })
|
||||
@ApiResponse({ status: 201, description: '添加成功' })
|
||||
async addAddress(@Request() req: any, @Body() addressDto: any) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.addAddress(memberId, addressDto);
|
||||
}
|
||||
|
||||
@Put('address/:id')
|
||||
@ApiOperation({ summary: '更新地址' })
|
||||
@ApiResponse({ status: 200, description: '更新成功' })
|
||||
async updateAddress(
|
||||
@Request() req: any,
|
||||
@Param('id') id: number,
|
||||
@Body() addressDto: any,
|
||||
) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.updateAddress(memberId, id, addressDto);
|
||||
}
|
||||
|
||||
@Delete('address/:id')
|
||||
@ApiOperation({ summary: '删除地址' })
|
||||
@ApiResponse({ status: 200, description: '删除成功' })
|
||||
async deleteAddress(@Request() req: any, @Param('id') id: number) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.deleteAddress(memberId, id);
|
||||
}
|
||||
|
||||
@Post('address/:id/default')
|
||||
@ApiOperation({ summary: '设置默认地址' })
|
||||
@ApiResponse({ status: 200, description: '设置成功' })
|
||||
async setDefaultAddress(@Request() req: any, @Param('id') id: number) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.setDefaultAddress(memberId, id);
|
||||
}
|
||||
|
||||
@Get('level')
|
||||
@ApiOperation({ summary: '获取会员等级信息' })
|
||||
@ApiResponse({ status: 200, description: '获取成功' })
|
||||
async getMemberLevel(@Request() req: any) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.getMemberLevel(memberId);
|
||||
}
|
||||
|
||||
@Get('logout')
|
||||
@ApiOperation({ summary: '会员登出' })
|
||||
@ApiResponse({ status: 200, description: '登出成功' })
|
||||
async logout(@Request() req: any) {
|
||||
const memberId = req.user.member_id;
|
||||
return await this.memberService.logout(memberId);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
wwjcloud/src/common/member/dto/api/AccountCountDto.ts
Normal file
11
wwjcloud/src/common/member/dto/api/AccountCountDto.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
|
||||
export class AccountCountDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
from_type?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
account_type?: string;
|
||||
}
|
||||
19
wwjcloud/src/common/member/dto/api/AccountQueryDto.ts
Normal file
19
wwjcloud/src/common/member/dto/api/AccountQueryDto.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { IsString, IsOptional, IsArray } from 'class-validator';
|
||||
|
||||
export class AccountQueryDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
from_type?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
amount_type?: string;
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
create_time?: string[];
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
trade_type?: string;
|
||||
}
|
||||
40
wwjcloud/src/common/member/dto/api/AddAddressDto.ts
Normal file
40
wwjcloud/src/common/member/dto/api/AddAddressDto.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { IsString, IsNumber, IsOptional } from 'class-validator';
|
||||
|
||||
export class AddAddressDto {
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsString()
|
||||
mobile: string;
|
||||
|
||||
@IsNumber()
|
||||
province_id: number;
|
||||
|
||||
@IsNumber()
|
||||
city_id: number;
|
||||
|
||||
@IsNumber()
|
||||
district_id: number;
|
||||
|
||||
@IsString()
|
||||
address: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
address_name?: string;
|
||||
|
||||
@IsString()
|
||||
full_address: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
lng?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
lat?: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
is_default?: number;
|
||||
}
|
||||
23
wwjcloud/src/common/member/dto/api/AddCashOutAccountDto.ts
Normal file
23
wwjcloud/src/common/member/dto/api/AddCashOutAccountDto.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class AddCashOutAccountDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
account_type: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
bank_name: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
realname: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
account_no: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
transfer_payment_code: string;
|
||||
}
|
||||
23
wwjcloud/src/common/member/dto/api/ApplyCashOutDto.ts
Normal file
23
wwjcloud/src/common/member/dto/api/ApplyCashOutDto.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { IsNumber, IsString, IsNotEmpty, IsArray } from 'class-validator';
|
||||
|
||||
export class ApplyCashOutDto {
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
apply_money: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
account_type: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
transfer_type: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
account_id: number;
|
||||
|
||||
@IsArray()
|
||||
@IsNotEmpty()
|
||||
transfer_payee: any[];
|
||||
}
|
||||
11
wwjcloud/src/common/member/dto/api/BindMobileDto.ts
Normal file
11
wwjcloud/src/common/member/dto/api/BindMobileDto.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class BindMobileDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
mobile: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
mobile_code: string;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
|
||||
export class CashOutAccountQueryDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
account_type?: string;
|
||||
}
|
||||
11
wwjcloud/src/common/member/dto/api/CashOutQueryDto.ts
Normal file
11
wwjcloud/src/common/member/dto/api/CashOutQueryDto.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
|
||||
export class CashOutQueryDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
status?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
account_type?: string;
|
||||
}
|
||||
23
wwjcloud/src/common/member/dto/api/CommissionQueryDto.ts
Normal file
23
wwjcloud/src/common/member/dto/api/CommissionQueryDto.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { IsString, IsOptional, IsArray } from 'class-validator';
|
||||
|
||||
export class CommissionQueryDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
keyword?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
from_type?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
account_data_gt?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
account_data_lt?: string;
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
create_time?: string[];
|
||||
}
|
||||
40
wwjcloud/src/common/member/dto/api/EditAddressDto.ts
Normal file
40
wwjcloud/src/common/member/dto/api/EditAddressDto.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { IsString, IsNumber, IsOptional } from 'class-validator';
|
||||
|
||||
export class EditAddressDto {
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsString()
|
||||
mobile: string;
|
||||
|
||||
@IsNumber()
|
||||
province_id: number;
|
||||
|
||||
@IsNumber()
|
||||
city_id: number;
|
||||
|
||||
@IsNumber()
|
||||
district_id: number;
|
||||
|
||||
@IsString()
|
||||
address: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
address_name?: string;
|
||||
|
||||
@IsString()
|
||||
full_address: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
lng?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
lat?: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
is_default?: number;
|
||||
}
|
||||
23
wwjcloud/src/common/member/dto/api/EditCashOutAccountDto.ts
Normal file
23
wwjcloud/src/common/member/dto/api/EditCashOutAccountDto.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class EditCashOutAccountDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
account_type: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
bank_name: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
realname: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
account_no: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
transfer_payment_code: string;
|
||||
}
|
||||
7
wwjcloud/src/common/member/dto/api/EditMemberDto.ts
Normal file
7
wwjcloud/src/common/member/dto/api/EditMemberDto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsObject, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class EditMemberDto {
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
data: Record<string, any>;
|
||||
}
|
||||
7
wwjcloud/src/common/member/dto/api/GetMobileDto.ts
Normal file
7
wwjcloud/src/common/member/dto/api/GetMobileDto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class GetMobileDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
mobile_code: string;
|
||||
}
|
||||
15
wwjcloud/src/common/member/dto/api/MemberLogDto.ts
Normal file
15
wwjcloud/src/common/member/dto/api/MemberLogDto.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
|
||||
export class MemberLogDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
route?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
params?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
pre_route?: string;
|
||||
}
|
||||
15
wwjcloud/src/common/member/dto/api/ModifyMemberDto.ts
Normal file
15
wwjcloud/src/common/member/dto/api/ModifyMemberDto.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class ModifyMemberDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
value: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
field: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
member_id: string;
|
||||
}
|
||||
7
wwjcloud/src/common/member/dto/api/TransferCashOutDto.ts
Normal file
7
wwjcloud/src/common/member/dto/api/TransferCashOutDto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsNumber, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class TransferCashOutDto {
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
open_id: number;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { BaseEntity } from '@wwjCore/base/BaseEntity';
|
||||
import { BaseEntity } from '../../../core/base/BaseEntity';
|
||||
import { MemberAccount } from './MemberAccount';
|
||||
import { MemberCashOut } from './MemberCashOut';
|
||||
import { MemberLabel } from './MemberLabel';
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { BaseEntity } from '@wwjCore/base/BaseEntity';
|
||||
import { BaseEntity } from '../../../core/base/BaseEntity';
|
||||
import { Member } from './Member';
|
||||
|
||||
@Entity('member_address')
|
||||
|
||||
@@ -14,9 +14,41 @@ import { MemberBalance } from './entities/MemberBalance';
|
||||
import { MemberConfig } from './entities/MemberConfig';
|
||||
import { CoreMemberService } from './services/core/CoreMemberService';
|
||||
import { MemberService as MemberApiService } from './services/api/MemberService';
|
||||
import { MemberAccountService } from './services/api/MemberAccountService';
|
||||
import { AddressService } from './services/api/AddressService';
|
||||
import { MemberLogService } from './services/api/MemberLogService';
|
||||
import { MemberCashOutAccountService } from './services/api/MemberCashOutAccountService';
|
||||
import { MemberLevelService } from './services/api/MemberLevelService';
|
||||
import { MemberCashOutService } from './services/api/MemberCashOutService';
|
||||
import { MemberService as MemberAdminService } from './services/admin/MemberService';
|
||||
import { MemberAccountService as MemberAccountAdminService } from './services/admin/MemberAccountService';
|
||||
import { MemberAddressService } from './services/admin/MemberAddressService';
|
||||
import { MemberCashOutService as MemberCashOutAdminService } from './services/admin/MemberCashOutService';
|
||||
import { MemberConfigService } from './services/admin/MemberConfigService';
|
||||
import { MemberLabelService } from './services/admin/MemberLabelService';
|
||||
import { MemberLevelService as MemberLevelAdminService } from './services/admin/MemberLevelService';
|
||||
import { MemberSignService } from './services/admin/MemberSignService';
|
||||
import { CoreMemberAccountService } from './services/core/CoreMemberAccountService';
|
||||
import { CoreMemberAddressService } from './services/core/CoreMemberAddressService';
|
||||
import { CoreMemberCashOutService } from './services/core/CoreMemberCashOutService';
|
||||
import { CoreMemberConfigService } from './services/core/CoreMemberConfigService';
|
||||
import { CoreMemberLabelService } from './services/core/CoreMemberLabelService';
|
||||
import { CoreMemberLevelService } from './services/core/CoreMemberLevelService';
|
||||
import { CoreMemberSignService } from './services/core/CoreMemberSignService';
|
||||
import { MemberController as MemberApiController } from './controllers/api/MemberController';
|
||||
import { AccountController } from './controllers/api/AccountController';
|
||||
import { AddressController } from './controllers/api/AddressController';
|
||||
import { CashOutAccountController } from './controllers/api/CashOutAccountController';
|
||||
import { LevelController } from './controllers/api/LevelController';
|
||||
import { MemberCashOutController } from './controllers/api/MemberCashOutController';
|
||||
import { MemberController as MemberAdminController } from './controllers/adminapi/MemberController';
|
||||
import { MemberAccountController } from './controllers/adminapi/MemberAccountController';
|
||||
import { MemberAddressController } from './controllers/adminapi/MemberAddressController';
|
||||
import { MemberCashOutController as MemberCashOutAdminController } from './controllers/adminapi/MemberCashOutController';
|
||||
import { MemberConfigController } from './controllers/adminapi/MemberConfigController';
|
||||
import { MemberLabelController } from './controllers/adminapi/MemberLabelController';
|
||||
import { MemberLevelController } from './controllers/adminapi/MemberLevelController';
|
||||
import { MemberSignController } from './controllers/adminapi/MemberSignController';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -35,8 +67,71 @@ import { MemberController as MemberAdminController } from './controllers/adminap
|
||||
MemberConfig,
|
||||
]),
|
||||
],
|
||||
providers: [CoreMemberService, MemberApiService, MemberAdminService],
|
||||
controllers: [MemberApiController, MemberAdminController],
|
||||
exports: [CoreMemberService, MemberApiService, MemberAdminService],
|
||||
providers: [
|
||||
CoreMemberService,
|
||||
MemberApiService,
|
||||
MemberAccountService,
|
||||
AddressService,
|
||||
MemberLogService,
|
||||
MemberCashOutAccountService,
|
||||
MemberLevelService,
|
||||
MemberCashOutService,
|
||||
MemberAdminService,
|
||||
MemberAccountAdminService,
|
||||
MemberAddressService,
|
||||
MemberCashOutAdminService,
|
||||
MemberConfigService,
|
||||
MemberLabelService,
|
||||
MemberLevelAdminService,
|
||||
MemberSignService,
|
||||
CoreMemberAccountService,
|
||||
CoreMemberAddressService,
|
||||
CoreMemberCashOutService,
|
||||
CoreMemberConfigService,
|
||||
CoreMemberLabelService,
|
||||
CoreMemberLevelService,
|
||||
CoreMemberSignService,
|
||||
],
|
||||
controllers: [
|
||||
MemberApiController,
|
||||
AccountController,
|
||||
AddressController,
|
||||
CashOutAccountController,
|
||||
LevelController,
|
||||
MemberCashOutController,
|
||||
MemberAdminController,
|
||||
MemberAccountController,
|
||||
MemberAddressController,
|
||||
MemberCashOutAdminController,
|
||||
MemberConfigController,
|
||||
MemberLabelController,
|
||||
MemberLevelController,
|
||||
MemberSignController,
|
||||
],
|
||||
exports: [
|
||||
CoreMemberService,
|
||||
MemberApiService,
|
||||
MemberAccountService,
|
||||
AddressService,
|
||||
MemberLogService,
|
||||
MemberCashOutAccountService,
|
||||
MemberLevelService,
|
||||
MemberCashOutService,
|
||||
MemberAdminService,
|
||||
MemberAccountAdminService,
|
||||
MemberAddressService,
|
||||
MemberCashOutAdminService,
|
||||
MemberConfigService,
|
||||
MemberLabelService,
|
||||
MemberLevelAdminService,
|
||||
MemberSignService,
|
||||
CoreMemberAccountService,
|
||||
CoreMemberAddressService,
|
||||
CoreMemberCashOutService,
|
||||
CoreMemberConfigService,
|
||||
CoreMemberLabelService,
|
||||
CoreMemberLevelService,
|
||||
CoreMemberSignService,
|
||||
],
|
||||
})
|
||||
export class MemberModule {}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberAccountService } from '../core/CoreMemberAccountService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberAccountService {
|
||||
constructor(private readonly coreMemberAccountService: CoreMemberAccountService) {}
|
||||
|
||||
/**
|
||||
* 获取会员账户列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberAccountService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员账户详情
|
||||
*/
|
||||
async getInfo(account_id: number) {
|
||||
return this.coreMemberAccountService.getInfo(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员账户
|
||||
*/
|
||||
async create(dto: any) {
|
||||
return this.coreMemberAccountService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员账户
|
||||
*/
|
||||
async update(account_id: number, dto: any) {
|
||||
return this.coreMemberAccountService.update(account_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员账户
|
||||
*/
|
||||
async delete(account_id: number) {
|
||||
return this.coreMemberAccountService.delete(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整账户余额
|
||||
*/
|
||||
async adjust(dto: any) {
|
||||
return this.coreMemberAccountService.adjust(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账户变动记录
|
||||
*/
|
||||
async getLog(account_id: number, query: any) {
|
||||
return this.coreMemberAccountService.getLog(account_id, query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberAddressService } from '../core/CoreMemberAddressService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberAddressService {
|
||||
constructor(private readonly coreMemberAddressService: CoreMemberAddressService) {}
|
||||
|
||||
/**
|
||||
* 获取会员地址列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberAddressService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员地址详情
|
||||
*/
|
||||
async getInfo(address_id: number) {
|
||||
return this.coreMemberAddressService.getInfo(address_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员地址
|
||||
*/
|
||||
async create(dto: any) {
|
||||
return this.coreMemberAddressService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员地址
|
||||
*/
|
||||
async update(address_id: number, dto: any) {
|
||||
return this.coreMemberAddressService.update(address_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员地址
|
||||
*/
|
||||
async delete(address_id: number) {
|
||||
return this.coreMemberAddressService.delete(address_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
*/
|
||||
async setDefault(address_id: number) {
|
||||
return this.coreMemberAddressService.setDefault(address_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberCashOutService } from '../core/CoreMemberCashOutService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberCashOutService {
|
||||
constructor(private readonly coreMemberCashOutService: CoreMemberCashOutService) {}
|
||||
|
||||
/**
|
||||
* 获取提现申请列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberCashOutService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现申请详情
|
||||
*/
|
||||
async getInfo(cashout_id: number) {
|
||||
return this.coreMemberCashOutService.getInfo(cashout_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核提现申请
|
||||
*/
|
||||
async audit(cashout_id: number, dto: any) {
|
||||
return this.coreMemberCashOutService.audit(cashout_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝提现申请
|
||||
*/
|
||||
async reject(cashout_id: number, dto: any) {
|
||||
return this.coreMemberCashOutService.reject(cashout_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成提现
|
||||
*/
|
||||
async complete(cashout_id: number) {
|
||||
return this.coreMemberCashOutService.complete(cashout_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现统计
|
||||
*/
|
||||
async getStatistics(query: any) {
|
||||
return this.coreMemberCashOutService.getStatistics(query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberConfigService } from '../core/CoreMemberConfigService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberConfigService {
|
||||
constructor(private readonly coreMemberConfigService: CoreMemberConfigService) {}
|
||||
|
||||
/**
|
||||
* 获取会员配置
|
||||
*/
|
||||
async getInfo(query: any) {
|
||||
return this.coreMemberConfigService.getInfo(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员配置
|
||||
*/
|
||||
async update(dto: any) {
|
||||
return this.coreMemberConfigService.update(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级配置
|
||||
*/
|
||||
async getLevelConfig(query: any) {
|
||||
return this.coreMemberConfigService.getLevelConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员等级配置
|
||||
*/
|
||||
async updateLevelConfig(dto: any) {
|
||||
return this.coreMemberConfigService.updateLevelConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分规则配置
|
||||
*/
|
||||
async getPointConfig(query: any) {
|
||||
return this.coreMemberConfigService.getPointConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新积分规则配置
|
||||
*/
|
||||
async updatePointConfig(dto: any) {
|
||||
return this.coreMemberConfigService.updatePointConfig(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberLabelService } from '../core/CoreMemberLabelService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberLabelService {
|
||||
constructor(private readonly coreMemberLabelService: CoreMemberLabelService) {}
|
||||
|
||||
/**
|
||||
* 获取会员标签列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberLabelService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员标签详情
|
||||
*/
|
||||
async getInfo(label_id: number) {
|
||||
return this.coreMemberLabelService.getInfo(label_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员标签
|
||||
*/
|
||||
async create(dto: any) {
|
||||
return this.coreMemberLabelService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员标签
|
||||
*/
|
||||
async update(label_id: number, dto: any) {
|
||||
return this.coreMemberLabelService.update(label_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员标签
|
||||
*/
|
||||
async delete(label_id: number) {
|
||||
return this.coreMemberLabelService.delete(label_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给会员添加标签
|
||||
*/
|
||||
async addToMember(dto: any) {
|
||||
return this.coreMemberLabelService.addToMember(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除会员标签
|
||||
*/
|
||||
async removeFromMember(dto: any) {
|
||||
return this.coreMemberLabelService.removeFromMember(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberLevelService } from '../core/CoreMemberLevelService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberLevelService {
|
||||
constructor(private readonly coreMemberLevelService: CoreMemberLevelService) {}
|
||||
|
||||
/**
|
||||
* 获取会员等级列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberLevelService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级详情
|
||||
*/
|
||||
async getInfo(level_id: number) {
|
||||
return this.coreMemberLevelService.getInfo(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建会员等级
|
||||
*/
|
||||
async create(dto: any) {
|
||||
return this.coreMemberLevelService.create(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员等级
|
||||
*/
|
||||
async update(level_id: number, dto: any) {
|
||||
return this.coreMemberLevelService.update(level_id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员等级
|
||||
*/
|
||||
async delete(level_id: number) {
|
||||
return this.coreMemberLevelService.delete(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认等级
|
||||
*/
|
||||
async setDefault(level_id: number) {
|
||||
return this.coreMemberLevelService.setDefault(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取等级权益配置
|
||||
*/
|
||||
async getBenefits(level_id: number) {
|
||||
return this.coreMemberLevelService.getBenefits(level_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新等级权益配置
|
||||
*/
|
||||
async updateBenefits(level_id: number, dto: any) {
|
||||
return this.coreMemberLevelService.updateBenefits(level_id, dto);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@ import { MemberLevel } from '../../entities/MemberLevel';
|
||||
import { MemberAddress } from '../../entities/MemberAddress';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { CreateMemberAdminDto, UpdateMemberDto } from '../../dto/admin/MemberDto';
|
||||
import {
|
||||
CreateMemberAdminDto,
|
||||
UpdateMemberDto,
|
||||
} from '../../dto/admin/MemberDto';
|
||||
|
||||
@Injectable()
|
||||
export class MemberService {
|
||||
@@ -120,8 +123,9 @@ export class MemberService {
|
||||
throw new Error('用户名已存在');
|
||||
}
|
||||
|
||||
// 创建会员
|
||||
const member = await this.memberCoreService.createMember(memberData);
|
||||
// 创建会员 - 排除addresses字段
|
||||
const { addresses, ...memberCreateData } = memberData;
|
||||
const member = await this.memberCoreService.createMember(memberCreateData);
|
||||
|
||||
// 创建会员地址
|
||||
if (memberData.addresses && memberData.addresses.length > 0) {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberSignService } from '../core/CoreMemberSignService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberSignService {
|
||||
constructor(private readonly coreMemberSignService: CoreMemberSignService) {}
|
||||
|
||||
/**
|
||||
* 获取签到记录列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
return this.coreMemberSignService.getList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录详情
|
||||
*/
|
||||
async getInfo(sign_id: number) {
|
||||
return this.coreMemberSignService.getInfo(sign_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
*/
|
||||
async getStatistics(query: any) {
|
||||
return this.coreMemberSignService.getStatistics(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到配置
|
||||
*/
|
||||
async getConfig(query: any) {
|
||||
return this.coreMemberSignService.getConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到配置
|
||||
*/
|
||||
async updateConfig(dto: any) {
|
||||
return this.coreMemberSignService.updateConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到奖励配置
|
||||
*/
|
||||
async getRewardConfig(query: any) {
|
||||
return this.coreMemberSignService.getRewardConfig(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到奖励配置
|
||||
*/
|
||||
async updateRewardConfig(dto: any) {
|
||||
return this.coreMemberSignService.updateRewardConfig(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动签到
|
||||
*/
|
||||
async manualSign(dto: any) {
|
||||
return this.coreMemberSignService.manualSign(dto);
|
||||
}
|
||||
}
|
||||
42
wwjcloud/src/common/member/services/api/AddressService.ts
Normal file
42
wwjcloud/src/common/member/services/api/AddressService.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class AddressService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 获取地址列表
|
||||
*/
|
||||
async getList(data: any) {
|
||||
return this.coreMemberService.getAddressList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址详情
|
||||
*/
|
||||
async getInfo(id: number) {
|
||||
return this.coreMemberService.getAddressInfo(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加地址
|
||||
*/
|
||||
async add(data: any) {
|
||||
return this.coreMemberService.addAddress(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑地址
|
||||
*/
|
||||
async edit(id: number, data: any) {
|
||||
return this.coreMemberService.editAddress(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地址
|
||||
*/
|
||||
async del(id: number) {
|
||||
return this.coreMemberService.delAddress(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberAccountService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 积分分页
|
||||
*/
|
||||
async getPointPage(data: any) {
|
||||
return this.coreMemberService.getPointPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户分页
|
||||
*/
|
||||
async getPage(data: any) {
|
||||
return this.coreMemberService.getPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额分页
|
||||
*/
|
||||
async getBalancePage(data: any) {
|
||||
return this.coreMemberService.getBalancePage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数量
|
||||
*/
|
||||
async getCount(data: any) {
|
||||
return this.coreMemberService.getCount(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取来源类型
|
||||
*/
|
||||
async getFromType(account_type: string) {
|
||||
return this.coreMemberService.getFromType(account_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分数量
|
||||
*/
|
||||
async getPointCount() {
|
||||
return this.coreMemberService.getPointCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberCashOutAccountService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 获取提现账户分页
|
||||
*/
|
||||
async getPage(data: any) {
|
||||
return this.coreMemberService.getCashOutAccountPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现账户信息
|
||||
*/
|
||||
async getInfo(account_id: number) {
|
||||
return this.coreMemberService.getCashOutAccountInfo(account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首条提现账户信息
|
||||
*/
|
||||
async getFirstInfo(data: any) {
|
||||
return this.coreMemberService.getCashOutAccountFirstInfo(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加提现账户
|
||||
*/
|
||||
async add(data: any) {
|
||||
return this.coreMemberService.addCashOutAccount(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑提现账户
|
||||
*/
|
||||
async edit(account_id: number, data: any) {
|
||||
return this.coreMemberService.editCashOutAccount(account_id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提现账户
|
||||
*/
|
||||
async del(account_id: number) {
|
||||
return this.coreMemberService.delCashOutAccount(account_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberCashOutService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 获取提现分页
|
||||
*/
|
||||
async getPage(data: any) {
|
||||
return this.coreMemberService.getCashOutPage(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现信息
|
||||
*/
|
||||
async getInfo(id: number) {
|
||||
return this.coreMemberService.getCashOutInfo(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现配置
|
||||
*/
|
||||
async getCashOutConfig() {
|
||||
return this.coreMemberService.getCashOutConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转账方式
|
||||
*/
|
||||
async getTransferType() {
|
||||
return this.coreMemberService.getTransferType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
*/
|
||||
async apply(data: any) {
|
||||
return this.coreMemberService.applyCashOut(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销提现
|
||||
*/
|
||||
async cancel(id: number) {
|
||||
return this.coreMemberService.cancelCashOut(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
async transfer(id: number, data: any) {
|
||||
return this.coreMemberService.transferCashOut(id, data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberLevelService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 获取会员等级列表
|
||||
*/
|
||||
async getList() {
|
||||
return this.coreMemberService.getMemberLevelList();
|
||||
}
|
||||
}
|
||||
14
wwjcloud/src/common/member/services/api/MemberLogService.ts
Normal file
14
wwjcloud/src/common/member/services/api/MemberLogService.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
|
||||
@Injectable()
|
||||
export class MemberLogService {
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 记录会员日志
|
||||
*/
|
||||
async log(data: any) {
|
||||
return this.coreMemberService.log(data);
|
||||
}
|
||||
}
|
||||
@@ -1,470 +1,42 @@
|
||||
import {
|
||||
Injectable,
|
||||
BadRequestException,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository, Not } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreMemberService } from '../core/CoreMemberService';
|
||||
import { MemberSign } from '../../entities/MemberSign';
|
||||
import { MemberAddress } from '../../entities/MemberAddress';
|
||||
import { MemberAccountLog } from '../../entities/MemberAccountLog';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
|
||||
@Injectable()
|
||||
export class MemberService {
|
||||
constructor(
|
||||
private memberCoreService: CoreMemberService,
|
||||
@InjectRepository(MemberSign)
|
||||
private memberSignRepository: Repository<MemberSign>,
|
||||
@InjectRepository(MemberAddress)
|
||||
private memberAddressRepository: Repository<MemberAddress>,
|
||||
@InjectRepository(MemberAccountLog)
|
||||
private memberAccountLogRepository: Repository<MemberAccountLog>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 会员注册
|
||||
*/
|
||||
async register(registerDto: any): Promise<any> {
|
||||
// 检查用户名是否已存在
|
||||
const existingUser = await this.memberCoreService.findByUsername(
|
||||
registerDto.username,
|
||||
);
|
||||
if (existingUser) {
|
||||
throw new BadRequestException('用户名已存在');
|
||||
}
|
||||
|
||||
// 检查手机号是否已存在
|
||||
const existingMobile = await this.memberCoreService.findByMobile(
|
||||
registerDto.mobile,
|
||||
);
|
||||
if (existingMobile) {
|
||||
throw new BadRequestException('手机号已存在');
|
||||
}
|
||||
|
||||
// 检查邮箱是否已存在
|
||||
if (registerDto.email) {
|
||||
const existingEmail = await this.memberCoreService.findByEmail(
|
||||
registerDto.email,
|
||||
);
|
||||
if (existingEmail) {
|
||||
throw new BadRequestException('邮箱已存在');
|
||||
}
|
||||
}
|
||||
|
||||
// 创建会员
|
||||
const member = await this.memberCoreService.create(registerDto);
|
||||
|
||||
// 返回注册成功信息(不包含密码)
|
||||
const { password, ...result } = member;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员登录
|
||||
*/
|
||||
async login(loginDto: any): Promise<any> {
|
||||
const { username, password } = loginDto;
|
||||
|
||||
// 查找会员
|
||||
const member = await this.memberCoreService.findByUsername(username);
|
||||
if (!member) {
|
||||
throw new UnauthorizedException('用户名或密码错误');
|
||||
}
|
||||
|
||||
// 验证密码
|
||||
const isValidPassword = await this.memberCoreService.validatePassword(
|
||||
member,
|
||||
password,
|
||||
);
|
||||
if (!isValidPassword) {
|
||||
throw new UnauthorizedException('用户名或密码错误');
|
||||
}
|
||||
|
||||
// 检查状态
|
||||
if (member.status !== 1) {
|
||||
throw new UnauthorizedException('账号已被禁用');
|
||||
}
|
||||
|
||||
// 更新最后登录信息
|
||||
await this.memberCoreService.updateLastLogin(member.member_id, {
|
||||
ip: loginDto.ip || '',
|
||||
address: loginDto.address || '',
|
||||
device: loginDto.device || '',
|
||||
});
|
||||
|
||||
// 返回登录成功信息(不包含密码)
|
||||
const { password: _, ...result } = member;
|
||||
return result;
|
||||
}
|
||||
constructor(private readonly coreMemberService: CoreMemberService) {}
|
||||
|
||||
/**
|
||||
* 获取会员信息
|
||||
*/
|
||||
async getProfile(memberId: number): Promise<any> {
|
||||
const member = await this.memberCoreService.findById(memberId);
|
||||
|
||||
// 返回会员信息(不包含密码)
|
||||
const { password, ...result } = member;
|
||||
return result;
|
||||
async getInfo() {
|
||||
return this.coreMemberService.getInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员信息
|
||||
* 会员中心
|
||||
*/
|
||||
async updateProfile(memberId: number, updateDto: any): Promise<any> {
|
||||
// 不允许更新敏感字段
|
||||
delete updateDto.password;
|
||||
delete updateDto.member_no;
|
||||
delete updateDto.site_id;
|
||||
delete updateDto.register_time;
|
||||
delete updateDto.status;
|
||||
delete updateDto.level_id;
|
||||
|
||||
// 检查用户名是否重复
|
||||
if (updateDto.username) {
|
||||
const exists = await this.memberCoreService.isUsernameExists(
|
||||
updateDto.username,
|
||||
memberId,
|
||||
);
|
||||
if (exists) {
|
||||
throw new BadRequestException('用户名已存在');
|
||||
}
|
||||
}
|
||||
|
||||
// 检查手机号是否重复
|
||||
if (updateDto.mobile) {
|
||||
const exists = await this.memberCoreService.isMobileExists(
|
||||
updateDto.mobile,
|
||||
memberId,
|
||||
);
|
||||
if (exists) {
|
||||
throw new BadRequestException('手机号已存在');
|
||||
}
|
||||
}
|
||||
|
||||
// 检查邮箱是否重复
|
||||
if (updateDto.email) {
|
||||
const exists = await this.memberCoreService.isEmailExists(
|
||||
updateDto.email,
|
||||
memberId,
|
||||
);
|
||||
if (exists) {
|
||||
throw new BadRequestException('邮箱已存在');
|
||||
}
|
||||
}
|
||||
|
||||
await this.memberCoreService.update(memberId, updateDto);
|
||||
return this.getProfile(memberId);
|
||||
async center() {
|
||||
return this.coreMemberService.center();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* 修改会员
|
||||
*/
|
||||
async changePassword(
|
||||
memberId: number,
|
||||
changePasswordDto: any,
|
||||
): Promise<void> {
|
||||
const { oldPassword, newPassword } = changePasswordDto;
|
||||
|
||||
const member = await this.memberCoreService.findById(memberId);
|
||||
|
||||
// 验证旧密码
|
||||
const isValidPassword = await this.memberCoreService.validatePassword(
|
||||
member,
|
||||
oldPassword,
|
||||
);
|
||||
if (!isValidPassword) {
|
||||
throw new BadRequestException('原密码错误');
|
||||
}
|
||||
|
||||
// 更新新密码
|
||||
const hashedPassword = await bcrypt.hash(newPassword, 10);
|
||||
await this.memberCoreService.update(memberId, { password: hashedPassword });
|
||||
async modify(field: string, value: string) {
|
||||
return this.coreMemberService.modify(field, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* 编辑会员
|
||||
*/
|
||||
async resetPassword(resetDto: any): Promise<void> {
|
||||
const { mobile, verifyCode, newPassword } = resetDto;
|
||||
|
||||
// 验证手机号
|
||||
const member = await this.memberCoreService.findByMobile(mobile);
|
||||
if (!member) {
|
||||
throw new BadRequestException('手机号不存在');
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
if (!verifyCode) {
|
||||
throw new Error('验证码不能为空');
|
||||
}
|
||||
|
||||
// 这里应该验证验证码的有效性
|
||||
// 可以从缓存中获取验证码进行比较
|
||||
|
||||
// 更新密码
|
||||
const hashedPassword = await bcrypt.hash(newPassword, 10);
|
||||
await this.memberCoreService.update(member.member_id, {
|
||||
password: hashedPassword,
|
||||
});
|
||||
async edit(data: Record<string, any>) {
|
||||
return this.coreMemberService.edit(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员签到
|
||||
* 获取会员码
|
||||
*/
|
||||
async sign(memberId: number, signInfo: any): Promise<any> {
|
||||
// 1. 检查是否已签到
|
||||
const today = new Date();
|
||||
const existingSign = await this.memberSignRepository.findOne({
|
||||
where: {
|
||||
member_id: memberId,
|
||||
sign_date: today,
|
||||
is_del: 0,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingSign) {
|
||||
throw new BadRequestException('今日已签到');
|
||||
}
|
||||
|
||||
// 2. 计算连续签到天数
|
||||
const yesterday = new Date(today);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
const yesterdaySign = await this.memberSignRepository.findOne({
|
||||
where: {
|
||||
member_id: memberId,
|
||||
sign_date: yesterday,
|
||||
is_del: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const continuousDays = yesterdaySign
|
||||
? yesterdaySign.continuous_days + 1
|
||||
: 1;
|
||||
|
||||
// 3. 分配积分(根据连续签到天数计算)
|
||||
const signPoints = this.calculateSignPoints(continuousDays);
|
||||
|
||||
// 4. 记录签到信息
|
||||
const signRecord = this.memberSignRepository.create({
|
||||
member_id: memberId,
|
||||
site_id: signInfo.site_id || 0,
|
||||
sign_date: today,
|
||||
sign_point: signPoints,
|
||||
continuous_days: continuousDays,
|
||||
sign_ip: signInfo.ip,
|
||||
sign_address: signInfo.address,
|
||||
sign_device: signInfo.device,
|
||||
status: 1,
|
||||
});
|
||||
|
||||
await this.memberSignRepository.save(signRecord);
|
||||
|
||||
// 5. 增加会员积分
|
||||
await this.memberCoreService.addPoints(memberId, signPoints);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: '签到成功',
|
||||
continuous_days: continuousDays,
|
||||
sign_point: signPoints,
|
||||
total_points: await this.getMemberTotalPoints(memberId),
|
||||
};
|
||||
async getQrcode() {
|
||||
return this.coreMemberService.getQrcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算签到积分
|
||||
*/
|
||||
private calculateSignPoints(continuousDays: number): number {
|
||||
if (continuousDays >= 7) return 20; // 连续7天以上
|
||||
if (continuousDays >= 3) return 15; // 连续3天以上
|
||||
return 10; // 基础积分
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员总积分
|
||||
*/
|
||||
private async getMemberTotalPoints(memberId: number): Promise<number> {
|
||||
const member = await this.memberCoreService.findById(memberId);
|
||||
return member.point;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分历史
|
||||
*/
|
||||
async getPointsHistory(memberId: number, queryDto: any): Promise<any> {
|
||||
const { page = 1, limit = 20 } = queryDto;
|
||||
|
||||
// 查询积分变动记录
|
||||
const [records, total] = await this.memberAccountLogRepository.findAndCount(
|
||||
{
|
||||
where: {
|
||||
member_id: memberId,
|
||||
account_type: 'point',
|
||||
},
|
||||
order: { create_time: 'DESC' },
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
list: records,
|
||||
total,
|
||||
page,
|
||||
limit,
|
||||
total_pages: Math.ceil(total / limit),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取余额历史
|
||||
*/
|
||||
async getBalanceHistory(memberId: number, queryDto: any): Promise<any> {
|
||||
const { page = 1, limit = 20 } = queryDto;
|
||||
|
||||
// 查询余额变动记录
|
||||
const [records, total] = await this.memberAccountLogRepository.findAndCount(
|
||||
{
|
||||
where: {
|
||||
member_id: memberId,
|
||||
account_type: 'balance',
|
||||
},
|
||||
order: { create_time: 'DESC' },
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
list: records,
|
||||
total,
|
||||
page,
|
||||
limit,
|
||||
total_pages: Math.ceil(total / limit),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级信息
|
||||
*/
|
||||
async getMemberLevel(memberId: number): Promise<any> {
|
||||
const member = await this.memberCoreService.findById(memberId);
|
||||
return member.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员地址列表
|
||||
*/
|
||||
async getAddressList(memberId: number): Promise<MemberAddress[]> {
|
||||
const member = await this.memberCoreService.findById(memberId);
|
||||
return member.addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员地址
|
||||
*/
|
||||
async addAddress(memberId: number, addressDto: any): Promise<MemberAddress> {
|
||||
// 如果设置为默认地址,先取消其他默认地址
|
||||
if (addressDto.is_default) {
|
||||
await this.memberAddressRepository.update(
|
||||
{ member_id: memberId, is_default: 1 },
|
||||
{ is_default: 0 },
|
||||
);
|
||||
}
|
||||
|
||||
const address = this.memberAddressRepository.create({
|
||||
...addressDto,
|
||||
member_id: memberId,
|
||||
site_id: addressDto.site_id || 0,
|
||||
status: 1,
|
||||
});
|
||||
|
||||
return this.memberAddressRepository.save(addressDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员地址
|
||||
*/
|
||||
async updateAddress(
|
||||
memberId: number,
|
||||
addressId: number,
|
||||
addressDto: any,
|
||||
): Promise<void> {
|
||||
// 验证地址是否属于当前会员
|
||||
const address = await this.memberAddressRepository.findOne({
|
||||
where: { id: addressId, member_id: memberId },
|
||||
});
|
||||
|
||||
if (!address) {
|
||||
throw new BadRequestException('地址不存在或无权限修改');
|
||||
}
|
||||
|
||||
// 如果设置为默认地址,先取消其他默认地址
|
||||
if (addressDto.is_default) {
|
||||
await this.memberAddressRepository.update(
|
||||
{ member_id: memberId, is_default: 1, id: Not(addressId) },
|
||||
{ is_default: 0 },
|
||||
);
|
||||
}
|
||||
|
||||
await this.memberAddressRepository.update(addressId, addressDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员地址
|
||||
*/
|
||||
async deleteAddress(memberId: number, addressId: number): Promise<void> {
|
||||
// 验证地址是否属于当前会员
|
||||
const address = await this.memberAddressRepository.findOne({
|
||||
where: { id: addressId, member_id: memberId },
|
||||
});
|
||||
|
||||
if (!address) {
|
||||
throw new BadRequestException('地址不存在或无权限删除');
|
||||
}
|
||||
|
||||
// 硬删除(数据库表没有软删除字段)
|
||||
await this.memberAddressRepository.delete(addressId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
*/
|
||||
async setDefaultAddress(memberId: number, addressId: number): Promise<void> {
|
||||
// 验证地址是否属于当前会员
|
||||
const address = await this.memberAddressRepository.findOne({
|
||||
where: { id: addressId, member_id: memberId },
|
||||
});
|
||||
|
||||
if (!address) {
|
||||
throw new BadRequestException('地址不存在或无权限修改');
|
||||
}
|
||||
|
||||
// 先取消其他默认地址
|
||||
await this.memberAddressRepository.update(
|
||||
{ member_id: memberId, is_default: 1, id: Not(addressId) },
|
||||
{ is_default: 0 },
|
||||
);
|
||||
|
||||
// 设置当前地址为默认
|
||||
await this.memberAddressRepository.update(addressId, { is_default: 1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员登出
|
||||
*/
|
||||
async logout(
|
||||
memberId: number,
|
||||
): Promise<{ success: boolean; message: string }> {
|
||||
// 这里可以清除会员的登录状态、token 等
|
||||
// 暂时返回成功状态
|
||||
return {
|
||||
success: true,
|
||||
message: '登出成功',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberAccount } from '../../entities/MemberAccount';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberAccountService extends BaseService<MemberAccount> {
|
||||
constructor(
|
||||
@InjectRepository(MemberAccount)
|
||||
private memberAccountRepository: Repository<MemberAccount>,
|
||||
) {
|
||||
super(memberAccountRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员账户列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, member_id, account_type } = query;
|
||||
const where: any = {};
|
||||
|
||||
if (member_id) where.member_id = member_id;
|
||||
if (account_type) where.account_type = account_type;
|
||||
|
||||
return this.memberAccountRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员账户详情
|
||||
*/
|
||||
async getInfo(account_id: number) {
|
||||
return this.memberAccountRepository.findOne({
|
||||
where: { account_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整账户余额
|
||||
*/
|
||||
async adjust(dto: any) {
|
||||
const { account_id, amount, type, remark } = dto;
|
||||
|
||||
// 这里应该实现账户余额调整逻辑
|
||||
// 包括记录变动日志等
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: '账户调整成功',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账户变动记录
|
||||
*/
|
||||
async getLog(account_id: number, query: any) {
|
||||
// 这里应该查询账户变动记录
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberAddress } from '../../entities/MemberAddress';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberAddressService extends BaseService<MemberAddress> {
|
||||
constructor(
|
||||
@InjectRepository(MemberAddress)
|
||||
private memberAddressRepository: Repository<MemberAddress>,
|
||||
) {
|
||||
super(memberAddressRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员地址列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, member_id } = query;
|
||||
const where: any = {};
|
||||
|
||||
if (member_id) where.member_id = member_id;
|
||||
|
||||
return this.memberAddressRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { is_default: 'DESC', create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员地址详情
|
||||
*/
|
||||
async getInfo(address_id: number) {
|
||||
return this.memberAddressRepository.findOne({
|
||||
where: { address_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
*/
|
||||
async setDefault(address_id: number) {
|
||||
// 先取消其他地址的默认状态
|
||||
await this.memberAddressRepository.update(
|
||||
{ is_default: 1 },
|
||||
{ is_default: 0 }
|
||||
);
|
||||
|
||||
// 设置当前地址为默认
|
||||
const result = await this.memberAddressRepository.update(address_id, {
|
||||
is_default: 1,
|
||||
});
|
||||
|
||||
return result.affected > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberCashOut } from '../../entities/MemberCashOut';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberCashOutService extends BaseService<MemberCashOut> {
|
||||
constructor(
|
||||
@InjectRepository(MemberCashOut)
|
||||
private memberCashOutRepository: Repository<MemberCashOut>,
|
||||
) {
|
||||
super(memberCashOutRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现申请列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, status, member_id } = query;
|
||||
const where: any = {};
|
||||
|
||||
if (status !== undefined) where.status = status;
|
||||
if (member_id) where.member_id = member_id;
|
||||
|
||||
return this.memberCashOutRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现申请详情
|
||||
*/
|
||||
async getInfo(cashout_id: number) {
|
||||
return this.memberCashOutRepository.findOne({
|
||||
where: { cashout_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核提现申请
|
||||
*/
|
||||
async audit(cashout_id: number, dto: any) {
|
||||
const { status, audit_remark } = dto;
|
||||
|
||||
const result = await this.memberCashOutRepository.update(cashout_id, {
|
||||
status,
|
||||
audit_remark,
|
||||
audit_time: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
return result.affected > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝提现申请
|
||||
*/
|
||||
async reject(cashout_id: number, dto: any) {
|
||||
return this.audit(cashout_id, { ...dto, status: 2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成提现
|
||||
*/
|
||||
async complete(cashout_id: number) {
|
||||
const result = await this.memberCashOutRepository.update(cashout_id, {
|
||||
status: 3,
|
||||
complete_time: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
return result.affected > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现统计
|
||||
*/
|
||||
async getStatistics(query: any) {
|
||||
// 这里应该实现提现统计逻辑
|
||||
return {
|
||||
total_amount: 0,
|
||||
total_count: 0,
|
||||
pending_count: 0,
|
||||
success_count: 0,
|
||||
reject_count: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { SysConfig } from '../../entities/SysConfig';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberConfigService extends BaseService<SysConfig> {
|
||||
constructor(
|
||||
@InjectRepository(SysConfig)
|
||||
private configRepository: Repository<SysConfig>,
|
||||
) {
|
||||
super(configRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员配置
|
||||
*/
|
||||
async getInfo(query: any) {
|
||||
const { site_id } = query;
|
||||
|
||||
const configs = await this.configRepository.find({
|
||||
where: {
|
||||
site_id,
|
||||
config_key: { $like: 'member_%' },
|
||||
},
|
||||
});
|
||||
|
||||
// 将配置转换为对象格式
|
||||
const configObj = {};
|
||||
configs.forEach(config => {
|
||||
configObj[config.config_key] = config.config_value;
|
||||
});
|
||||
|
||||
return configObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员配置
|
||||
*/
|
||||
async update(dto: any) {
|
||||
const { site_id, configs } = dto;
|
||||
|
||||
for (const [key, value] of Object.entries(configs)) {
|
||||
await this.configRepository.update(
|
||||
{ site_id, config_key: key },
|
||||
{ config_value: value as string }
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级配置
|
||||
*/
|
||||
async getLevelConfig(query: any) {
|
||||
// 这里应该返回会员等级相关配置
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员等级配置
|
||||
*/
|
||||
async updateLevelConfig(dto: any) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分规则配置
|
||||
*/
|
||||
async getPointConfig(query: any) {
|
||||
// 这里应该返回积分规则相关配置
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新积分规则配置
|
||||
*/
|
||||
async updatePointConfig(dto: any) {
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberLabel } from '../../entities/MemberLabel';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberLabelService extends BaseService<MemberLabel> {
|
||||
constructor(
|
||||
@InjectRepository(MemberLabel)
|
||||
private memberLabelRepository: Repository<MemberLabel>,
|
||||
) {
|
||||
super(memberLabelRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员标签列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, site_id } = query;
|
||||
const where: any = { site_id };
|
||||
|
||||
return this.memberLabelRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { sort: 'ASC', create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员标签详情
|
||||
*/
|
||||
async getInfo(label_id: number) {
|
||||
return this.memberLabelRepository.findOne({
|
||||
where: { label_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 给会员添加标签
|
||||
*/
|
||||
async addToMember(dto: any) {
|
||||
const { member_id, label_id } = dto;
|
||||
|
||||
// 这里应该实现给会员添加标签的逻辑
|
||||
// 可能需要操作关联表
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除会员标签
|
||||
*/
|
||||
async removeFromMember(dto: any) {
|
||||
const { member_id, label_id } = dto;
|
||||
|
||||
// 这里应该实现移除会员标签的逻辑
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberLevel } from '../../entities/MemberLevel';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberLevelService extends BaseService<MemberLevel> {
|
||||
constructor(
|
||||
@InjectRepository(MemberLevel)
|
||||
private memberLevelRepository: Repository<MemberLevel>,
|
||||
) {
|
||||
super(memberLevelRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, site_id } = query;
|
||||
const where: any = { site_id };
|
||||
|
||||
return this.memberLevelRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { level_value: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员等级详情
|
||||
*/
|
||||
async getInfo(level_id: number) {
|
||||
return this.memberLevelRepository.findOne({
|
||||
where: { level_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认等级
|
||||
*/
|
||||
async setDefault(level_id: number) {
|
||||
// 先取消其他等级的默认状态
|
||||
await this.memberLevelRepository.update(
|
||||
{ is_default: 1 },
|
||||
{ is_default: 0 }
|
||||
);
|
||||
|
||||
// 设置当前等级为默认
|
||||
const result = await this.memberLevelRepository.update(level_id, {
|
||||
is_default: 1,
|
||||
});
|
||||
|
||||
return result.affected > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取等级权益配置
|
||||
*/
|
||||
async getBenefits(level_id: number) {
|
||||
// 这里应该返回等级权益配置
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新等级权益配置
|
||||
*/
|
||||
async updateBenefits(level_id: number, dto: any) {
|
||||
// 这里应该更新等级权益配置
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,19 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 创建会员
|
||||
*/
|
||||
async create(createMemberDto: any): Promise<Member> {
|
||||
async create(createMemberDto: Record<string, any>): Promise<Member> {
|
||||
const member = new Member();
|
||||
|
||||
// 生成会员编号
|
||||
member.member_no = await this.generateMemberNo();
|
||||
|
||||
// 加密密码
|
||||
member.password = await bcrypt.hash(createMemberDto.password, 10);
|
||||
if (
|
||||
createMemberDto.password &&
|
||||
typeof createMemberDto.password === 'string'
|
||||
) {
|
||||
member.password = await bcrypt.hash(createMemberDto.password, 10);
|
||||
}
|
||||
|
||||
// 设置其他字段
|
||||
Object.assign(member, createMemberDto);
|
||||
@@ -38,9 +43,9 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 创建会员
|
||||
*/
|
||||
async createMember(memberData: any): Promise<Member> {
|
||||
async createMember(memberData: Partial<Member>): Promise<Member> {
|
||||
const member = this.memberRepository.create(memberData);
|
||||
return await this.memberRepository.save(memberData);
|
||||
return await this.memberRepository.save(member);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,11 +91,11 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
|
||||
/**
|
||||
* 根据邮箱查找会员
|
||||
* 注意:Member实体没有email字段,此方法暂时返回null
|
||||
*/
|
||||
async findByEmail(email: string): Promise<Member | null> {
|
||||
return await this.memberRepository.findOne({
|
||||
where: { is_del: 0 },
|
||||
});
|
||||
findByEmail(): Promise<Member | null> {
|
||||
// TODO: 如果Member实体需要email字段,请添加后再实现此方法
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,8 +115,11 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 更新会员
|
||||
*/
|
||||
async updateMember(memberId: number, updateDto: any): Promise<void> {
|
||||
const member = await this.findById(memberId);
|
||||
async updateMember(
|
||||
memberId: number,
|
||||
updateDto: Record<string, any>,
|
||||
): Promise<void> {
|
||||
await this.findById(memberId);
|
||||
|
||||
// 不允许更新敏感字段
|
||||
delete updateDto.member_id;
|
||||
@@ -139,7 +147,7 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 生成会员编号
|
||||
*/
|
||||
private async generateMemberNo(): Promise<string> {
|
||||
public async generateMemberNo(): Promise<string> {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
@@ -170,6 +178,72 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
await this.memberRepository.update(memberId, { member_level: levelId });
|
||||
}
|
||||
|
||||
/**
|
||||
* 为缺失会员编号的会员补齐编号
|
||||
* @param siteId 可选站点过滤
|
||||
* @returns 更新数量
|
||||
*/
|
||||
async assignMissingMemberNos(siteId?: number): Promise<number> {
|
||||
const where: Record<string, any> = { is_del: 0 };
|
||||
if (typeof siteId === 'number') where.site_id = siteId;
|
||||
const list = await this.memberRepository.find({ where });
|
||||
let updated = 0;
|
||||
for (const m of list) {
|
||||
if (!m.member_no || m.member_no === '') {
|
||||
const newNo = await this.generateMemberNo();
|
||||
await this.memberRepository.update(m.member_id, { member_no: newNo });
|
||||
updated += 1;
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员礼包发放
|
||||
* 对齐 PHP: CoreMemberService->memberGiftGrant($site_id, $member_id, $gift, $param)
|
||||
*/
|
||||
async memberGiftGrant(
|
||||
siteId: number,
|
||||
memberId: number,
|
||||
gift: unknown,
|
||||
param: Record<string, unknown> = {},
|
||||
): Promise<void> {
|
||||
// 校验会员存在
|
||||
const member = await this.memberRepository.findOne({
|
||||
where: { member_id: memberId, is_del: 0 },
|
||||
});
|
||||
if (!member) {
|
||||
throw new NotFoundException('会员不存在');
|
||||
}
|
||||
|
||||
// 规范化 gift
|
||||
const payload = (gift || {}) as Record<string, unknown>;
|
||||
const point = Number(payload.point ?? 0);
|
||||
const balance = Number(payload.balance ?? 0);
|
||||
|
||||
// 发放积分
|
||||
if (!Number.isNaN(point) && point !== 0) {
|
||||
if (point > 0) {
|
||||
await this.addPoints(memberId, point);
|
||||
} else {
|
||||
await this.deductPoints(memberId, Math.abs(point));
|
||||
}
|
||||
}
|
||||
|
||||
// 发放余额
|
||||
if (!Number.isNaN(balance) && balance !== 0) {
|
||||
if (balance > 0) {
|
||||
await this.addBalance(memberId, balance);
|
||||
} else {
|
||||
await this.deductBalance(memberId, Math.abs(balance));
|
||||
}
|
||||
}
|
||||
|
||||
// 预留:优惠券/等级等后续按 PHP 继续对齐
|
||||
void param;
|
||||
void siteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加积分
|
||||
*/
|
||||
@@ -217,7 +291,10 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 更新最后登录信息
|
||||
*/
|
||||
async updateLastLogin(memberId: number, loginInfo: any): Promise<void> {
|
||||
async updateLastLogin(
|
||||
memberId: number,
|
||||
loginInfo: { ip: string },
|
||||
): Promise<void> {
|
||||
await this.memberRepository.update(memberId, {
|
||||
login_time: Math.floor(Date.now() / 1000),
|
||||
login_ip: loginInfo.ip,
|
||||
@@ -231,7 +308,7 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
username: string,
|
||||
excludeId?: number,
|
||||
): Promise<boolean> {
|
||||
const where: any = { username, is_del: 0 };
|
||||
const where: Record<string, any> = { username, is_del: 0 };
|
||||
if (excludeId) {
|
||||
where.member_id = Not(excludeId);
|
||||
}
|
||||
@@ -244,7 +321,7 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
* 检查手机号是否已存在
|
||||
*/
|
||||
async isMobileExists(mobile: string, excludeId?: number): Promise<boolean> {
|
||||
const where: any = { mobile, is_del: 0 };
|
||||
const where: Record<string, any> = { mobile, is_del: 0 };
|
||||
if (excludeId) {
|
||||
where.member_id = Not(excludeId);
|
||||
}
|
||||
@@ -257,7 +334,7 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
* 检查邮箱是否已存在
|
||||
*/
|
||||
async isEmailExists(email: string, excludeId?: number): Promise<boolean> {
|
||||
const where: any = { email, is_del: 0 };
|
||||
const where: Record<string, any> = { email, is_del: 0 };
|
||||
if (excludeId) {
|
||||
where.member_id = Not(excludeId);
|
||||
}
|
||||
@@ -269,8 +346,13 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
/**
|
||||
* 获取会员统计信息
|
||||
*/
|
||||
async getMemberStats(siteId: number = 0): Promise<any> {
|
||||
const where: any = { is_del: 0 };
|
||||
async getMemberStats(siteId: number = 0): Promise<{
|
||||
total: number;
|
||||
active: number;
|
||||
today_new: number;
|
||||
inactive: number;
|
||||
}> {
|
||||
const where: Record<string, any> = { is_del: 0 };
|
||||
if (siteId > 0) {
|
||||
where.site_id = siteId;
|
||||
}
|
||||
@@ -297,4 +379,260 @@ export class CoreMemberService extends BaseService<Member> {
|
||||
inactive: totalMembers - activeMembers,
|
||||
};
|
||||
}
|
||||
|
||||
// ========== API服务需要的方法 ==========
|
||||
|
||||
/**
|
||||
* 获取会员信息
|
||||
*/
|
||||
async getInfo() {
|
||||
// TODO: 实现获取当前登录会员信息
|
||||
return { message: 'getInfo not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员中心
|
||||
*/
|
||||
async center() {
|
||||
// TODO: 实现会员中心数据
|
||||
return { message: 'center not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员
|
||||
*/
|
||||
async modify(field: string, value: string) {
|
||||
// TODO: 实现修改会员字段
|
||||
return { message: 'modify not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑会员
|
||||
*/
|
||||
async edit(data: Record<string, any>) {
|
||||
// TODO: 实现编辑会员
|
||||
return { message: 'edit not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员码
|
||||
*/
|
||||
async getQrcode() {
|
||||
// TODO: 实现获取会员二维码
|
||||
return { message: 'getQrcode not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分分页
|
||||
*/
|
||||
async getPointPage(data: any) {
|
||||
// TODO: 实现积分分页查询
|
||||
return { message: 'getPointPage not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户分页
|
||||
*/
|
||||
async getPage(data: any) {
|
||||
// TODO: 实现账户分页查询
|
||||
return { message: 'getPage not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额分页
|
||||
*/
|
||||
async getBalancePage(data: any) {
|
||||
// TODO: 实现余额分页查询
|
||||
return { message: 'getBalancePage not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数量
|
||||
*/
|
||||
async getCount(data: any) {
|
||||
// TODO: 实现获取数量
|
||||
return { message: 'getCount not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取来源类型
|
||||
*/
|
||||
async getFromType(account_type: string) {
|
||||
// TODO: 实现获取来源类型
|
||||
return { message: 'getFromType not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分数量
|
||||
*/
|
||||
async getPointCount() {
|
||||
// TODO: 实现积分数量统计
|
||||
return { message: 'getPointCount not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址列表
|
||||
*/
|
||||
async getAddressList(data: any) {
|
||||
// TODO: 实现获取地址列表
|
||||
return { message: 'getAddressList not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址详情
|
||||
*/
|
||||
async getAddressInfo(id: number) {
|
||||
// TODO: 实现获取地址详情
|
||||
return { message: 'getAddressInfo not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加地址
|
||||
*/
|
||||
async addAddress(data: any) {
|
||||
// TODO: 实现添加地址
|
||||
return { message: 'addAddress not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑地址
|
||||
*/
|
||||
async editAddress(id: number, data: any) {
|
||||
// TODO: 实现编辑地址
|
||||
return { message: 'editAddress not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地址
|
||||
*/
|
||||
async delAddress(id: number) {
|
||||
// TODO: 实现删除地址
|
||||
return { message: 'delAddress not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录会员日志
|
||||
*/
|
||||
async log(data: any) {
|
||||
// TODO: 实现记录会员日志
|
||||
return { message: 'log not implemented' };
|
||||
}
|
||||
|
||||
// ========== 提现账户相关方法 ==========
|
||||
|
||||
/**
|
||||
* 获取提现账户分页
|
||||
*/
|
||||
async getCashOutAccountPage(data: any) {
|
||||
// TODO: 实现获取提现账户分页
|
||||
return { message: 'getCashOutAccountPage not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现账户信息
|
||||
*/
|
||||
async getCashOutAccountInfo(account_id: number) {
|
||||
// TODO: 实现获取提现账户信息
|
||||
return { message: 'getCashOutAccountInfo not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首条提现账户信息
|
||||
*/
|
||||
async getCashOutAccountFirstInfo(data: any) {
|
||||
// TODO: 实现获取首条提现账户信息
|
||||
return { message: 'getCashOutAccountFirstInfo not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加提现账户
|
||||
*/
|
||||
async addCashOutAccount(data: any) {
|
||||
// TODO: 实现添加提现账户
|
||||
return { message: 'addCashOutAccount not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑提现账户
|
||||
*/
|
||||
async editCashOutAccount(account_id: number, data: any) {
|
||||
// TODO: 实现编辑提现账户
|
||||
return { message: 'editCashOutAccount not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提现账户
|
||||
*/
|
||||
async delCashOutAccount(account_id: number) {
|
||||
// TODO: 实现删除提现账户
|
||||
return { message: 'delCashOutAccount not implemented' };
|
||||
}
|
||||
|
||||
// ========== 会员等级相关方法 ==========
|
||||
|
||||
/**
|
||||
* 获取会员等级列表
|
||||
*/
|
||||
async getMemberLevelList() {
|
||||
// TODO: 实现获取会员等级列表
|
||||
return { message: 'getMemberLevelList not implemented' };
|
||||
}
|
||||
|
||||
// ========== 提现相关方法 ==========
|
||||
|
||||
/**
|
||||
* 获取提现分页
|
||||
*/
|
||||
async getCashOutPage(data: any) {
|
||||
// TODO: 实现获取提现分页
|
||||
return { message: 'getCashOutPage not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现信息
|
||||
*/
|
||||
async getCashOutInfo(id: number) {
|
||||
// TODO: 实现获取提现信息
|
||||
return { message: 'getCashOutInfo not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现配置
|
||||
*/
|
||||
async getCashOutConfig() {
|
||||
// TODO: 实现获取提现配置
|
||||
return { message: 'getCashOutConfig not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转账方式
|
||||
*/
|
||||
async getTransferType() {
|
||||
// TODO: 实现获取转账方式
|
||||
return { message: 'getTransferType not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
*/
|
||||
async applyCashOut(data: any) {
|
||||
// TODO: 实现申请提现
|
||||
return { message: 'applyCashOut not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销提现
|
||||
*/
|
||||
async cancelCashOut(id: number) {
|
||||
// TODO: 实现撤销提现
|
||||
return { message: 'cancelCashOut not implemented' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
async transferCashOut(id: number, data: any) {
|
||||
// TODO: 实现转账
|
||||
return { message: 'transferCashOut not implemented' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { MemberSign } from '../../entities/MemberSign';
|
||||
|
||||
@Injectable()
|
||||
export class CoreMemberSignService extends BaseService<MemberSign> {
|
||||
constructor(
|
||||
@InjectRepository(MemberSign)
|
||||
private memberSignRepository: Repository<MemberSign>,
|
||||
) {
|
||||
super(memberSignRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录列表
|
||||
*/
|
||||
async getList(query: any) {
|
||||
const { page = 1, limit = 20, member_id, site_id } = query;
|
||||
const where: any = { site_id };
|
||||
|
||||
if (member_id) where.member_id = member_id;
|
||||
|
||||
return this.memberSignRepository.findAndCount({
|
||||
where,
|
||||
skip: (page - 1) * limit,
|
||||
take: limit,
|
||||
order: { create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录详情
|
||||
*/
|
||||
async getInfo(sign_id: number) {
|
||||
return this.memberSignRepository.findOne({
|
||||
where: { sign_id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
*/
|
||||
async getStatistics(query: any) {
|
||||
const { site_id, member_id, start_time, end_time } = query;
|
||||
const where: any = { site_id };
|
||||
|
||||
if (member_id) where.member_id = member_id;
|
||||
if (start_time) where.create_time = { $gte: start_time };
|
||||
if (end_time) where.create_time = { $lte: end_time };
|
||||
|
||||
const total = await this.memberSignRepository.count({ where });
|
||||
|
||||
return {
|
||||
total_sign_count: total,
|
||||
today_sign_count: 0, // 今日签到数
|
||||
continuous_sign_count: 0, // 连续签到数
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到配置
|
||||
*/
|
||||
async getConfig(query: any) {
|
||||
// 这里应该返回签到配置
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到配置
|
||||
*/
|
||||
async updateConfig(dto: any) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到奖励配置
|
||||
*/
|
||||
async getRewardConfig(query: any) {
|
||||
// 这里应该返回签到奖励配置
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新签到奖励配置
|
||||
*/
|
||||
async updateRewardConfig(dto: any) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动签到
|
||||
*/
|
||||
async manualSign(dto: any) {
|
||||
const { member_id, site_id, remark } = dto;
|
||||
|
||||
const sign = this.memberSignRepository.create({
|
||||
member_id,
|
||||
site_id,
|
||||
remark,
|
||||
create_time: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
const saved = await this.memberSignRepository.save(sign);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: saved,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user