import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { TMSClaimAcceptance } from "../../entity/express/tms/tmsClaimAcceptance";
|
import { TMSClaim } from "../../entity/express/tms/tmsClaim";
|
|
/**
|
* 理赔处理
|
*/
|
export default class ClaimController extends BaseController {
|
//#region 受理运单
|
@Post()
|
public async acceptanceOrder() {
|
try {
|
let acceptanceInfo = new TMSClaimAcceptance();
|
acceptanceInfo.claimAcceptanceType = this.body.backWay; //受理结果
|
acceptanceInfo.claimAcceptanceDesc = this.body.descText; // 受理内容 //受理方式
|
acceptanceInfo.claim_Id = this.body.claim_Id;
|
acceptanceInfo.acceptanceWay = this.body.acceptanceWay; //受理方式
|
acceptanceInfo.createDate = new Date();
|
await this.dbWrite.save(acceptanceInfo);
|
|
let data: any = {};
|
data.claimStatus = this.body.state;
|
data.acceptResult = this.body.backWay;
|
if (this.body.claimAmount) {
|
data.claimAmount = this.body.claimAmount;
|
}
|
await this.dbWrite.update(TMSClaim, this.body.claim_Id, data);
|
this.info.result = true;
|
this.info.msg = "受理成功";
|
this.ctx.body = this.info;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误消息:" + ex.message;
|
this.ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 受理-发送通知消息
|
/// <summary>
|
/// 发送通知消息
|
/// </summary>
|
/// <param name="this.body">发送通知消息参数</param>
|
/// <returns>返回发送通知消息是否成功</returns>
|
@Post()
|
public async sendMsgToMobile() {
|
let claimInfo = await this.dbRead.findOne(TMSClaim, this.body.claim_Id);
|
|
try {
|
//#region 校验数据
|
//验证手机号不能为空
|
if (claimInfo.mobile == "") {
|
this.info.result = false;
|
this.info.msg = "您没有输入手机号!";
|
this.ctx.body = this.info;
|
}
|
//验证手机号格式是否正确
|
let reg = /^(134[012345678]\d{7}|1[345789][012356789]\d{8})$/;
|
if (!reg.test(claimInfo.mobile)) {
|
this.info.result = false;
|
this.info.statusCode = 1205;
|
this.info.state = "mobileFormatError";
|
this.info.msg = "手机号格式错误";
|
this.ctx.body = this.info;
|
}
|
|
//#endregion
|
|
// 发送验证码
|
let mobile = claimInfo.mobile;
|
let code = -1;
|
if (this.body.aackWay == "已受理") {
|
code = 2828526;
|
} else if (this.body.aackWay == "不予受理") {
|
code = 2828530;
|
} else if (this.body.aackWay == "确认赔付") {
|
code = 2828542;
|
} else if (this.body.aackWay == "不予赔付") {
|
code = 2828552;
|
}
|
let params = {
|
"#order_number#": claimInfo.claimCode,
|
"#name#": claimInfo.contacts
|
};
|
this.info = await this.ctx.service.utils.smsHelper.sendYPSMS(mobile, params, code);
|
this.ctx.body = this.info;
|
} catch (ex) {
|
let msg = "出现异常:" + ex.essage;
|
this.info.result = false;
|
this.info.statusCode = 500;
|
this.info.msg = msg;
|
this.ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 受理-发送邮件
|
@Post()
|
public async sendEmaliToFriend() {
|
try {
|
//发送邮件
|
let mailSubject = this.ctx.service.common.getConfig("mailSubject");
|
let mailBody = "<div>" + this.body.DescText + "</div>"; //邮件内容
|
let result = this.ctx.helper.sendMail(this.body.email, mailSubject, mailBody);
|
if (result) {
|
this.info.result = true;
|
this.info.msg = "发送成功";
|
this.ctx.body = this.info;
|
} else {
|
this.info.result = true;
|
this.info.msg = "发送失败";
|
this.ctx.body = this.info;
|
}
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误消息:" + ex.essage;
|
this.ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 获取跟进记录
|
/// <summary>
|
/// 获取跟进记录
|
/// </summary>
|
/// <param name="this.body"></param>
|
/// <returns></returns>
|
@Post()
|
public async getClaimList() {
|
try {
|
let claimInfo = await this.dbRead.find(TMSClaimAcceptance, {
|
claim_Id: this.body.claim_Id
|
});
|
this.info.data = claimInfo;
|
this.info.result = true;
|
} catch (ex) {
|
this.info.msg = ex.essage;
|
this.info.result = false;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
}
|