132 lines
4.6 KiB
PHP
132 lines
4.6 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
|
|
namespace app\model\express;
|
|
|
|
use app\model\system\Config as ConfigModel;
|
|
use app\model\BaseModel;
|
|
use extend\Kdbird as KdbirdExtend;
|
|
use extend\KdApiSpace;
|
|
|
|
/**
|
|
* 快递鸟
|
|
*/
|
|
class Kdbird extends BaseModel
|
|
{
|
|
|
|
/*********************************************************************** 快递100 start ***********************************************************************/
|
|
/**
|
|
* 快递鸟配置
|
|
* @param $site_id
|
|
* @return \multitype
|
|
*/
|
|
public function getKdbirdConfig($site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['app_module', '=', 'shop'], ["site_id", "=", $site_id], ['config_key', '=', 'EXPRESS_KDBIRD_CONFIG']]);
|
|
if(empty($res['data']['value']['status'])){
|
|
$res['data']['value']['status'] = 0;
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
|
|
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 $data
|
|
* @return \multitype
|
|
*/
|
|
public function setKdbirdConfig($data, $is_use, $site_id)
|
|
{
|
|
if ($is_use > 0) {
|
|
event("CloseTrace", ['site_id' => $site_id]);
|
|
}
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '快递鸟设置', $is_use, [['app_module', '=', 'shop'], ["site_id", "=", $site_id], ['config_key', '=', 'EXPRESS_KDBIRD_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_KDBIRD_CONFIG']]);
|
|
return $res;
|
|
}
|
|
/*********************************************************************** 快递100 end ***********************************************************************/
|
|
|
|
/**
|
|
* 查询物流轨迹 并且转化为兼容数据结构
|
|
* @param $code
|
|
* @param $express_no
|
|
* @return array
|
|
*/
|
|
public function trace($code, $express_no, $site_id, $mobile)
|
|
{
|
|
$config_result = $this->getKdbirdConfig($site_id);
|
|
$config = $config_result["data"];
|
|
|
|
if ($config["is_use"] == 0) return $this->error();
|
|
|
|
$kd100_extend = new KdbirdExtend($config["value"]);
|
|
$result = $kd100_extend->orderTracesSubByJson($express_no, $code, $mobile);
|
|
if (isset($result['success']) && $result['success']) {
|
|
return $this->success($result);
|
|
} else {
|
|
return $this->error($result, $result['reason']);
|
|
}
|
|
}
|
|
|
|
|
|
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']);
|
|
}
|
|
}
|
|
} |