schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
}