Commit 7bf1df7f authored by 王源's avatar 王源
Browse files

Merge branch 'develop' into test

parents 1c46cdf0 94d2b42d
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -22,4 +22,19 @@ interface MessageServiceInterface
     * @return bool
     * @return bool
     */
     */
    public function send(array $receiveUserId, $application, $templateId = 0, $sendUserId = 0, $replace = [], $content = ''): bool;
    public function send(array $receiveUserId, $application, $templateId = 0, $sendUserId = 0, $replace = [], $content = ''): bool;


    /**
     * description:发送邮件
     * author: fuyunnan
     * @param array $userList ['111@qq.com','222@qq.com']
     * @param string $subject 邮件标题
     * @param string $body 邮件内容
     * @return bool
     * @throws
     * Date: 2020/9/10
     */
    public function sendMail($userList, $subject, $body): bool;


}
}
+46 −37
Original line number Original line Diff line number Diff line
@@ -25,22 +25,22 @@ interface StoreServiceInterface
     * author: fuyunnan
     * author: fuyunnan
     * @param array $data 需要入库的数组 格式 入库添加
     * @param array $data 需要入库的数组 格式 入库添加
     * *
     * *
        data[master][warehousing_date]:2020-01-08 入库时间
     * data[master][warehousing_date]:2020-01-08 入库时间
        data[master][creator_id]:12 创建人id
     * data[master][creator_id]:12 创建人id
        data[master][warehouse_id]:2 仓库id
     * data[master][warehouse_id]:2 仓库id
        data[master][type_id]:1 入库单类型
     * data[master][type_id]:1 入库单类型
        data[master][source_no]:no_121333 来源单号 (选填)
     * data[master][source_no]:no_121333 来源单号 (选填)
        data[master][stock_up_status]:1二次质检状态 (选填)
     * data[master][stock_up_status]:1二次质检状态 (选填)
        data[master][remark]:备注 (选填)
     * data[master][remark]:备注 (选填)
        data[master][status]:2 状态 (选填 不填默认1)
     * data[master][status]:2 状态 (选填 不填默认1)
     *
     *
     * 产品二维数组
     * 产品二维数组
        data[goods][0][product_id]:16 产品id
     * data[goods][0][product_id]:16 产品id
        data[goods][0][should_cnt]:133 应入数量
     * data[goods][0][should_cnt]:133 应入数量
        data[goods][0][real_cnt]:10 实入数量
     * data[goods][0][real_cnt]:10 实入数量
        data[goods][1][product_id]:18
     * data[goods][1][product_id]:18
        data[goods][1][should_cnt]:10
     * data[goods][1][should_cnt]:10
        data[goods][1][real_cnt]:15
     * data[goods][1][real_cnt]:15
     *
     *
     * 或者参考yapi  http://api.huaperfect.com/project/38/interface/api/1617
     * 或者参考yapi  http://api.huaperfect.com/project/38/interface/api/1617
     *
     *
@@ -51,30 +51,28 @@ interface StoreServiceInterface
    public function createWarehousing(array $data): array;
    public function createWarehousing(array $data): array;






    /**
    /**
     * description:批量创建出库单
     * description:批量创建出库单
     * author: fuyunnan
     * author: fuyunnan
     * [
     * [
            'main' => [
     * 'main' => [
                'creator_id' => 1,
     *     'creator_id' => 1,
                'warehouse_id' => 1,
     *     'warehouse_id' => 1,
                'type' => 5,
     *     'type' => 5,
            ],
     * ],
            'products' => [
     * 'products' => [
                [
     * [
                    'source_no' => 1,
     *     'source_no' => 1,
                    'product_id' => 1,
     *     'product_id' => 1,
                    'real_cnt' => 1
     *     'real_cnt' => 1
                ],
     * ],
                [
     * [
                    'source_no' => 1,
     *     'source_no' => 1,
                    'product_id' => 1,
     *     'product_id' => 1,
                    'real_cnt' => 1
     *     'real_cnt' => 1
                ]
     * ]
            ]
     * ]
        ]
     * ]
     *
     *
     * @param array $attributes 提交的数组  或参考yapi http://api.huaperfect.com/project/38/interface/api/6968
     * @param array $attributes 提交的数组  或参考yapi http://api.huaperfect.com/project/38/interface/api/6968
     * @return array
     * @return array
@@ -175,4 +173,15 @@ interface StoreServiceInterface
     */
     */
    public function checkStock($ids): array;
    public function checkStock($ids): array;



    /**
     * description:出库单 恢复库存 出库单定为已取消
     * author: fuyunnan
     * @param string $sourceNo 来源单号
     * @return int
     * @throws
     * Date: 2020/9/7
     */
    public function restoreStock($sourceNo): int;

}
}
 No newline at end of file
