payIn.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { CoolController, BaseController } from '@cool-midway/core';
  2. import { ALL, Body, Get, Inject, Post, Provide,Query,Param } from '@midwayjs/decorator';
  3. import { BusinessEntity } from '../../payment/entity/business';
  4. import { OrderService } from "../../payment/service/order";
  5. /**
  6. * 入金
  7. */
  8. @Provide()
  9. @CoolController('/api/v1/Fiat')
  10. export class PayInController extends BaseController {
  11. @Inject()
  12. orderService: OrderService;
  13. /**
  14. * 创建订单
  15. * /api/v3/Fiat/PayIn
  16. */
  17. @Post('/PayIn', { summary: '创建订单' })
  18. async createPayInOrder(@Body(ALL) business: BusinessEntity) {
  19. // if (!this.allowKeys.includes(key)) {
  20. // return this.fail('非法操作');
  21. // }
  22. // 关键参数校验
  23. // 数据落库
  24. // 回调
  25. console.log('createPayInOrder-=-=payIn-=-=000',business);
  26. return this.ok(await this.orderService.recharge(business));
  27. }
  28. /**
  29. * 查询订单
  30. * /api/v3/Fiat/PayIn/{orderNo}
  31. */
  32. @Get('/PayIn/', { summary: '查询订单' })
  33. async getPayInForOrderNo(@Query('orderNo') orderNo: string,) {
  34. // if (!this.allowKeys.includes(key)) {
  35. // return this.fail('非法操作');
  36. // }
  37. // 关键参数校验
  38. // 数据落库
  39. // 回调
  40. console.log('getPayInForOrderNo-=-=-=-111',orderNo);
  41. return this.ok(await this.orderService.rechargeOrder({ orderNo: orderNo,channel:'SUNPAY'}));
  42. }
  43. /**
  44. * 取消订单
  45. * /api/v3/Fiat/PayIn/{orderNo}/Cancel
  46. */
  47. @Post('/PayIn/:orderNo/Cancel', { summary: '取消订单' })
  48. async cancelPayInOrderForOrderNo(@Param('orderNo') orderNo: string) {
  49. // if (!this.allowKeys.includes(key)) {
  50. // return this.fail('非法操作');
  51. // }
  52. // 关键参数校验
  53. // 数据落库
  54. // 回调
  55. console.log('cancelPayInOrderForOrderNo-=-=-=111',orderNo);
  56. return this.ok(await this.orderService.rechargeOrderCancel({orderNo:orderNo}));
  57. }
  58. // /**
  59. // * TODO 创建订单回调通知
  60. // * /api/v3/Fiat/PayIn/{orderNo}/Cancel
  61. // */
  62. // @Post('Fiat/PayIn/orderNo/Cancel', { summary: '创建订单回调通知' })
  63. // async createPayInOrderForCallback(@Body(ALL) business: BusinessEntity) {
  64. // // if (!this.allowKeys.includes(key)) {
  65. // // return this.fail('非法操作');
  66. // // }
  67. // // 关键参数校验
  68. // // 数据落库
  69. // // 回调
  70. // console.log(business);
  71. // return this.ok('hello, cool-admin!!!');
  72. // }
  73. }