transport.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict';
  2. const _ = require('lodash');
  3. const moment = require('moment');
  4. const meta = require('./.transport.js');
  5. const Controller = require('egg').Controller;
  6. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  7. // 运输
  8. class TransportController extends Controller {
  9. constructor(ctx) {
  10. super(ctx);
  11. this.service = this.ctx.service.order.transport;
  12. }
  13. /**
  14. * 运输签收
  15. */
  16. async sign() {
  17. const res = await this.service.sign(this.ctx.request.body);
  18. this.ctx.ok(res);
  19. }
  20. /**
  21. * 获取运输单号
  22. */
  23. async getNo() {
  24. const no = `t_${moment().format('YYYYMMDDHHmmss')}_${_.random(100, 999)}`;
  25. this.ctx.ok({ data: no });
  26. }
  27. /**
  28. * 单趟核算
  29. */
  30. async calculate() {
  31. const data = await this.service.calculate(this.ctx.request.body);
  32. this.ctx.ok({ data });
  33. }
  34. /**
  35. * 单车核算
  36. */
  37. async carCalculate() {
  38. const data = await this.service.carCalculate(this.ctx.request.body);
  39. this.ctx.ok({ data });
  40. }
  41. /**
  42. * 核算导出
  43. */
  44. async toExport() {
  45. const data = await this.service.toExport(this.ctx.request.body);
  46. this.ctx.ok({ data });
  47. }
  48. /**
  49. * 供应商结算导出
  50. */
  51. async supplierExport() {
  52. const res = await this.service.supplierExport(this.ctx.request.body);
  53. this.ctx.ok({ data: res });
  54. }
  55. /**
  56. * 供应商支出结算
  57. */
  58. async supplierJs() {
  59. const res = await this.service.js(this.ctx.request.body);
  60. this.ctx.ok({ data: res });
  61. }
  62. }
  63. module.exports = CrudController(TransportController, meta);