| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace App\Services;
- use AlibabaAlihealthSynergyYzwQuerysealdrugreportRequest;
- use TopClient;
- class AlihealthService
- {
- private $client;
- private $config;
- public function __construct()
- {
- $this->config = config('taobao');
- $this->client = new TopClient;
- $this->client->appkey = $this->config['app_key'];
- $this->client->secretKey = $this->config['secret_key'];
- $this->client->format = "json";
- }
- /**
- * 查询上传报告信息接口(@link https://open.taobao.com/api.htm?docId=70145&docType=2&scopeId=30361)
- * @param string $beginTime
- * @param string $endTime
- * @param int $page
- * @param int $pageSize
- * @param int $isSeal
- * @return array
- * @throws \Exception
- */
- public function querySealDrugReport(string $beginTime, string $endTime, int $page = 1, int $pageSize = 20, int $isSeal = 0): array
- {
- $req = new AlibabaAlihealthSynergyYzwQuerysealdrugreportRequest;
- $req->setRefEntId($this->config['enterprise_id']);
- $req->setBeginTime($beginTime);
- $req->setEndTime($endTime);
- $req->setPage($page);
- $req->setPageSize($pageSize);
- if ($isSeal) {
- $req->setStatus($isSeal);
- }
- $resp = $this->client->execute($req);
- if ('SUCCESS' <> $resp->result->msg_code) {
- throw new \Exception($resp->result->msg_info);
- }
- $data = json_decode(json_encode(
- $resp->result->model->result_list->ocr_seal_drug_report_d_t_o
- ), true);
- app(DrugReportInfoService::class)->bulkInsert($data);
- return (array)$resp;
- }
- }
|