From bfc2915403df3f9a98fd866ef5fab106c0fbb043 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 2 Jun 2026 17:49:40 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E4=BF=AE=E5=BE=A9=E4=B8=AD=E5=9C=8B?= =?UTF-8?q?=E9=86=AB=E5=A4=9A=E8=B2=A8=E9=81=93=E5=BA=AB=E5=AD=98=E5=88=86?= =?UTF-8?q?=E9=85=8D=E7=95=B0=E5=B8=B8=E8=88=87=E9=81=9E=E5=A2=9E=E7=99=BC?= =?UTF-8?q?=E7=89=88=E7=89=88=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修復 SaleFlowHandler.java:重構中國醫客製領藥流程中的多商品貨道分配演算法,引進動態多貨道輪替分配機制,徹底解決一筆單多商品(如 3 個同商品)時貨道重複分配為 3, 4, 4 的 Bug。 2. 更新 build.gradle:配合生產發版,將修補版號 verPatch 遞增至 66,並在背景成功編譯產出正式 Release APK (CmuhS9XYURelease)。 --- app/build.gradle | 2 +- .../smartdevice/ui/SaleFlowHandler.java | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6507b9b..6bc7304 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ plugins { // 避免不同尺寸機台間版本號產生衝突。 // ========================================================================= def verMinor = 1 -def verPatch = 65 +def verPatch = 66 android { diff --git a/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java b/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java index 218ce96..2c94e2e 100644 --- a/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java +++ b/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java @@ -322,14 +322,36 @@ public class SaleFlowHandler { haveValuestate = true; if (requestQty > 1) { - int checkcount = 0; - int slotnum = 0; + class TempSlot { + int slotNo; + int stock; + TempSlot(int slotNo, int stock) { + this.slotNo = slotNo; + this.stock = stock; + } + } + String[] slotPairs = medicineList.get(i).getMedicineSlot().split(","); + java.util.List tempSlots = new java.util.ArrayList<>(); + for (String pair : slotPairs) { + if (pair.trim().isEmpty()) continue; + String[] parts = pair.split("-"); + if (parts.length == 2) { + tempSlots.add(new TempSlot(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]))); + } + } + + int slotIdx = 0; for (int j = 0; j < requestQty; j++) { - checkcount += 1; - if (checkcount > Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[0].split("-")[1])) { - slotnum = Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[1].split("-")[0]); + while (slotIdx < tempSlots.size() && tempSlots.get(slotIdx).stock <= 0) { + slotIdx++; + } + int slotnum; + if (slotIdx < tempSlots.size()) { + TempSlot activeSlot = tempSlots.get(slotIdx); + slotnum = activeSlot.slotNo; + activeSlot.stock--; } else { - slotnum = Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[0].split("-")[0]); + slotnum = tempSlots.get(tempSlots.size() - 1).slotNo; } addMedicineToBuyList( medicineList.get(i).getProductId(),