Skip to content

SAAS中枢API规范

站点的某个saas ->中枢

php

//请求(站点的某个saas)
use app\model\SaasCmd;
global $_W;
$aciton = "/api/wxthird/upload_code";
 $param = [
            "version" => $version,
            "uniacid" => $_W["uniacid"], //有带uniacid参数,表示为某个saas,不带则表示站点的请求
        ];
  $res = (new SaasCmd())->apiPost($aciton, $param);

//响应 (中枢)  app/Http/Controllers/xxController.php
app\Http\Controllers\Server\ApiBaseController.php  --为基类

站点 ->中枢(在框架中执行)

php
//请求(站点)
use App\Lib\SaasCmd;
$aciton = "/api/wxthird/upload_code";
 $param = [
            "version" => $version,
        ];
  $res = (new SaasCmd())->apiPost($aciton, $param);
  
//响应 (中枢)  app/Http/Controllers/Server/xxController.php
app\Http\Controllers\Server\ApiBaseController.php  --为基类

中枢->站点的某个saas

php

//请求(中枢)
use App\Lib\Notify\ServerNotify;
  $server = Server::where("appid", $bind["server_appid"])->first();
            $domain = $server["domain"];
            $uniacid = $bind["uniacid"];
            $action = "wxcodeupload_bindResult"; //用_隔开,第一个字符串为controller名,第二个字符串为方法名
            $res = (new ServerNotify())->sendSaas($domain, $uniacid, $action, $data);
            
//响应 (站点的某个saas)  application/saasapi/controller/xx.php

中枢->站点(在框架中收到)

php
//请求(中枢)
use App\Lib\Notify\ServerNotify;
  $server = Server::where("appid", $bind["server_appid"])->first();
            $domain = $server["domain"];
             $action = "createsaas";
            $res = (new ServerNotify())->sendServer($domain, $action, $data);
            
            
//响应 (站点-框架)  app/Http/Controllers/xxController.php
app\Http\Controllers\ApiSaaSBaseController.php -为基类

销售平台->中枢

php
//请求(销售平台)
use app\plugins\autosaas\model\AutosaasApi;
$param = [
];
 $res = (new AutosaasApi())->apiPost("/api/account_create", $param);

//响应 (中枢)  app/Http/Controllers/Platform/xxController.php
app\Http\Controllers\Platform\ApiBaseController.php  --为基类

中枢->销售平台

php
//请求(中枢)
use App\Lib\Notify\PlatformNotify;
$platform_id = 1;
$action = "wxcodeupload_bindResult"; //用_隔开,第一个字符串为controller名,第二个字符串为方法名
$data = [];
$res = (new PlatformNotify())->send($platform_id, $action, $data);

//响应 (销售平台)  application/plugins/autosaas/notify/controller/xx.php
application/plugins/autosaas/notify/controller/ApiNewBase.php  --为基类

对外->中枢

php
//请求(对外)
暂不支持

//响应 (中枢)  app/Http/Controllers/External/xxController.php
app\Http\Controllers\External\ApiBaseController.php  --为基类

中枢->对外

php
//请求(中枢)
use App\Lib\Notify\ExternalNotify;
$platform_id = 1;
$action = "wxcodeupload_bindResult"; //用_隔开,第一个字符串为controller名,第二个字符串为方法名
$data = [];
$res = (new ExternalNotify())->send($platform_id, $action, $data);

//响应 (销售平台)  
暂不支持

站点的某个saas ->中枢-->销售平台(用于中转)

php

//请求(站点的某个saas)
use app\model\SaasCmd;
global $_W;
$aciton = "/api/saas_to_platform";
 $param = [
            "version" => $version,
            "platform_action" => "test_hello", //销售平台的控制器及方法
            "uniacid" => $_W["uniacid"], //有带uniacid参数,表示为某个saas,不带则表示站点的请求
        ];
  $res = (new SaasCmd())->apiPost($aciton, $param);

//响应 (中枢)  App\Http\Controllers\SaasToPlatformController.php--sassToPlatform方法

数据库API日志文件

php
1. 站点与saas

server_apilogs

server_notifylogs

2. 销售平台

platform_apilogs

platform_notifylogs


3. 对外平台

external_apilogs

external_notifylogs