63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
namespace app\model\express;
|
|
use app\model\system\Config as ConfigModel;
|
|
use app\model\BaseModel;
|
|
use extend\KdApiSpace;
|
|
|
|
class ApiSpace extends BaseModel
|
|
{
|
|
|
|
|
|
public function getapiSpaceConfig($site_id){
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['app_module', '=', 'shop'], ["site_id", "=", $site_id], ['config_key', '=', 'EXPRESS_SPACE_CONFIG']]);
|
|
if(empty($res['data']['value']['status'])){
|
|
$res['data']['value']['status'] = 0;
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
|
|
/**
|
|
* 设置物流配送配置
|
|
* @param $data
|
|
* @return \multitype
|
|
*/
|
|
public function setapiSpaceConfig($data, $is_use, $site_id)
|
|
{
|
|
if ($is_use > 0) {
|
|
event("CloseTrace", ['site_id' => $site_id]);
|
|
}
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, 'apiSpace设置', $is_use, [['app_module', '=', 'shop'], ["site_id", "=", $site_id], ['config_key', '=', 'EXPRESS_SPACE_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 开关状态
|
|
* @param $is_use
|
|
* @return array
|
|
*/
|
|
public function modifyStatus($is_use, $site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->modifyConfigIsUse($is_use, [['app_module', '=', 'shop'], ['site_id', '=', $site_id], ['config_key', '=', 'EXPRESS_SPACE_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
|
|
public function getSpaceTrace($code, $express_no, $site_id, $mobile){
|
|
|
|
$config_result = $this->getapiSpaceConfig($site_id);
|
|
$config = $config_result["data"];
|
|
if ($config["is_use"] == 0) return $this->error();
|
|
$kd_extend = new KdApiSpace($config["value"]);
|
|
$result = $kd_extend->getExpressTracesEnterpriseEdition($express_no, $code, $mobile);
|
|
if (isset($result['success']) && $result['success']) {
|
|
return $this->success($result);
|
|
} else {
|
|
return $this->error($result, $result['reason']);
|
|
}
|
|
}
|
|
|
|
} |