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
import * as mssql from "mssql";
import { Post } from "egg-shell-decorators";
import { SaleOuter } from "../../entity/outbound/sale/saleOuter";
import BaseController from "../baseController";
 
export default class OuterController extends BaseController {
  //#region 生成一次性费用
  /**
   * 生成一次性费用
   */
  @Post()
  public async getFeeItem() {
    let { ctx } = this;
    let body = ctx.request.body;
    if (!Array.isArray(body.ids) || !body.ids.length) {
      this.info.result = false;
      this.info.msg = "数据不存在 ";
      ctx.body = this.info;
      return;
    }
    try {
      const connection: any = await this.dbWrite.connection;
      let request = new mssql.Request(connection.driver.master);
      let msg = [];
 
      for (let outer_Id of body.ids) {
        request.input("Outer_Id", outer_Id);
        request.output("outMsg", mssql.NVarChar(2000));
        let result = await request.execute("sp_Fee_Base_OneCharge_Out");
        let outMsg = result.output.outMsg;
 
        if (outMsg) {
          msg.push(outMsg);
        } else {
          let outerInfo = await this.dbRead.findOne(SaleOuter, outer_Id);
          msg.push(outerInfo.outerCode + "执行完成");
        }
      }
      this.info.msg = msg.join(",");
      this.info.result = true;
    } catch (error) {
      this.info.msg = error.message;
      this.info.result = false;
    }
    this.ctx.body = this.info;
  }
  //#endregion
}