util.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
  4. const { BusinessError, ErrorCode } = require('naf-core').Error;
  5. const _ = require('lodash');
  6. const moment = require('moment');
  7. // 业务工具
  8. class UtilController extends Controller {
  9. constructor(ctx) {
  10. super(ctx);
  11. this.queryObject = this.ctx.query;
  12. this.bodyObject = this.ctx.request.body;
  13. this.service = this.ctx.service.util;
  14. this.tradeService = this.ctx.service.util.trade;
  15. }
  16. async util() {
  17. // await this.ctx.service.util.rabbitMq.shopMsg('6333d71d32c5f69745f9bd32');
  18. this.ctx.ok({ data: 'ok' });
  19. }
  20. async crk() {
  21. const key = await this.ctx.service.util.rk.crk();
  22. this.ctx.ok({ data: key });
  23. }
  24. /**
  25. * 查询是否可以购买
  26. */
  27. async checkCanBuy() {
  28. const data = await this.tradeService.checkCanBuy(this.bodyObject);
  29. this.ctx.ok({ data });
  30. }
  31. async checkCartBuy() {
  32. const data = await this.tradeService.checkCartBuy(this.bodyObject);
  33. this.ctx.ok({ data });
  34. }
  35. async getGroup() {
  36. this.ctx.ok();
  37. }
  38. }
  39. module.exports = CrudController(UtilController, {});