import BaseService from "../baseService";
|
import { ResultInfo } from "../../public/commonInterface";
|
import { PurchaseDamagedOrder } from "../../entity/inbound/purchase/purchaseDamagedOrder";
|
import { In } from "typeorm";
|
|
/**
|
* 产品入库单Service
|
*/
|
export default class DamagedOrderService extends BaseService {
|
//#region 终止
|
public async stop(): Promise<ResultInfo> {
|
try {
|
let dataInfo = await this.dbRead.find(PurchaseDamagedOrder, {
|
damagedOrder_Id: In(this.body.idValues)
|
});
|
for (let data of dataInfo) {
|
await this.dbRead.update(
|
PurchaseDamagedOrder,
|
{
|
damagedOrder_Id: data.damagedOrder_Id
|
},
|
{
|
statusID: 4,
|
statusText: "终止",
|
auditDate: null,
|
auditing: null,
|
auditor: null
|
}
|
);
|
this.info.result = true;
|
this.info.msg = "终止成功";
|
}
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = error.message;
|
}
|
return this.info;
|
}
|
//#endregion
|
|
//#region 开启
|
public async open(): Promise<ResultInfo> {
|
try {
|
let dataInfo = await this.dbRead.find(PurchaseDamagedOrder, {
|
damagedOrder_Id: In(this.body.idValues)
|
});
|
for (let data of dataInfo) {
|
if (data.statusText != "终止") {
|
this.info.result = false;
|
this.info.msg = "只有状态为终止, 才能开启!";
|
this.ctx.body = this.info;
|
return this.info;
|
}
|
await this.dbRead.update(
|
PurchaseDamagedOrder,
|
{
|
damagedOrder_Id: data.damagedOrder_Id
|
},
|
{
|
statusID: 1,
|
statusText: "新建",
|
auditDate: null,
|
auditing: null,
|
auditor: null
|
}
|
);
|
this.info.result = true;
|
this.info.msg = "开启成功";
|
}
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = error.message;
|
}
|
return this.info;
|
}
|
//#endregion
|
}
|