import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import * as sql from "mssql";
|
import { SaleOrder } from "../../entity/outbound/sale/saleOrder";
|
import { SaleOrderList } from "../../entity/outbound/sale/saleOrderList";
|
import { SaleReturn } from "../../entity/outbound/service/saleReturn";
|
import { In } from "typeorm";
|
/**
|
* 身份证处理
|
*/
|
export default class ReturnController extends BaseController {
|
//#region getByCode
|
/// <summary>
|
/// 根据销售退货单Code获取销售退货单信息
|
/// </summary>
|
/// <param name="ReturnCode">销售退货单号</param>
|
/// <returns>销售退货实体</returns>
|
@Post()
|
public async getByCode() {
|
let orderCode = this.body.orderCode;
|
let where: any = {};
|
let userInfo = await this.userInfo;
|
if (!userInfo) {
|
this.info.result = false;
|
this.info.data = null;
|
this.info.msg = "获取失败。";
|
this.ctx.body = this.info;
|
}
|
where.orderCode = orderCode;
|
where.userProduct_Id = userInfo.userProduct_Id;
|
let model = await this.dbRead.findOne(SaleOrder, where);
|
if (!model) {
|
this.info.result = false;
|
this.info.data = null;
|
this.info.msg = "获取失败。";
|
this.ctx.body = this.info;
|
} else {
|
let detailList = await this.dbRead.find(SaleOrderList, {
|
order_Id: model.order_Id
|
});
|
model.saleOrderList = detailList;
|
this.info.result = true;
|
this.info.data = model;
|
this.ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 审核
|
/// <summary>
|
/// 预到货单-审核
|
/// </summary>
|
/// <param name="reqinfo"></param>
|
/// <returns></returns>
|
@Post()
|
public async singleAuditing() {
|
let return_Ids = this.body.return_Ids;
|
let userInfo = await this.ctx.helper.userInfo();
|
try {
|
await this.dbWrite.update(
|
SaleReturn,
|
{
|
return_Id: In(return_Ids)
|
},
|
{
|
statusID: 2,
|
auditor: userInfo.userTrueName,
|
auditing: 2,
|
auditDate: new Date(),
|
statusText: "审核成功"
|
}
|
);
|
|
this.info.result = true;
|
this.info.msg = "审核成功";
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
//#region 转到预到货单
|
@Post()
|
public async toPurchase() {
|
let userInfo = await this.ctx.helper.userInfo();
|
try {
|
const connection: any = await this.dbWrite.connection;
|
let request = new sql.Request(connection.driver.master);
|
request.input("return_Id", this.body.return_Id);
|
request.input("user_Id", userInfo.user_Id);
|
request.input("userTrueName", userInfo.userTrueName);
|
request.input("userProduct_Id", userInfo.userProduct_Id);
|
request.output("outMsg", sql.NVarChar(2000));
|
let result = await request.execute("sp_Sale_Return_ToPurchaseOrder");
|
let outMsg = result.output.outMsg;
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
} else {
|
this.info.msg = "转到预到货成功";
|
this.info.result = true;
|
this.ctx.body = this.info;
|
}
|
} catch (error) {
|
this.info.msg = error.message;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
}
|
}
|
|
//#endregion
|
}
|