import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { ExpressYTOrder } from '../../entity/express/yuantong/expressYTOrder';
|
|
export default class ExpressZTOrderController extends BaseController {
|
//#region 获取路由 getRouteByYT
|
/// <summary>
|
///圆通获取路由 getRouteByYT
|
/// </summary>
|
/// <returns>返回获取路由结果</returns>
|
///
|
@Post()
|
public async getRouteByYT() {
|
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(ExpressYTOrder, {
|
mailNo: orderId
|
});
|
info = await ctx.service.express.yuantongHelper.getRouteByYT(orderInfo.yTOrder_Id);
|
if (!info.result) {
|
aLLSuccess = false;
|
}
|
msg = msg + info.msg;
|
}
|
this.info.result = aLLSuccess;
|
this.info.msg = msg;
|
ctx.body = this.info;
|
return;
|
|
//this.info = await this.ctx.service.express.yuantongHelper.getRouteByYT();
|
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = ex.message;
|
ctx.body = this.info;
|
return;
|
}
|
}
|
//#endregion
|
|
//#region 圆通推送运单 pushOrderbyYT
|
/// <summary>
|
///圆通推送运单 pushOrderbyYT
|
/// </summary>
|
/// <returns>返回获取快递单号结果</returns>
|
///
|
@Post()
|
public async pushOrderbyYT() {
|
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.yuantongHelper.pushOrderbyYT(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
|
}
|