Commit a25b37a4 authored by 王海's avatar 王海

Merge remote-tracking branch 'origin/master'

parents 4abb5f41 a10dd4cc
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<w>liubei</w> <w>liubei</w>
<w>lvzhi</w> <w>lvzhi</w>
<w>mawu</w> <w>mawu</w>
<w>nong</w>
<w>patt</w> <w>patt</w>
<w>shixiu</w> <w>shixiu</w>
<w>sunquan</w> <w>sunquan</w>
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
<w>yuji</w> <w>yuji</w>
<w>zhangfei</w> <w>zhangfei</w>
<w>zhouyu</w> <w>zhouyu</w>
<w>zzdpos</w>
</words> </words>
</dictionary> </dictionary>
</component> </component>
\ No newline at end of file
...@@ -49,6 +49,13 @@ public abstract class BaseSelectedAdapter<T, B extends ViewDataBinding> extends ...@@ -49,6 +49,13 @@ public abstract class BaseSelectedAdapter<T, B extends ViewDataBinding> extends
this.mOnItemClickListener = listener; this.mOnItemClickListener = listener;
} }
public T getSelectedItemObject() {
if (mSelectedPosition > 0) {
return getData().get(mSelectedPosition);
} else {
return null;
}
}
public int getSelectedPosition() { public int getSelectedPosition() {
return mSelectedPosition; return mSelectedPosition;
......
...@@ -45,7 +45,7 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint { ...@@ -45,7 +45,7 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint {
if (param.offFlag) { if (param.offFlag) {
param.offBal = vipOffAmt; param.offBal = vipOffAmt;
} }
param.boundFlag = this.boundNum > 0; param.boundFlag = isUseBound;
if (param.boundFlag) { if (param.boundFlag) {
param.boundBal = this.boundAmt; param.boundBal = this.boundAmt;
param.boundCount = this.boundNum; param.boundCount = this.boundNum;
...@@ -384,10 +384,10 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint { ...@@ -384,10 +384,10 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint {
//积分 //积分
long poIntegers = orderPayAmt / 10; long poIntegers = orderPayAmt / 10;
if (poIntegers > vipBound) poIntegers = vipBound; if (poIntegers > vipBound) poIntegers = vipBound;
this.boundNum = isUseBound ? poIntegers : 0; this.boundNum = poIntegers;
this.boundAmt = isUseBound ? poIntegers : 0; this.boundAmt = poIntegers;
//积分优惠后金额 //积分优惠后金额
this.orderPayAmt -= this.boundAmt; this.orderPayAmt -= isUseBound ? this.boundAmt : 0;
//抹零 //抹零
//抹零后金额 //抹零后金额
...@@ -1077,6 +1077,10 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint { ...@@ -1077,6 +1077,10 @@ public class Saleorder implements BaseModel, BaseBean, BaseOrderPrint {
this.payType = payType; this.payType = payType;
} }
public long getMsDisAmt() {
return msDisAmt;
}
/** /**
* 优惠项目实体类 * 优惠项目实体类
*/ */
......
...@@ -31,8 +31,8 @@ public class Ticket { ...@@ -31,8 +31,8 @@ public class Ticket {
@Deprecated @Deprecated
public Ticket(Long l) { public Ticket(Long l) {
this.ticketNo = l; this.ticketNo = l;
this.ticketValAmt = 3000L; this.ticketValAmt = 0L;
this.truleOrderAmt = 5000L; this.truleOrderAmt = 0L;
this.mac = "MAC"; this.mac = "MAC";
} }
...@@ -54,7 +54,7 @@ public class Ticket { ...@@ -54,7 +54,7 @@ public class Ticket {
private Long vipId; private Long vipId;
private Date ticketExp; private Long ticketExp;
private Long ticketValAmt; private Long ticketValAmt;
...@@ -122,11 +122,11 @@ public class Ticket { ...@@ -122,11 +122,11 @@ public class Ticket {
this.vipId = vipId; this.vipId = vipId;
} }
public Date getTicketExp() { public Long getTicketExp() {
return ticketExp; return ticketExp;
} }
public void setTicketExp(Date ticketExp) { public void setTicketExp(Long ticketExp) {
this.ticketExp = ticketExp; this.ticketExp = ticketExp;
} }
......
...@@ -4,7 +4,6 @@ package com.xingdata.zzdpos.ui.payment.view; ...@@ -4,7 +4,6 @@ package com.xingdata.zzdpos.ui.payment.view;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.base.BasePresenter; import com.xingdata.zzdpos.base.BasePresenter;
...@@ -58,7 +57,6 @@ public class CalculatorView<P extends BasePresenter> extends BaseFragment<P, Vie ...@@ -58,7 +57,6 @@ public class CalculatorView<P extends BasePresenter> extends BaseFragment<P, Vie
settle(); settle();
break; break;
default: default:
LogUtils.e("mExp : " + mExp + "\nmValue : " + mValue + "\nmLast" + mLast);
if (view instanceof TextView) { if (view instanceof TextView) {
String str = ((TextView) view).getText().toString(); String str = ((TextView) view).getText().toString();
...@@ -71,13 +69,12 @@ public class CalculatorView<P extends BasePresenter> extends BaseFragment<P, Vie ...@@ -71,13 +69,12 @@ public class CalculatorView<P extends BasePresenter> extends BaseFragment<P, Vie
if (str.matches("[0-9]+") && mValue.split("[.]").length > 1 && mValue.split("[.]")[1].length() == 2) if (str.matches("[0-9]+") && mValue.split("[.]").length > 1 && mValue.split("[.]")[1].length() == 2)
return; return;
//限制小数点 //限制小数点
if ((mExp.length() == 0 || mValue.contains(".")) && str.matches("[.]")) if (mValue.contains(".") && str.matches("[.]"))
return; return;
//限制符号 //限制符号
if (mLast.matches("[+\\-×÷.]") && str.matches("[+\\-×÷.]")) if ((mExp.length() == 0 || mLast.matches("[+\\-×÷.]")) && str.matches("[+\\-×÷.]"))
return; return;
mLast = str; mLast = str;
mExp += str; mExp += str;
} }
......
...@@ -87,16 +87,12 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle ...@@ -87,16 +87,12 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
@Override @Override
public void showTicketFragment() { public void showTicketFragment() {
this.start(mTicketFragment);
} }
@Override @Override
public void loadTickets(List<Ticket> tickets) { public void loadTickets(List<Ticket> tickets) {
} mTicketFragment.loadTickets(tickets);
@Override
public void loadTicket(Ticket ticket) {
} }
@Override @Override
......
...@@ -56,13 +56,6 @@ interface SettleContract { ...@@ -56,13 +56,6 @@ interface SettleContract {
*/ */
void loadTickets(List<Ticket> tickets); void loadTickets(List<Ticket> tickets);
/**
* 加载优惠券信息
*
* @param ticket 优惠券信息
*/
void loadTicket(Ticket ticket);
/** /**
* 加载可用优惠券数量 * 加载可用优惠券数量
* *
...@@ -164,7 +157,7 @@ interface SettleContract { ...@@ -164,7 +157,7 @@ interface SettleContract {
/** /**
* 结算页面 - 查询优惠券 * 结算页面 - 查询优惠券
*/ */
public abstract void searchTicket(Long vipId); public abstract void searchTicket();
/** /**
* 优惠券页面 - 选择优惠券 * 优惠券页面 - 选择优惠券
......
...@@ -4,6 +4,7 @@ package com.xingdata.zzdpos.ui.settle; ...@@ -4,6 +4,7 @@ package com.xingdata.zzdpos.ui.settle;
import com.blankj.utilcode.util.StringUtils; import com.blankj.utilcode.util.StringUtils;
import com.xingdata.zzdpos.C; import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.api.ApiFactory; import com.xingdata.zzdpos.api.ApiFactory;
import com.xingdata.zzdpos.db.DBFactory;
import com.xingdata.zzdpos.model.Ms; import com.xingdata.zzdpos.model.Ms;
import com.xingdata.zzdpos.model.Pay; import com.xingdata.zzdpos.model.Pay;
import com.xingdata.zzdpos.model.Saledetail; import com.xingdata.zzdpos.model.Saledetail;
...@@ -28,6 +29,11 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -28,6 +29,11 @@ public class SettlePresenter extends SettleContract.Presenter {
*/ */
private Vip mVip; private Vip mVip;
/**
* 当前会员的优惠券
*/
private List<Ticket> mTickets;
/** /**
* 当前的营销活动列表 * 当前的营销活动列表
*/ */
...@@ -73,7 +79,7 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -73,7 +79,7 @@ public class SettlePresenter extends SettleContract.Presenter {
private void getPaymentIntent() { private void getPaymentIntent() {
Long payAmt = getIntent().getLongExtra(C.EXTRA_KEY.SETTLE_EXTRA, 0); Long payAmt = getIntent().getLongExtra(C.EXTRA_KEY.SETTLE_EXTRA, 0);
mSaledetails.add(0, Saledetail.create("收款", payAmt, mVip)); mSaledetails.add(0, Saledetail.create("收款", payAmt, mVip));
mSaleorder.setSaledetails(mSaledetails).settle(); mSaleorder.setSaledetails(mSaledetails);
} }
/** /**
...@@ -86,13 +92,13 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -86,13 +92,13 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override @Override
public void initSettle() { public void initSettle() {
ApiFactory.Pay.query().subscribe( DBFactory.Settle.queryPays().subscribe(
pays -> mView.loadPays(pays), pays -> mView.loadPays(pays),
throwable -> { throwable -> {
} }
); );
mView.loadSaleorder(mSaleorder);
mView.setSettleFragmentBySettleMode(mSettleMode); mView.setSettleFragmentBySettleMode(mSettleMode);
this.reprice();
} }
@Override @Override
...@@ -100,6 +106,7 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -100,6 +106,7 @@ public class SettlePresenter extends SettleContract.Presenter {
mView.showVipFragment(); mView.showVipFragment();
} }
@Override @Override
public void searchVip(String keyword) { public void searchVip(String keyword) {
ApiFactory.User.queryUserDetailByKeyword(keyword).subscribe( ApiFactory.User.queryUserDetailByKeyword(keyword).subscribe(
...@@ -114,8 +121,19 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -114,8 +121,19 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override @Override
public void selectVip(Vip vip) { public void selectVip(Vip vip) {
mVip = vip; // 设置会员
mView.loadVip(mVip); this.setVip(vip);
// 计算价格
this.reprice();
// 获取订单
ApiFactory.Ticket.query(mVip.getVipId()).subscribe(
tickets -> {
this.mTickets = tickets;
this.searchAvlTicket();
},
throwable -> {
});
} }
@Override @Override
...@@ -124,30 +142,27 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -124,30 +142,27 @@ public class SettlePresenter extends SettleContract.Presenter {
} }
@Override @Override
public void searchTicket(Long vipId) { public void searchTicket() {
ApiFactory.Ticket.query(vipId).subscribe( List<Ticket> _tickets = new ArrayList<>();
tickets -> { for (int i = 0; i < mTickets.size(); i++) {
mView.loadTickets(tickets); if (mSaleorder.getOrderVipOffAmt() - mSaleorder.getMsDisAmt() >= mTickets.get(i).getTruleOrderAmt()) {
int avlTicketNum = 0; mTickets.get(i).setSelected(mSaleorder.getTicketId() == mTickets.get(i).getTicketNo());
for (int i = 0; i < tickets.size(); i++) { _tickets.add(mTickets.get(i));
if (tickets.get(i).getTruleOrderAmt() <= mSaleorder.getOrderPayAmt()) }
avlTicketNum++; }
} mView.loadTickets(_tickets);
mView.loadAvlTicketNum(avlTicketNum);
},
throwable -> {
});
} }
@Override @Override
public void selectTicket(Ticket ticket) { public void selectTicket(Ticket ticket) {
mView.loadTicket(ticket); mSaleorder.setTicket(ticket);
this.reprice();
} }
@Override @Override
public void changePointState(boolean isUsePoint) { public void changePointState(boolean isUsePoint) {
mSaleorder.setBound(isUsePoint, mVip.getBoundCbal()).settle(); mSaleorder.setBound(isUsePoint, mVip.getBoundCbal());
mView.loadSaleorder(mSaleorder); this.reprice();
} }
@Override @Override
...@@ -245,4 +260,43 @@ public class SettlePresenter extends SettleContract.Presenter { ...@@ -245,4 +260,43 @@ public class SettlePresenter extends SettleContract.Presenter {
mView.showPayFailFragment(throwable, mSaleorder); mView.showPayFailFragment(throwable, mSaleorder);
} }
/**
* 设置会员
*
* @param vip 会员信息
*/
private void setVip(Vip vip) {
this.mVip = vip;
for (int i = 0; i < mSaledetails.size(); i++) mSaledetails.get(i).setVip(mVip);
if (vip.getBoundCbal() != null) {
//清空优惠券和积分
mSaleorder.setBound(false, vip.getBoundCbal()).setTicket(Ticket.defualt());
}
//加载会员信息
mView.loadVip(mVip);
}
/**
* 查询可用的优惠券数量
*/
private void searchAvlTicket() {
int avlTicketNum = 0;
for (int i = 0; i < mTickets.size(); i++) {
if (mTickets.get(i).getTruleOrderAmt() <= mSaleorder.getOrderPayAmt())
avlTicketNum++;
}
mView.loadAvlTicketNum(avlTicketNum);
}
/**
* 统计订单信息
*/
private void reprice() {
mSaleorder.settle();
mView.loadSaleorder(mSaleorder);
}
} }
package com.xingdata.zzdpos.ui.settle.adapter;
import com.blankj.utilcode.util.TimeUtils;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseAdapter;
import com.xingdata.zzdpos.databinding.ItemSettleTicketBinding;
import com.xingdata.zzdpos.model.Ticket;
import com.xingdata.zzdpos.util.ConvertUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Locale;
public class TicketAdapter extends BaseAdapter<Ticket, ItemSettleTicketBinding> {
public TicketAdapter() {
super(R.layout.item_settle_ticket, new ArrayList<>());
}
@Override
protected void convert(ItemSettleTicketBinding mViewBinding, Ticket item) {
mViewBinding.tvTicketMoney.setText(mContext.getResources().getString(R.string.tv_money,
ConvertUtil.fenToYuanNoPoint(item.getTicketValAmt())));
mViewBinding.tvTicketMoneys.setText(mContext.getResources().getString(R.string.money,
ConvertUtil.fenToYuanNoPoint(item.getTicketValAmt())));
mViewBinding.tvRule.setText(mContext.getResources().getString(R.string.tv_rule,
ConvertUtil.fenToYuanNoPoint(item.getTruleOrderAmt())));
mViewBinding.tvDate.setText(mContext.getResources().getString(R.string.tv_date,
TimeUtils.millis2String(item.getTicketExp(), new SimpleDateFormat("yyy-mm-dd", Locale.getDefault()))));
mViewBinding.ivSelected.setImageResource(item.isSelected() ? R.mipmap.but_elect01 : R.mipmap.but_elect02);
}
}
...@@ -3,6 +3,7 @@ package com.xingdata.zzdpos.ui.settle.fragment; ...@@ -3,6 +3,7 @@ package com.xingdata.zzdpos.ui.settle.fragment;
import android.support.design.widget.BottomSheetBehavior; import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.widget.StaggeredGridLayoutManager; import android.support.v7.widget.StaggeredGridLayoutManager;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentSettleBinding; import com.xingdata.zzdpos.databinding.FragmentSettleBinding;
...@@ -14,11 +15,13 @@ import com.xingdata.zzdpos.ui.settle.adapter.PayAdapter; ...@@ -14,11 +15,13 @@ import com.xingdata.zzdpos.ui.settle.adapter.PayAdapter;
import com.xingdata.zzdpos.util.ConvertUtil; import com.xingdata.zzdpos.util.ConvertUtil;
import com.xingdata.zzdpos.util.RecyclerViewUtil; import com.xingdata.zzdpos.util.RecyclerViewUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettleBinding> { public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettleBinding> {
private PayAdapter mPayAdapter; private PayAdapter mPayAdapter;
private List<Pay> mPays;
@Override @Override
public int getLayoutId() { public int getLayoutId() {
...@@ -27,6 +30,7 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle ...@@ -27,6 +30,7 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
@Override @Override
public void initView() { public void initView() {
mPays = new ArrayList<>();
mViewBinding.setDefualtVip(true); mViewBinding.setDefualtVip(true);
// pay adapter // pay adapter
...@@ -50,6 +54,14 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle ...@@ -50,6 +54,14 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
mPresenter.initSettle(); mPresenter.initSettle();
} }
@Override
public boolean onBackPressedSupport() {
if (BottomSheetBehavior.from(mViewBinding.llSheet).getState() == BottomSheetBehavior.STATE_EXPANDED) {
BottomSheetBehavior.from(mViewBinding.llSheet).setState(BottomSheetBehavior.STATE_COLLAPSED);
return true;
}
return super.onBackPressedSupport();
}
/** /**
* 设置界面 * 设置界面
...@@ -65,9 +77,24 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle ...@@ -65,9 +77,24 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
* @param vip 会员信息 * @param vip 会员信息
*/ */
public void loadVip(Vip vip) { public void loadVip(Vip vip) {
if (vip.isDefaultVip()) {
for (int i = 0; i < mPayAdapter.getData().size(); i++) {
if (mPayAdapter.getData().get(i).isNeedVip()) mPayAdapter.remove(i);
}
} else {
for (int i = 0; i < mPays.size(); i++) {
if (mPays.get(i).isNeedVip() && (mPays.get(i).getPayType() != C.PAY_CHANNEL.CARD || vip.getAcctCbal() > mViewBinding.getOrderPayAmt())) {
mPayAdapter.addData(mPays.get(i));
}
}
}
mViewBinding.setDefualtVip(vip.isDefaultVip()); mViewBinding.setDefualtVip(vip.isDefaultVip());
mViewBinding.setName(vip.getVipName()); mViewBinding.setName(vip.getVipName());
mViewBinding.setPhone(ConvertUtil.longToString(vip.getVipMobile())); mViewBinding.setPhone(ConvertUtil.longToString(vip.getVipMobile()));
mViewBinding.setBalance(vip.getAcctCbal());
mViewBinding.cbPoint.setChecked(false);
if (vip.getVipDefDiscount() < 100 && vip.getVipDefDiscount() > 0) { if (vip.getVipDefDiscount() < 100 && vip.getVipDefDiscount() > 0) {
mViewBinding.setDisRate(String.valueOf((double) vip.getVipDefDiscount() / 10)); mViewBinding.setDisRate(String.valueOf((double) vip.getVipDefDiscount() / 10));
} }
...@@ -94,21 +121,33 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle ...@@ -94,21 +121,33 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
mViewBinding.setAvlTicketNum(avlNum); mViewBinding.setAvlTicketNum(avlNum);
} }
/** /**
* 加载订单信息 * 加载订单信息
* *
* @param saleorder 订单信息 * @param saleorder 订单信息
*/ */
public void loadSaleorder(Saleorder saleorder) { public void loadSaleorder(Saleorder saleorder) {
mViewBinding.tvPayAmt.setText(ConvertUtil.fenToYuan(saleorder.getOrderPayAmt())); mViewBinding.setOrderAuthAmt(saleorder.getOrderAuthAmt());
mViewBinding.tvAuthAmt.setText(ConvertUtil.fenToYuan(saleorder.getOrderAuthAmt())); mViewBinding.setOrderPayAmt(saleorder.getOrderPayAmt());
mViewBinding.setTicketAmt(saleorder.getTicketAmt());
mViewBinding.setAvlPoints(saleorder.getBoundNum());
mViewBinding.setPointDisAmt(ConvertUtil.fenToYuan(saleorder.getBoundAmt()));
} }
/** /**
* 加载支付方式 * 加载支付方式
*/ */
public void loadPays(List<Pay> pays) { public void loadPays(List<Pay> pays) {
mPayAdapter.setNewData(pays); mPays.addAll(pays);
List<Pay> _pays = new ArrayList<>();
for (int i = 0; i < pays.size(); i++) {
pays.get(i).init();
if (!pays.get(i).isNeedVip()) _pays.add(pays.get(i));
}
mPayAdapter.setNewData(_pays);
} }
......
package com.xingdata.zzdpos.ui.settle.fragment; package com.xingdata.zzdpos.ui.settle.fragment;
public class TicketFragment { import android.annotation.SuppressLint;
import android.support.v7.widget.LinearLayoutManager;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentSettleTicketBinding;
import com.xingdata.zzdpos.model.Ticket;
import com.xingdata.zzdpos.ui.settle.SettlePresenter;
import com.xingdata.zzdpos.ui.settle.adapter.TicketAdapter;
import java.util.ArrayList;
import java.util.List;
public class TicketFragment extends BaseFragment<SettlePresenter, FragmentSettleTicketBinding> {
private Ticket mTicket;
private List<Ticket> mTicketList;
private TicketAdapter mTicketAdapter;
private int mPosition = -1;
@Override
public int getLayoutId() {
return R.layout.fragment_settle_ticket;
}
@Override
public void initView() {
mTicketList = new ArrayList<>();
mTicket = Ticket.defualt();
mTicketAdapter = new TicketAdapter();
mViewBinding.rlTicket.setAdapter(mTicketAdapter);
mViewBinding.rlTicket.setLayoutManager(new LinearLayoutManager(mContext));
mTicketAdapter.setOnItemClickListener((adapter, view, position) -> changeSelectedTicket(position));
mViewBinding.tvConfirm.setOnClickListener(view -> {
mPresenter.selectTicket(mTicket);
this.pop();
});
mPresenter.searchTicket();
}
/**
* 加载优惠券信息
*
* @param tickets 优惠券列表
*/
public void loadTickets(List<Ticket> tickets) {
for (int i = 0; i < tickets.size(); i++) {
if (tickets.get(i).isSelected()) {
mTicket = tickets.get(i);
mViewBinding.setSelectedNum(1);
mPosition = i;
break;
}
}
mTicketAdapter.setNewData(tickets);
}
/**
* 切换选中的优惠券
*
* @param position 被选中优惠券的position
*/
@SuppressLint("SetTextI18n")
private void changeSelectedTicket(int position) {
if (mPosition != -1) {
//取消选择
if (mPosition == position && mTicketAdapter.getData().get(mPosition).isSelected()) {
mTicketAdapter.getData().get(mPosition).setSelected(false);
mTicketAdapter.notifyDataSetChanged();
mTicket = Ticket.defualt();
mViewBinding.setSelectedNum(0);
return;
}
if (mTicketAdapter.getData().size() > mPosition) {
mTicketAdapter.getData().get(mPosition).setSelected(false);
} else {
for (int i = 0; i < mTicketList.size(); i++) {
mTicketList.get(i).setSelected(false);
}
}
}
mPosition = position;
mTicketAdapter.getData().get(position).setSelected(true);
mTicket = mTicketAdapter.getData().get(position);
mViewBinding.setSelectedNum(1);
mTicketAdapter.notifyDataSetChanged();
}
} }
...@@ -7,6 +7,16 @@ ...@@ -7,6 +7,16 @@
<import type="android.view.View" /> <import type="android.view.View" />
<import type="com.xingdata.zzdpos.util.ConvertUtil" />
<variable
name="orderAuthAmt"
type="long" />
<variable
name="orderPayAmt"
type="long" />
<variable <variable
name="defualtVip" name="defualtVip"
type="boolean" /> type="boolean" />
...@@ -28,17 +38,20 @@ ...@@ -28,17 +38,20 @@
type="int" /> type="int" />
<variable <variable
name="usePoint" name="ticketAmt"
type="boolean" /> type="long" />
<variable <variable
name="pointVip" name="avlPoints"
type="int" /> type="long" />
<variable <variable
name="pointAmt" name="pointDisAmt"
type="String" /> type="String" />
<variable
name="balance"
type="long" />
</data> </data>
...@@ -89,7 +102,7 @@ ...@@ -89,7 +102,7 @@
android:id="@+id/iv_level" android:id="@+id/iv_level"
android:layout_width="@dimen/settle_vip_level" android:layout_width="@dimen/settle_vip_level"
android:layout_height="@dimen/settle_vip_level" android:layout_height="@dimen/settle_vip_level"
android:visibility="@{defualtVip?View.GONE:View.VISIBLE}" android:visibility="@{defualtVip?View.INVISIBLE:View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@id/iv_head" app:layout_constraintBottom_toBottomOf="@id/iv_head"
app:layout_constraintRight_toRightOf="@id/iv_head" app:layout_constraintRight_toRightOf="@id/iv_head"
app:roundAsCircle="true" /> app:roundAsCircle="true" />
...@@ -99,7 +112,7 @@ ...@@ -99,7 +112,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/all_margin" android:layout_marginStart="@dimen/all_margin"
android:orientation="vertical" android:orientation="vertical"
android:visibility="@{defualtVip?View.GONE:View.VISIBLE}" android:visibility="@{defualtVip?View.INVISIBLE:View.VISIBLE}"
app:layout_constraintBottom_toTopOf="parent" app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/iv_head" app:layout_constraintLeft_toRightOf="@id/iv_head"
app:layout_constraintTop_toBottomOf="parent"> app:layout_constraintTop_toBottomOf="parent">
...@@ -126,7 +139,7 @@ ...@@ -126,7 +139,7 @@
android:text="@string/settle_select_vip" android:text="@string/settle_select_vip"
android:textColor="@color/black_zhangfei" android:textColor="@color/black_zhangfei"
android:textSize="@dimen/all_text_size" android:textSize="@dimen/all_text_size"
android:visibility="@{defualtVip?View.VISIBLE:View.GONE}" android:visibility="@{defualtVip?View.VISIBLE:View.INVISIBLE}"
app:layout_constraintBottom_toTopOf="parent" app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/iv_head" app:layout_constraintLeft_toRightOf="@id/iv_head"
app:layout_constraintTop_toBottomOf="parent" /> app:layout_constraintTop_toBottomOf="parent" />
...@@ -138,7 +151,7 @@ ...@@ -138,7 +151,7 @@
android:text="@{@string/settle_vip_dis_rate_hint + disRate + @string/settle_vip_dis_rate}" android:text="@{@string/settle_vip_dis_rate_hint + disRate + @string/settle_vip_dis_rate}"
android:textColor="@color/black_zhangfei" android:textColor="@color/black_zhangfei"
android:textSize="@dimen/all_caption_size" android:textSize="@dimen/all_caption_size"
android:visibility="@{defualtVip?View.GONE:View.VISIBLE}" android:visibility="@{defualtVip?View.INVISIBLE:View.VISIBLE}"
app:layout_constraintBottom_toTopOf="parent" app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@id/iv_arrow" app:layout_constraintRight_toLeftOf="@id/iv_arrow"
app:layout_constraintTop_toBottomOf="parent" /> app:layout_constraintTop_toBottomOf="parent" />
...@@ -195,11 +208,11 @@ ...@@ -195,11 +208,11 @@
android:textSize="@dimen/all_text_size" /> android:textSize="@dimen/all_text_size" />
<TextView <TextView
android:id="@+id/tv_auth_amt"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="end" android:gravity="end"
android:text="@{ConvertUtil.fenToYuan(orderAuthAmt,true)}"
android:textColor="@color/red_guanyu" android:textColor="@color/red_guanyu"
android:textSize="@dimen/all_sub_title_size" android:textSize="@dimen/all_sub_title_size"
android:textStyle="bold" /> android:textStyle="bold" />
...@@ -216,6 +229,7 @@ ...@@ -216,6 +229,7 @@
android:id="@+id/ll_ticket" android:id="@+id/ll_ticket"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/title_height" android:layout_height="@dimen/title_height"
android:clickable="@{avlTicketNum>0}"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:paddingEnd="@dimen/all_margin" android:paddingEnd="@dimen/all_margin"
...@@ -240,7 +254,7 @@ ...@@ -240,7 +254,7 @@
android:paddingEnd="@dimen/all_padding" android:paddingEnd="@dimen/all_padding"
android:paddingStart="@dimen/all_padding" android:paddingStart="@dimen/all_padding"
android:paddingTop="@dimen/all_shape_radius" android:paddingTop="@dimen/all_shape_radius"
android:text="@{avlTicketNum + @string/settle_ticket_text}" android:text="@{ticketAmt>0 ?ConvertUtil.fenToYuanNoPoint(ticketAmt)+@string/settle_ticket_info : avlTicketNum + @string/settle_ticket_text}"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/all_caption_size" /> android:textSize="@dimen/all_caption_size" />
...@@ -263,6 +277,7 @@ ...@@ -263,6 +277,7 @@
android:id="@+id/ll_point" android:id="@+id/ll_point"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/title_height" android:layout_height="@dimen/title_height"
android:clickable="@{!defualtVip}"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:paddingEnd="@dimen/all_margin" android:paddingEnd="@dimen/all_margin"
...@@ -281,7 +296,7 @@ ...@@ -281,7 +296,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_spacing" android:layout_marginEnd="@dimen/all_spacing"
android:text="@{@string/settle_point_vip_text + pointVip + @string/settle_point_amt_text + pointAmt}" android:text="@{@string/settle_point_vip_text + avlPoints + @string/settle_point_amt_text + pointDisAmt}"
android:textColor="@color/black_likui" /> android:textColor="@color/black_likui" />
<CheckBox <CheckBox
...@@ -315,11 +330,11 @@ ...@@ -315,11 +330,11 @@
android:textSize="@dimen/all_text_size" /> android:textSize="@dimen/all_text_size" />
<TextView <TextView
android:id="@+id/tv_balance"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="end" android:gravity="end"
android:text="@{ConvertUtil.fenToYuan(balance,true)}"
android:textColor="@color/black_baozheng" android:textColor="@color/black_baozheng"
android:textSize="@dimen/all_sub_title_size" android:textSize="@dimen/all_sub_title_size"
android:textStyle="bold" /> android:textStyle="bold" />
...@@ -375,10 +390,10 @@ ...@@ -375,10 +390,10 @@
android:textSize="@dimen/all_text_size" /> android:textSize="@dimen/all_text_size" />
<TextView <TextView
android:id="@+id/tv_pay_amt"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@{ConvertUtil.fenToYuan(orderPayAmt)}"
android:textColor="@color/red_guanyu" android:textColor="@color/red_guanyu"
android:textSize="@dimen/all_sub_title_size" android:textSize="@dimen/all_sub_title_size"
android:textStyle="bold" /> android:textStyle="bold" />
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="selectedNum"
type="int" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_zhouyu"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rl_ticket"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:background="@color/gray_huanggai" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white_caocao"
android:gravity="center_vertical"
android:paddingEnd="@dimen/all_margin"
android:paddingStart="@dimen/all_margin">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settle_ticket_selected"
android:textColor="@color/black_baozheng"
android:textSize="@dimen/all_text_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_spacing"
android:layout_marginStart="@dimen/all_spacing"
android:text='@{selectedNum+""}'
android:textColor="@color/red_guanyu"
android:textSize="@dimen/all_sub_title_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settle_ticket_unit"
android:textColor="@color/black_baozheng"
android:textSize="@dimen/all_text_size" />
</LinearLayout>
<TextView
android:id="@+id/tv_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_red_round_rectangle_more_round"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:paddingBottom="@dimen/all_spacing"
android:paddingEnd="@dimen/all_margin_big"
android:paddingStart="@dimen/all_margin_big"
android:paddingTop="@dimen/all_spacing"
android:text="@string/all_confirm"
android:textColor="@color/white_caocao" />
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="ticket"
type="com.xingdata.zzdpos.model.Ticket" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/all_margin"
android:baselineAligned="false"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_item"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/return_ticket_one"
android:contentDescription="@null" />
<LinearLayout
android:id="@+id/ll_top"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/all_padding"
app:layout_constraintBottom_toTopOf="@id/ll_bottom"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="4">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="1.8"
android:contentDescription="@null"
android:src="@mipmap/bg_return_ticker_logo" />
<TextView
android:id="@+id/tv_ticket_money"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5"
android:gravity="center"
android:text="@string/tv_money"
android:textColor="@color/white"
android:textSize="@dimen/text_secondary_title"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll_top"
app:layout_constraintVertical_weight="2">
<TextView
android:id="@+id/tv_date"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingEnd="@dimen/all_margin"
android:paddingStart="@dimen/all_margin"
android:text="@string/tv_date"
android:textColor="@color/white"
android:textSize="@dimen/et_textsize" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@mipmap/return_ticket_two"
android:contentDescription="@null" />
<TextView
android:id="@+id/tv_ticket_moneys"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:text="@string/money"
android:textColor="@color/white"
android:textSize="@dimen/text_primary_title_smile"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/vw_line"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vw_line"
android:layout_width="0dp"
android:layout_height="@dimen/all_line_width"
android:layout_marginLeft="@dimen/all_padding"
android:layout_marginRight="@dimen/all_padding"
android:background="@color/gray1"
app:layout_constraintBottom_toTopOf="@id/tv_rule"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_ticket_moneys" />
<TextView
android:id="@+id/tv_rule"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:text="@string/tv_rule"
android:textColor="@color/white"
android:textSize="@dimen/et_textsize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vw_line" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
app:backgroundImage="@color/gray_zhouyu"
app:layout_constraintBottom_toBottomOf="@id/iv_selected"
app:layout_constraintLeft_toLeftOf="@id/iv_selected"
app:layout_constraintRight_toRightOf="@id/iv_selected"
app:layout_constraintTop_toTopOf="@id/iv_selected"
app:roundAsCircle="true" />
<ImageView
android:id="@+id/iv_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/all_margin_big"
android:layout_marginTop="@dimen/all_spacing"
android:contentDescription="@null"
android:padding="@dimen/view_line_L1"
android:src="@mipmap/but_elect01"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</layout>
\ No newline at end of file
...@@ -527,6 +527,10 @@ ...@@ -527,6 +527,10 @@
<string name="settle_vip_search_empty">请输入会员手机号进行搜索~</string> <string name="settle_vip_search_empty">请输入会员手机号进行搜索~</string>
<string name="settle_vip_none">不需要会员</string> <string name="settle_vip_none">不需要会员</string>
<!--支付里的优惠券-->
<string name="settle_ticket_selected">已选</string>
<string name="settle_ticket_unit"></string>
<string name="settle_ticket_info">元优惠券</string>
<!--帮助POS--> <!--帮助POS-->
<string name="help_hint">帮助</string> <string name="help_hint">帮助</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