[FEAT] 取貨碼改綁商品:App 刷碼依即時庫存自挑可出貨道(升版號 verPatch 29)
1. StarCloudAPI.verifyPickupCode 解析 B660 回傳的 product_id(數字且可能為 JSON null,改用 optInt 避免 optString 把 null 轉成 "null" 字串),PickupVerificationCallback.onSuccess 新增 productId 參數。 2. FontendPickupCodeDialog.onSuccess 依回傳分流:有 product_id(綁商品碼)→ getSlotDataByPid 取代表貨道 + allocateBuyStructures 自挑可出貨道(已濾 count>0 && !lock && !expired,壞一條自動換同商品下一條);無 product_id(舊綁貨道碼)→ 沿用原 slot_no 路徑,向後相容。 3. 綁商品碼若挑不到可出貨道(全缺貨/鎖定/過期)→ 提示缺貨並取消。 4. 升 verPatch 26→29(S9XYU OTA:versionName 21_02_29、versionCode 210229)。
This commit is contained in:
parent
8dc0433e66
commit
f46dbe0b51
@ -10,7 +10,7 @@ plugins {
|
||||
// 避免不同尺寸機台間版本號產生衝突。
|
||||
// =========================================================================
|
||||
def verMinor = 2
|
||||
def verPatch = 26
|
||||
def verPatch = 29
|
||||
|
||||
|
||||
|
||||
|
||||
@ -646,9 +646,13 @@ public class StarCloudAPI {
|
||||
void onFailure(String message);
|
||||
}
|
||||
|
||||
/** 取貨碼驗證回呼:成功時回傳 code_id 與要出貨的貨道 slot_no。 */
|
||||
/**
|
||||
* 取貨碼驗證回呼:成功時回傳 code_id。
|
||||
* 綁商品碼 → productId 有值(App 依即時庫存自挑可出貨道),slotNo 為 -1;
|
||||
* 綁貨道碼(舊) → slotNo 有值、productId 為空字串。
|
||||
*/
|
||||
public interface PickupVerificationCallback {
|
||||
void onSuccess(String codeId, int slotNo);
|
||||
void onSuccess(String codeId, int slotNo, String productId);
|
||||
void onFailure(String message);
|
||||
}
|
||||
|
||||
@ -832,7 +836,10 @@ public class StarCloudAPI {
|
||||
JSONObject data = res.optJSONObject("data");
|
||||
String codeId = data != null ? data.optString("code_id", "") : "";
|
||||
int slotNo = data != null ? data.optInt("slot_no", -1) : -1;
|
||||
callback.onSuccess(codeId, slotNo);
|
||||
// product_id 為數字且可能為 JSON null;用 optInt 避免 optString 把 null 轉成 "null" 字串
|
||||
int pid = data != null ? data.optInt("product_id", 0) : 0;
|
||||
String productId = pid > 0 ? String.valueOf(pid) : "";
|
||||
callback.onSuccess(codeId, slotNo, productId);
|
||||
} else {
|
||||
callback.onFailure(res.optString("message", "取貨碼驗證失敗"));
|
||||
}
|
||||
|
||||
@ -434,27 +434,43 @@ public class FontendPickupCodeDialog extends DialogAbstract {
|
||||
new com.unibuy.smartdevice.external.StarCloudAPI(getHandlerMain(), getHandlerMain())
|
||||
.verifyPickupCode(code, new com.unibuy.smartdevice.external.StarCloudAPI.PickupVerificationCallback() {
|
||||
@Override
|
||||
public void onSuccess(String codeId, int slotNo) {
|
||||
public void onSuccess(String codeId, int slotNo, String productId) {
|
||||
try {
|
||||
SlotStructure slotProduct = MyApp.getInstance().getSlotData(SlotField.VMC.getField(), slotNo);
|
||||
if (slotProduct == null) {
|
||||
setStatusText(getContext().getString(R.string.product_not_found));
|
||||
openBarcode = true;
|
||||
return;
|
||||
}
|
||||
if (slotProduct.isLock()) {
|
||||
getSrcHandlerMain().start("FontendPickupCodeDialog", "@" + getContext().getString(R.string.product_sales_suspended));
|
||||
dialogCancel();
|
||||
return;
|
||||
}
|
||||
if (slotProduct.getCount() == 0) {
|
||||
getSrcHandlerMain().start("FontendPickupCodeDialog", "@" + getContext().getString(R.string.product_out_of_stock));
|
||||
dialogCancel();
|
||||
return;
|
||||
java.util.List<BuyStructure> buys;
|
||||
if (productId != null && !productId.isEmpty()) {
|
||||
// 綁商品碼:後台只給商品,App 依本機即時庫存/鎖定/效期自挑可出貨道
|
||||
// (allocateBuyStructures 已濾 count>0 && !lock && !expired,壞一條會換同商品下一條)
|
||||
SlotStructure rep = MyApp.getInstance().getSlotDataByPid(productId);
|
||||
buys = MyApp.getInstance().allocateBuyStructures(rep, 1);
|
||||
if (buys.isEmpty()) {
|
||||
getSrcHandlerMain().start("FontendPickupCodeDialog", "@" + getContext().getString(R.string.product_out_of_stock));
|
||||
dialogCancel();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 綁貨道碼(舊):後台指定貨道,沿用原行為,向後相容
|
||||
SlotStructure slotProduct = MyApp.getInstance().getSlotData(SlotField.VMC.getField(), slotNo);
|
||||
if (slotProduct == null) {
|
||||
setStatusText(getContext().getString(R.string.product_not_found));
|
||||
openBarcode = true;
|
||||
return;
|
||||
}
|
||||
if (slotProduct.isLock()) {
|
||||
getSrcHandlerMain().start("FontendPickupCodeDialog", "@" + getContext().getString(R.string.product_sales_suspended));
|
||||
dialogCancel();
|
||||
return;
|
||||
}
|
||||
if (slotProduct.getCount() == 0) {
|
||||
getSrcHandlerMain().start("FontendPickupCodeDialog", "@" + getContext().getString(R.string.product_out_of_stock));
|
||||
dialogCancel();
|
||||
return;
|
||||
}
|
||||
buys = new java.util.ArrayList<>();
|
||||
buys.add(new BuyStructure(slotProduct.getField(), slotProduct.getSlot(), slotProduct.getProduct(), 1));
|
||||
}
|
||||
|
||||
MyApp.getInstance().getBuyList().clear();
|
||||
MyApp.getInstance().getBuyList().add(
|
||||
new BuyStructure(slotProduct.getField(), slotProduct.getSlot(), slotProduct.getProduct(), 1));
|
||||
MyApp.getInstance().getBuyList().addAll(buys);
|
||||
|
||||
MyApp.getInstance().getReportFlowInfoData().setFlowType(6); // 取貨碼 → payment_type 6
|
||||
MyApp.getInstance().getReportFlowInfoData().setFlowBarCode(code);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user