Commit 3b7309d6 by wjg

add release apk

parent 2c55e454
...@@ -55,7 +55,6 @@ import java.util.Arrays; ...@@ -55,7 +55,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class GoodsDetailDialog extends Dialog { public class GoodsDetailDialog extends Dialog {
...@@ -83,11 +82,11 @@ public class GoodsDetailDialog extends Dialog { ...@@ -83,11 +82,11 @@ public class GoodsDetailDialog extends Dialog {
super(context); super(context);
this.mGoods = goods; this.mGoods = goods;
// 处理售罄的SKU和规格选项 // // 处理售罄的SKU和规格选项
processSelloutRules(); // processSelloutRules();
//
// 处理删除的SKU和规格选项 // // 处理删除的SKU和规格选项
processDeleteRules(); // processDeleteRules();
} }
@Override @Override
...@@ -385,7 +384,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -385,7 +384,7 @@ public class GoodsDetailDialog extends Dialog {
Utils.fastPushBroadcast(getContext(), Base.PUSH_ACTION_SKU_STATE_CHANGED, JsonUtils.toString(changedVo)); Utils.fastPushBroadcast(getContext(), Base.PUSH_ACTION_SKU_STATE_CHANGED, JsonUtils.toString(changedVo));
} }
} }
processSelloutRules(); // processSelloutRules();
buildSpecs(); buildSpecs();
} }
...@@ -404,7 +403,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -404,7 +403,7 @@ public class GoodsDetailDialog extends Dialog {
AutoWrapLayout layoutRules = specView.findViewById(R.id.layout_rules); AutoWrapLayout layoutRules = specView.findViewById(R.id.layout_rules);
txtName.setText(spec.getSpecName()); txtName.setText(spec.getSpecName());
AtomicBoolean checkNextFlag = new AtomicBoolean(false); // AtomicBoolean checkNextFlag = new AtomicBoolean(false);
spec.getRules().forEach(rule -> { spec.getRules().forEach(rule -> {
AutoWrapLayout.LayoutParams layoutParams = new AutoWrapLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT); AutoWrapLayout.LayoutParams layoutParams = new AutoWrapLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
layoutParams.rightMargin = Utils.getDimens(getContext(), R.dimen.padding5); layoutParams.rightMargin = Utils.getDimens(getContext(), R.dimen.padding5);
...@@ -419,12 +418,6 @@ public class GoodsDetailDialog extends Dialog { ...@@ -419,12 +418,6 @@ public class GoodsDetailDialog extends Dialog {
ruleView.findViewById(R.id.txt_recommend).setVisibility(View.VISIBLE); ruleView.findViewById(R.id.txt_recommend).setVisibility(View.VISIBLE);
} }
if (Base.DELETE.equals(rule.getIsDelete())) {
if (Base.TRUE.equals(rule.getIsDefault())) { // 如果默认选项售罄,则选中第一个未售罄的选项
checkNextFlag.set(true);
}
return;
} else if (SkuState.isSellin(rule.getState())) {
if (Base.TRUE.equals(rule.getIsDefault())) { if (Base.TRUE.equals(rule.getIsDefault())) {
ruleView.setSelected(true); ruleView.setSelected(true);
button.setSelected(true); button.setSelected(true);
...@@ -435,25 +428,42 @@ public class GoodsDetailDialog extends Dialog { ...@@ -435,25 +428,42 @@ public class GoodsDetailDialog extends Dialog {
button.setSelected(true); button.setSelected(true);
changeSkuWithRule(); changeSkuWithRule();
}); });
} else {
ruleView.setEnabled(false); // if (Base.DELETE.equals(rule.getIsDelete())) {
button.setEnabled(false); // if (Base.TRUE.equals(rule.getIsDefault())) { // 如果默认选项售罄,则选中第一个未售罄的选项
if (Base.TRUE.equals(rule.getIsDefault())) { // 如果默认选项售罄,则选中第一个未售罄的选项 // checkNextFlag.set(true);
checkNextFlag.set(true); // }
} // return;
} // } else if (SkuState.isSellin(rule.getState())) {
// if (Base.TRUE.equals(rule.getIsDefault())) {
// ruleView.setSelected(true);
// button.setSelected(true);
// }
// ruleView.setOnClickListener(v -> {
// clearSelected(layoutRules);
// ruleView.setSelected(true);
// button.setSelected(true);
// changeSkuWithRule();
// });
// } else {
// ruleView.setEnabled(false);
// button.setEnabled(false);
// if (Base.TRUE.equals(rule.getIsDefault())) { // 如果默认选项售罄,则选中第一个未售罄的选项
// checkNextFlag.set(true);
// }
// }
layoutRules.addView(ruleView, layoutParams); layoutRules.addView(ruleView, layoutParams);
}); });
// 如果默认选项售罄,则选中第一个未售罄的选项 // // 如果默认选项售罄,则选中第一个未售罄的选项
if (checkNextFlag.get() && layoutRules.getChildCount() > 0) { // if (checkNextFlag.get() && layoutRules.getChildCount() > 0) {
for (int i = 0; i < layoutRules.getChildCount(); i++) { // for (int i = 0; i < layoutRules.getChildCount(); i++) {
ViewGroup ruleView = (ViewGroup) layoutRules.getChildAt(i); // ViewGroup ruleView = (ViewGroup) layoutRules.getChildAt(i);
if (ruleView.isEnabled()) { // if (ruleView.isEnabled()) {
ruleView.callOnClick(); // ruleView.callOnClick();
break; // break;
} // }
} // }
} // }
layoutSpecs.addView(specView); layoutSpecs.addView(specView);
// layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule()); // layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule());
}); });
...@@ -465,6 +475,10 @@ public class GoodsDetailDialog extends Dialog { ...@@ -465,6 +475,10 @@ public class GoodsDetailDialog extends Dialog {
Utils.showToast(getContext(), R.string.not_found_goods); Utils.showToast(getContext(), R.string.not_found_goods);
return; return;
} }
if (!SkuState.isSellin(mSku.getState())) {
Utils.showToast(getContext(), R.string.sku_sellout);
return;
}
CheckGoodsHandler handler = new CheckGoodsHandler(mGoods, mSku, mCount, 1); CheckGoodsHandler handler = new CheckGoodsHandler(mGoods, mSku, mCount, 1);
HttpUtil.checkSku(mSku.getSkuId(), handler); HttpUtil.checkSku(mSku.getSkuId(), handler);
} }
...@@ -474,6 +488,10 @@ public class GoodsDetailDialog extends Dialog { ...@@ -474,6 +488,10 @@ public class GoodsDetailDialog extends Dialog {
Utils.showToast(getContext(), R.string.not_found_goods); Utils.showToast(getContext(), R.string.not_found_goods);
return; return;
} }
if (!SkuState.isSellin(mSku.getState())) {
Utils.showToast(getContext(), R.string.sku_sellout);
return;
}
if (mCount + HLApplication.getGoodsCount() > HLApplication.getCountOfOrder()) { if (mCount + HLApplication.getGoodsCount() > HLApplication.getCountOfOrder()) {
Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString())); Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString()));
return; return;
...@@ -493,6 +511,14 @@ public class GoodsDetailDialog extends Dialog { ...@@ -493,6 +511,14 @@ public class GoodsDetailDialog extends Dialog {
} }
private void addCount() { private void addCount() {
if (mSku == null) {
Utils.showToast(getContext(), R.string.not_found_goods);
return;
}
if (!SkuState.isSellin(mSku.getState())) {
Utils.showToast(getContext(), R.string.sku_sellout);
return;
}
if (mCount + HLApplication.getGoodsCount() >= HLApplication.getCountOfOrder()) { if (mCount + HLApplication.getGoodsCount() >= HLApplication.getCountOfOrder()) {
Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString())); Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString()));
return; return;
...@@ -502,6 +528,14 @@ public class GoodsDetailDialog extends Dialog { ...@@ -502,6 +528,14 @@ public class GoodsDetailDialog extends Dialog {
} }
private void subtractCount() { private void subtractCount() {
if (mSku == null) {
Utils.showToast(getContext(), R.string.not_found_goods);
return;
}
if (!SkuState.isSellin(mSku.getState())) {
Utils.showToast(getContext(), R.string.sku_sellout);
return;
}
if (mCount <= 1) { if (mCount <= 1) {
return; return;
} }
...@@ -543,6 +577,16 @@ public class GoodsDetailDialog extends Dialog { ...@@ -543,6 +577,16 @@ public class GoodsDetailDialog extends Dialog {
} }
txtPrice.setText(Utils.toString(mSku.getPrice())); txtPrice.setText(Utils.toString(mSku.getPrice()));
txtDiscount.setText(Utils.toString(mSku.getDiscount())); txtDiscount.setText(Utils.toString(mSku.getDiscount()));
if (SkuState.isSellin(mSku.getState())) {
butnTrolley.setBackground(getContext().getResources().getDrawable(R.drawable.bg_button));
butnTrolley.setTextColor(getContext().getColor(R.color.colorPrimary));
butnBuy.setBackgroundColor(getContext().getColor(R.color.colorPrimary));
} else {
butnTrolley.setBackground(getContext().getResources().getDrawable(R.drawable.bg_button_disable));
butnTrolley.setTextColor(getContext().getColor(R.color.textDisable));
butnBuy.setBackgroundColor(getContext().getColor(R.color.textDisable));
}
} }
private View getSelectedView(AutoWrapLayout layoutRules) { private View getSelectedView(AutoWrapLayout layoutRules) {
...@@ -592,160 +636,160 @@ public class GoodsDetailDialog extends Dialog { ...@@ -592,160 +636,160 @@ public class GoodsDetailDialog extends Dialog {
}); });
} }
private void processSelloutRules() { // private void processSelloutRules() {
if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs()) || CollectionUtils.isEmpty(mGoods.getSkus())) { // if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs()) || CollectionUtils.isEmpty(mGoods.getSkus())) {
showSelloutViews(); // showSelloutViews();
return; // return;
} // }
mGoods.getSpecs().forEach(spec -> { // mGoods.getSpecs().forEach(spec -> {
if (CollectionUtils.isEmpty(spec.getRules())) { // if (CollectionUtils.isEmpty(spec.getRules())) {
return; // return;
} // }
spec.getRules().forEach(rule -> rule.setState(SkuState.SELLIN.getCode())); // spec.getRules().forEach(rule -> rule.setState(SkuState.SELLIN.getCode()));
}); // });
// 将商品所有SKU列表按售罄和未售罄分组 // // 将商品所有SKU列表按售罄和未售罄分组
Map<Integer, List<Sku>> map = mGoods.getSkus().stream().collect(Collectors.groupingBy(Sku::getState)); // Map<Integer, List<Sku>> map = mGoods.getSkus().stream().collect(Collectors.groupingBy(Sku::getState));
if (CollectionUtils.isEmpty(map)) { // if (CollectionUtils.isEmpty(map)) {
return; // return;
} // }
// 售罄SKU列表 // // 售罄SKU列表
List<Sku> sellOuts = map.get(SkuState.SELLOUT.getCode()); // List<Sku> sellOuts = map.get(SkuState.SELLOUT.getCode());
// 未售罄SKU列表 // // 未售罄SKU列表
List<Sku> sellIns = map.get(SkuState.SELLIN.getCode()); // List<Sku> sellIns = map.get(SkuState.SELLIN.getCode());
if (CollectionUtils.isEmpty(sellIns)) { // if (CollectionUtils.isEmpty(sellIns)) {
showSelloutViews(); // showSelloutViews();
return; // return;
} // }
// 售罄SKU列表为空不需要处理 // // 售罄SKU列表为空不需要处理
if (CollectionUtils.isEmpty(sellOuts)) { // if (CollectionUtils.isEmpty(sellOuts)) {
return; // return;
} // }
sellOuts.forEach(sku -> { // sellOuts.forEach(sku -> {
if (CollectionUtils.isEmpty(sku.getRules())) { // if (CollectionUtils.isEmpty(sku.getRules())) {
return; // return;
} // }
sku.getRules().forEach(skuRule -> { // sku.getRules().forEach(skuRule -> {
// 检查未售罄的sku里是否有此规格选项,如果有则此选项可选 // // 检查未售罄的sku里是否有此规格选项,如果有则此选项可选
Integer ruleState = checkRuleState(skuRule, sellIns); // Integer ruleState = checkRuleState(skuRule, sellIns);
setRuleState(skuRule, ruleState); // setRuleState(skuRule, ruleState);
}); // });
}); // });
} // }
private void processDeleteRules() {
if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs()) || CollectionUtils.isEmpty(mGoods.getSkus())) {
showSelloutViews();
return;
}
mGoods.getSpecs().forEach(spec -> {
if (CollectionUtils.isEmpty(spec.getRules())) {
return;
}
spec.getRules().forEach(rule -> rule.setIsDelete(Base.TRUE));
});
// 将商品所有SKU列表按删除和未删除分组
Map<Integer, List<Sku>> map = mGoods.getSkus().stream().collect(Collectors.groupingBy(Sku::getIsDelete));
if (CollectionUtils.isEmpty(map)) {
return;
}
// 删除SKU列表
List<Sku> deletes = map.get(Base.DELETE);
// 未删除SKU列表
List<Sku> uses = map.get(0);
if (CollectionUtils.isEmpty(uses)) {
showSelloutViews();
return;
}
// 售罄SKU列表为空不需要处理
if (CollectionUtils.isEmpty(deletes)) {
return;
}
deletes.forEach(sku -> {
if (CollectionUtils.isEmpty(sku.getRules())) {
return;
}
sku.getRules().forEach(skuRule -> {
// 检查未售罄的sku里是否有此规格选项,如果有则此选项可选
Integer ruleState = checkRuleDelete(skuRule, uses);
setRuleDelete(skuRule, ruleState);
});
});
}
private void setRuleDelete(SkuRule skuRule, Integer ruleDelete) {
if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs())) {
return;
}
mGoods.getSpecs().forEach(spec -> {
// 选项为空的规格不处理
if (CollectionUtils.isEmpty(spec.getRules())) {
return;
}
spec.getRules().forEach(rule -> {
// 设置匹配的选项
if (rule.getRuleId().equals(skuRule.getRuleId())) {
rule.setIsDelete(ruleDelete);
}
});
});
}
/** 检查未售罄的sku里是否有此规格选项,如果有则此选项可选 */ // private void processDeleteRules() {
private Integer checkRuleDelete(SkuRule skuRule, List<Sku> uses) { // if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs()) || CollectionUtils.isEmpty(mGoods.getSkus())) {
if (CollectionUtils.isEmpty(uses)) { // showSelloutViews();
return Base.DELETE; // return;
} // }
// mGoods.getSpecs().forEach(spec -> {
// if (CollectionUtils.isEmpty(spec.getRules())) {
// return;
// }
// spec.getRules().forEach(rule -> rule.setIsDelete(Base.TRUE));
// });
// // 将商品所有SKU列表按删除和未删除分组
// Map<Integer, List<Sku>> map = mGoods.getSkus().stream().collect(Collectors.groupingBy(Sku::getIsDelete));
// if (CollectionUtils.isEmpty(map)) {
// return;
// }
// // 删除SKU列表
// List<Sku> deletes = map.get(Base.DELETE);
// // 未删除SKU列表
// List<Sku> uses = map.get(0);
// if (CollectionUtils.isEmpty(uses)) {
// showSelloutViews();
// return;
// }
// // 售罄SKU列表为空不需要处理
// if (CollectionUtils.isEmpty(deletes)) {
// return;
// }
// deletes.forEach(sku -> {
// if (CollectionUtils.isEmpty(sku.getRules())) {
// return;
// }
// sku.getRules().forEach(skuRule -> {
// // 检查未售罄的sku里是否有此规格选项,如果有则此选项可选
// Integer ruleState = checkRuleDelete(skuRule, uses);
// setRuleDelete(skuRule, ruleState);
// });
// });
// }
for (Sku sku : uses) { // private void setRuleDelete(SkuRule skuRule, Integer ruleDelete) {
if (CollectionUtils.isEmpty(sku.getRules())) { // if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs())) {
continue; // return;
} // }
for (SkuRule rule : sku.getRules()) { // mGoods.getSpecs().forEach(spec -> {
if (rule.getRuleId().equals(skuRule.getRuleId())) { // // 选项为空的规格不处理
return Base.TRUE; // if (CollectionUtils.isEmpty(spec.getRules())) {
} // return;
} // }
} // spec.getRules().forEach(rule -> {
return Base.DELETE; // // 设置匹配的选项
} // if (rule.getRuleId().equals(skuRule.getRuleId())) {
// rule.setIsDelete(ruleDelete);
// }
// });
// });
// }
/** 检查未售罄的sku里是否有此规格选项,如果有则此选项可选 */ // /** 检查未售罄的sku里是否有此规格选项,如果有则此选项可选 */
private Integer checkRuleState(SkuRule skuRule, List<Sku> sellIns) { // private Integer checkRuleDelete(SkuRule skuRule, List<Sku> uses) {
if (CollectionUtils.isEmpty(sellIns)) { // if (CollectionUtils.isEmpty(uses)) {
return Base.FALSE; // return Base.DELETE;
} // }
//
// for (Sku sku : uses) {
// if (CollectionUtils.isEmpty(sku.getRules())) {
// continue;
// }
// for (SkuRule rule : sku.getRules()) {
// if (rule.getRuleId().equals(skuRule.getRuleId())) {
// return Base.TRUE;
// }
// }
// }
// return Base.DELETE;
// }
for (Sku sku : sellIns) { // /** 检查未售罄的sku里是否有此规格选项,如果有则此选项可选 */
if (CollectionUtils.isEmpty(sku.getRules())) { // private Integer checkRuleState(SkuRule skuRule, List<Sku> sellIns) {
continue; // if (CollectionUtils.isEmpty(sellIns)) {
} // return Base.FALSE;
for (SkuRule rule : sku.getRules()) { // }
if (rule.getRuleId().equals(skuRule.getRuleId())) { //
return Base.TRUE; // for (Sku sku : sellIns) {
} // if (CollectionUtils.isEmpty(sku.getRules())) {
} // continue;
} // }
return Base.FALSE; // for (SkuRule rule : sku.getRules()) {
} // if (rule.getRuleId().equals(skuRule.getRuleId())) {
// return Base.TRUE;
// }
// }
// }
// return Base.FALSE;
// }
/** 设备商品规格 选项状态 */ // /** 设备商品规格 选项状态 */
private void setRuleState(SkuRule skuRule, Integer ruleState) { // private void setRuleState(SkuRule skuRule, Integer ruleState) {
if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs())) { // if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs())) {
return; // return;
} // }
mGoods.getSpecs().forEach(spec -> { // mGoods.getSpecs().forEach(spec -> {
// 选项为空的规格不处理 // // 选项为空的规格不处理
if (CollectionUtils.isEmpty(spec.getRules())) { // if (CollectionUtils.isEmpty(spec.getRules())) {
return; // return;
} // }
spec.getRules().forEach(rule -> { // spec.getRules().forEach(rule -> {
// 设置匹配的选项 // // 设置匹配的选项
if (rule.getRuleId().equals(skuRule.getRuleId())) { // if (rule.getRuleId().equals(skuRule.getRuleId())) {
rule.setState(ruleState); // rule.setState(ruleState);
} // }
}); // });
}); // });
} // }
private void showSelloutViews() { private void showSelloutViews() {
dismiss(); dismiss();
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke
android:width="0.5px"
android:color="@color/textDisable" />
</shape>
</item>
</layer-list>
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<string name="all_sku_sellout">商品已售罄</string> <string name="all_sku_sellout">商品已售罄</string>
<string name="default_sku_sellout">默认规格已售罄,已添加其他规格</string> <string name="default_sku_sellout">默认规格已售罄,已添加其他规格</string>
<string name="not_found_goods">未找到相应商品</string> <string name="not_found_goods">未找到相应商品</string>
<string name="sku_sellout">这款已经卖完啦</string>
<string name="count_limit">单次最多购买%1$s杯,请结算后再次下单</string> <string name="count_limit">单次最多购买%1$s杯,请结算后再次下单</string>
<string name="error_get_qrcode">生成订单失败,请重新提交,多次失败请联系客服</string> <string name="error_get_qrcode">生成订单失败,请重新提交,多次失败请联系客服</string>
<string name="expire_times">%1$s秒后失效</string> <string name="expire_times">%1$s秒后失效</string>
......
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 to comment