41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
namespace addon\supply\v1;
|
|
use addon\ali1688\model\Choice;
|
|
use addon\saas\model\Config as ConfigModel;
|
|
use addon\supply\model\Supplier;
|
|
use app\Controller;
|
|
use app\model\system\Site as SiteModel;
|
|
|
|
class ApiBase extends Controller
|
|
{
|
|
protected $appInfo = [];
|
|
protected $SiteInfo = [];
|
|
protected $AgConfig = [];
|
|
|
|
protected $ag_site_id = 0;
|
|
protected $SupplyInfo = [];
|
|
protected $Choice;
|
|
|
|
protected $supplier_site_id;
|
|
|
|
public function __construct($data = [])
|
|
{
|
|
$this->appInfo = $data;
|
|
if (isset($data['site_id'])) {
|
|
request()->siteid($data['site_id']);
|
|
$field = 'site_id,agent_id,site_name,manage_id,manage_name';
|
|
$site_model = new SiteModel();
|
|
$ConModel = new ConfigModel();
|
|
$supply_model = new Supplier();
|
|
$this->SiteInfo = $site_model->getSiteInfo([['site_id', '=', $data['site_id']]], $field)['data'];
|
|
$this->ag_site_id = $this->SiteInfo['agent_id'] ?: $data['site_id'];
|
|
$this->AgConfig = $ConModel->getSupplierConfig($this->ag_site_id)['data']['value'];
|
|
if ($this->AgConfig['supplier_id']) {
|
|
$this->SupplyInfo = $supply_model->getSupplierInfo([['supplier_id', '=', $this->AgConfig['supplier_id']]])['data'];
|
|
$this->supplier_site_id = $this->SupplyInfo['supplier_site_id'] ?? 0;
|
|
}
|
|
$this->Choice = new Choice($this->ag_site_id);
|
|
}
|
|
}
|
|
}
|