import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { ExpressSTOOrder } from '../../entity/express/shentong/expressSTOOrder';
|
|
export default class ExpressSTOOrderController extends BaseController {
|
//#region 获取路由 getRouteBySTO
|
/// <summary>
|
///申通获取路由 getRouteBySTO
|
/// </summary>
|
/// <returns>返回获取路由结果</returns>
|
///
|
@Post()
|
public async getRouteBySTO() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
try {
|
// #region 校验数据
|
if (!body.orderIdList) {
|
this.info.result = false;
|
this.info.msg = "至少选择一条记录!";
|
ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
|
let orderIdList = body.orderIdList.split(",");
|
var aLLSuccess = true;
|
var msg = "返回信息:";
|
for (let orderId of orderIdList) {
|
let info = null;
|
let orderInfo = await this.dbRead.findOne(ExpressSTOOrder, {
|
stoOrder_Id: orderId
|
});
|
info = await ctx.service.express.stoHelper.getRouteBySTO(orderInfo.stoOrder_Id);
|
if (!info.result) {
|
aLLSuccess = false;
|
}
|
msg = msg + info.msg;
|
}
|
this.info.result = aLLSuccess;
|
this.info.msg = msg;
|
ctx.body = this.info;
|
return;
|
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = ex.message;
|
ctx.body = this.info;
|
return;
|
}
|
}
|
//#endregion
|
|
//#region 申通推送运单 pushOrderbySTO
|
/// <summary>
|
///申通推送运单 pushOrderbySTO
|
/// </summary>
|
/// <returns>返回获取快递单号结果</returns>
|
///
|
@Post()
|
public async pushOrderbySTO() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
try {
|
//#region 校验数据
|
|
if (!body.orderIdList) {
|
this.info.result = false;
|
this.info.msg = "至少选择一条记录!";
|
ctx.body = this.info;
|
return;
|
}
|
// #endregion
|
let orderIdList = body.orderIdList.split(",");
|
var aLLSuccess = true;
|
var msg = "返回信息:";
|
for (let orderId of orderIdList) {
|
let info = null;
|
info = await ctx.service.express.stoHelper.pushOrderbySTO(orderId);
|
if (!info.result) {
|
aLLSuccess = false;
|
}
|
msg = msg + info.msg;
|
}
|
this.info.result = aLLSuccess;
|
this.info.msg = msg;
|
ctx.body = this.info;
|
return;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = ex.message;
|
ctx.body = this.info;
|
return;
|
}
|
}
|
// #endregion
|
}
|