schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
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
import BaseController from "../baseController";
import { Post } from "egg-shell-decorators";
import { OACommonMessage } from "../../entity/oa/message/oACommonMessage";
 
/**
 * 短信发送
 */
export default class WaybillAbnormalController extends BaseController {
  //#region  发送短信
  /// <summary>
  /// 发送短信
  /// </summary>
  /// <param name="reqInfo"></param>
  /// <returns></returns>
  @Post()
  public async send() {
    var where = "CommonMessage_Id in(:...ids)/* And isnull(MsgStatus, '未发送')='未发送'*/";
    var smsList = await this.dbRead
      .createQueryBuilder(OACommonMessage, "t")
      .where(where, {
        ids: this.body.ids
      })
      .getMany();
    let sendCount = 0;
    for (var smsInfo of smsList) {
      try {
        if (smsInfo.mainInnerCode) {
          let params = {
            "#order_number#": smsInfo.message
          };
          this.info = await this.ctx.service.utils.smsHelper.sendYPSMS(smsInfo.mainInnerCode, params, smsInfo.mainId);
          if (this.info.result) {
            await this.dbWrite.update(OACommonMessage, smsInfo.commonMessage_Id, {
              sendCount: smsInfo.sendCount++,
              sendDate: new Date(),
              msgStatus: "已发送"
            });
          }
          sendCount++;
        }
      } catch (ex) {}
    }
    this.info.msg += ",共发送:" + sendCount + "条短信";
 
    this.ctx.body = this.info;
  }
  //#endregion
}