Compare commits

..

No commits in common. "dev" and "v1.0.7" have entirely different histories.
dev ... v1.0.7

2 changed files with 15 additions and 43 deletions

View File

@ -26,13 +26,13 @@ $secretKey = 'gFBfirGATxafTeq74RAngaL74Ksdxhuy';
$options = [ $options = [
'logger' => true, 'logger' => true,
'logs_path' => storage_path('logs/mes-sdk'), 'logs_path' => storage_path('logs/mes-sdk/sdk.log'),
]; ];
$w = new Order($secretKey, 'callback url', $options); $w = new Order($secretKey, 'callback url', $options);
// 获取工单数据 // 获取工单数据
$response = $w->getProductOrder(1); $response = $w->getProductOrder('SN5436745676543');
// 加工工单原木材种 // 加工工单原木材种
$w->getWoodTypeOptions([ $w->getWoodTypeOptions([
@ -57,17 +57,6 @@ $response = $w->createProductOrder([
'number_pcs' => 10, 'number_pcs' => 10,
'owner' => 'ykxiao' 'owner' => 'ykxiao'
]); ]);
// 更新加工工单
$response = $w->updateProductOrder([
'id' => 1,
'company_id' => 1,
]);
// 撤回加工工单
$response = $w->revokeProductOrder([
'id' => 1
]);
``` ```
# 回调说明 # 回调说明

View File

@ -124,10 +124,10 @@ class Order
$result = 'json' === self::DEFAULT_FORMAT ? json_decode($response, true) : $response; $result = 'json' === self::DEFAULT_FORMAT ? json_decode($response, true) : $response;
// 日志 // 日志
$this->logger(['request' => $body, 'response' => $result]); $this->logger(['response' => $result]);
return $result; return $result;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger(['request' => $body, 'response' => $e]); $this->logger(['response' => $e]);
throw new HttpException($e->getMessage(), $e->getCode(), $e); throw new HttpException($e->getMessage(), $e->getCode(), $e);
} }
} }
@ -136,63 +136,46 @@ class Order
* 获取工单信息 * 获取工单信息
* @param $order_sn * @param $order_sn
* @return mixed|string * @return mixed|string
* @throws GuzzleException * @throws \Exception|GuzzleException
*/ */
public function getProductOrder($orderId) public function getProductOrder($order_sn)
{ {
$data = [ $data = [
'id' => $orderId 'order_sn' => $order_sn
]; ];
return $this->sendRequest('production.info', $data); return $this->sendRequest('production.status', $data);
} }
/** /**
* 加工工单原木材种 * 加工工单原木材种
* @return mixed|string * @return mixed|string
* @throws GuzzleException * @throws GuzzleException
* @throws HttpException
* @throws InvalidArgumentException
*/ */
public function getWoodTypeOptions($data) public function getWoodTypeOptions($data)
{ {
return $this->sendRequest('Wood.types', $data); return $this->baseFun($data, 'Wood.types');
} }
/** /**
* 加工等级 * 加工等级
* @return mixed|string * @return mixed|string
* @throws GuzzleException * @throws GuzzleException
* @throws HttpException
* @throws InvalidArgumentException
*/ */
public function getProductionLevelOptions($data) public function getProductionLevelOptions($data)
{ {
return $this->sendRequest('production.levels', $data); return $this->baseFun($data, 'production.levels');
} }
/** /**
* 加工工单创建 * 加工工单创建
* @return mixed|string * @return mixed|string
* @throws GuzzleException * @throws \Exception|GuzzleException
*/ */
public function createProductOrder($data) public function createProductOrder($data)
{ {
return $this->sendRequest('production.create', $data); return $this->sendRequest('production.create', $data);
} }
/**
* 加工工单更新
* @return mixed|string
* @throws HttpException|GuzzleException
*/
public function updateProductOrder($data)
{
return $this->sendRequest('production.update', $data);
}
/**
* 加工工单撤回
* @return mixed|string
* @throws HttpException|GuzzleException
*/
public function revokeProductOrder($data)
{
return $this->sendRequest('production.revoke', $data);
}
} }