schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
}