Compare commits
3 Commits
v1.0.5
...
4829305a44
Author | SHA1 | Date | |
---|---|---|---|
4829305a44 | |||
c9484deaec | |||
8c9680d364 |
28
README.md
28
README.md
@ -1,9 +1,11 @@
|
||||
# 德木自动化项目开放接口SDK
|
||||
|
||||
# 介绍
|
||||
|
||||
用于德木自动化对外开放接口数据交互
|
||||
|
||||
# 要求
|
||||
|
||||
- php版本:>=7.0
|
||||
|
||||
# 安装
|
||||
@ -22,14 +24,33 @@ $w = new Order($secretKey);
|
||||
// 获取工单数据
|
||||
$response = $w->getProductOrder('SN5436745676543');
|
||||
|
||||
// 加工工单原木材种
|
||||
$w->getWoodTypeOptions([
|
||||
'company_id' => 1
|
||||
]);
|
||||
|
||||
// 加工工单加工等级
|
||||
$w->getProductionLevelOptions([
|
||||
'company_id' => 1
|
||||
]);
|
||||
|
||||
// 创建加工工单
|
||||
$response = $w->createProductOrder([
|
||||
'cube_plan' => 32.23,
|
||||
'company_id' => 1,
|
||||
'wood_type_id' => 1,
|
||||
'wood_level_id' => 1,
|
||||
'spec_thickness' => 12,
|
||||
'spec_width' => 22,
|
||||
'spec_length' => 38,
|
||||
'number_width' => 12,
|
||||
'number_height' => 22,
|
||||
'number_pcs' => 10,
|
||||
'owner' => 'ykxiao'
|
||||
]);
|
||||
```
|
||||
|
||||
# 回调说明
|
||||
|
||||
- 配置回调后地址后,应用服务器会以POST方式请求你的服务器地址,以便你做进一步业务流程。
|
||||
- 回调你服务器地址后,可获取参数"data"、"signature"进行验签,"response" 为服务器处理结果。
|
||||
|
||||
@ -42,7 +63,8 @@ $request = require();
|
||||
$params = json_decode($request->contents(), true);
|
||||
|
||||
// 回调验签
|
||||
$receivedSignature = $request->headers('signature');
|
||||
$receivedSignature = $request->headers('mes-open-signature');
|
||||
$timestamp = $request->headers('mes-open-timestamp');
|
||||
$data = json_encode($params['data']);
|
||||
/**
|
||||
* 生成HMAC签名
|
||||
@ -55,7 +77,7 @@ function generateHmacSignature($data): string
|
||||
return hash_hmac('sha256', $data, $secretKey);
|
||||
}
|
||||
|
||||
$calculatedSignature = $this->generateHmacSignature($data);
|
||||
$calculatedSignature = $this->generateHmacSignature($timestamp . $data);
|
||||
|
||||
// 验证签名是否匹配 hash_equals($receivedSignature, $calculatedSignature)
|
||||
if ($receivedSignature === $calculatedSignature) {
|
||||
|
@ -106,6 +106,29 @@ class Order
|
||||
return $this->sendRequest('production.status', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加工工单原木材种
|
||||
* @return mixed|string
|
||||
* @throws GuzzleException
|
||||
* @throws HttpException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getWoodTypeOptions($data)
|
||||
{
|
||||
return $this->baseFun($data, 'Wood.types');
|
||||
}
|
||||
/**
|
||||
* 加工等级
|
||||
* @return mixed|string
|
||||
* @throws GuzzleException
|
||||
* @throws HttpException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getProductionLevelOptions($data)
|
||||
{
|
||||
return $this->baseFun($data, 'production.levels');
|
||||
}
|
||||
|
||||
/**
|
||||
* 加工工单创建
|
||||
* @return mixed|string
|
||||
|
Reference in New Issue
Block a user