import { Inject,Body,Post } from "@midwayjs/core";
|
|
import { CoolController, BaseController } from "@cool-midway/core";
|
import { RecycleOrderEntity } from "../../entity/recycleorder";
|
import { RecycleOrderService } from "../../service/recycleorder";
|
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department';
|
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
|
|
/**
|
* 回收订单后台管理
|
*/
|
@CoolController({
|
api: ["add", "delete", "update", "info", "list", "page"],
|
entity: RecycleOrderEntity,
|
service: RecycleOrderService,
|
pageQueryOp: {
|
keyWordLikeFields: ["a.orderNo"],
|
fieldEq: ["a.orderType", "a.status"],
|
select: ["a.*", "c.name AS departmentName"],
|
join: [
|
{
|
entity: BaseSysDepartmentEntity,
|
alias: "c",
|
condition: 'a.departmentId = c.id',
|
type: "leftJoin"
|
}
|
],
|
where: async (ctx) => {
|
const { startTime, endTime } = ctx.request.body;
|
const conditions: any[][] = [];
|
if (startTime && endTime) {
|
conditions.push(["a.finishTime BETWEEN :startTime AND :endTime", { startTime, endTime }]);
|
}
|
conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
|
return conditions;
|
},
|
addOrderBy: {
|
createTime: 'desc',
|
},
|
}
|
})
|
export class AdminRecycleOrderController extends BaseController {
|
@Inject()
|
recycleOrderService: RecycleOrderService;
|
|
@Post("/saveWithSummary")
|
async saveWithSummary(
|
@Body()
|
body: {
|
orderNo: string;
|
items: any[];
|
}
|
) {
|
await this.recycleOrderService.saveWithSummary(body.orderNo, body.items);
|
return this.ok();
|
}
|
}
|