Commit 0fd4dde9 by 赵增煜

限购bug修复

parent 898de112
......@@ -105,13 +105,17 @@ public function drugLimit(Request $request)
->get();
$drugCounts = [];
foreach ($prescriptions as $prescription) {
$drugs = json_decode($prescription->drugs, true); // Parse JSON data
foreach ($drugs as $drug) {
$drugId = $drug['drug_id'];
$drugCounts[$drugId] = ($drugCounts[$drugId] ?? 0) + $drug['num'];
// 判断搜索出来的处方不为空
if ($prescriptions->count() > 0) {
foreach ($prescriptions as $prescription) {
$drugs = json_decode($prescription->drug_info, true); // Parse JSON data
foreach ($drugs as $drug) {
$drugId = $drug['drug_id'];
$drugCounts[$drugId] = ($drugCounts[$drugId] ?? 0) + $drug['num'];
}
}
}
$purchaseCount = $drugCounts[$drug_id] ?? 0;
// 计算获取剩余可买的次数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment