Commit 54f5d43f authored by 赵鹏's avatar 赵鹏
Browse files

Merge remote-tracking branch 'origin/develop' into pull_fulfillmentOrders

parents b7d052df dd86c54d
Loading
Loading
Loading
Loading
+27 −14
Original line number Diff line number Diff line
@@ -23,24 +23,37 @@ class ExceptionLogProducer extends ProducerMessage
        } catch (HttpResponseException $e) {
            put_log('获取操作人失败; ' . $e->getMessage(), 'ExceptionLogProducer.log');
        }
        // 排除依赖包文件和运行缓存文件
        put_log("file: {$data['file']}", 'ExceptionLogProducerEcho.log');
        if (strpos($data['file'], '/vendor/') === false && strpos($data['file'], '/runtime/') === false) {
        // 获取trace中真实文件和行数
        if (!empty($data['trace'])) {
            preg_match('/(\/var\/www\/html\/.+?\/app\/.+?\.php)(?=\()/', $data['trace'], $matchFiles);
            if (!empty($matchFiles[0])) {
                $data['file'] = $matchFiles[0];
                $file = str_replace('/', '\/', $matchFiles[0]);
                $file = str_replace('.', '\.', $file);
                $pattern = '/(?<=' . $file . '\()[0-9]+(?=\))/';
                preg_match($pattern, $data['trace'], $matchLines);
                if (!empty($matchLines[0])) {
                    $data['line'] = $matchLines[0];
                }
            }
        }
        if (!empty($data['file'])) {
            // 只对项目app文件夹下的错误获取编码人
            preg_match('/(\/var\/www\/html\/.+?\/app\/)/', $data['file'], $matchPaths);
            if (!empty($matchPaths[0])) {
                try {
                put_log("git: git blame -L {$data['line']},{$data['line']} {$data['file']}", 'ExceptionLogProducerEcho.log');
                exec("git blame -L {$data['line']},{$data['line']} {$data['file']}", $output);
                put_log("output: $output", 'ExceptionLogProducerEcho.log');
                    exec("cd {$matchPaths[0]} && git blame -L {$data['line']},{$data['line']} {$data['file']}", $output);
                    if (!empty($output[0]) && is_string($output[0])) {
                    preg_match('/(?<=\()[^ ]+/', $output[0], $matches);
                    put_log("matches: $matches", 'ExceptionLogProducerEcho.log');
                    if (!empty($matches[0])) {
                        $data['coder'] = $matches[0];
                        preg_match('/(?<=\()[^ ]+/', $output[0], $matchCoders);
                        if (!empty($matchCoders[0])) {
                            $data['coder'] = $matchCoders[0];
                        }
                    }
                } catch (Exception $e) {
                    put_log('获取编码人失败; ' . $e->getMessage(), 'ExceptionLogProducer.log');
                }
            }
        }
        $this->payload = $data;
    }

+15 −0
Original line number Diff line number Diff line
<?php


namespace Meibuyu\Micro\Service\Interfaces\File;


interface FileServiceInterface
{
    /**
     * @param string $type 类型编码 0001
     * @param integer $number 生成条形码数量 100
     * @return mixed
     */
    public function generateBarCode($type, $number);
}
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -86,4 +86,13 @@ interface ShopifyServiceInterface
     */
    public function updateFulfillmentTracking($fulfillmentId, $params, $shopifySiteId);

    /**
     * 通过id数组获取shopify的location数据
     * @param $ids
     * @param string[] $columns
     * @return array 默认keyBy('id')
     * @author zero
     */
    public function getLocationsByIds($ids, $columns = ['*']);

}
+8 −0
Original line number Diff line number Diff line
@@ -26,4 +26,12 @@ interface PurchaseDoneServiceInterface
     * @return mixed
     */
    public function productStandard($data);


    /**
     * 通过子订单编号查询状态
     * @param array $orderIds 子订单编号 ['3333444','12222']
     * @return mixed
     */
    public function getOrderStatus($orderIds);
}
 No newline at end of file
+24 −48
Original line number Diff line number Diff line
@@ -9,7 +9,8 @@
namespace Meibuyu\Micro\Shopify\lib;

use Exception;
use Meibuyu\Micro\Shopify\Tools\HttpRequestJson;
use Meibuyu\Micro\Shopify\tools\CurlHttpRequestJson;
use Meibuyu\Micro\Shopify\tools\HttpRequestJson;
use Psr\Http\Message\ResponseInterface;

abstract class AbstractShopify
@@ -45,7 +46,7 @@ abstract class AbstractShopify
    private $config;

    /**
     * @var HttpRequestJson
     * @var HttpRequestJson|CurlHttpRequestJson
     */
    private $httpRequestJson;

@@ -62,7 +63,7 @@ abstract class AbstractShopify
        $this->id = $id;
        $this->pluralizeKey = $this->pluralizeKey ?: $this->resourceKey . 's';
        $this->resourceUrl = ($parentResourceUrl ? "$parentResourceUrl/" : $config['api_url']) . $this->pluralizeKey . ($this->id ? "/{$this->id}" : '');
        $this->httpRequestJson = make(HttpRequestJson::class);
        $this->httpRequestJson = make(CurlHttpRequestJson::class);
        if (isset($config['api_password'])) {
            $this->httpHeaders['X-Shopify-Access-Token'] = $config['api_password'];
        } elseif (!isset($config['api_password'])) {
@@ -158,20 +159,20 @@ abstract class AbstractShopify
        return $resourceUrl . ($customAction ? "/$customAction" : '') . '.json' . (!empty($urlParams) ? '?' . http_build_query($urlParams) : '');
    }

//    /**
//     * 获取数量
//     * @param array $urlParams
//     * @return mixed
//     * @throws Exception
//     */
//    public function count($urlParams = [])
//    {
//        if (!$this->countEnabled) {
//            throw new Exception("当前类{$this->getResourceName()}不支持count()方法");
//        }
//        $url = $this->generateUrl($urlParams, null, 'count');
//        return $this->get([], $url, 'count');
//    }
    /**
     * 获取数量
     * @param array $urlParams
     * @return mixed
     * @throws Exception
     */
    public function count($urlParams = [])
    {
        if (!$this->countEnabled) {
            throw new Exception("当前类{$this->getResourceName()}不支持count()方法");
        }
        $url = $this->generateUrl($urlParams, null, 'count');
        return $this->get([], $url, 'count');
    }

    /**
     * @param array $urlParams
@@ -282,15 +283,14 @@ abstract class AbstractShopify

    /**
     * 处理响应
     * @param ResponseInterface $response
     * @param array $response
     * @param null $dataKey
     * @return mixed
     * @throws Exception
     */
    public function processResponse($response, $dataKey = null)
    {
        $code = $response->getStatusCode();
        $content = $response->getBody()->getContents();
        [$code, , $content] = $response;
        $content = json_decode($content, true);
        if (isset($content['errors'])) {
            throw new Exception($this->castString($content['errors']), $code);
@@ -302,28 +302,6 @@ abstract class AbstractShopify
        }
    }

    /**
     * 处理响应
     * @param array $response
     * @param null $dataKey
     * @return mixed
     * @throws Exception
     */
    public function processResponseOld($response, $dataKey = null)
    {
        [$code, $header, $body] = $response;
        $content = json_decode($body, true);

        if (isset($content['errors'])) {
            throw new Exception($this->castString($content['errors']), $code);
        }
        if ($dataKey && isset($content[$dataKey])) {
            return $content[$dataKey];
        } else {
            return $content;
        }
    }

    /**
     * 处理响应
     * @param ResponseInterface $response
@@ -333,9 +311,7 @@ abstract class AbstractShopify
     */
    public function processPageResponse($response, $dataKey = null)
    {
        $code = $response->getStatusCode();
        $headers = $response->getHeaders();
        $content = $response->getBody()->getContents();
        [$code, $headers, $content] = $response;
        $content = json_decode($content, true);
        $link = $this->getLink($headers);
        if (isset($content['errors'])) {
@@ -351,11 +327,11 @@ abstract class AbstractShopify

    public function getLink($header, $type = 'next')
    {
        if (!empty($header['X-Shopify-API-Version'][0]) && $header['X-Shopify-API-Version'][0] < '2019-07') {
        if (!empty($header['x-shopify-api-version'][0]) && $header['x-shopify-api-version'][0] < '2019-07') {
            return null;
        }
        if (!empty($header['Link'][0])) {
            $headerLinks = $header['Link'][0];
        if (!empty($header['link'][0])) {
            $headerLinks = $header['link'][0];
            if (stristr($headerLinks, '; rel="' . $type . '"') > -1) {
                $headerLinks = explode(',', $headerLinks);
                foreach ($headerLinks as $headerLink) {
Loading