+0 −8
Original line number Original line Diff line number Diff line
@@ -14,8 +14,6 @@ use Meibuyu\Micro\Shopify\lib\Collect;
use Meibuyu\Micro\Shopify\lib\Collection;
use Meibuyu\Micro\Shopify\lib\Collection;
use Meibuyu\Micro\Shopify\lib\CustomCollection;
use Meibuyu\Micro\Shopify\lib\CustomCollection;
use Meibuyu\Micro\Shopify\lib\Metafield;
use Meibuyu\Micro\Shopify\lib\Metafield;
use Meibuyu\Micro\Shopify\lib\Product;
use Meibuyu\Micro\Shopify\lib\ProductVariant;
use Meibuyu\Micro\Shopify\lib\SmartCollection;
use Meibuyu\Micro\Shopify\lib\SmartCollection;
use Meibuyu\Micro\Shopify\lib\Webhook;
use Meibuyu\Micro\Shopify\lib\Webhook;


@@ -29,16 +27,12 @@ use Meibuyu\Micro\Shopify\lib\Webhook;
 * @property-read CustomCollection $CustomCollection
 * @property-read CustomCollection $CustomCollection
 * @property-read SmartCollection $SmartCollection
 * @property-read SmartCollection $SmartCollection
 * @property-read Metafield $Metafield
 * @property-read Metafield $Metafield
 * @property-read Product $Product
 * @property-read ProductVariant $ProductVariant
 *
 *
 * @method Webhook Webhook(integer $id = null)
 * @method Webhook Webhook(integer $id = null)
 * @method Collection Collection(integer $id = null)
 * @method Collection Collection(integer $id = null)
 * @method CustomCollection CustomCollection(integer $id = null)
 * @method CustomCollection CustomCollection(integer $id = null)
 * @method SmartCollection SmartCollection(integer $id = null)
 * @method SmartCollection SmartCollection(integer $id = null)
 * @method Metafield Metafield(integer $id = null)
 * @method Metafield Metafield(integer $id = null)
 * @method Product Product(integer $id = null)
 * @method ProductVariant ProductVariant(integer $id = null)
 *
 *
 */
 */
class ShopifyApp
class ShopifyApp
@@ -51,8 +45,6 @@ class ShopifyApp
        'CustomCollection',
        'CustomCollection',
        'SmartCollection',
        'SmartCollection',
        'Metafield',
        'Metafield',
        'Product',
        'ProductVariant',
    ];
    ];


    protected $childResources = array(
    protected $childResources = array(
+19 −115
Original line number Original line Diff line number Diff line
@@ -153,95 +153,6 @@ abstract class AbstractShopify
        return $resourceUrl . ($customAction ? "/$customAction" : '') . '.json' . (!empty($urlParams) ? '?' . http_build_query($urlParams) : '');
        return $resourceUrl . ($customAction ? "/$customAction" : '') . '.json' . (!empty($urlParams) ? '?' . http_build_query($urlParams) : '');
    }
    }


