import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { TMSFreightPrice } from "../../entity/express/tms/tmsFreightPrice";
|
import { BaseConsignor } from "../../entity/basicInfo/consignor/baseConsignor";
|
|
/**
|
* 运费价格设置
|
*/
|
export default class FreightPriceController extends BaseController {
|
//#region getFreightPriceList 获取运费模板中的数据
|
/// <summary>
|
/// 获取运费模板中的数据
|
/// </summary>
|
/// <returns></returns>
|
@Post()
|
public async getFreightPriceList() {
|
try {
|
var model = await this.dbRead.find(TMSFreightPrice, {
|
userProduct_Id: (await this.userInfo).userProduct_Id,
|
port_Id: this.body.port_Id
|
});
|
if (model != null) {
|
this.info.result = true;
|
this.info.data = model;
|
}
|
} catch (e) {
|
this.info.result = false;
|
this.info.msg = e.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region saveTemplateSettingList 保存运费模板设置
|
@Post()
|
public async saveTemplateSettingList() {
|
if (!this.body.port_Id) {
|
this.info.result = false;
|
this.info.msg = "口岸不能为空";
|
this.ctx.body = this.info;
|
return;
|
}
|
for (var item of this.body.dataList) {
|
let conInfo = await this.dbRead.findOne(BaseConsignor, {
|
consignor_Id: this.body.consignor_Id
|
});
|
if (conInfo != null) {
|
item.creator = conInfo.consignorName;
|
item.createID = conInfo.consignor_Id;
|
}
|
let model = await this.dbRead.findOne(TMSFreightPrice, {
|
expressCorp_Id: item.expressCorp_Id,
|
port_Id: item.port_Id
|
});
|
if (!model) {
|
let fre = new TMSFreightPrice();
|
fre.expressCorp_Id = item.expressCorp_Id;
|
fre.expressCorpName = item.expressCorpName;
|
fre.port_Id = item.port_Id;
|
fre.portName = item.portName;
|
fre.feeRate = item.feeRate;
|
fre.unit = item.unit;
|
fre.unit_Id = item.unit_Id;
|
fre.remark = item.remark;
|
fre.createID = item.createID;
|
fre.creator = item.creator;
|
await this.setAccountInfo(fre);
|
fre.enable = item.enable;
|
fre.createDate = new Date();
|
await this.dbWrite.save(fre);
|
} else {
|
model.expressCorp_Id = item.expressCorp_Id;
|
model.expressCorpName = item.expressCorpName;
|
model.port_Id = item.port_Id;
|
model.portName = item.portName;
|
model.feeRate = item.feeRate;
|
model.unit = item.unit;
|
model.unit_Id = item.unit_Id;
|
model.remark = item.remark;
|
model.createID = item.createID;
|
model.creator = item.creator;
|
await this.setAccountInfo(model);
|
model.enable = item.enable;
|
await this.dbWrite.save(model);
|
}
|
}
|
this.info.result = true;
|
this.info.msg = "保存成功";
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
}
|