|
@@ -12,6 +12,7 @@ class OrderService extends CrudService {
|
|
|
this.model = this.ctx.model.Order;
|
|
|
this.util = this.ctx.service.util.util;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* 新添订单
|
|
|
* @param {Object} data 订单数据
|
|
@@ -184,7 +185,6 @@ class OrderService extends CrudService {
|
|
|
|
|
|
const good = order.split.id(split_id);
|
|
|
good.status = '1';
|
|
|
- console.log(good);
|
|
|
order.goods_status = await this.checkGoodsStatus(order.split);
|
|
|
await this.model.update({ _id: order._id }, order);
|
|
|
|
|
@@ -426,7 +426,6 @@ class OrderService extends CrudService {
|
|
|
*/
|
|
|
async clientExport(query) {
|
|
|
const { ids } = query;
|
|
|
- console.log(ids);
|
|
|
let list = await this.model
|
|
|
.find({ _id: ids.map(i => ObjectId(i)) })
|
|
|
.populate([
|
|
@@ -482,7 +481,7 @@ class OrderService extends CrudService {
|
|
|
const res = i.replace(reg, '');
|
|
|
return res;
|
|
|
});
|
|
|
- let lastData = arr.map(i => ({ content: i }));
|
|
|
+ let lastData = arr.map(i => ({ content: i }));
|
|
|
lastData.push({ content: header });
|
|
|
const alignment = { vertical: 'middle', horizontal: 'center' };
|
|
|
lastData = lastData.map(i => ({ ...i, alignment }));
|
|
@@ -625,7 +624,6 @@ class OrderService extends CrudService {
|
|
|
for (const oin of inList) {
|
|
|
const { key, item, value } = oin;
|
|
|
const r = in_bill.find(f => f.item === item);
|
|
|
-
|
|
|
if (r) {
|
|
|
obj[`${key}${os}`] = _.get(r, value);
|
|
|
}
|
|
@@ -718,8 +716,15 @@ class OrderService extends CrudService {
|
|
|
assert(client, '缺少客户信息');
|
|
|
assert(owner, '缺少创建人信息');
|
|
|
const params = { ids, client, owner };
|
|
|
- const bill = await this.ctx.model.Bill.create({ params, client, owner, ...info });
|
|
|
- if (!bill) { throw new BusinessError(ErrorCode.DATABASE_FAULT, '结算单创建失败'); }
|
|
|
+ const bill = await this.ctx.model.Bill.create({
|
|
|
+ params,
|
|
|
+ client,
|
|
|
+ owner,
|
|
|
+ ...info,
|
|
|
+ });
|
|
|
+ if (!bill) {
|
|
|
+ throw new BusinessError(ErrorCode.DATABASE_FAULT, '结算单创建失败');
|
|
|
+ }
|
|
|
const res = await this.model.updateMany(
|
|
|
{ _id: ids.map(i => ObjectId(i)) },
|
|
|
{ is_js: true }
|
|
@@ -733,13 +738,14 @@ class OrderService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
* 支出结算
|
|
|
* @param {Object} {ids,client,car_no} ids:订单id列表,client:客户id,car_no:车牌号(第三方)/车辆id(自运)
|
|
|
*/
|
|
|
async outJs({ ids, client, car_no }) {
|
|
|
- const orderList = await this.model.find({ _id: ids.map(i => ObjectId(i)) });
|
|
|
+ const orderList = await this.model.find({
|
|
|
+ _id: ids.map(i => ObjectId(i)),
|
|
|
+ });
|
|
|
for (const order of orderList) {
|
|
|
const { out_bill, _id } = order;
|
|
|
let target;
|
|
@@ -747,7 +753,7 @@ class OrderService extends CrudService {
|
|
|
if (client) {
|
|
|
res = out_bill.filter(f => f.client === client);
|
|
|
const cInfo = await this.ctx.model.Client.findById(client);
|
|
|
- if (!cInfo) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定供应商');
|
|
|
+ if (!cInfo) { throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定供应商'); }
|
|
|
target = _.get(cInfo, 'name');
|
|
|
} else {
|
|
|
res = out_bill.filter(f => f.car_no === car_no);
|
|
@@ -756,7 +762,7 @@ class OrderService extends CrudService {
|
|
|
target = car_no;
|
|
|
} else {
|
|
|
const cInfo = await this.ctx.model.Car.findById(car_no);
|
|
|
- if (!cInfo) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定车辆');
|
|
|
+ if (!cInfo) { throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定车辆'); }
|
|
|
target = cInfo.car_no;
|
|
|
}
|
|
|
}
|