import { default as BaseController } from "../../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { BaseDriverContract } from "../../../entity/tms/base/baseDriverContract"; // models
|
export default class BaseDriverContractController extends BaseController {
|
//#region 更新货主信息
|
/**
|
* 审核状态更新
|
*/
|
@Post()
|
public async updateAuditing() {
|
let { ctx } = this;
|
let body = ctx.body; // 接收前端发来的数据
|
let auditing = body.auditing; // 接收审核状态值
|
let userInfo = await ctx.helper.userInfo(); // 权限
|
let userProduct_Id = userInfo.userProduct_Id; // 获取权限id
|
try {
|
let dataInfo = await this.dbRead.findOne(BaseDriverContract, {
|
where: {
|
contract_Id: body.contract_Id,
|
userProduct_Id: userProduct_Id
|
}
|
});
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "数据不存在";
|
ctx.body = this.info;
|
return;
|
}
|
await this.dbWrite.update(
|
BaseDriverContract,
|
{
|
contract_Id: body.contract_Id
|
},
|
{
|
auditing: auditing
|
}
|
);
|
if (auditing === 0) {
|
this.info.result = true;
|
this.info.msg = "审核驳回";
|
} else if (auditing === 2) {
|
this.info.result = true;
|
this.info.msg = "通过审核";
|
} else {
|
this.info.result = true;
|
this.info.msg = "审核失败";
|
}
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 更新货主信息
|
/**
|
* 签署状态更新
|
*/
|
@Post()
|
public async updateSign() {
|
let { ctx } = this;
|
let body = ctx.body; // 接收前端发来的数据
|
let signingStatus = body.signingStatus; // 接收签署状态 1 签署成功 2签署驳回
|
let userInfo = await ctx.helper.userInfo(); // 权限
|
let userProduct_Id = userInfo.userProduct_Id; // 获取权限id
|
try {
|
let dataInfo = await this.dbRead.findOne(BaseDriverContract, {
|
where: {
|
contract_Id: body.contract_Id,
|
userProduct_Id: userProduct_Id
|
}
|
});
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "数据不存在";
|
ctx.body = this.info;
|
return;
|
}
|
await this.dbWrite.update(
|
BaseDriverContract,
|
{
|
contract_Id: body.contract_Id
|
},
|
{
|
signingStatus: signingStatus
|
}
|
);
|
if (signingStatus === "已签署") {
|
this.info.result = true;
|
this.info.msg = "签署成功";
|
} else if (signingStatus === "未签署") {
|
this.info.result = true;
|
this.info.msg = "签署驳回";
|
} else {
|
this.info.result = false;
|
this.info.msg = "签署失败";
|
}
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
}
|