diff --git a/member/modules/v1/controllers/ProductOrderController.php b/member/modules/v1/controllers/ProductOrderController.php index 5f76722..2ded5f8 100644 --- a/member/modules/v1/controllers/ProductOrderController.php +++ b/member/modules/v1/controllers/ProductOrderController.php @@ -177,9 +177,15 @@ class ProductOrderController extends BaseAppController $h->select('name'); }])->asArray()->one(); - $prescription = Prescription::find()->select('cr_ids,wr_ids,gr_ids,category')->where(['id' => $ProductOrder['p_id']])->one(); + $prescription = Prescription::find()->select('cr_ids,wr_ids,gr_ids,category,store_id')->where(['id' => $ProductOrder['p_id']])->one(); - if($prescription['wr_ids']){ + // 获取处方来源诊所信息 + $prescriptionStore = null; + if ($prescription && isset($prescription['store_id']) && $prescription['store_id']) { + $prescriptionStore = Store::find()->select('id,name,mobile,position')->where(['id' => $prescription['store_id']])->asArray()->one(); + } + + if($prescription && $prescription['wr_ids']){ $wr_ids = explode(',', $prescription['wr_ids']); if ($ProductOrder['prescription_type'] == 5) { $west = ServicePackageRepice::find()->select('content,number,total_price')->where([ @@ -194,7 +200,7 @@ class ProductOrderController extends BaseAppController $value['content']=Json::decode($value['content']); } $count = count($west); - }else if($prescription['cr_ids']){ + }else if($prescription && $prescription['cr_ids']){ $cr_ids = explode(',', $prescription['cr_ids']); $chinese = ChineseRepice::find()->select('content,total_price')->where([ 'in', 'id', $cr_ids @@ -220,7 +226,7 @@ class ProductOrderController extends BaseAppController $count = count($granular['list']); } if ($ProductOrder['p_id'] !== 0 && $ProductOrder['order_type'] !== 2) { - if ($prescription['category'] === 2) { + if ($prescription && isset($prescription['category']) && $prescription['category'] === 2) { $ProductOrder['total_pay_price'] = $ProductOrder['trans_expenses']; $ProductOrder['items_price'] = 0; } @@ -234,6 +240,7 @@ class ProductOrderController extends BaseAppController 'west' => $west ?? null, 'chinese' => $chinese ?? null, 'granular' => $granular ?? null, + 'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null, ]; } @@ -426,11 +433,22 @@ class ProductOrderController extends BaseAppController $q->select('id,drug_name,function,specification,usage,instruction'); }])->asArray()->all(); $ProductOrder['count'] = count($ProductOrderItems); + + // 获取处方来源诊所信息 + $prescriptionStore = null; + if ($ProductOrder['p_id']) { + $prescription = Prescription::find()->select('store_id')->where(['id' => $ProductOrder['p_id']])->asArray()->one(); + if ($prescription && isset($prescription['store_id']) && $prescription['store_id']) { + $prescriptionStore = Store::find()->select('id,name,mobile,position')->where(['id' => $prescription['store_id']])->asArray()->one(); + } + } + return [ 'ProductOrder' => $ProductOrder, 'userInfo' => $userInfo, 'hospital' => $hospital, - 'ProductOrderItems' => $ProductOrderItems + 'ProductOrderItems' => $ProductOrderItems, + 'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null, ]; }