max 5 mesi fa
parent
commit
0ec56b8d92

+ 1 - 1
src/modules/api/controller/admin/accounts.ts

@@ -68,7 +68,7 @@ export class AccountsController extends BaseController {
       }
     });
     if(res.hasOwnProperty('errors') && res.errors.length > 0) {
-      return this.fail("添加失败!")
+      return res
     }
     // 创建商户
     await this.accountsService.addAccounts(params, res)

+ 8 - 9
src/modules/api/middleware/authority.ts

@@ -77,7 +77,6 @@ export class BaseAuthorityMiddleware
           },
         ],
       });
-      console.log(80, merchantInfo, vaKey);
       let customer = await this.customerEntity.findOne({
         where: {
           merchantId: merchantInfo.mchId,
@@ -136,14 +135,14 @@ export class BaseAuthorityMiddleware
       );
       console.log('9999-=-=',`${sign}`.toLocaleUpperCase())
       console.log('1000-=-=',`${vaSign}`.toLocaleUpperCase())
-      // if (`${sign}`.toLocaleUpperCase() !== `${vaSign}`.toLocaleUpperCase()) {
-      //   ctx.status = 401;
-      //   ctx.body = {
-      //     code: ctx.status,
-      //     message: '签名不匹配,认证失败',
-      //   };
-      //   return;
-      // }
+      if (`${sign}`.toLocaleUpperCase() !== `${vaSign}`.toLocaleUpperCase()) {
+        ctx.status = 401;
+        ctx.body = {
+          code: ctx.status,
+          message: '签名不匹配,认证失败',
+        };
+        return;
+      }
 
       /*如果说商户没有认证,我们需要提示商户进行认证*/
       // this.customerEntity

+ 15 - 9
src/modules/api/service/open.ts

@@ -3,6 +3,7 @@ import { ILogger, Init, Inject, Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
 import { OpenUserEntity } from '../entity/open_user';
 import * as crypto from 'crypto';
+import * as fs from 'fs';
 import { LessThan, QueryRunner, Repository } from 'typeorm';
 import {
   OpenPaymentOrderEntity,
@@ -366,14 +367,17 @@ export class EasyOpenService extends BaseService {
       // 生成 OSS 存储路径(带原始文件名)
       const ossPath = `fusion/uploads/${Date.now()}_${file.filename}`;
       // const result = await this.ossService.put('/test/test.log', localFile);
-
-      // 使用临时文件路径上传
-      const result = await this.ossService.put(
-        ossPath,
-        file.data, // 直接使用 file.data 作为路径
-        // 如果需要设置 headers 可以添加第三个参数
-        { headers: { 'Content-Type': file.mimeType } }
-      );
+      const fileContent = typeof file.data === 'string' ? fs.readFileSync(file.data) : file.data;
+      const result = await this.ossService.put(ossPath, fileContent, {
+        headers: { 'Content-Type': file.mimeType },
+      });
+      // // 使用临时文件路径上传
+      // const result = await this.ossService.put(
+      //   ossPath,
+      //   file.data, // 直接使用 file.data 作为路径
+      //   // 如果需要设置 headers 可以添加第三个参数
+      //   { headers: { 'Content-Type': file.mimeType } }
+      // );
       console.log(file.data);
       // await unlinkSync(file.data);
 
@@ -383,7 +387,9 @@ export class EasyOpenService extends BaseService {
         originalName: file.filename,
         size: file.size,
       };
-    } catch (e) {}
+    } catch (e) {
+      console.log(e);
+    }
   }
 
     // 获取商户信息

+ 0 - 1
src/modules/payment/adapter/easypay.adapter.ts

@@ -155,7 +155,6 @@ export class EasyPayAdapter {
     let url = this.config.apiUrl;
     try {
       url = `${url}${endpoint.replace('/api/open', '')}`;
-      console.log(158, data)
       const accessToken = await this.config.tokenManager.getAccessToken();
       const axiosParams = {
         method,