1. 修改app/controller/admin/system/serve/Export.php中的 getExportTemp 方法,如下
public function getExportTemp(CrmebServeServices $services){
$com = $this->request->param('com');
if (!$com) return app('json')->fail('请输入快递公司编号');
$siid = merchantConfig($this->request->merId(),'mer_config_siid');
$func = $siid ? 'temp' : 'tempV2';
return app('json')->success($services->express()->{$func}($com));
}
通过商户siid判断是走新的电子面单方法还是旧的方法
2. 修改crmeb/services/express/storage/Express.php的 temp 方法,如下
public function temp(string $com)
{
$param = ['com' => $com];
return $this->accessToken->httpRequest(self::EXPRESS_TEMP, $param,'post',true);
}
去掉版本参数 ['version:v1.1']
3. crmeb/services/express/storage/Express.php中添加 tempV2 方法和 EXPRESS_TEMP_V2 常量,如下
const EXPRESS_TEMP_V2 = 'expr_dump/temp';
public function tempV2(string $com)
{
$param = ['com' => $com];
return $this->accessToken->httpRequest(self::EXPRESS_TEMP_V2, $param,'get',true, ['version:v1.1']);
}
新增一个常量和方法,没啥好说的
4. 修改crmeb/services/HttpService.php中的 request 方法,添加处理get请求参数逻辑,如下
public static function request($url, $method = 'get', $data = array(), $header = false, $timeout = 15)
{
self::$status = null;
self::$curlError = null;
self::$headerStr = null;
$method = strtoupper($method);
if ($method == 'GET' && !empty($data)) $url .= "?". http_build_query($data);
$curl = curl_init($url);
//请求方式
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
//post请求
if ($method == 'POST') curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//超时时间
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
//设置header头
if ($header !== false) curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
//返回抓取数据
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//输出header头信息
curl_setopt($curl, CURLOPT_HEADER, true);
//TRUE 时追踪句柄的请求字符串,从 PHP 5.1.3 开始可用。这个很关键,就是允许你查看请求header
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
//https请求
if (1 == strpos("$" . $url, "https://")) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
self::$curlError = curl_error($curl);
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
self::$status = $status;
self::$headerStr = trim(substr($content, 0, $status['header_size']));
$content = trim(substr($content, $status['header_size']));
return (intval($status["http_code"]) === 200) ? $content : false;
}
将 $method = strtoupper($method); 代码前移,添加get请求是处理参数的逻辑
5. 修改crmeb/services/express/storage/Express.php 中 express方法
return $this->accessToken->httpRequest(self::EXPRESS_LIST, $param,'get');
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}