123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- import { CoolController, BaseController } from '@cool-midway/core';
- import { Context } from '@midwayjs/koa';
- import {Fields, Files, Get, Provide, Query} from '@midwayjs/core';
- import {ALL, Body, Inject, Post} from "@midwayjs/decorator";
- import {EasyPayAdapter} from "../../../payment/adapter/easypay.adapter";
- import {EasyOpenService} from "../../service/open";
- import {accountsService} from "../../service/admin/accounts";
- import {OpenApplicationsEntity} from "../../entity/open_applications";
- import { applicationsService } from '../../service/admin/applications';
- /**
- * 开发接口的流水订单
- */
- @Provide()
- @CoolController({
- api: ['add', 'delete', 'update', 'info', 'list', 'page'],
- entity: OpenApplicationsEntity,
- pageQueryOp: {
- where: async (ctx: Context) => {
- const { merchant, roleId } = ctx.admin;
- if ([1, 3].includes(roleId)) {
- return [['mchId=:mchId', { mchId: merchant.mchId }]];
- }
- return [];
- },
- },
- })
- export class ApplicationsController extends BaseController {
- @Inject()
- ctx: Context; // Inject the context
- @Inject()
- easyPayAdapter: EasyPayAdapter;
- @Inject()
- easyOpenService: EasyOpenService;
- @Inject()
- accountsService: accountsService;
- @Inject()
- applicationsService: applicationsService;
- /**
- * merchant_certification
- */
- @Post('/v1/upload', { summary: '上传文件' })
- async upload(@Files() files: any[], @Fields() fields) {
- const results = [];
- for (const file of files) {
- const result = await this.easyOpenService.upload(file);
- results.push(result);
- }
- return { success: true, data: results };
- }
- /**
- * 申请收款账户
- * {
- * "request_id": "fusion_0002",
- * "purpose": "ECOMM_PLATFORM",
- * "account_id": "2bd64372841a54bf8b41f879ff07884b",
- * "currency": "EUR",
- * "payment_type": "SWIFT",
- * "additional_info": {
- * "online_sales_method": "AMAZON",
- * "payer_party": "AMAZON",
- * "store_name": "redius",
- * "store_photos": ["2123321"],
- * "business_category": "纺织、服装及日化用品专门销售",
- * "store_address": {
- * "region": "HK",
- * "city": "HK",
- * "street": "HK"
- * }
- * }
- * }
- *
- *
- * {
- id: '48a39dc9aec5417b883fcd3d5f9f5a0a',
- request_id: 'fusionget_1740974452715',
- reference: null,
- account_id: '2bd64372841a54bf8b41f879ff07884b',
- order_no: '20250303120053717551',
- currency: 'EUR',
- payment_type: 'SWIFT',
- purpose: 'ECOMM_STANDALONE',
- additional_info: {
- store_name: '赚钱浜',
- offline_sales_method: null,
- online_sales_method: 'AMAZON,SHOPIFY',
- website_url: 'va.fusion.com',
- store_photos: [
- 'http://easypay-legal-entity-demo.oss-cn-hongkong.aliyuncs.com/fusion/uploads/1740973141012_9.png'
- ],
- business_category: '纺织、服装及日化用品专门销售',
- business_regions: null,
- monthly_transaction_count: 1000,
- monthly_transaction_amount: null,
- payer_party: 'AMAZON',
- payer_party_account: '1231231',
- funds_regions: null,
- funds_type: 'INVESTMENT',
- documents: null,
- store_address: {
- region: 'HK',
- state_or_province: '香港',
- city: '香港',
- street: '香港西贡区市场街124号',
- zip_code: '123123'
- },
- official_account: null,
- official_account_appid: null,
- mini_program: null,
- mini_program_appid: null,
- app_download_url: null,
- app_appid: null,
- abbreviated_company_name: null
- },
- status: 'PENDING',
- reason: null,
- create_time: '2025-03-03T12:00:53+08:00',
- update_time: '2025-03-03T12:00:53+08:00'
- }
- */
- @Post('/applications', { summary: '申请收款账户' })
- async createPayInOrder(@Body(ALL) params: any) {
- return await this.applicationsService.addApplications(params, {
- fail: this.fail,
- ok: this.ok,
- })
- // this.easyOpenService.save_user(res, params);
- // return res;
- }
- /**
- * 创建账户
- */
- @Post('/get_applications_list', { summary: '创建账户' })
- async getApplicationsList(@Body(ALL) params: any) {
- // 获取申请列表
- return await this.applicationsService.getApplicationsList(params);
- // this.easyOpenService.save_user(res, params);
- // return res;
- }
- /**
- * 获取用户的账户余额
- */
- @Post('/getApplicationsListByMchId', { summary: '获取用户的账户余额' })
- async getApplicationsListByMchId() {
- // 获取申请列表
- return await this.applicationsService.getApplicationsListByMchId();
- // this.easyOpenService.save_user(res, params);
- // return res;
- }
- /**
- * 获取用户的账户流水
- */
- @Get('/getTransactionsListByMchId', { summary: '获取用户的账户流水' })
- async getTransactionsListByMchId(@Query(ALL) params: any,) {
- return await this.applicationsService.getTransactionsListByMchId(params);
- }
- /**
- * 获取用户的收款账户
- */
- @Get('/getBankAccountsBy', { summary: '获取用户的收款账户' })
- async getBankAccountsBy(@Query(ALL) params: any,) {
- return await this.applicationsService.getBankAccountsBy(params);
- }
- /**
- * 查询汇率
- */
- @Get('/getExchangeCurrency', { summary: '获取用户的收款账户' })
- async getExchangeCurrency(@Query(ALL) params: any,) {
- return await this.applicationsService.getExchangeCurrency(params);
- }
- /**
- * 换汇
- */
- @Post('/exchanges', { summary: '获取用户的收款账户' })
- async exchanges(@Body(ALL) params: any,) {
- return await this.applicationsService.exchanges(params);
- }
- /**
- * 转账
- * 账户:b847628dec3e59509ac3d3f9d32ad533
- */
- @Post('/transfer', { summary: '获取用户的收款账户' })
- async transfer(@Body(ALL) params: any,) {
- return await this.applicationsService.transfer(params);
- }
- /**
- * 付款
- * 账户:b847628dec3e59509ac3d3f9d32ad533
- */
- @Post('/payments', { summary: '获取用户的收款账户' })
- async payments(@Body(ALL) params: any,) {
- return await this.applicationsService.payments(params);
- }
- }
|