Compare commits

...

13 Commits

Author SHA1 Message Date
李琦
313e9ff79e 回滚门店绑定 2026-05-08 15:54:18 +08:00
李琦
857fd0730e 分账剂数还原 2026-05-08 15:37:52 +08:00
李琦
4e5507187d 分账剂数还原 2026-04-30 13:08:20 +08:00
李琦
dcfbb830db 分账剂数还原 2026-04-30 13:05:16 +08:00
李琦
cff74a74b6 分账剂数 2026-04-30 13:04:58 +08:00
李琦
d2fe8f5a58 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	common/forms/LedgerForm.php
2026-04-30 13:02:48 +08:00
李琦
ec5e919803 修复因为订单计数0导致的分账问题 2026-04-30 09:19:47 +08:00
李琦
9852b8534b 默认剂数 2026-04-29 16:52:58 +08:00
李琦
1d81f31135 默认剂数 2026-04-27 16:21:48 +08:00
李琦
c71ab2cb10 订单详情关联 2026-03-24 12:31:19 +08:00
李琦
a3befd977b 订单详情关联 2026-02-07 16:55:06 +08:00
李琦
908b00db83 订单详情关联 2026-02-07 16:52:55 +08:00
李琦
0297899367 转接方分账 2026-02-07 16:32:21 +08:00
5 changed files with 508 additions and 108 deletions

View File

