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
//#region import
import BaseApiService from "../baseApiService";
import { SaleOrderStatusHistory } from "../../entity/outbound/order/saleOrderStatusHistory";
import { SysParamValue } from "../../entity/sys/core/sysParamValue";
//#endregion
 
/**
 * 运单轨迹帮助类
 */
export default class OrderHelperService extends BaseApiService {
  public async setStatusHistory(
    order_Id: number,
    fromStatusID: number,
    toStatusID: number,
    statusType: string,
    operationType: string,
    billId?: number,
    billCode?: string,
    creator?: string
  ) {
    let { ctx } = this;
    let userInfo = await ctx.helper.userInfo();
    if (!creator) creator = userInfo.userTrueName;
 
    let hisEntity = new SaleOrderStatusHistory();
    hisEntity.billId = billId;
    hisEntity.billCode = billCode;
    hisEntity.fromStatusID = fromStatusID;
    hisEntity.fromStatus = await this.getStatusText(fromStatusID);
    hisEntity.toStatusID = toStatusID;
    hisEntity.toStatus = await this.getStatusText(toStatusID);
    hisEntity.statusType = statusType;
    hisEntity.operationType = operationType;
    hisEntity.order_Id = order_Id;
    hisEntity.creator = creator;
    hisEntity.createDate = new Date();
 
    await this.dbWrite.save(hisEntity);
  }
 
  async getStatusText(statusID: number) {
    let paramInfo = await this.dbRead.findOne(SysParamValue, {
      select: ["value02"],
      where: { type_Id: 509, value01: statusID }
    });
 
    if (!paramInfo) {
      return null;
    }
 
    return paramInfo.value02;
  }
}