333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
}