//    /**
//     * @param array $urlParams
//     * @param null $url
//     * @param null $dataKey
//     * @return mixed
//     * @throws Exception
//     */
//    public function get($urlParams = [], $url = null, $dataKey = null)
//    {
//        if (!$url) $url = $this->generateUrl($urlParams);
//        $response = HttpRequestJson::get($url, $this->httpHeaders);
//        if (!$dataKey) $dataKey = $this->id ? $this->resourceKey : $this->pluralizeKey;
//        return $this->processResponse($response, $dataKey);
//    }
//
//    /**
//     * 根据id获取一条数据
//     * @param $id
//     * @param array $urlParams
//     * @return mixed
//     * @throws Exception
//     */
//    public function show($id, $urlParams = [])
//    {
//        $url = $this->generateUrl($urlParams, $id);
//        $response = HttpRequestJson::get($url, $this->httpHeaders);
//        return $this->processResponse($response, $this->resourceKey);
//    }
//
//    /**
//     * 获取数量
//     * @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 $dataArray
//     * @param null $url
//     * @param bool $wrapData
//     * @return mixed
//     * @throws Exception
//     */
//    public function post($dataArray, $url = null, $wrapData = true)
//    {
//        if (!$url) $url = $this->generateUrl();
//        if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray);
//        $response = HttpRequestJson::post($url, $dataArray, $this->httpHeaders);
//        return $this->processResponse($response, $this->resourceKey);
//    }
//
//    /**
//     * @param int|string $id
//     * @param $dataArray
//     * @param null $url
//     * @param bool $wrapData
//     * @return mixed
//     * @throws Exception
//     */
//    public function put($id, $dataArray, $url = null, $wrapData = true)
//    {
//        if (!$url) $url = $this->generateUrl([], $id);
//        if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray);
//        $response = HttpRequestJson::put($url, $dataArray, $this->httpHeaders);
//        return $this->processResponse($response, $this->resourceKey);
//    }
//
//    /**
//     * @param int|string $id
//     * @param array $urlParams
//     * @param null $url
//     * @return mixed
//     * @throws Exception
//     */
//    public function delete($id = null, $urlParams = [], $url = null)
//    {
//        if (!$url) $url = $this->generateUrl($urlParams, $id);
//        $response = HttpRequestJson::delete($url, $this->httpHeaders);
//        return $this->processResponse($response);
//    }

    /**
    /**
     * @param array $urlParams
     * @param array $urlParams
     * @param null $url
     * @param null $url
@@ -285,6 +196,21 @@ abstract class AbstractShopify
        return $this->processResponse($response, $this->resourceKey);
        return $this->processResponse($response, $this->resourceKey);
    }
    }


    /**
     * 获取数量
     * @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 $dataArray
     * @param $dataArray
     * @param null $url
     * @param null $url
@@ -356,36 +282,14 @@ abstract class AbstractShopify
     * @return mixed
     * @return mixed
     * @throws Exception
     * @throws Exception
     */
     */
//    public function processResponse($response, $dataKey = null)
//    {
//        $httpCode = $response->getStatusCode();
//        $content = $response->getBody()->getContents();
//        $content = json_decode($content, true);
//
//        if (isset($content['errors'])) {
//            throw new Exception($this->castString($content['errors']), $httpCode);
//        }
//        if ($dataKey && isset($content[$dataKey])) {
//            return $content[$dataKey];
//        } else {
//            return $content;
//        }
//    }

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


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

src/Shopify/lib/Product.php

deleted100644 → 0
+0 −34
Original line number Original line Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: Zero
 * Date: 2020/9/2
 * Time: 16:50
 */

namespace Meibuyu\Micro\Shopify\lib;

/**
 * Class Product
 * @package Meibuyu\Micro\Shopify\lib
 *
 * @property-read ProductImage $Image
 * @property-read ProductVariant $Variant
 * @property-read Metafield $Metafield
 *
 * @method ProductImage Image(integer $id = null)
 * @method ProductVariant Variant(integer $id = null)
 * @method Metafield Metafield(integer $id = null)
 */
class Product extends AbstractShopify
{

    protected $resourceKey = 'product';

    protected $childResource = [
        'ProductImage' => 'Image',
        'ProductVariant' => 'Variant',
        'Metafield',
    ];

}
Loading