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
|
}
|