Commit 3b7309d6 by wjg

add release apk

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