@@ -53,7 +53,7 @@ class LedgerForm extends BaseModel
throw new Exception('门店不存在'); throw new Exception('门店不存在');
} }
$time = time(); $time = time();
$ledger[] = [ $ledger[] = [
@@ -84,7 +84,7 @@ class LedgerForm extends BaseModel
throw $e; throw $e;
} }
break; break;
default: //产品订单 default: //产品订单
ProductOrderLog::saveLog($this->order_id, '产品订单增加待结算记录开始'); ProductOrderLog::saveLog($this->order_id, '产品订单增加待结算记录开始');
$t = \Yii::$app->db->beginTransaction(); $t = \Yii::$app->db->beginTransaction();
@@ -316,45 +316,45 @@ class LedgerForm extends BaseModel
$transferPrescription = null; $transferPrescription = null;
$transferStoreId = null; $transferStoreId = null;
$delegateStoreId = null; $delegateStoreId = null;
if ($productOrder->prescription && $productOrder->prescription->is_from_transfer == 1 && $productOrder->prescription_type == '1') { if ($productOrder->prescription && $productOrder->prescription->is_from_transfer == 1 && $productOrder->prescription_type == '1') {
// 通过处方关联挂号,再通过挂号关联转诊记录 // 通过处方关联挂号,再通过挂号关联转诊记录
// 处方 -> 挂号(register_id) -> 转诊记录(transfer_prescription_id) // 处方 -> 挂号(register_id) -> 转诊记录(transfer_prescription_id)
if ($productOrder->prescription->register && $productOrder->prescription->register->transferPrescription) { if ($productOrder->prescription->register && $productOrder->prescription->register->transferPrescription) {
$transferPrescription = $productOrder->prescription->register->transferPrescription; $transferPrescription = $productOrder->prescription->register->transferPrescription;
$isTransferPrescription = true; $isTransferPrescription = true;
$transferStoreId = $transferPrescription->transfer_store_id; // 发起方(转诊诊所,西医诊所) $transferStoreId = $transferPrescription->transfer_store_id; // 发起方(转诊诊所,西医诊所)
$delegateStoreId = $transferPrescription->delegate_store_id; // 承接方(委托诊所,中医诊所) $delegateStoreId = $transferPrescription->delegate_store_id; // 承接方(委托诊所,中医诊所)
if (!$transferStoreId || !$delegateStoreId) { if (!$transferStoreId || !$delegateStoreId) {
// 如果转诊信息不完整,按普通处方处理 // 如果转诊信息不完整,按普通处方处理
$isTransferPrescription = false; $isTransferPrescription = false;
} }
} }
} }
// 如果是转诊处方,需要特殊处理分账逻辑 // 如果是转诊处方,需要特殊处理分账逻辑
if ($isTransferPrescription) { if ($isTransferPrescription) {
/* /*
* 转诊处方分账逻辑: * 转诊处方分账逻辑:
* 1. 承接方(委托诊所)分走15%发起方(转诊诊所)的利润 * 1. 发起方(转诊诊所)获得100%的利润
* 2. 发起方获得85%的利润 * 2. 承接方(委托诊所)不分账
* 3. 平台分账保持不变(成本价) * 3. 平台分账保持不变(成本价)
*/ */
// 第一遍遍历:计算所有药品的总利润 // 第一遍遍历:计算所有药品的总利润
$totalProfit = 0; $totalProfit = 0;
$itemProfits = []; $itemProfits = [];
$itemData = []; $itemData = [];
foreach($productOrderItems as $v) { foreach($productOrderItems as $v) {
$number = $v['number']; $number = $v['number'];
$dosage = $v['dosage'] ?? 1; $dosage = $v['dosage'] ?? 1;
$totalPrice = round($dosage * $number * $v['price'], 4); $totalPrice = round($dosage * $number * $v['price'], 4);
$totalBuyPrice = round($dosage * $number * $v['buy_price'], 4); $totalBuyPrice = round($dosage * $number * $v['buy_price'], 4);
$profit = $totalPrice - $totalBuyPrice; $profit = $totalPrice - $totalBuyPrice;
$totalProfit += $profit; $totalProfit += $profit;
$itemProfits[] = $profit; $itemProfits[] = $profit;
$itemData[] = [ $itemData[] = [
@@ -365,15 +365,15 @@ class LedgerForm extends BaseModel
'drug_id' => $v['drug_id'], 'drug_id' => $v['drug_id'],
]; ];
} }
// 计算分账金额:从总利润中分配 // 计算分账金额:从总利润中分配
$delegateProfit = round($totalProfit * 0.15, 2); // 承接方分得15%的总利润 // 转诊处方分账逻辑:全部利润(100%)分给发起方(转诊诊所),承接方不分账
$transferProfit = round($totalProfit * 0.85, 2); // 发起方分得85%的总利润 $transferProfit = round($totalProfit, 2); // 发起方分得100%的总利润(全部利润)
// 第二遍遍历:按每个药品的利润占比,分配承接方和发起方的分账金额 // 第二遍遍历:按每个药品的利润占比,分配发起方的分账金额
foreach($itemData as $index => $item) { foreach($itemData as $index => $item) {
$ledger = []; $ledger = [];
// 医保支付(走月付) // 医保支付(走月付)
if ($productOrder['prescription']['category'] == 2) { if ($productOrder['prescription']['category'] == 2) {
// 查询订单是否已生成月付 // 查询订单是否已生成月付
@@ -389,10 +389,9 @@ class LedgerForm extends BaseModel
} else { } else {
// 按该药品利润占比分配总利润 // 按该药品利润占比分配总利润
$itemProfitRatio = $totalProfit > 0 ? ($itemProfits[$index] / $totalProfit) : 0; $itemProfitRatio = $totalProfit > 0 ? ($itemProfits[$index] / $totalProfit) : 0;
$itemDelegateProfit = round($delegateProfit * $itemProfitRatio, 2); // 该药品承接方应分得的金额 $itemTransferProfit = round($transferProfit * $itemProfitRatio, 2); // 该药品发起方应分得的金额(100%利润)
$itemTransferProfit = round($transferProfit * $itemProfitRatio, 2); // 该药品发起方应分得的金额
// 创建分账记录:发起方(转诊诊所)分得100%利润
// 创建分账记录:发起方(转诊诊所)分得85%利润
$ledger[] = [ $ledger[] = [
'order_id' => $this->order_id, 'order_id' => $this->order_id,
'user_id' => $transferStoreId, // 发起方诊所ID 'user_id' => $transferStoreId, // 发起方诊所ID
@@ -404,30 +403,12 @@ class LedgerForm extends BaseModel
'drug_id' => $item['drug_id'], 'drug_id' => $item['drug_id'],
'xd_time' => $productOrder->created_at, 'xd_time' => $productOrder->created_at,
'number' => $item['number'], 'number' => $item['number'],
'money' => $itemTransferProfit, // 发起方获得85%利润 'money' => $itemTransferProfit, // 发起方获得100%利润
'status' => 0, 'status' => 0,
'created_at' => $time, 'created_at' => $time,
'updated_at' => $time 'updated_at' => $time
]; ];
// 创建分账记录:承接方(委托诊所)分得15%利润
$ledger[] = [
'order_id' => $this->order_id,
'user_id' => $delegateStoreId, // 承接方诊所ID
'user_type' => 1, //门店
'order_type' => 1,//产品订单
'fee_type' => 1,//药品费用
'su_id' => $productOrder->su_id,
'drugstore_id' => $productOrder->store_id,
'drug_id' => $item['drug_id'],
'xd_time' => $productOrder->created_at,
'number' => $item['number'],
'money' => $itemDelegateProfit, // 承接方获得15%利润
'status' => 0,
'created_at' => $time,
'updated_at' => $time
];
// 创建分账记录:平台分账保持不变(成本价) // 创建分账记录:平台分账保持不变(成本价)
$ledger[] = [ $ledger[] = [
'order_id' => $this->order_id, 'order_id' => $this->order_id,
@@ -445,7 +426,7 @@ class LedgerForm extends BaseModel
'created_at' => $time, 'created_at' => $time,
'updated_at' => $time 'updated_at' => $time
]; ];
\Yii::$app->db->createCommand()->batchInsert(Ledger::tableName(), [ \Yii::$app->db->createCommand()->batchInsert(Ledger::tableName(), [
'order_id', 'user_id', 'user_type', 'order_type', 'fee_type', 'su_id', 'drugstore_id', 'order_id', 'user_id', 'user_type', 'order_type', 'fee_type', 'su_id', 'drugstore_id',
'drug_id','xd_time', 'number', 'money', 'status', 'created_at', 'updated_at' 'drug_id','xd_time', 'number', 'money', 'status', 'created_at', 'updated_at'
@@ -678,26 +659,26 @@ class LedgerForm extends BaseModel
$store = Store::findOne(['id' => $Register->store_id]); $store = Store::findOne(['id' => $Register->store_id]);
if(!$store){ if(!$store){
throw new Exception('门店不存在'); throw new Exception('门店不存在');
} }
$time = time(); $time = time();
$t = \Yii::$app->db->beginTransaction(); $t = \Yii::$app->db->beginTransaction();
$model = new LedgerLog(); $model = new LedgerLog();
try { try {
switch ($this->status) { switch ($this->status) {
case 1: // 已结算 case 1: // 已结算
//更新挂号订单为已结算 //更新挂号订单为已结算
$Register->is_settled = 1; $Register->is_settled = 1;
$Register->created_at = strtotime($Register->created_at); $Register->created_at = strtotime($Register->created_at);
$Register->updated_at = $time; $Register->updated_at = $time;
$Register->saveOrFail(); $Register->saveOrFail();
//分账表批量更新状态为已结算 //分账表批量更新状态为已结算
Ledger::updateAll(['status' => 1, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 2]); //1产品订单 2挂号订单 Ledger::updateAll(['status' => 1, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 2]); //1产品订单 2挂号订单
/******************************************** 门店 ********************************************** */ /******************************************** 门店 ********************************************** */
$storeTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_id' => $store->id, 'user_type' => 1, 'order_type' => 2, 'fee_type' => 2])->sum('money'); // 该订单门店分佣总金额 $storeTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_id' => $store->id, 'user_type' => 1, 'order_type' => 2, 'fee_type' => 2])->sum('money'); // 该订单门店分佣总金额
$storeTotal = round($storeTotal, 2);//4舍5入 $storeTotal = round($storeTotal, 2);//4舍5入
//增加门店分佣 //增加门店分佣
$log = clone $model; $log = clone $model;
$log->order_id = $this->order_id; $log->order_id = $this->order_id;
@@ -714,7 +695,7 @@ class LedgerForm extends BaseModel
//门店可提现及累计金额更新 //门店可提现及累计金额更新
CashAccount::updateAllCounters(['able_cash' => $storeTotal, 'total_cash' => $storeTotal],['user_type' => 1, 'user_id' => $store->id]); //门店 CashAccount::updateAllCounters(['able_cash' => $storeTotal, 'total_cash' => $storeTotal],['user_type' => 1, 'user_id' => $store->id]); //门店
break; break;
case 2://已取消 case 2://已取消
if($Register->is_settled == 1){ //已结算回退 if($Register->is_settled == 1){ //已结算回退
@@ -722,7 +703,7 @@ class LedgerForm extends BaseModel
Reconciliation::updateAll(['status' => -1], ['order_id' => $this->order_id]); Reconciliation::updateAll(['status' => -1], ['order_id' => $this->order_id]);
//分账表批量更新状态为已取消 //分账表批量更新状态为已取消
Ledger::updateAll(['status' => 2, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]);//1产品订单 2挂号订单 Ledger::updateAll(['status' => 2, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]);//1产品订单 2挂号订单
$ledgerLog = LedgerLog::find()->where(['order_id' => $this->order_id])->asArray()->all(); $ledgerLog = LedgerLog::find()->where(['order_id' => $this->order_id])->asArray()->all();
foreach($ledgerLog as $v){ foreach($ledgerLog as $v){
$log = clone $model; $log = clone $model;
@@ -737,7 +718,7 @@ class LedgerForm extends BaseModel
$log->created_at = $time; $log->created_at = $time;
$log->updated_at = $time; $log->updated_at = $time;
$log->saveOrFail(); $log->saveOrFail();
//可提现及累计金额更新 //可提现及累计金额更新
CashAccount::updateAllCounters(['able_cash' => $v['amount'] * -1, 'total_cash' => $v['amount'] * -1],['user_type' => $v['user_type'], 'user_id' => $v['user_id'], 'order_type' => $v['order_type'], 'fee_type' => $v['fee_type']]); CashAccount::updateAllCounters(['able_cash' => $v['amount'] * -1, 'total_cash' => $v['amount'] * -1],['user_type' => $v['user_type'], 'user_id' => $v['user_id'], 'order_type' => $v['order_type'], 'fee_type' => $v['fee_type']]);
} }
@@ -757,7 +738,7 @@ class LedgerForm extends BaseModel
throw $e; throw $e;
} }
break; break;
default: //产品订单 default: //产品订单
ProductOrderLog::saveLog($this->order_id, '产品订单结算更新开始'); ProductOrderLog::saveLog($this->order_id, '产品订单结算更新开始');
$productOrder = ProductOrder::find()->where(['id' => $this->order_id])->one(); $productOrder = ProductOrder::find()->where(['id' => $this->order_id])->one();
@@ -767,17 +748,17 @@ class LedgerForm extends BaseModel
$store = Store::findOne(['id' => $productOrder->store_id]); $store = Store::findOne(['id' => $productOrder->store_id]);
if(!$store){ if(!$store){
throw new Exception('门店不存在'); throw new Exception('门店不存在');
} }
$time = time(); $time = time();
$t = \Yii::$app->db->beginTransaction(); $t = \Yii::$app->db->beginTransaction();
$model = new LedgerLog(); $model = new LedgerLog();
try { try {
switch ($this->status) { switch ($this->status) {
case 1: // 已结算 case 1: // 已结算
//更新产品订单为已结算 //更新产品订单为已结算
$productOrder->is_settled = 1; $productOrder->is_settled = 1;
$productOrder->saveOrFail(); $productOrder->saveOrFail();
$productOrderItems = ProductOrderItems::find()->with(['drug.supplier'])->where(['product_order_id' => $productOrder->id])->asArray()->all(); $productOrderItems = ProductOrderItems::find()->with(['drug.supplier'])->where(['product_order_id' => $productOrder->id])->asArray()->all();
$Reconciliation = new Reconciliation(); $Reconciliation = new Reconciliation();
foreach($productOrderItems as $v){ foreach($productOrderItems as $v){
@@ -834,12 +815,12 @@ class LedgerForm extends BaseModel
]); ]);
} }
} }
//分账表批量更新状态为已结算 //分账表批量更新状态为已结算
Ledger::updateAll(['status' => 1, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]); //1产品订单 2挂号订单 Ledger::updateAll(['status' => 1, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]); //1产品订单 2挂号订单
/******************************************** 平台 ********************************************** */ /******************************************** 平台 ********************************************** */
$platformDrugTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_type' => 2, 'order_type' => 1, 'fee_type' => 1])->sum('money'); // 该订单平台分佣总金额 $platformDrugTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_type' => 2, 'order_type' => 1, 'fee_type' => 1])->sum('money'); // 该订单平台分佣总金额
//增加药品分佣 //增加药品分佣
$log = clone $model; $log = clone $model;
$log->order_id = $this->order_id; $log->order_id = $this->order_id;
@@ -917,7 +898,7 @@ class LedgerForm extends BaseModel
/******************************************** 门店 ********************************************** */ /******************************************** 门店 ********************************************** */
$storeTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_id' => $store->id, 'user_type' => 1, 'order_type' => 1, 'fee_type' => 1])->sum('money'); // 该订单门店分佣总金额 $storeTotal = Ledger::find()->where(['order_id' => $this->order_id, 'user_id' => $store->id, 'user_type' => 1, 'order_type' => 1, 'fee_type' => 1])->sum('money'); // 该订单门店分佣总金额
$storeTotal = round($storeTotal, 2);//4舍5入 $storeTotal = round($storeTotal, 2);//4舍5入
//增加门店分佣 //增加门店分佣
$log = clone $model; $log = clone $model;
$log->order_id = $this->order_id; $log->order_id = $this->order_id;
@@ -949,9 +930,9 @@ class LedgerForm extends BaseModel
$logTreatement->saveOrFail(); $logTreatement->saveOrFail();
} }
//门店可提现及累计金额更新 //门店可提现及累计金额更新
CashAccount::updateAllCounters(['able_cash' => $storeTotal, 'total_cash' => $storeTotal],['user_type' => 1, 'user_id' => $store->id]); //门店 CashAccount::updateAllCounters(['able_cash' => $storeTotal, 'total_cash' => $storeTotal],['user_type' => 1, 'user_id' => $store->id]); //门店
break; break;
case 2://已取消 case 2://已取消
if($productOrder->is_settled == 1){ //已结算回退 if($productOrder->is_settled == 1){ //已结算回退
@@ -959,7 +940,7 @@ class LedgerForm extends BaseModel
Reconciliation::updateAll(['status' => -1], ['order_id' => $this->order_id]); Reconciliation::updateAll(['status' => -1], ['order_id' => $this->order_id]);
//分账表批量更新状态为已取消 //分账表批量更新状态为已取消
Ledger::updateAll(['status' => 2, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]);//1产品订单 2挂号订单 Ledger::updateAll(['status' => 2, 'updated_at' => $time], ['order_id' => $this->order_id, 'order_type' => 1]);//1产品订单 2挂号订单
$ledgerLog = LedgerLog::find()->where(['order_id' => $this->order_id])->asArray()->all(); $ledgerLog = LedgerLog::find()->where(['order_id' => $this->order_id])->asArray()->all();
foreach($ledgerLog as $v){ foreach($ledgerLog as $v){
if ($v['user_type'] === 3) { if ($v['user_type'] === 3) {
@@ -1020,7 +1001,7 @@ class LedgerForm extends BaseModel
throw $e; throw $e;
} }
break; break;
} }
} }
} }

View File

@@ -177,10 +177,17 @@ class ProductOrderController extends BaseAppController
$h->select('name'); $h->select('name');
}])->asArray()->one(); }])->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']){ // 获取处方来源诊所信息
$wr_ids = explode(',', $prescription['wr_ids']); $prescriptionStore = null;
if ($prescription && $prescription->store_id) {
$prescriptionStore = Store::find()->select('id,name,mobile,position')->where(['id' => $prescription->store_id])->asArray()->one();
}
$count = 0;
if($prescription && $prescription->wr_ids){
$wr_ids = explode(',', $prescription->wr_ids);
if ($ProductOrder['prescription_type'] == 5) { if ($ProductOrder['prescription_type'] == 5) {
$west = ServicePackageRepice::find()->select('content,number,total_price')->where([ $west = ServicePackageRepice::find()->select('content,number,total_price')->where([
'in', 'id', $wr_ids 'in', 'id', $wr_ids
@@ -194,8 +201,8 @@ class ProductOrderController extends BaseAppController
$value['content']=Json::decode($value['content']); $value['content']=Json::decode($value['content']);
} }
$count = count($west); $count = count($west);
}else if($prescription['cr_ids']){ }else if($prescription && $prescription->cr_ids){
$cr_ids = explode(',', $prescription['cr_ids']); $cr_ids = explode(',', $prescription->cr_ids);
$chinese = ChineseRepice::find()->select('content,total_price')->where([ $chinese = ChineseRepice::find()->select('content,total_price')->where([
'in', 'id', $cr_ids 'in', 'id', $cr_ids
])->all(); ])->all();
@@ -206,8 +213,8 @@ class ProductOrderController extends BaseAppController
} }
} }
$count = count($chinese['list']); $count = count($chinese['list']);
}else{ }else if($prescription && $prescription->gr_ids){
$gr_ids = explode(',', $prescription['gr_ids']); $gr_ids = explode(',', $prescription->gr_ids);
$granular = GranularRepice::find()->select('content,total_price')->where([ $granular = GranularRepice::find()->select('content,total_price')->where([
'in', 'id', $gr_ids 'in', 'id', $gr_ids
])->all(); ])->all();
@@ -220,7 +227,7 @@ class ProductOrderController extends BaseAppController
$count = count($granular['list']); $count = count($granular['list']);
} }
if ($ProductOrder['p_id'] !== 0 && $ProductOrder['order_type'] !== 2) { if ($ProductOrder['p_id'] !== 0 && $ProductOrder['order_type'] !== 2) {
if ($prescription['category'] === 2) { if ($prescription && $prescription->category === 2) {
$ProductOrder['total_pay_price'] = $ProductOrder['trans_expenses']; $ProductOrder['total_pay_price'] = $ProductOrder['trans_expenses'];
$ProductOrder['items_price'] = 0; $ProductOrder['items_price'] = 0;
} }
@@ -234,6 +241,7 @@ class ProductOrderController extends BaseAppController
'west' => $west ?? null, 'west' => $west ?? null,
'chinese' => $chinese ?? null, 'chinese' => $chinese ?? null,
'granular' => $granular ?? null, 'granular' => $granular ?? null,
'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null,
]; ];
} }
@@ -426,11 +434,22 @@ class ProductOrderController extends BaseAppController
$q->select('id,drug_name,function,specification,usage,instruction'); $q->select('id,drug_name,function,specification,usage,instruction');
}])->asArray()->all(); }])->asArray()->all();
$ProductOrder['count'] = count($ProductOrderItems); $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 [ return [
'ProductOrder' => $ProductOrder, 'ProductOrder' => $ProductOrder,
'userInfo' => $userInfo, 'userInfo' => $userInfo,
'hospital' => $hospital, 'hospital' => $hospital,
'ProductOrderItems' => $ProductOrderItems 'ProductOrderItems' => $ProductOrderItems,
'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null,
]; ];
} }

