修改消息推送

This commit is contained in:
2023-04-04 18:39:10 +08:00
parent ad119be0e8
commit 9c44f13498
11 changed files with 351 additions and 277 deletions
+39 -23
View File
@@ -54,13 +54,20 @@ class Prescription
try {
$response = $this->httpRequest($this->api_url . $this->version . '/user_thrid/token', $option);
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['result'])){
if (empty($response['data']['result'])){
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['result']['token'])){
if (empty($response['data']['result']['token'])){
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
@@ -70,11 +77,11 @@ class Prescription
}
$this->header = [
"Authorization" => "Bearer " . $response['result']['token']
"Authorization" => "Bearer " . $response['data']['result']['token']
];
$this->redis->set("prescription_token",$response['result']['token'],60 * 60 * 1.5);
return $response['result']['token'];
$this->redis->set("prescription_token",$response['data']['result']['token'],60 * 60 * 1.5);
return $response['data']['result']['token'];
}
/**
@@ -83,7 +90,8 @@ class Prescription
* @param int $pageSize
* @return mixed
*/
public function getProd(int $page = 1,int $pageSize = 10){
public function getProd(int $page = 1,int $pageSize = 10): mixed
{
$option = [
"json" => array(
"page" => $page,
@@ -93,12 +101,20 @@ class Prescription
try {
$response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option);
if (empty($response['result'])){
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['data']['result'])){
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
return $response['result'];
return $response['data']['result'];
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
}
@@ -113,18 +129,22 @@ class Prescription
{
$option = [
"json" => array(
"pharmacyCode" => "JG-10009",
"pharmacyCode" => "ZD-10003",
"drugCode" => $product_platform_code,
),
];
try {
$response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/pharmacyInventory', $option);
if (empty($response)){
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
return $response;
return $response['data'];
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
}
@@ -144,12 +164,15 @@ class Prescription
try {
$response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/transportationExpenses', $option);
if (empty($response)){
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
return $response;
return $response['data'];
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
}
@@ -169,7 +192,7 @@ class Prescription
try {
$response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option);
if (empty($response)){
// 返回值为空
// 返回值错误为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
@@ -210,6 +233,7 @@ class Prescription
}
$response = $this->client->post($path, $arg);
if ($response->getStatusCode() != '200'){
// 请求失败
throw new BusinessException($response->getBody()->getContents());
@@ -221,14 +245,6 @@ class Prescription
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($body['data'])){
// 返回值为空
if (!empty($body['message'])){
throw new BusinessException($body['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
return $body['data'];
return $body;
}
}