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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { default as BaseController } from "../../baseController";
import { Post } from "egg-shell-decorators";
import { BaseDriverContract } from "../../../entity/tms/base/baseDriverContract"; // models
export default class BaseDriverContractController extends BaseController {
  //#region 更新货主信息
  /**
   * 审核状态更新
   */
  @Post()
  public async updateAuditing() {
    let { ctx } = this;
    let body = ctx.body; // 接收前端发来的数据
    let auditing = body.auditing; // 接收审核状态值
    let userInfo = await ctx.helper.userInfo(); // 权限
    let userProduct_Id = userInfo.userProduct_Id; // 获取权限id
    try {
      let dataInfo = await this.dbRead.findOne(BaseDriverContract, {
        where: {
          contract_Id: body.contract_Id,
          userProduct_Id: userProduct_Id
        }
      });
      if (!dataInfo) {
        this.info.result = false;
        this.info.msg = "数据不存在";
        ctx.body = this.info;
        return;
      }
      await this.dbWrite.update(
        BaseDriverContract,
        {
          contract_Id: body.contract_Id
        },
        {
          auditing: auditing
        }
      );
      if (auditing === 0) {
        this.info.result = true;
        this.info.msg = "审核驳回";
      } else if (auditing === 2) {
        this.info.result = true;
        this.info.msg = "通过审核";
      } else {
        this.info.result = true;
        this.info.msg = "审核失败";
      }
    } catch (error) {
      this.info.result = false;
      this.info.msg = "错误信息:" + error.message;
    }
    ctx.body = this.info;
  }
  //#endregion
 
  //#region 更新货主信息
  /**
   * 签署状态更新
   */
  @Post()
  public async updateSign() {
    let { ctx } = this;
    let body = ctx.body; // 接收前端发来的数据
    let signingStatus = body.signingStatus; // 接收签署状态 1 签署成功 2签署驳回
    let userInfo = await ctx.helper.userInfo(); // 权限
    let userProduct_Id = userInfo.userProduct_Id; // 获取权限id
    try {
      let dataInfo = await this.dbRead.findOne(BaseDriverContract, {
        where: {
          contract_Id: body.contract_Id,
          userProduct_Id: userProduct_Id
        }
      });
      if (!dataInfo) {
        this.info.result = false;
        this.info.msg = "数据不存在";
        ctx.body = this.info;
        return;
      }
      await this.dbWrite.update(
        BaseDriverContract,
        {
          contract_Id: body.contract_Id
        },
        {
          signingStatus: signingStatus
        }
      );
      if (signingStatus === "已签署") {
        this.info.result = true;
        this.info.msg = "签署成功";
      } else if (signingStatus === "未签署") {
        this.info.result = true;
        this.info.msg = "签署驳回";
      } else {
        this.info.result = false;
        this.info.msg = "签署失败";
      }
    } catch (error) {
      this.info.result = false;
      this.info.msg = error.message;
    }
    ctx.body = this.info;
  }
  //#endregion
}