diff --git a/common/models/ProductOrder.php b/common/models/ProductOrder.php index c6614a5..bf897f0 100644 --- a/common/models/ProductOrder.php +++ b/common/models/ProductOrder.php @@ -117,7 +117,12 @@ class ProductOrder extends \common\modelsgii\ProductOrder foreach ($list as $key => $value) { $ProductOrder=self::getSHH($value['order_no']); - $inventory[$key]['epl_order_no'] = "\t".$ProductOrder->transaction_id??'暂无';//易票联订单号 + if (!empty($ProductOrder)) { + $inventory[$key]['epl_order_no'] = "\t".$ProductOrder['transaction_id']??'暂无';//易票联订单号 + } else { + $inventory[$key]['epl_order_no'] = "\t".'暂无';//易票联订单号 + } + $inventory[$key]['order_no'] = "\t" . $value['order_no'];//订单号 $inventory[$key]['store'] = "\t" . $value['store']['name'];//诊所名称 $content = $value['prescription']; @@ -126,11 +131,23 @@ class ProductOrder extends \common\modelsgii\ProductOrder $repice = json_decode($content['content'], true)['repice']; foreach ($repice as $val) { - foreach (json_decode($val['content']) as $vv) { - $item['drug_name'] .= $vv->name . '|'; - $item['specification'] .= $vv->specification . '|' ?? '无' . '|'; - $item['source'] .= $vv->source . '|' ?? '无' . '|'; - $item['unit_price'] .= $vv->price . '|' ?? '无' . '|'; + if (!isset($item['drug_name'])) { + $item['drug_name'] = ''; + } + if (!isset($item['specification'])) { + $item['specification'] = ''; + } + if (!isset($item['source'])) { + $item['source'] = ''; + } + if (!isset($item['unit_price'])) { + $item['unit_price'] = ''; + } + foreach (json_decode($val['content'], true) as $vv) { + $item['drug_name'] .= array_key_exists('drug_name', $vv)? $vv['drug_name'] . '|': '获取失败' . '|'; + $item['specification'] .= array_key_exists('specification', $vv)? $vv['specification'] . '|' : '无' . '|'; + $item['source'] .= array_key_exists('source', $vv)? $vv['source'] . '|' : '无' . '|'; + $item['unit_price'] .= $val['total_price'] . '|' ?? '无' . '|'; } } } else {//西药 @@ -138,9 +155,23 @@ class ProductOrder extends \common\modelsgii\ProductOrder $repice = json_decode($content['content'], true)['repice']; if(!empty($repice)){ foreach ($repice as $val) { - $item['drug_name'] .= json_decode($val['content'], true)['drug_name'] . '|'; - $item['specification'] .= json_decode($val['content'], true)['specification'] . '|' ?? '无' . '|'; - $item['source'] .= json_decode($val['content'], true)['source'] . '|' ?? '无' . '|'; + if (!isset($item['drug_name'])) { + $item['drug_name'] = ''; + } + if (!isset($item['specification'])) { + $item['specification'] = ''; + } + if (!isset($item['source'])) { + $item['source'] = ''; + } + if (!isset($item['unit_price'])) { + $item['unit_price'] = ''; + } + + $contentItem = json_decode($val['content'], true); + $item['drug_name'] .= array_key_exists('drug_name', $contentItem)? $contentItem['drug_name'] . '|': '获取失败' . '|'; + $item['specification'] .= array_key_exists('specification', $contentItem)? $contentItem['specification'] . '|' : '无' . '|'; + $item['source'] .= array_key_exists('source', $contentItem)? $contentItem['source'] . '|' : '无' . '|'; $item['unit_price'] .= $val['total_price'] . '|' ?? '无' . '|'; } }