| New file |
| | |
| | | import { CoolController, BaseController } from '@cool-midway/core'; |
| | | import { BasicdataBuyerEntity } from '../../entity/buyer'; |
| | | import { BasicdataBuyerService } from '../../service/buyer'; |
| | | import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department'; |
| | | |
| | | /** |
| | | * 购买方管理 |
| | | */ |
| | | @CoolController({ |
| | | api: ['add', 'delete', 'update', 'info', 'list', 'page'], |
| | | entity: BasicdataBuyerEntity, |
| | | service: BasicdataBuyerService, |
| | | pageQueryOp: { |
| | | fieldEq: ['a.departmentId', 'a.name', 'a.contact'], |
| | | fieldLike: ['a.name','a.address'], |
| | | select: ['a.*', 'b.name AS departmentName'], |
| | | join: [ |
| | | { |
| | | entity: BaseSysDepartmentEntity, |
| | | alias: 'b', |
| | | condition: 'a.departmentId = b.id', |
| | | type: 'leftJoin', |
| | | }, |
| | | ], |
| | | }, |
| | | }) |
| | | export class AdminOperationBuyerController extends BaseController {} |
| | |
| | | 'a.phone', |
| | | 'a.licenseNo', |
| | | ], |
| | | fieldEq: ['a.departmentId','a.status'], |
| | | fieldEq: ['a.departmentId', 'a.status'], |
| | | select: ['a.*', 'b.name AS departmentName'], |
| | | join: [ |
| | | { |
| | | entity: BaseSysDepartmentEntity, |
| | | alias: 'b', |
| | | condition: 'a.departmentId = b.id', |
| | | type: 'leftJoin', |
| | | }, |
| | | ], |
| | | join: [ |
| | | { |
| | | entity: BaseSysDepartmentEntity, |
| | | alias: 'b', |
| | | condition: 'a.departmentId = b.id', |
| | | type: 'leftJoin', |
| | | }, |
| | | ], |
| | | |
| | | }, |
| | | }) |
| New file |
| | |
| | | import { BaseEntity } from '../../base/entity/base'; |
| | | import { Column, Entity, Index } from 'typeorm'; |
| | | |
| | | /** |
| | | * 购买方信息 |
| | | */ |
| | | @Entity('t_basicdata_buyer') |
| | | export class BasicdataBuyerEntity extends BaseEntity { |
| | | @Index() |
| | | @Column({ comment: '部门ID', type: 'bigint', nullable: true }) |
| | | departmentId: number; |
| | | |
| | | departmentName: string; |
| | | |
| | | @Index({ unique: true }) |
| | | @Column({ comment: '代码', length: 50 }) |
| | | code: string; |
| | | |
| | | @Column({ comment: '名称', length: 200 }) |
| | | name: string; |
| | | |
| | | @Column({ comment: '地址', length: 255, nullable: true }) |
| | | address: string; |
| | | |
| | | @Column({ comment: '联系人', length: 50, nullable: true }) |
| | | contact: string; |
| | | |
| | | @Column({ comment: '联系电话', length: 50, nullable: true }) |
| | | phone: string; |
| | | |
| | | @Column({ comment: '备注', type: 'text', nullable: true }) |
| | | remark: string; |
| | | } |
| New file |
| | |
| | | import { Provide } from '@midwayjs/core'; |
| | | import { BaseService } from '@cool-midway/core'; |
| | | import { InjectEntityModel } from '@midwayjs/typeorm'; |
| | | import { Repository } from 'typeorm'; |
| | | import { BasicdataBuyerEntity } from '../entity/buyer'; |
| | | |
| | | /** |
| | | * 可回收物购买方服务 |
| | | */ |
| | | @Provide() |
| | | export class BasicdataBuyerService extends BaseService { |
| | | @InjectEntityModel(BasicdataBuyerEntity) |
| | | basicdataBuyerEntity: Repository<BasicdataBuyerEntity>; |
| | | } |
| New file |
| | |
| | | import { ModuleConfig } from '@cool-midway/core'; |
| | | |
| | | /** |
| | | * 运营回收 |
| | | */ |
| | | export default () => { |
| | | return { |
| | | name: '运营回收模块', |
| | | description: '运营回收和统计服务', |
| | | middlewares: [], |
| | | globalMiddlewares: [], |
| | | } as ModuleConfig; |
| | | }; |
| New file |
| | |
| | | import { Inject } from '@midwayjs/core'; |
| | | import { CoolController, BaseController } from '@cool-midway/core'; |
| | | import { OperationWastesaleEntity } from '../../entity/wastesale'; |
| | | import { OperationWastesaleService } from '../../service/wastesale'; |
| | | import { BaseSysUserEntity } from '../../../base/entity/sys/user'; |
| | | import { BasicdataBuyerEntity } from '../../../basicdata/entity/buyer' |
| | | import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department'; |
| | | import { BasicdataSiteEntity } from '../../../basicdata/entity/site' |
| | | import { BasicdataWastetypeEntity } from '../../../basicdata/entity/wastetype'; |
| | | |
| | | /** |
| | | * 可回收物收益管理 |
| | | */ |
| | | @CoolController({ |
| | | api: ['add', 'delete', 'update', 'info', 'list', 'page'], |
| | | entity: OperationWastesaleEntity, |
| | | service: OperationWastesaleService, |
| | | insertParam: (ctx) => { |
| | | return { |
| | | handlerId: ctx.admin.userId, |
| | | }; |
| | | }, |
| | | pageQueryOp: { |
| | | select: [ |
| | | 'a.*', |
| | | 'b.name AS departmentName', |
| | | 'c.businessName AS siteName', |
| | | 'd.name AS wasteName', |
| | | 'e.name AS handlerName', |
| | | 'f.name AS buyerName', |
| | | ], |
| | | join: [ |
| | | { |
| | | entity: BaseSysDepartmentEntity, |
| | | alias: 'b', |
| | | condition: 'a.departmentId = b.id', |
| | | type: 'leftJoin', |
| | | }, |
| | | { |
| | | entity: BasicdataSiteEntity, |
| | | alias: 'c', |
| | | condition: 'a.siteId = c.businessId', |
| | | type: 'leftJoin', |
| | | }, |
| | | { |
| | | entity: BasicdataWastetypeEntity, |
| | | alias: 'd', |
| | | condition: 'a.wasteCode = d.code', |
| | | type: 'leftJoin', |
| | | }, |
| | | { |
| | | entity: BaseSysUserEntity, |
| | | alias: 'e', |
| | | condition: 'a.handlerId = e.userId', |
| | | type: 'leftJoin', |
| | | }, |
| | | { |
| | | entity: BasicdataBuyerEntity, |
| | | alias: 'f', |
| | | condition: 'a.buyerCode = f.code', |
| | | type: 'leftJoin', |
| | | }, |
| | | ], |
| | | fieldEq: ['a.departmentId', 'a.collectionPointId'], |
| | | where: async (ctx) => { |
| | | const { startTime, endTime } = ctx.request.body; |
| | | const condition = []; |
| | | if (startTime && endTime) { |
| | | condition.push(['a.dateTime BETWEEN :startTime AND :endTime', { startTime, endTime }]); |
| | | } |
| | | return condition; |
| | | }, |
| | | }, |
| | | }) |
| | | export class AdminOperationWastesaleController extends BaseController { |
| | | @Inject() |
| | | ctx; |
| | | } |
| New file |
| | |
| | | import { BaseEntity } from '../../base/entity/base'; |
| | | import { Column, Entity, Index } from 'typeorm'; |
| | | |
| | | /** |
| | | * 可回收物收益 |
| | | */ |
| | | @Entity('t_operation_waste_sale') |
| | | export class OperationWastesaleEntity extends BaseEntity { |
| | | @Index() |
| | | @Column({ comment: '部门ID', type: 'bigint' }) |
| | | departmentId: number; |
| | | |
| | | departmentName: string; |
| | | |
| | | @Index() |
| | | @Column({ comment: '收集点ID', nullable: true }) |
| | | siteId: string; |
| | | |
| | | siteName: string; |
| | | |
| | | @Index() |
| | | @Column({ comment: '垃圾种类' }) |
| | | wasteCode: string; |
| | | |
| | | wasteName: string; |
| | | |
| | | @Column({ comment: '日期时间', type: 'datetime' }) |
| | | dateTime: Date; |
| | | |
| | | @Column({ comment: '重量', type: 'decimal', precision: 10, scale: 2 }) |
| | | weight: number; |
| | | |
| | | @Column({ comment: '单价', type: 'decimal', precision: 10, scale: 2 }) |
| | | unitPrice: number; |
| | | |
| | | @Column({ comment: '总价', type: 'decimal', precision: 12, scale: 2 }) |
| | | totalPrice: number; |
| | | |
| | | @Index() |
| | | @Column({ comment: '经手人ID', type: 'bigint' }) |
| | | handlerId: number; |
| | | |
| | | handlerName: string; |
| | | |
| | | @Column({ comment: '收购方代码', length: 50 }) |
| | | buyerCode: string; |
| | | |
| | | buyerName: string; |
| | | |
| | | } |
| New file |
| | |
| | | import { Provide } from '@midwayjs/core'; |
| | | import { BaseService } from '@cool-midway/core'; |
| | | import { InjectEntityModel } from '@midwayjs/typeorm'; |
| | | import { Repository } from 'typeorm'; |
| | | import { OperationWastesaleEntity } from '../entity/wastesale'; |
| | | |
| | | /** |
| | | * 可回收物收益服务 |
| | | */ |
| | | @Provide() |
| | | export class OperationWastesaleService extends BaseService { |
| | | @InjectEntityModel(OperationWastesaleEntity) |
| | | operationWastesaleEntity: Repository<OperationWastesaleEntity>; |
| | | |
| | | /** |
| | | * 写入前计算总价 |
| | | */ |
| | | async modifyBefore(data: any, type: 'add' | 'update') { |
| | | if (type === 'add' || type === 'update') { |
| | | if (data.weight !== undefined && data.unitPrice !== undefined) { |
| | | data.totalPrice = Number((Number(data.weight) * Number(data.unitPrice)).toFixed(2)); |
| | | } |
| | | } |
| | | } |
| | | } |