diff --git a/service/modules/v1/controllers/PrescriptionController.php b/service/modules/v1/controllers/PrescriptionController.php index 87bd038..a52eea7 100644 --- a/service/modules/v1/controllers/PrescriptionController.php +++ b/service/modules/v1/controllers/PrescriptionController.php @@ -2205,7 +2205,7 @@ class PrescriptionController extends BaseAppController $drug['stock'] = $v['drugStoreDrug']['stock']; $collect[] = $drug; } - $unCollect = Drug::find()->alias('d')->select('d.*')->where([ + $unCollect = Drug::find()->with(['supplier'])->alias('d')->select('d.*')->where([ 'in','d.type', [5] ])->andWhere([ 'not in', 'd.id', $ids @@ -2217,13 +2217,14 @@ class PrescriptionController extends BaseAppController $unCollect[$k]['buy_price'] = $v['drugStoreRelation']['buy_price']; $unCollect[$k]['price'] = $v['drugStoreRelation']['price']; $unCollect[$k]['stock'] = $v['drugStoreDrug']['stock']; + $unCollect[$k]['source'] = $v['supplier']['name']?? ''; unset($unCollect[$k]['drugStoreRelation']); unset($unCollect[$k]['drugStoreDrug']); } return ['collect' => $collect, 'uncollect' => $unCollect]; } - $unCollect = Drug::find()->alias('d')->select('d.*')->where([ + $unCollect = Drug::find()->with(['supplier'])->alias('d')->select('d.*')->where([ 'in','d.type', [5] ])->joinWith(['drugStoreDrug dsd' => function($q){ $q->andWhere(['dsd.status' => 2]); @@ -2235,6 +2236,7 @@ class PrescriptionController extends BaseAppController $unCollect[$k]['buy_price'] = $v['drugStoreRelation']['buy_price']; $unCollect[$k]['price'] = $v['drugStoreRelation']['price']; $unCollect[$k]['stock'] = $v['drugStoreDrug']['stock']; + $unCollect[$k]['source'] = $v['supplier']['name']?? ''; unset($unCollect[$k]['drugStoreRelation']); unset($unCollect[$k]['drugStoreDrug']); @@ -2242,7 +2244,7 @@ class PrescriptionController extends BaseAppController return ['uncollect' => $unCollect]; } //搜索 - $allDrug = Drug::find()->alias('d')->select('d.*')->where([ + $allDrug = Drug::find()->with(['supplier'])->alias('d')->select('d.*')->where([ 'in','d.type', [5] ])->andWhere([ 'or', @@ -2263,6 +2265,7 @@ class PrescriptionController extends BaseAppController $allDrug[$k]['buy_price'] = $v['drugStoreRelation']['buy_price']; $allDrug[$k]['price'] = $v['drugStoreRelation']['price']; $allDrug[$k]['stock'] = $v['drugStoreDrug']['stock']; + $allDrug[$k]['source'] = $v['supplier']['name']?? ''; unset($allDrug[$k]['drugStoreRelation']); unset($allDrug[$k]['drugStoreDrug']); $ids[] = $v['id']; @@ -2295,7 +2298,7 @@ class PrescriptionController extends BaseAppController } } - $no_collect = Drug::find()->alias('d')->select('d.*')->where([ + $no_collect = Drug::find()->with(['supplier'])->alias('d')->select('d.*')->where([ 'in', 'd.id', $ids ])->andWhere([ 'in','d.type', [5] @@ -2309,11 +2312,12 @@ class PrescriptionController extends BaseAppController $no_collect[$k]['buy_price'] = $v['drugStoreRelation']['buy_price']; $no_collect[$k]['price'] = $v['drugStoreRelation']['price']; $no_collect[$k]['stock'] = $v['drugStoreDrug']['stock']; + $no_collect[$k]['source'] = $v['supplier']['name']?? ''; unset($no_collect[$k]['drugStoreRelation']); unset($no_collect[$k]['drugStoreDrug']); } - $collected = Drug::find()->alias('d')->select('d.*')->where([ + $collected = Drug::find()->with(['supplier'])->alias('d')->select('d.*')->where([ 'in', 'd.id', $is_collect ])->andWhere([ 'in','d.type', [5] @@ -2327,6 +2331,7 @@ class PrescriptionController extends BaseAppController $collected[$k]['buy_price'] = $v['drugStoreRelation']['buy_price']; $collected[$k]['price'] = $v['drugStoreRelation']['price']; $collected[$k]['stock'] = $v['drugStoreDrug']['stock']; + $no_collect[$k]['source'] = $v['supplier']['name']?? ''; unset($collected[$k]['drugStoreRelation']); unset($collected[$k]['drugStoreDrug']); }