更新项目部分结构,新增加DB
This commit is contained in:
44
common/models/oldDb/DrugStoreRelations.php
Normal file
44
common/models/oldDb/DrugStoreRelations.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\oldDb;
|
||||
|
||||
class DrugStoreRelations extends \common\modelsgii\oldDb\DrugStoreRelations
|
||||
{
|
||||
|
||||
//关联基本药品信息
|
||||
public function getDrug()
|
||||
{
|
||||
return $this->hasOne(Drug::class,['id'=>'drug_id']);
|
||||
}
|
||||
|
||||
|
||||
//关联仓库
|
||||
public function getDrugStoreDrug()
|
||||
{
|
||||
return $this->hasOne(DrugStoreDrug::class,['drug_id'=>'drug_id']);
|
||||
}
|
||||
|
||||
|
||||
public function getStore()
|
||||
{
|
||||
return $this->hasOne(Store::class,['id' => 'store_id']);
|
||||
}
|
||||
|
||||
public static function inventory($params, $storeId)
|
||||
{
|
||||
$list = self::find()->with(['drugStoreDrug', 'drug'])->where(['store_id' => $storeId])->select([
|
||||
'drug_id',
|
||||
'price',
|
||||
])->asArray()->all();
|
||||
$result = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$result[$k]['drug_id'] = $v['drug_id'];
|
||||
$result[$k]['drug_name'] = $v['drug']['drug_name'];
|
||||
$result[$k]['market_price'] = $v['drugStoreDrug']['market_price'];
|
||||
$result[$k]['test_price'] = $v['drugStoreDrug']['price'];
|
||||
$result[$k]['price'] = $v['price'];
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user