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
| import BaseService from "../baseService";
| import { In } from "typeorm";
| import { BaseProductPlaceHolder } from "../../entity/storage/storage/baseProductPlaceHolder";
| import { PurchaseReturn } from "../../entity/inbound/purchase/purchaseReturn";
|
| /**
| * 预到货退货Service
| */
| export default class ReturnService extends BaseService {
| //#region Stop
| public async stop() {
| let userInfo = await this.userInfo;
| // 删除占位
| await this.dbRead.delete(BaseProductPlaceHolder, {
| className: "采购退货出库",
| mainID: In(this.body.idValues)
| });
|
| // 增加轨迹
| let sql = `INSERT INTO Purchase_Return_StatusHistory
| (Return_Id, StatusType, OperationType, FromStatus, ToStatus, Remark, CreateID, Creator, CreateDate)
| SELECT Return_Id , '单据状态', '订单状态','审核成功', '终止', Remark,
| ${userInfo.user_Id} as CreateID, '${userInfo.userName}' as Creator, getdate() as CreateDate
| FROM dbo.Purchase_Return
| WHERE Return_Id IN(${this.body.idValues.join(",")}) and userProduct_Id=${userInfo.userProduct_Id};`;
| await this.dbWrite.query(sql);
|
| await this.dbRead.update(
| PurchaseReturn,
| {
| return_Id: In(this.body.idValues)
| },
| {
| statusID: 9,
| statusText: "终止",
| auditing: 0,
| auditor: null,
| auditDate: null
| }
| );
|
| this.info.result = true;
| this.info.msg = "终止成功!";
|
| return this.info;
| }
| //#endregion
|
| //#region Open
| public async open() {
| let userInfo = await this.userInfo;
| // 删除占位
| await this.dbRead.delete(BaseProductPlaceHolder, {
| className: "采购退货出库",
| mainID: In(this.body.idValues)
| });
|
| // 增加轨迹
| let sql = `INSERT INTO Purchase_Return_StatusHistory
| (Return_Id, StatusType, OperationType, FromStatus, ToStatus, Remark, CreateID, Creator, CreateDate)
| SELECT Return_Id , '单据状态', '订单状态','终止', '新建', Remark,
| ${userInfo.user_Id} as CreateID, '${userInfo.userName}' as Creator, getdate() as CreateDate
| FROM dbo.Purchase_Return
| WHERE return_Id IN(${this.body.idValues.join(",")}) and userProduct_Id =${userInfo.userProduct_Id};`;
| await this.dbWrite.query(sql);
|
| await this.dbRead.update(
| PurchaseReturn,
| {
| return_Id: In(this.body.idValues)
| },
| {
| statusID: 1,
| statusText: "新建",
| auditing: 0,
| auditor: null,
| auditDate: null
| }
| );
|
| this.info.result = true;
| this.info.msg = "开启成功!";
|
| return this.info;
| }
| //#endregion
| }
|
|