| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace App\Services;
- use AlibabaAlihealthSynergyYzwDrugreportOptHistoryAllRequest;
- use AlibabaAlihealthSynergyYzwQuerydrugreportRequest;
- use AlibabaAlihealthSynergyYzwQuerysealdrugreportRequest;
- use Page;
- 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=70169&docType=2&scopeId=30361
- * @param string $beginTime
- * @param string $endTime
- * @param int $page
- * @param int $pageSize
- * @return array
- */
- public function queryDrugReport(string $beginTime, string $endTime, int $page = 1, int $pageSize = 20): array
- {
- $req = new AlibabaAlihealthSynergyYzwQuerydrugreportRequest;
- $req->setRefEntId($this->config['enterprise_id']);
- // $req->setFromRefEntId(""); // 发货企业(可选)
- // $req->setBillCode(""); // 单据编号(可选)
- $req->setBeginTime($beginTime);
- $req->setEndTime($endTime);
- // $req->setDrugId(""); // 药品ID(可选)
- // $req->setBatchNo(""); // 批号(可选)
- $pageObj = new Page;
- $pageObj->page = $page;
- $pageObj->page_size = $pageSize;
- $req->setPage(json_encode($pageObj));
- $resp = $this->client->execute($req);
- if ('SUCCESS' <> $resp->res_result->msg_code) {
- throw new \Exception($resp->result->msg_info);
- }
- $data = json_decode(json_encode(
- $resp->res_result->model->result->onenet_drug_report_top_d_t_o
- ), true);
- return (array)$resp;
- }
- /**
- * 查询上传报告信息接口
- * @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;
- }
- /**
- * 药检报告操作日志
- * @link https://open.taobao.com/api.htm?docId=71189&docType=2&scopeId=30361
- * @param string $beginDate
- * @param string $endDate
- * @param int $page
- * @param int $pageSize
- * @return array
- * @throws \Exception
- */
- public function drugReportOptHistory(string $beginDate, string $endDate, int $page = 1, int $pageSize = 20): array
- {
- $req = new AlibabaAlihealthSynergyYzwDrugreportOptHistoryAllRequest;
- $req->setRefEntId($this->config['enterprise_id']);
- $req->setBeginTime($beginDate);
- $req->setEndTime($endDate);
- // $req->setBatchNo(""); // 批次号(可选)
- // $req->setDrugId(""); // 药品ID(可选)
- $req->setPage($page);
- $req->setPageSize($pageSize);
- $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->top_drug_report_opt_log
- ), true);
- return (array)$resp;
- }
- }
|