import BaseService from "../baseService";
|
import { ResultInfo } from "../../public/commonInterface";
|
import { FeePayableBill } from "../../entity/finance/fee/feePayableBill";
|
|
export default class PayableBillService extends BaseService {
|
//#region 批量审核
|
public async batchAuditing(): Promise<ResultInfo> {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
try {
|
let idValues = body.idValues;
|
if (!Array.isArray(idValues)) {
|
this.info.result = false;
|
this.info.msg = "没有可执行的数据";
|
return this.info;
|
}
|
for (var idValue of idValues) {
|
let dataInfo = await this.dbRead.findOne(FeePayableBill, idValue);
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "单据不存在";
|
return this.info;
|
}
|
if (dataInfo.auditing == 2) {
|
this.info.result = false;
|
this.info.msg = dataInfo.payableBillCode + "只有未审核的单子才允许审核";
|
return this.info;
|
}
|
if (dataInfo.payStatus != "新建") {
|
this.info.result = false;
|
this.info.msg = dataInfo.payableBillCode + "只有新建的单子才允许审核";
|
return this.info;
|
}
|
await this.dbWrite.update(
|
FeePayableBill,
|
{
|
payableBill_Id: dataInfo.payableBill_Id,
|
userProduct_Id: userInfo.userProduct_Id
|
},
|
{
|
payStatus: "审核成功",
|
auditing: 2,
|
auditor: userInfo.userTrueName,
|
auditDate: new Date()
|
}
|
);
|
}
|
this.info.result = true;
|
this.info.msg = "审核成功";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "审核失败" + error.message;
|
}
|
return this.info;
|
}
|
//#endregion
|
}
|