View File

@@ -206,6 +206,21 @@ class LoginForm extends BaseModel
'su_id' => $ServiceUser->id, 'su_id' => $ServiceUser->id,
])->with(['serviceUser']) ])->with(['serviceUser'])
->asArray()->one(); ->asArray()->one();
// 把ServiceUser信息存在Redis里面(使用DB 1,key前缀加上doctor_wx区分)
$ServiceUserData = [
'user' => [
'id' => $ServiceUser->id,
'mobile' => $ServiceUser->mobile ?? '',
'nickname' => $ServiceUser->nickname ?? '微信用户',
'role' => $ServiceUser->role,
'status' => $ServiceUser->status,
'plate_type' => $ServiceUser->plate_type,
]
];
\Yii::$app->redis->select(1);
\Yii::$app->redis->set('xiaokang_database_xk_user_doctor_wx_' . $token, json_encode($ServiceUserData));
return [ return [
'token'=>$token, 'token'=>$token,
'data'=>$StoreDoctor 'data'=>$StoreDoctor
@@ -256,6 +271,21 @@ class LoginForm extends BaseModel
$StoreDoctor = StoreDoctor::find()->where([ $StoreDoctor = StoreDoctor::find()->where([
'su_id' => $ServiceUser->id, 'su_id' => $ServiceUser->id,
])->with(['serviceUser'])->asArray()->one(); ])->with(['serviceUser'])->asArray()->one();
// 把ServiceUser信息存在Redis里面(使用DB 1,key前缀加上doctor_wx区分)
$ServiceUserData = [
'user' => [
'id' => $ServiceUser->id,
'mobile' => $ServiceUser->mobile ?? '',
'nickname' => $ServiceUser->nickname ?? '微信用户',
'role' => $ServiceUser->role,
'status' => $ServiceUser->status,
'plate_type' => $ServiceUser->plate_type,
]
];
\Yii::$app->redis->select(1);
\Yii::$app->redis->set('xiaokang_database_xk_user_doctor_wx_' . $token, json_encode($ServiceUserData));
return [ return [
'token'=>$token, 'token'=>$token,
'data'=>$StoreDoctor, 'data'=>$StoreDoctor,
@@ -321,6 +351,21 @@ class LoginForm extends BaseModel
} }
$t->commit(); $t->commit();
// 把ServiceUser信息存在Redis里面(使用DB 1,key前缀加上doctor_wx区分)
$ServiceUserData = [
'user' => [
'id' => $ServiceUser->id,
'mobile' => $ServiceUser->mobile ?? '',
'nickname' => $ServiceUser->nickname ?? '微信用户',
'role' => $ServiceUser->role,
'status' => $ServiceUser->status,
'plate_type' => $ServiceUser->plate_type,
]
];
\Yii::$app->redis->select(1);
\Yii::$app->redis->set('xiaokang_database_xk_user_doctor_wx_' . $token, json_encode($ServiceUserData));
return [ return [
'token'=>$token, 'token'=>$token,
'StoreDoctor'=>$StoreDoctor, 'StoreDoctor'=>$StoreDoctor,

View File

@@ -4,15 +4,21 @@ namespace service\modules\v1\controllers;
use common\core\BaseAppController; use common\core\BaseAppController;
use common\helpers\FuncHelper; use common\helpers\FuncHelper;
use common\models\oldDb\PackageMethod;
use common\models\oldDb\ChineseRepice; use common\models\oldDb\ChineseRepice;
use common\models\oldDb\Drug;
use common\models\oldDb\GranularRepice; use common\models\oldDb\GranularRepice;
use common\models\oldDb\ProcessRule;
use common\models\oldDb\ProcessRuleNote;
use common\models\oldDb\Prescription; use common\models\oldDb\Prescription;
use common\models\oldDb\PrescriptionChinese; use common\models\oldDb\PrescriptionChinese;
use common\models\oldDb\PrescriptionGranular; use common\models\oldDb\PrescriptionGranular;
use common\models\oldDb\PrescriptionWest; use common\models\oldDb\PrescriptionWest;
use common\models\oldDb\WestRepice; use common\models\oldDb\WestRepice;
use common\modelsgii\oldDb\ChineseMedicine;
use common\services\PrescriptionService; use common\services\PrescriptionService;
use yii\base\Exception; use yii\base\Exception;
use yii\helpers\Json;
/** /**
* @doc-module 处方详情 * @doc-module 处方详情
@@ -103,6 +109,354 @@ class PrescripDetailController extends BaseAppController
* 开处方-常用方 * 开处方-常用方
*/ */
public function actionCommonUse() public function actionCommonUse()
{
return $this->commonUseResponseLikeXkApi(\Yii::$app->request->post());
}
/**
* @doc-name 开处方-常用方详情(中药)
* @doc-param int id 处方id
*/
public function actionCommonChinese()
{
return $this->commonChineseDetailLikeXkApi(\Yii::$app->request->post());
}
/**
* @doc-name 开处方-常用方详情(颗粒药)
* @doc-param int id 处方id
*/
public function actionCommonGranular()
{
return $this->commonGranularDetailLikeXkApi(\Yii::$app->request->post());
}
/**
* @doc-name 开处方-常用方详情(西药)
* @doc-param int id 处方id
*/
public function actionCommonWest()
{
return $this->commonWestDetailLikeXkApi(\Yii::$app->request->post());
}
protected function commonUseResponseLikeXkApi(array $post): array
{
$this->requestValidate($post, [
['store_id', 'required'],
]);
$storeId = (int) $post['store_id'];
// $checkPrice = !isset($post['check_price']) || (int) $post['check_price'] === 1;
$checkPrice = 1;
$chinese = PrescriptionChinese::find()->where([
'type' => 2,
'store_id' => $storeId,
])->andWhere(['su_id' => \Yii::$app->user->identity->id])->asArray()->all();
$west = PrescriptionWest::find()->where([
'type' => 2,
'store_id' => $storeId,
])->andWhere(['su_id' => \Yii::$app->user->identity->id])->asArray()->all();
$granular = PrescriptionGranular::find()->where([
'type' => 2,
'store_id' => $storeId,
])->andWhere(['su_id' => \Yii::$app->user->identity->id])->asArray()->all();
if (!$chinese && !$west && !$granular) {
throw new Exception('没有常用方');
}
$chineseRepice = [];
foreach ($chinese as &$chineseRow) {
$ids = array_filter(explode(',', (string) $chineseRow['cr_ids']));
$recipes = ChineseRepice::find()->where(['in', 'id', $ids])->asArray()->all();
$syncResult = $this->syncChineseCommonRecipesWithStorePrices($storeId, $chineseRow, $recipes, $checkPrice);
$recipes = $syncResult['recipes'];
$chineseRow['price_adjusted'] = $syncResult['price_adjusted'] ? 1 : 0;
if (!empty($recipes[0])) {
$this->attachChineseMetaForList($chineseRow, $recipes[0]);
}
foreach ($recipes as &$recipeRow) {
$recipeRow = $this->normalizeChineseRecipeRow($recipeRow);
}
unset($recipeRow);
$chineseRepice[] = $recipes;
}
unset($chineseRow);
$westRepice = [];
foreach ($west as $westRow) {
$ids = array_filter(explode(',', (string) $westRow['wr_ids']));
$recipes = WestRepice::find()->where(['in', 'id', $ids])
->with(['usetime', 'usetype', 'frequency', 'westUnit'])
->asArray()->all();
$westRepice[] = $this->buildCommonWestRecipeRowsLikeXkApi($recipes);
}
$granularRepice = [];
foreach ($granular as $granularRow) {
$ids = array_filter(explode(',', (string) $granularRow['gr_ids']));
$recipes = GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all();
$granularRepice[] = $this->buildCommonGranularRecipeRowsLikeXkApi($recipes);
}
return [
'chin_prescription' => $chinese,
'chinese' => $chineseRepice,
'west_prescription' => $west,
'west' => $westRepice,
'granular_prescription' => $granular,
'granular' => $granularRepice,
];
}
protected function commonChineseDetailLikeXkApi(array $post): array
{
$this->requestValidate($post, [
['id', 'required'],
['store_id', 'required'],
]);
$chinese = PrescriptionChinese::find()->where([
'id' => $post['id'],
'store_id' => $post['store_id'],
])->andWhere(['type' => 2])->asArray()->one();
if (!$chinese) {
throw new Exception('没有该处方');
}
$ids = array_filter(explode(',', (string) $chinese['cr_ids']));
$recipes = ChineseRepice::find()->where(['in', 'id', $ids])->asArray()->all();
$syncResult = $this->syncChineseCommonRecipesWithStorePrices((int) $chinese['store_id'], $chinese, $recipes, true);
$recipes = $syncResult['recipes'];
foreach ($recipes as &$recipeRow) {
$recipeRow = $this->normalizeChineseRecipeRow($recipeRow);
}
unset($recipeRow);
return $recipes;
}
protected function commonGranularDetailLikeXkApi(array $post): array
{
$this->requestValidate($post, [
['id', 'required'],
['store_id', 'required'],
]);
$granular = PrescriptionGranular::find()->where([
'id' => $post['id'],
'store_id' => $post['store_id'],
])->andWhere(['type' => 2])->asArray()->one();
if (!$granular) {
throw new Exception('没有该处方');
}
$ids = array_filter(explode(',', (string) $granular['gr_ids']));
$recipes = GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all();
return $this->buildCommonGranularRecipeRowsLikeXkApi($recipes);
}
protected function commonWestDetailLikeXkApi(array $post): array
{
$this->requestValidate($post, [
['id', 'required'],
['store_id', 'required'],
]);
$west = PrescriptionWest::find()->where([
'id' => $post['id'],
'store_id' => $post['store_id'],
])->andWhere(['type' => 2])->asArray()->one();
if (!$west) {
throw new Exception('没有该处方');
}
$ids = array_filter(explode(',', (string) $west['wr_ids']));
$recipes = WestRepice::find()->where(['in', 'id', $ids])
->with(['usetime', 'usetype', 'frequency', 'westUnit'])
->asArray()->all();
return $this->buildCommonWestRecipeRowsLikeXkApi($recipes);
}
protected function syncChineseCommonRecipesWithStorePrices(int $storeId, array $prescriptionRow, array $recipeRows, bool $persist): array
{
$priceAdjusted = false;
if (empty($recipeRows)) {
return ['recipes' => $recipeRows, 'price_adjusted' => false];
}
$time = time();
$transaction = \Yii::$app->db->beginTransaction();
try {
foreach ($recipeRows as &$recipeRow) {
$contentList = Json::decode($recipeRow['content'] ?? '', true);
if (!is_array($contentList)) {
continue;
}
$cmIds = array_values(array_filter(explode(',', (string) ($recipeRow['cm_id'] ?? ''))));
$dosage = max(1, (int) ($recipeRow['dosage'] ?? 1));
$drugTotal = 0.0;
$recipeChanged = false;
foreach ($contentList as $idx => &$drugRow) {
$drugRow = $this->normalizeChineseDrugRow($drugRow);
$drugId = (int) ($drugRow['drug_id'] ?? $drugRow['id'] ?? 0);
$price = (float) ($drugRow['price'] ?? 0);
$buyPrice = (float) ($drugRow['buy_price'] ?? 0);
if ($drugId > 0) {
$drug = Drug::find()->alias('d')->select('d.*')->where([
'd.id' => $drugId,
])->joinWith(['drugStoreDrug dsd' => function ($q) {
$q->andWhere(['dsd.status' => 2]);
}])->joinWith(['drugStoreRelation dsr' => function ($q) use ($storeId) {
$q->andWhere(['dsr.store_id' => $storeId]);
$q->andWhere(['dsr.status' => 2]);
}])->asArray()->one();
if ($drug && !empty($drug['drugStoreRelation'])) {
$latestPrice = (float) $drug['drugStoreRelation']['price'];
$latestBuyPrice = (float) $drug['drugStoreRelation']['buy_price'];
if ($latestPrice !== $price || $latestBuyPrice !== $buyPrice) {
$priceAdjusted = true;
$recipeChanged = true;
}
$price = $latestPrice;
$buyPrice = $latestBuyPrice;
$drugRow['price'] = $latestPrice;
$drugRow['buy_price'] = $latestBuyPrice;
if ($persist && isset($cmIds[$idx]) && is_numeric($cmIds[$idx])) {
ChineseMedicine::updateAll([
'price' => $latestPrice,
'buy_price' => $latestBuyPrice,
'updated_at' => $time,
], ['id' => (int) $cmIds[$idx]]);
}
}
}
$drugTotal += (float) ($drugRow['number'] ?? 0) * $price * $dosage;
}
unset($drugRow);
if ($persist && $recipeChanged) {
$recipeRow['content'] = Json::encode($contentList);
$recipeRow['total_price'] = round($drugTotal, 4);
ChineseRepice::updateAll([
'content' => $recipeRow['content'],
'total_price' => $recipeRow['total_price'],
'updated_at' => $time,
], ['id' => $recipeRow['id']]);
} else {
$recipeRow['content'] = Json::encode($contentList);
$recipeRow['total_price'] = round($drugTotal, 4);
}
}
unset($recipeRow);
if ($persist && $priceAdjusted && !empty($prescriptionRow['id'])) {
PrescriptionChinese::updateAll(['updated_at' => $time], ['id' => $prescriptionRow['id']]);
}
$transaction->commit();
return ['recipes' => $recipeRows, 'price_adjusted' => $priceAdjusted];
} catch (\Throwable $e) {
$transaction->rollBack();
throw $e;
}
}
protected function normalizeChineseRecipeRow(array $recipeRow): array
{
$contentList = Json::decode($recipeRow['content'] ?? '', true);
if (is_array($contentList)) {
foreach ($contentList as &$drugRow) {
$drugRow = $this->normalizeChineseDrugRow($drugRow);
}
unset($drugRow);
$recipeRow['content'] = Json::encode($contentList);
}
return $recipeRow;
}
protected function normalizeChineseDrugRow(array $drugRow): array
{
$name = $drugRow['drug_name'] ?? ($drugRow['name'] ?? '');
$drugRow['name'] = $name;
$drugRow['drug_name'] = $name;
if (isset($drugRow['way_id']) && !isset($drugRow['order'])) {
$drugRow['order'] = $drugRow['way_id'];
}
if (isset($drugRow['order']) && !isset($drugRow['way_id'])) {
$drugRow['way_id'] = $drugRow['order'];
}
if (!isset($drugRow['unit']) || empty($drugRow['unit'])) {
$drugRow['unit'] = ['name' => 'g'];
}
return $drugRow;
}
protected function attachChineseMetaForList(array &$prescriptionRow, array $firstRecipeRow): void
{
$prescriptionRow['rule_type'] = (int) ($firstRecipeRow['deployment'] ?? 1);
$prescriptionRow['dosage'] = (int) ($firstRecipeRow['dosage'] ?? 7);
$prescriptionRow['day_dosage'] = (int) ($firstRecipeRow['consumption'] ?? 2);
$prescriptionRow['process_rule_id'] = (int) ($firstRecipeRow['process_rule_id'] ?? 0);
$prescriptionRow['process_rule_note'] = $firstRecipeRow['process_rule_note'] ?? '';
$prescriptionRow['package_method_id'] = (int) ($firstRecipeRow['package_method_id'] ?? 0);
if ($prescriptionRow['process_rule_id']) {
$processRule = ProcessRule::findOne($prescriptionRow['process_rule_id']);
$prescriptionRow['process_rule_name'] = $processRule ? $processRule->name : '';
}
if ($prescriptionRow['process_rule_note']) {
$processRuleNote = ProcessRuleNote::find()->where(['note' => $prescriptionRow['process_rule_note']])->one();
$prescriptionRow['process_rule_note_name'] = $processRuleNote ? $processRuleNote->note : $prescriptionRow['process_rule_note'];
}
if ($prescriptionRow['package_method_id']) {
$packageMethod = PackageMethod::findOne($prescriptionRow['package_method_id']);
$prescriptionRow['package_method_name'] = $packageMethod ? $packageMethod->name : '';
}
}
protected function buildCommonWestRecipeRowsLikeXkApi(array $recipeRows): array
{
foreach ($recipeRows as &$recipeRow) {
$content = Json::decode($recipeRow['content'] ?? '', true);
if (is_array($content)) {
$recipeRow['drug_name'] = $content['drug_name'] ?? '';
$recipeRow['drug_id'] = $content['id'] ?? 0;
$recipeRow['image'] = $content['image'] ?? '';
$recipeRow['price'] = $content['price'] ?? ($recipeRow['total_price'] ?? 0);
}
$recipeRow['frequency_id'] = $recipeRow['f_id'] ?? 0;
$recipeRow['unit_id'] = $recipeRow['wu_id'] ?? 0;
$recipeRow['number'] = $recipeRow['grain_number'] ?? ($recipeRow['number'] ?? 1);
}
unset($recipeRow);
return $recipeRows;
}
protected function buildCommonGranularRecipeRowsLikeXkApi(array $recipeRows): array
{
foreach ($recipeRows as &$recipeRow) {
$contentList = Json::decode($recipeRow['content'] ?? '', true);
if (!is_array($contentList)) {
continue;
}
foreach ($contentList as &$drugRow) {
$name = $drugRow['drug_name'] ?? ($drugRow['name'] ?? '');
$drugRow['name'] = $name;
$drugRow['drug_name'] = $name;
if (isset($drugRow['way_id']) && !isset($drugRow['order'])) {
$drugRow['order'] = $drugRow['way_id'];
}
if (isset($drugRow['order']) && !isset($drugRow['way_id'])) {
$drugRow['way_id'] = $drugRow['order'];
}
if (!isset($drugRow['unit']) || empty($drugRow['unit'])) {
$drugRow['unit'] = ['name' => 'g'];
}
}
unset($drugRow);
$recipeRow['content'] = Json::encode($contentList);
}
unset($recipeRow);
return $recipeRows;
}
protected function actionCommonUseLegacy()
{ {
$post = \YII::$app->request->post(); $post = \YII::$app->request->post();
@@ -134,14 +488,14 @@ class PrescripDetailController extends BaseAppController
$westRepice[] = WestRepice::find()->where(['in', 'id', $ids])->with(['usetime', 'usetype', 'frequency', 'westUnit'])->asArray()->all(); $westRepice[] = WestRepice::find()->where(['in', 'id', $ids])->with(['usetime', 'usetype', 'frequency', 'westUnit'])->asArray()->all();
} }
} }
if($granular){ if($granular){
foreach ($granular as $value) { foreach ($granular as $value) {
$ids = explode(',', $value['gr_ids']); $ids = explode(',', $value['gr_ids']);
$granularRepice[] = GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all(); $granularRepice[] = GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all();
} }
} }
return [ return [
'chin_prescription' => $chinese, 'chin_prescription' => $chinese,
'chinese' => $chineseRepice, 'chinese' => $chineseRepice,
@@ -152,11 +506,7 @@ class PrescripDetailController extends BaseAppController
]; ];
} }
/** protected function actionCommonChineseLegacy()
* @doc-name 开处方-常用方详情(中药)
* @doc-param int id 处方id
*/
public function actionCommonChinese()
{ {
$post = \Yii::$app->request->post(); $post = \Yii::$app->request->post();
$this->requestValidate($post,[ $this->requestValidate($post,[
@@ -170,16 +520,10 @@ class PrescripDetailController extends BaseAppController
throw new Exception('没有该处方'); throw new Exception('没有该处方');
} }
$ids = explode(',', $chinese['cr_ids']); $ids = explode(',', $chinese['cr_ids']);
return ChineseRepice::find()->where(['in', 'id', $ids])->asArray()->all();
$recipe = ChineseRepice::find()->where(['in', 'id', $ids])->asArray()->all();
return $recipe;
} }
/** protected function actionCommonGranularLegacy()
* @doc-name 开处方-常用方详情(颗粒药)
* @doc-param int id 处方id
*/
public function actionCommonGranular()
{ {
$post = \Yii::$app->request->post(); $post = \Yii::$app->request->post();
$this->requestValidate($post,[ $this->requestValidate($post,[
@@ -193,17 +537,10 @@ class PrescripDetailController extends BaseAppController
throw new Exception('没有该处方'); throw new Exception('没有该处方');
} }
$ids = explode(',', $granular['gr_ids']); $ids = explode(',', $granular['gr_ids']);
return GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all();
$recipe = GranularRepice::find()->where(['in', 'id', $ids])->asArray()->all();
return $recipe;
} }
protected function actionCommonWestLegacy()
/**
* @doc-name 开处方-常用方详情(西药)
* @doc-param int id 处方id
*/
public function actionCommonWest()
{ {
$post = \Yii::$app->request->post(); $post = \Yii::$app->request->post();
$this->requestValidate($post,[ $this->requestValidate($post,[
@@ -217,9 +554,7 @@ class PrescripDetailController extends BaseAppController
throw new Exception('没有该处方'); throw new Exception('没有该处方');
} }
$ids = explode(',', $west['wr_ids']); $ids = explode(',', $west['wr_ids']);
return WestRepice::find()->where(['in', 'id', $ids])->with(['usetime', 'usetype', 'frequency', 'westUnit'])->asArray()->all();
$recipe = WestRepice::find()->where(['in', 'id', $ids])->with(['usetime', 'usetype', 'frequency', 'westUnit'])->asArray()->all();
return $recipe;
} }
/** /**

View File

@@ -871,25 +871,42 @@ class PrescriptionController extends BaseAppController
$drug_ids_str=implode(',',$drug_ids); $drug_ids_str=implode(',',$drug_ids);
$totalNum = 0; $totalNum = 0;
foreach ($medicine as $value){ $time = time();
foreach ($medicine as &$value) {
$drug = Drug::find()->alias('d')->select('d.*')->where([ $drug = Drug::find()->alias('d')->select('d.*')->where([
'd.id' => $value['drug_id'] 'd.id' => $value['drug_id'],
])->joinWith(['drugStoreDrug dsd' => function($q){ ])->joinWith(['drugStoreDrug dsd' => function ($q) {
$q->andWhere(['dsd.status' => 2]); $q->andWhere(['dsd.status' => 2]);
}])->joinWith(['drugStoreRelation dsr' => function ($q) use ($store_id){ }])->joinWith(['drugStoreRelation dsr' => function ($q) use ($store_id) {
$q->andWhere(['dsr.store_id' => $store_id]); $q->andWhere(['dsr.store_id' => $store_id]);
$q->andWhere(['dsr.status' => 2]); $q->andWhere(['dsr.status' => 2]);
}])->asArray()->one(); }])->asArray()->one();
if(!$drug){ if (!$drug) {
throw new Exception('药品库存数据错误'); throw new Exception('药品库存数据错误');
} }
if (empty($drug['drugStoreRelation'])) {
throw new Exception('药品暂不售卖');
}
$salePrice = $drug['drugStoreRelation']['price'];
$buyPrice = $drug['drugStoreRelation']['buy_price'];
ChineseMedicine::updateAll(
[
'price' => $salePrice,
'buy_price' => $buyPrice,
'updated_at' => $time,
],
['id' => $value['id']],
);
$value['price'] = $salePrice;
$value['buy_price'] = $buyPrice;
$drugNumber = (int) $value['number'] * (int) $param['dosage']; $drugNumber = (int) $value['number'] * (int) $param['dosage'];
if($drug['drugStoreDrug']['stock'] < $drugNumber){ if ($drug['drugStoreDrug']['stock'] < $drugNumber) {
throw new Exception($value['name'].'库存数量不足'); throw new Exception($value['name'] . '库存数量不足');
} }
$totalNum += $drugNumber; $totalNum += $drugNumber;
$price+=$value['number'] * $value['price'] * $param['dosage']; $price += $value['number'] * $salePrice * $param['dosage'];
} }
unset($value);
$process_price = 0; $process_price = 0;
$processRuleContent = ''; $processRuleContent = '';
@@ -1021,7 +1038,8 @@ class PrescriptionController extends BaseAppController
if(!$drug){ if(!$drug){
throw new Exception('药品库存数据错误'); throw new Exception('药品库存数据错误');
} }
$drugNumber = (int) $content[$j]['number'] * (int) $recipe['dosage']; // $drugNumber = (int) $content[$j]['number'] * (int) $recipe['dosage'];
$drugNumber = $content[$j]['number'];
if($drug['drugStoreDrug']['stock']<$drugNumber){ if($drug['drugStoreDrug']['stock']<$drugNumber){
throw new Exception($content['name'].'库存数量不足'); throw new Exception($content['name'].'库存数量不足');
} }
@@ -1160,6 +1178,7 @@ class PrescriptionController extends BaseAppController
$item->drug_image = $v['image']; $item->drug_image = $v['image'];
$item->drug_no = $v['drug_number']; $item->drug_no = $v['drug_number'];
$item->number = $v['number']; $item->number = $v['number'];
$item->dosage = $repice[0]['dosage'];
$item->type = $v['type']; $item->type = $v['type'];
$item->price = $v['drugStoreRelation']['price']; $item->price = $v['drugStoreRelation']['price'];
$item->buy_price = $v['drugStoreRelation']['buy_price']; $item->buy_price = $v['drugStoreRelation']['buy_price'];
@@ -1724,6 +1743,7 @@ class PrescriptionController extends BaseAppController
$item->drug_image = $v['image']; $item->drug_image = $v['image'];
$item->drug_no = $v['drug_number']; $item->drug_no = $v['drug_number'];
$item->number = $v['number']; $item->number = $v['number'];
$item->dosage = $repice[0]['dosage'];
$item->type = $v['type']; $item->type = $v['type'];
$item->price = $v['drugStoreRelation']['price']; $item->price = $v['drugStoreRelation']['price'];
$item->buy_price = $v['drugStoreRelation']['buy_price']; $item->buy_price = $v['drugStoreRelation']['buy_price'];