Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-micro
Commits
11f57dba
Commit
11f57dba
authored
Aug 25, 2020
by
jiangkebao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of git.huaperfect.com:hwq/micro into develop
parents
0b29f590
d744cc4b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
536 additions
and
65 deletions
+536
-65
MessageHandler.php
src/Handler/MessageHandler.php
+49
-0
MaterialServiceInterface.php
src/Service/Interfaces/MaterialServiceInterface.php
+0
-46
MaterialServiceInterface.php
src/Service/Interfaces/Product/MaterialServiceInterface.php
+11
-3
PlatformProductChildServiceInterface.php
...terfaces/Product/PlatformProductChildServiceInterface.php
+5
-5
ProductChildServiceInterface.php
...rvice/Interfaces/Product/ProductChildServiceInterface.php
+11
-3
StoreServiceInterface.php
src/Service/Interfaces/StoreServiceInterface.php
+2
-2
ShopifyApp.php
src/Shopify/ShopifyApp.php
+73
-0
ShopifyFactory.php
src/Shopify/ShopifyFactory.php
+35
-0
AbstractShopify.php
src/Shopify/lib/AbstractShopify.php
+256
-0
Webhook.php
src/Shopify/lib/Webhook.php
+16
-0
Drawer.php
src/Tools/Drawer.php
+4
-4
ExcelImporter.php
src/Tools/ExcelImporter.php
+2
-2
HttpRequestJson.php
src/Tools/HttpRequestJson.php
+72
-0
No files found.
src/Handler/MessageHandler.php
View file @
11f57dba
...
...
@@ -64,4 +64,53 @@ class MessageHandler
$this
->
messageService
->
send
(
$receiverIds
,
$application
,
0
,
$sendUserId
,
[],
$content
);
}
/**
* 自动发送模板消息
* @param $receiverIds
* @param $templateId
* @param array $replace
* @throws HttpResponseException
*/
public
function
sendAutoTemp
(
$receiverIds
,
$templateId
,
$replace
=
[])
{
$application
=
$this
->
config
->
get
(
'app_name'
);
if
(
!
$application
)
{
throw
new
HttpResponseException
(
"请设置应用名app_name"
);
}
$receiverIds
=
is_array
(
$receiverIds
)
?
$receiverIds
:
[
$receiverIds
];
$this
->
messageService
->
send
(
$receiverIds
,
$application
,
$templateId
,
0
,
$replace
);
}
/**
* 自动发送文本消息
* @param $receiverIds
* @param $content
* @throws \Exception
*/
public
function
sendAutoText
(
$receiverIds
,
$content
)
{
$application
=
$this
->
config
->
get
(
'app_name'
);
if
(
!
$application
)
{
throw
new
\Exception
(
"请设置应用名app_name"
);
}
$receiverIds
=
is_array
(
$receiverIds
)
?
$receiverIds
:
[
$receiverIds
];
$this
->
messageService
->
send
(
$receiverIds
,
$application
,
0
,
0
,
[],
$content
);
}
/**
* 定时任务专用 发送文本消息
* @param $receiverIds
* @param $content
* @throws HttpResponseException
*/
public
function
sendCrontabText
(
$receiverIds
,
$content
)
{
$application
=
$this
->
config
->
get
(
'app_name'
);
if
(
!
$application
)
{
throw
new
HttpResponseException
(
"请设置应用名app_name"
);
}
$receiverIds
=
is_array
(
$receiverIds
)
?
$receiverIds
:
[
$receiverIds
];
$this
->
messageService
->
send
(
$receiverIds
,
$application
,
0
,
0
,
[],
$content
);
}
}
src/Service/Interfaces/MaterialServiceInterface.php
deleted
100644 → 0
View file @
0b29f590
<?php
/**
* Created by PhpStorm.
* User: 梁俊杰
* Date: 2020/5/15
* Time: 15:07
*/
namespace
Meibuyu\Micro\Service\Interfaces
;
interface
MaterialServiceInterface
{
/**
* 获取单个数据
* @param int $id 原料id
* @param array $columns 原料表的字段,默认显示全部
* @return array|null
*/
public
function
get
(
$id
,
array
$columns
=
[
'*'
]);
/**
* 通过id列表获取原料数组
* @param array $idList 原料id的列表, 默认去重
* @param array $columns 原料表的字段,默认显示全部
* @return array 默认keyBy('id')
*/
public
function
getByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 通过内部code列表获取原料列表
* @param array $codeList 默认去重
* @param array $columns
* @return array 默认keyBy('internal_code')
*/
public
function
getByCodeList
(
array
$codeList
,
array
$columns
=
[
'id'
]);
/**
* 通过原料品名id列表获取原料品名数组
* @param array $idList 原料品名id的列表, 默认去重
* @param array $columns 原料品名表的字段,默认显示全部
* @return array 默认keyBy('id')
*/
public
function
getMaterialNamesByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
}
src/Service/Interfaces/Product/MaterialServiceInterface.php
View file @
11f57dba
...
...
@@ -39,7 +39,7 @@ interface MaterialServiceInterface
* 获取指定品名下所有的原料数据
* @param array $nameIds 默认去重
* @param array $columns
* @return array 默认
key
By('material_name_id')
* @return array 默认
group
By('material_name_id')
*/
public
function
getListByNameIds
(
array
$nameIds
,
array
$columns
=
[
'*'
]);
...
...
@@ -76,9 +76,17 @@ interface MaterialServiceInterface
/**
* 获取产品对应颜色绑定的原料
* @param $productId
* @param array $colorIds
* @param array $colorIds 默认去重
* @param bool $withMaterials
* @return array 默认keyBy('color_id')
*/
public
function
getProductColorMaterials
(
$productId
,
array
$colorIds
,
$withMaterials
=
false
);
/**
* 获取维护完全原料数量的颜色id
* @param $productId
* @return array
*/
public
function
get
ProductColorMaterials
(
$productId
,
array
$colorIds
);
public
function
get
FullMaterialCountColorIds
(
$productId
);
}
src/Service/Interfaces/Product/PlatformProductChildServiceInterface.php
View file @
11f57dba
...
...
@@ -24,7 +24,7 @@ interface PlatformProductChildServiceInterface
/**
* 通过id列表获取平台子产品数组
* @param array $idList 平台子产品id的列表, 默认去重
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"]
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"
,"packs"
]
* @param array $columns 平台子产品表的字段,默认全部字段
* ['id','platform_product_id','product_child_id','platform_product_child_sku','asin','fnsku','is_sale']
* @return array 默认keyBy('id')
...
...
@@ -35,7 +35,7 @@ interface PlatformProductChildServiceInterface
* 获取单个数据
* @param string $sku 平台子产品sku
* @param int $siteId 平台子产品所属站点
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"]
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"
,"packs"
]
* @param array $columns 平台子产品表的字段,默认全部字段
* ['id','platform_product_id','product_child_id','platform_product_child_sku','asin','fnsku','is_sale']
* @return array
...
...
@@ -46,7 +46,7 @@ interface PlatformProductChildServiceInterface
* 通过sku列表获取平台子产品数组
* @param array $skuList 平台子产品sku的列表, 默认去重
* @param int $siteId 平台子产品所属站点
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"]
* @param array $relations 平台子产品的关联关系,支持:["platform_product","product_child","weight"
,"packs"
]
* @param array $columns 平台子产品表的字段,默认全部字段
* ['id','platform_product_id','product_child_id','platform_product_child_sku','asin','fnsku','is_sale']
* @return array 默认keyBy('platform_product_child_sku')
...
...
@@ -62,7 +62,7 @@ interface PlatformProductChildServiceInterface
public
function
getIdsByChildSku
(
string
$childSku
,
array
$limitIds
=
null
);
/**
* 获取仓库
子sku对应的平台子
sku
* 获取仓库
主sku对应的平台主
sku
* @param array $productChildIds 已去重
* @param null $siteId 指定站点id, 不传或传null,获取全部数据
* @param array $columns
...
...
@@ -74,7 +74,7 @@ interface PlatformProductChildServiceInterface
* 通过仓库产品id获取平台子产品数组
* @param $productId
* @param null $siteId
* @param array $relations
* @param array $relations
平台子产品的关联关系,支持:["platform_product","product_child","weight","packs"]
* @param array $columns
* @return array
*/
...
...
src/Service/Interfaces/Product/ProductChildServiceInterface.php
View file @
11f57dba
...
...
@@ -15,7 +15,7 @@ interface ProductChildServiceInterface
* 获取单个数据
* @param int $id 子SKU id
* @param array $columns 子SKU表的字段,默认显示全部
* @param array $relations 子SKU的关联关系,可传入['brand', 'category', 'product_name', 'images', 'cost']
* @param array $relations 子SKU的关联关系,可传入['brand', 'category', 'product_name', 'images', 'cost'
, 'weight', 'packs'
]
* @return array|null
*/
public
function
get
(
$id
,
array
$columns
=
[
'*'
],
array
$relations
=
[]);
...
...
@@ -24,7 +24,7 @@ interface ProductChildServiceInterface
* 通过id列表获取产品数组
* @param array $idList 子SKUid的列表, 默认去重
* @param array $columns 子SKU表的字段,默认显示全部
* @param array $relations 子SKU的关联关系,可传入['brand', 'category', 'product_name', 'images', 'cost']
* @param array $relations 子SKU的关联关系,可传入['brand', 'category', 'product_name', 'images', 'cost'
, 'weight', 'packs'
]
* @return array 默认keyBy('id')
*/
public
function
getByIdList
(
array
$idList
,
array
$columns
=
[
'*'
],
array
$relations
=
[])
:
array
;
...
...
@@ -33,7 +33,7 @@ interface ProductChildServiceInterface
* 通过sku列表获取子产品列表
* @param array $skuList 默认去重
* @param array $columns 子SKU表的字段,默认返回id
* @param array $relations 子SKU的关联关系,可传入['color', 'size','brand', 'category', 'product_name', 'images', 'cost', 'weight']
* @param array $relations 子SKU的关联关系,可传入['color', 'size','brand', 'category', 'product_name', 'images', 'cost', 'weight'
, 'packs'
]
* @return array 默认keyBy('child_sku')
*/
public
function
getListBySkuList
(
array
$skuList
,
array
$columns
=
[
'id'
],
array
$relations
=
[]);
...
...
@@ -92,4 +92,12 @@ interface ProductChildServiceInterface
*/
public
function
getListByProductId
(
int
$productId
,
$columns
=
[
'id'
,
'child_sku'
]);
/**
* 模糊搜索仓库子sku,获取id数组
* @param string $childSku 仓库子sku
* @param array|null $limitIds 限制id数组,不传为不限制
* @return array
*/
public
function
getIdsByChildSku
(
string
$childSku
,
array
$limitIds
=
null
);
}
src/Service/Interfaces/StoreServiceInterface.php
View file @
11f57dba
...
...
@@ -154,7 +154,7 @@ interface StoreServiceInterface
/**
* description:通过产品id数组获取库存列表
* description:通过产品id数组获取库存列表
给订单系统使用
* author: fuyunnan
* @param array $ids 产品ids 数组
* @param int $wareId 仓库id
...
...
@@ -166,7 +166,7 @@ interface StoreServiceInterface
/**
* description:检查是否有库存,有就返回库存数量(有记录)
* description:检查是否有库存,有就返回库存数量(有记录)
给产品系统使用
* author: fuyunnan
* @param array $ids 仓库产品的id数组
* @return array
...
...
src/Shopify/ShopifyApp.php
0 → 100644
View file @
11f57dba
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/18
* Time: 8:13
*/
namespace
Meibuyu\Micro\Shopify
;
use
Meibuyu\Micro\Shopify\lib\AbstractShopify
;
use
Meibuyu\Micro\Shopify\lib\Webhook
;
/**
* Class ShopifyApp
* @package Meibuyu\Shopify
*
* @property-read Webhook $Webhook
*/
class
ShopifyApp
{
protected
$resources
=
[
'Webhook'
,
];
public
$config
=
[];
public
$defaultApiVersion
=
'2020-07'
;
public
$timeAllowedForEachApiCall
=
.
5
;
/**
* ShopifyApp constructor.
* @param array $config
*/
public
function
__construct
(
$config
)
{
$this
->
config
=
[
'api_version'
=>
$this
->
defaultApiVersion
];
foreach
(
$config
as
$key
=>
$value
)
{
$this
->
config
[
$key
]
=
$value
;
}
if
(
isset
(
$config
[
'shop_url'
]))
{
$this
->
setApiUrl
();
}
}
/**
* 返回AbstractShopify实例
* @param string $className 实现的类名
* @return AbstractShopify
* @throws \Exception
*/
public
function
__get
(
$className
)
{
if
(
!
in_array
(
$className
,
$this
->
resources
))
{
throw
new
\Exception
(
"未知方法
$className
"
);
}
$resourceClassName
=
__NAMESPACE__
.
"
\\
lib
\\
$className
"
;
return
new
$resourceClassName
(
$this
->
config
);
}
public
function
setApiUrl
()
{
$shopUrl
=
$this
->
config
[
'shop_url'
];
$shopUrl
=
preg_replace
(
'#^https?://|/$#'
,
''
,
$shopUrl
);
$apiVersion
=
$this
->
config
[
'api_version'
];
$this
->
config
[
'api_url'
]
=
"https://
$shopUrl
/admin/api/
$apiVersion
/"
;
}
}
src/Shopify/ShopifyFactory.php
0 → 100644
View file @
11f57dba
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/19
* Time: 9:25
*/
namespace
Meibuyu\Micro\Shopify
;
use
Hyperf\Contract\ContainerInterface
;
class
ShopifyFactory
{
/**
* @var ContainerInterface
*/
private
$container
;
public
function
__construct
(
ContainerInterface
$container
)
{
$this
->
container
=
$container
;
}
public
function
create
(
array
$config
=
[])
:
ShopifyApp
{
if
(
method_exists
(
$this
->
container
,
'make'
))
{
// Create by DI for AOP.
return
$this
->
container
->
make
(
ShopifyApp
::
class
,
[
'config'
=>
$config
]);
}
return
new
ShopifyApp
(
$config
);
}
}
src/Shopify/lib/AbstractShopify.php
0 → 100644
View file @
11f57dba
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/18
* Time: 8:18
*/
namespace
Meibuyu\Micro\Shopify\lib
;
use
Meibuyu\Micro\Tools\HttpRequestJson
;
use
Psr\Http\Message\ResponseInterface
;
abstract
class
AbstractShopify
{
protected
$httpHeaders
=
[];
protected
$resourceUrl
;
protected
$resourceKey
;
protected
$pluralizeKey
;
/**
* 无count方法
* @var boolean
*/
public
$countEnabled
=
true
;
/**
* List of custom GET / POST / PUT / DELETE actions
*
* Custom actions can be used without calling the get(), post(), put(), delete() methods directly
* @example: ['enable', 'disable', 'remove','default' => 'makeDefault']
* Methods can be called like enable(), disable(), remove(), makeDefault() etc.
* If any array item has an associative key => value pair, value will be considered as the method name
* and key will be the associated path to be used with the action.
*
* @var array $customGetActions
* @var array $customPostActions
* @var array $customPutActions
* @var array $customDeleteActions
*/
protected
$customGetActions
=
[];
protected
$customPostActions
=
[];
protected
$customPutActions
=
[];
protected
$customDeleteActions
=
[];
/**
* AbstractShopify constructor.
* @param $config
* @throws \Exception
*/
public
function
__construct
(
$config
)
{
$this
->
pluralizeKey
=
$this
->
resourceKey
.
's'
;
$this
->
resourceUrl
=
$config
[
'api_url'
]
.
$this
->
pluralizeKey
;
if
(
isset
(
$config
[
'api_password'
]))
{
$this
->
httpHeaders
[
'X-Shopify-Access-Token'
]
=
$config
[
'api_password'
];
}
elseif
(
!
isset
(
$config
[
'api_password'
]))
{
throw
new
\Exception
(
"请设置api_password值"
);
}
}
/**
* 调用自定义方法
* @param $name
* @param $arguments
* @return mixed
* @throws \Exception
*/
public
function
__call
(
$name
,
$arguments
)
{
$actionMaps
=
array
(
'post'
=>
'customPostActions'
,
'put'
=>
'customPutActions'
,
'get'
=>
'customGetActions'
,
'delete'
=>
'customDeleteActions'
,
);
//Get the array key for the action in the actions array
foreach
(
$actionMaps
as
$httpMethod
=>
$actionArrayKey
)
{
$actionKey
=
array_search
(
$name
,
$this
->
$actionArrayKey
);
if
(
$actionKey
!==
false
)
break
;
}
if
(
$actionKey
===
false
)
{
throw
new
\Exception
(
"No action named
$name
is defined for "
.
$this
->
getResourceName
());
}
//If any associative key is given to the action, then it will be considered as the method name,
//otherwise the action name will be the method name
$customAction
=
!
is_numeric
(
$actionKey
)
?
$actionKey
:
$name
;
//Get the first argument if provided with the method call
$methodArgument
=
!
empty
(
$arguments
)
?
$arguments
[
0
]
:
[];
//Url parameters
$urlParams
=
[];
//Data body
$dataArray
=
[];
//Consider the argument as url parameters for get and delete request
//and data array for post and put request
if
(
$httpMethod
==
'post'
||
$httpMethod
==
'put'
)
{
$dataArray
=
$methodArgument
;
}
else
{
$urlParams
=
$methodArgument
;
}
$url
=
$this
->
generateUrl
(
$urlParams
,
null
,
$customAction
);
if
(
$httpMethod
==
'post'
||
$httpMethod
==
'put'
)
{
return
$this
->
$httpMethod
(
$dataArray
,
$url
,
false
);
}
else
{
return
$this
->
$httpMethod
(
$dataArray
,
$url
);
}
}
private
function
getResourceName
()
{
return
substr
(
get_called_class
(),
strrpos
(
get_called_class
(),
'\\'
)
+
1
);
}
public
function
generateUrl
(
$urlParams
=
[],
$id
=
null
,
$customAction
=
null
)
{
return
$this
->
resourceUrl
.
(
$id
?
"/
$id
"
:
''
)
.
(
$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
->
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
,
$urlParams
=
[],
$url
=
null
)
{
if
(
!
$url
)
$url
=
$this
->
generateUrl
(
$urlParams
,
$id
);
$response
=
HttpRequestJson
::
delete
(
$url
,
$this
->
httpHeaders
);
return
$this
->
processResponse
(
$response
);
}
protected
function
wrapData
(
$dataArray
,
$dataKey
=
null
)
{
if
(
!
$dataKey
)
$dataKey
=
$this
->
resourceKey
;
return
array
(
$dataKey
=>
$dataArray
);
}
protected
function
castString
(
$array
)
{
if
(
!
is_array
(
$array
))
return
(
string
)
$array
;
$string
=
''
;
$i
=
0
;
foreach
(
$array
as
$key
=>
$val
)
{
$string
.=
(
$i
===
$key
?
''
:
"
$key
- "
)
.
$this
->
castString
(
$val
)
.
', '
;
$i
++
;
}
$string
=
rtrim
(
$string
,
', '
);
return
$string
;
}
/**
* 处理响应
* @param ResponseInterface $response
* @param null $dataKey
* @return mixed
* @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
;
}
}
}
src/Shopify/lib/Webhook.php
0 → 100644
View file @
11f57dba
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/18
* Time: 8:13
*/
namespace
Meibuyu\Micro\Shopify\lib
;
class
Webhook
extends
AbstractShopify
{
protected
$resourceKey
=
'webhook'
;
}
src/Tools/Drawer.php
View file @
11f57dba
...
...
@@ -154,14 +154,14 @@ class Drawer
* @param int $h 图片高度
* @param string $p 单元格索引
* @param Worksheet $sheet
* @param
bool $addBoard
* @param
int $boardPx
*/
public
function
draw2Excel
(
$path
,
$h
,
$p
,
$sheet
,
$
addBoard
=
true
)
public
function
draw2Excel
(
$path
,
$h
,
$p
,
$sheet
,
$
boardPx
=
0
)
{
try
{
$path
=
$this
->
parseImagePath
(
$path
);
if
(
$
addBoard
)
{
$path
=
$this
->
addBoard
(
$path
);
if
(
$
boardPx
)
{
$path
=
$this
->
addBoard
(
$path
,
$boardPx
);
}
$drawing
=
new
Drawing
();
$drawing
->
setPath
(
$path
)
->
setCoordinates
(
$p
)
->
setHeight
(
$h
)
->
setWorksheet
(
$sheet
);
...
...
src/Tools/ExcelImporter.php
View file @
11f57dba
...
...
@@ -116,7 +116,7 @@ class ExcelImporter
}
/**
*
必填检测
数据
*
检测必填
数据
* @param $requires
* @param $errorCount
* @throws \PhpOffice\PhpSpreadsheet\Exception
...
...
@@ -136,7 +136,7 @@ class ExcelImporter
}
/**
*
必填检测
数据
*
检测数字类型
数据
* @param $data
* @param $errorCount
* @throws \PhpOffice\PhpSpreadsheet\Exception
...
...
src/Tools/HttpRequestJson.php
0 → 100644
View file @
11f57dba
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/19
* Time: 9:06
*/
namespace
Meibuyu\Micro\Tools
;
use
GuzzleHttp\Client
;
use
Psr\Http\Message\ResponseInterface
;
/**
* json格式请求(非协程)
* Class HttpRequestJson
* @package Meibuyu\Micro\Tools
*/
class
HttpRequestJson
{
/**
* get请求
* @param $url
* @param array $httpHeaders
* @return ResponseInterface
*/
public
static
function
get
(
$url
,
$httpHeaders
=
[])
{
$client
=
new
Client
();
return
$client
->
get
(
$url
,
[
'headers'
=>
$httpHeaders
]);
}
/**
* post请求
* @param $url
* @param $dataArray
* @param array $httpHeaders
* @return ResponseInterface
*/
public
static
function
post
(
$url
,
$dataArray
,
$httpHeaders
=
[])
{
$client
=
new
Client
();
return
$client
->
post
(
$url
,
[
'headers'
=>
$httpHeaders
,
'json'
=>
$dataArray
]);
}
/**
* put请求
* @param $url
* @param $dataArray
* @param array $httpHeaders
* @return ResponseInterface
*/
public
static
function
put
(
$url
,
$dataArray
,
$httpHeaders
=
[])
{
$client
=
new
Client
();
return
$client
->
put
(
$url
,
[
'headers'
=>
$httpHeaders
,
'json'
=>
$dataArray
]);
}
/**
* delete请求
* @param $url
* @param array $httpHeaders
* @return ResponseInterface
*/
public
static
function
delete
(
$url
,
$httpHeaders
=
[])
{
$client
=
new
Client
();
return
$client
->
delete
(
$url
,
[
'headers'
=>
$httpHeaders
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment