diff --git a/admin/controllers/store/WareController.php b/admin/controllers/store/WareController.php index d373c4e..3a01b6c 100644 --- a/admin/controllers/store/WareController.php +++ b/admin/controllers/store/WareController.php @@ -277,57 +277,57 @@ class WareController extends BaseAdminController $DrugStoreDrug->saveOrFail(); // TODO 2024-10-31 删除了修改门店售价的操作,门店售价由门店自己设置 - switch ($post['type']) { - case 1://中药 - $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); - if ($DrugStoreRelations) { - foreach ($DrugStoreRelations as $val) { - $store = Store::find()->where(['id' => $val['store_id']])->one(); - - \Yii::$app->db->createCommand()->update('yii_drug_store_relations', - [ 'buy_price' =>bcdiv(bcmul($store['z_buy_percent']??100,$DrugStoreDrug->market_price,4),100,4) ], - [ 'drug_id' => $val['drug_id'], 'store_id' => $val['store_id'] ])->execute(); - } - } - break; - - case 2://西药 - $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); - - if ($DrugStoreRelations) { - foreach ($DrugStoreRelations as $val) { - \Yii::$app->db->createCommand()->update('yii_drug_store_relations', - [ 'buy_price' => $DrugStoreDrug->market_price??0 ], - ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); - } - } - break; - case 3://配方颗粒 - - $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); - if ($DrugStoreRelations) { - foreach ($DrugStoreRelations as $val) { - $store = Store::find()->where(['id' => $val['store_id']])->one(); - \Yii::$app->db->createCommand()->update('yii_drug_store_relations', - ['buy_price' =>bcdiv(bcmul($store['g_buy_percent']??100,$DrugStoreDrug->market_price,4),100,4)], - ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); - } - } - break; - case 4://中成药 - $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); - if ($DrugStoreRelations) { - foreach ($DrugStoreRelations as $val) { - - \Yii::$app->db->createCommand()->update('yii_drug_store_relations', - [ 'buy_price' => $DrugStoreDrug->market_price??$DrugStoreDrug->price], - ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); - } - } - break; - default: - throw new Exception('参数错误'); - } +// switch ($post['type']) { +// case 1://中药 +// $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); +// if ($DrugStoreRelations) { +// foreach ($DrugStoreRelations as $val) { +// $store = Store::find()->where(['id' => $val['store_id']])->one(); +// +// \Yii::$app->db->createCommand()->update('yii_drug_store_relations', +// [ 'buy_price' =>bcdiv(bcmul($store['z_buy_percent']??100,$DrugStoreDrug->market_price,4),100,4) ], +// [ 'drug_id' => $val['drug_id'], 'store_id' => $val['store_id'] ])->execute(); +// } +// } +// break; +// +// case 2://西药 +// $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); +// +// if ($DrugStoreRelations) { +// foreach ($DrugStoreRelations as $val) { +// \Yii::$app->db->createCommand()->update('yii_drug_store_relations', +// [ 'buy_price' => $DrugStoreDrug->market_price??0 ], +// ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); +// } +// } +// break; +// case 3://配方颗粒 +// +// $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); +// if ($DrugStoreRelations) { +// foreach ($DrugStoreRelations as $val) { +// $store = Store::find()->where(['id' => $val['store_id']])->one(); +// \Yii::$app->db->createCommand()->update('yii_drug_store_relations', +// ['buy_price' =>bcdiv(bcmul($store['g_buy_percent']??100,$DrugStoreDrug->market_price,4),100,4)], +// ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); +// } +// } +// break; +// case 4://中成药 +// $DrugStoreRelations = DrugStoreRelations::find()->where(['drug_id' => $post['drug_id']])->asArray()->all(); +// if ($DrugStoreRelations) { +// foreach ($DrugStoreRelations as $val) { +// +// \Yii::$app->db->createCommand()->update('yii_drug_store_relations', +// [ 'buy_price' => $DrugStoreDrug->market_price??$DrugStoreDrug->price], +// ['drug_id' => $val['drug_id'], 'store_id' => $val['store_id']])->execute(); +// } +// } +// break; +// default: +// throw new Exception('参数错误'); +// } $t->commit();