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
import BaseController from "../../baseController";
import { Post } from "egg-shell-decorators";
import { BaseClient } from "../../../entity/crm/client/baseClient";
import { Like } from "typeorm";
import { CRMClientLinker } from "../../../entity/crm/linker/crmClientLinker";
 
export default class ClientController extends BaseController {
  //#region
  /**
   * 获得TableSelect获得客户信息列表
   */
  @Post()
  public async getList() {
    let userInfo = await this.userInfo;
    var dataList = await this.dbRead.find(BaseClient, {
      select: [
        "client_Id",
        "clientCode",
        "clientShortName",
        "mobile",
        "shippingName",
        "shippingAddress",
        "province_Id",
        "provinceName",
        "city_Id",
        "cityName",
        "region_Id",
        "regionName",
        "tel",
        "countryName",
        "expandFields",
        "tel"
      ],
      where: {
        userProduct_Id: userInfo.userProduct_Id,
        clientShortName: Like("%" + this.body.name + "%")
      }
    });
    if (dataList.length == 0) {
      this.info.result = false;
      this.info.data = dataList;
    } else {
      this.info.result = true;
      this.info.data = dataList;
    }
 
    this.ctx.body = this.info;
  }
  //#endregion
 
  //#region 获取联系人信息
  @Post()
  public async getClientLinker() {
    let userInfo = await this.userInfo;
    try {
      let dataList = await this.dbRead.find(CRMClientLinker, {
        where: {
          clientShortName: this.body.name,
          userProduct_Id: userInfo.userProduct_Id
        }
      });
 
      this.info.result = true;
      this.info.data = dataList;
 
      this.ctx.body = this.info;
    } catch (ex) {
      this.info.result = false;
      this.info.msg = "出现异常" + ex.message;
      this.ctx.body = this.info;
    }
  }
  //#endregion
}