//#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;
|
}
|
}
|