Commit c07e5af8 authored by zhang_z's avatar zhang_z

收款;

parent 4f0dcac5
......@@ -10,6 +10,7 @@ import android.view.KeyEvent;
import android.view.View;
import com.hwangjr.rxbus.RxBus;
import com.xingdata.zzdpos.util.InstanceUtil;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
......@@ -17,7 +18,6 @@ import java.util.List;
import me.yokeyword.fragmentation.ISupportFragment;
import me.yokeyword.fragmentation.SupportActivity;
import com.xingdata.zzdpos.util.InstanceUtil;
/**
* BaseActivity,供新创建的Activity继承
......@@ -57,11 +57,9 @@ public abstract class BaseActivity<P extends BasePresenter, B extends ViewDataBi
protected void initPresenter() {
if (this instanceof BaseView &&
this.getClass().getGenericSuperclass() instanceof ParameterizedType &&
((ParameterizedType) (this.getClass().getGenericSuperclass())).getActualTypeArguments().length > 0) {
Class mPresenterClass = (Class) ((ParameterizedType) (this.getClass()
.getGenericSuperclass())).getActualTypeArguments()[0];
if (this instanceof BaseView && this.getClass().getGenericSuperclass() instanceof ParameterizedType
&& ((ParameterizedType) (this.getClass().getGenericSuperclass())).getActualTypeArguments().length > 0) {
Class mPresenterClass = (Class) ((ParameterizedType) (this.getClass().getGenericSuperclass())).getActualTypeArguments()[0];
mPresenter = InstanceUtil.getInstance(mPresenterClass);
mPresenter.setIntent(getIntent()).setView(this).build();
}
......
......@@ -35,7 +35,6 @@ public abstract class BasePresenter<V> {
protected Realm getRealm() {
if (mRealm == null) {
mRealm = Realm.getInstance(App.instance.mRealmConfig);
// mRealm.setAutoRefresh(false);
}
return mRealm;
}
......
package com.xingdata.zzdpos.db;
import com.xingdata.zzdpos.App;
import com.xingdata.zzdpos.base.BaseModel;
import com.xingdata.zzdpos.model.Ms;
import com.xingdata.zzdpos.model.Pay;
import com.xingdata.zzdpos.ui.settle.SettlePresenter;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import io.realm.Realm;
import io.realm.RealmModel;
import io.realm.RealmObject;
import io.realm.RealmQuery;
import io.realm.RealmResults;
import com.xingdata.zzdpos.App;
import com.xingdata.zzdpos.base.BaseModel;
import io.realm.Sort;
public class DBFactory {
public static class Settle {
/**
* 查询支付渠道
*
* @return 支付渠道
*/
public static Observable<List<Pay>> queryPays() {
RealmQuery<Pay> query = DB.getInstance().get(SettlePresenter.class).where(Pay.class);
query.equalTo("payDispFlag", 1);
return Observable.just(query.findAll())
.flatMap(pays -> Observable.just(getList(pays)));
}
/**
* 查询营销活动
*
* @return 营销活动
*/
public static Observable<List<Ms>> queryMss() {
RealmQuery<Ms> query = DB.getInstance().get(SettlePresenter.class).where(Ms.class);
query.equalTo("msStatus", 0);
return Observable.just(query.findAllSorted("msTouchTag2", Sort.DESCENDING))
.flatMap(ms -> Observable.just(getList(ms)));
}
}
public static <E extends RealmModel> List<E> getLimitList(RealmResults<E> data, int offset, int limit) {
......
......@@ -2,7 +2,6 @@ package com.xingdata.zzdpos.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseBean;
import com.xingdata.zzdpos.base.BaseModel;
......@@ -40,64 +39,32 @@ public class Pay extends RealmObject implements BaseModel, BaseBean {
public void init() {
switch (getPayType()) {
case C.PAY_CHANNEL.CASH:
iconId = new int[]{R.mipmap.pay_xianjin_no, R.mipmap.pay_xianjin};
// iconId = new int[]{R.mipmap.pay_xianjin_no, R.mipmap.pay_xianjin};
isSelected = true;
break;
case C.PAY_CHANNEL.ALI:
iconId = new int[]{R.mipmap.pay_zhifubao_no, R.mipmap.pay_zhifubao};
// iconId = new int[]{R.mipmap.pay_zhifubao_no, R.mipmap.pay_zhifubao};
break;
case C.PAY_CHANNEL.WECHAT:
iconId = new int[]{R.mipmap.pay_weixin_no, R.mipmap.pay_weixin};
// iconId = new int[]{R.mipmap.pay_weixin_no, R.mipmap.pay_weixin};
break;
case C.PAY_CHANNEL.BANK:
iconId = new int[]{R.mipmap.pay_yinlian_no, R.mipmap.pay_yinlian};
// iconId = new int[]{R.mipmap.pay_yinlian_no, R.mipmap.pay_yinlian};
break;
case C.PAY_CHANNEL.CARD:
iconId = new int[]{R.mipmap.pay_chuzhi_no, R.mipmap.pay_chuzhi};
// iconId = new int[]{R.mipmap.pay_chuzhi_no, R.mipmap.pay_chuzhi};
isNeedVip = true;
break;
case C.PAY_CHANNEL.TALLY:
iconId = new int[]{R.mipmap.pay_shezhang_no, R.mipmap.pay_shezhang};
// iconId = new int[]{R.mipmap.pay_shezhang_no, R.mipmap.pay_shezhang};
isNeedVip = true;
break;
default:
iconId = new int[]{R.mipmap.pay_xianjin_no, R.mipmap.pay_xianjin};
// iconId = new int[]{R.mipmap.pay_xianjin_no, R.mipmap.pay_xianjin};
break;
}
}
// public BasePayFragment createView(Vip vip, Saleorder saleorder) {
// BasePayFragment basePayFragment = null;
// switch (payType) {
// case C.PAY_CHANNEL.CASH:
// basePayFragment = new CashPayFragment();
// break;
// case C.PAY_CHANNEL.ALI:
// basePayFragment = new AliPayFragment();
// break;
// case C.PAY_CHANNEL.WECHAT:
// basePayFragment = new WechatPayFragment();
// break;
// case C.PAY_CHANNEL.BANK:
// basePayFragment = new BankPayFragment();
// break;
// case C.PAY_CHANNEL.CARD:
// basePayFragment = new CardPayFragment();
// break;
// case C.PAY_CHANNEL.TALLY:
// basePayFragment = new TallyPayFragment();
// break;
// default:
// basePayFragment = new CashPayFragment();
// break;
// }
// basePayFragment.mVip = vip;
// basePayFragment.mSaleorder = saleorder;
// basePayFragment.mPayType = payType;
//
// return basePayFragment;
// }
@PrimaryKey
private Long id;
......
package com.xingdata.zzdpos.ui.payment;
import com.blankj.utilcode.util.EncryptUtils;
import com.xingdata.zzdpos.api.ApiFactory;
import com.xingdata.zzdpos.util.SystemUtil;
public class PaymentPresenter extends PaymentContract.Presenter {
@Override
public void onAttached() {
ApiFactory.Test.signBefore("13111111111", EncryptUtils.encryptMD5ToString("000000".getBytes()),
"1", SystemUtil.getDeviceSN()).subscribe(loginReturnBean -> {
}, throwable -> {
});
}
@Override
......
......@@ -4,6 +4,7 @@ import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.databinding.ActivitySettleBinding;
import com.xingdata.zzdpos.model.Pay;
import com.xingdata.zzdpos.model.Saleorder;
import com.xingdata.zzdpos.model.Ticket;
import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.settle.fragment.SettleFragment;
......@@ -26,7 +27,7 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
}
@Override
public void initSettleFragment(int settleMode) {
public void setSettleFragmentBySettleMode(int settleMode) {
}
@Override
......@@ -67,6 +68,11 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
mSettleFragment.loadPays(pays);
}
@Override
public void loadSaleorder(Saleorder saleorder) {
mSettleFragment.loadSaleorder(saleorder);
}
@Override
public void showPayFragment(int payChannel) {
......
......@@ -3,21 +3,22 @@ package com.xingdata.zzdpos.ui.settle;
import com.xingdata.zzdpos.base.BasePresenter;
import com.xingdata.zzdpos.base.BaseView;
import com.xingdata.zzdpos.model.Pay;
import com.xingdata.zzdpos.model.Saleorder;
import com.xingdata.zzdpos.model.Ticket;
import com.xingdata.zzdpos.model.Vip;
import java.util.List;
public interface SettleContract {
interface SettleContract {
interface View extends BaseView {
/**
* 初始化结算页面
* 设置初始化结算页面
*
* @param settleMode 结算模式
*/
void initSettleFragment(int settleMode);
void setSettleFragmentBySettleMode(int settleMode);
/**
* 显示结算Fragment
......@@ -62,7 +63,6 @@ public interface SettleContract {
*/
void loadTicket(Ticket ticket);
/***
* 加载支付方式列表
*
......@@ -70,6 +70,14 @@ public interface SettleContract {
*/
void loadPays(List<Pay> pays);
/**
* 加载订单信息
*
* @param saleorder 订单信息
*/
void loadSaleorder(Saleorder saleorder);
/**
* 显示支付页面
*
......@@ -80,6 +88,11 @@ public interface SettleContract {
abstract class Presenter extends BasePresenter<View> {
/**
* 结算页面 - 初始化结算页面
*/
public abstract void initSettle();
/**
* 结算页面 - 点击会员View
*/
......
package com.xingdata.zzdpos.ui.settle;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.api.ApiFactory;
import com.xingdata.zzdpos.model.Ms;
......@@ -10,49 +9,93 @@ import com.xingdata.zzdpos.model.Saledetail;
import com.xingdata.zzdpos.model.Saleorder;
import com.xingdata.zzdpos.model.Ticket;
import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.util.ConvertUtil;
import java.util.ArrayList;
import java.util.List;
public class SettlePresenter extends SettleContract.Presenter {
/**
* 结算模式
*/
private int mSettleMode;
/**
* 当前会员
*/
private Vip mVip;
/**
* 当前的营销活动列表
*/
private List<Ms> mMsList;
private List<Ms> mMss;
/**
* 当前设备的支付渠道信息
*/
private List<Pay> mPayChannels;
private List<Pay> mPays;
/**
* 当前购物车的商品明细
*/
private List<Saledetail> mCartProducts;
private List<Saledetail> mSaledetails;
/**
* 当前订单信息
*/
private Saleorder mOrderInfo;
private Saleorder mSaleorder;
@Override
public void onAttached() {
int settleMode = getIntent().getIntExtra(C.EXTRA_KEY.SETTLE_MODE, -1);
switch (settleMode) {
this.initRealm();
mSaleorder = new Saleorder();
mSaledetails = new ArrayList<>();
mVip = Vip.createDefault();
mSettleMode = getIntent().getIntExtra(C.EXTRA_KEY.SETTLE_MODE, -1);
switch (mSettleMode) {
case C.SETTLE_MODE.PAYMENT:
LogUtils.e("创建收款订单,订单金额" + ConvertUtil.fenToYuan(getIntent().getLongExtra(C.EXTRA_KEY.SETTLE_EXTRA, 0), true));
this.getPaymentIntent();
break;
case C.SETTLE_MODE.STORE:
this.getStoreIntent();
break;
}
}
/**
* 获取收款信息
*/
private void getPaymentIntent() {
Long payAmt = getIntent().getLongExtra(C.EXTRA_KEY.SETTLE_EXTRA, 0);
mSaledetails.add(0, Saledetail.create("收款", payAmt, mVip));
mSaleorder.setSaledetails(mSaledetails).settle();
}
/**
* 获取开单信息
*/
private void getStoreIntent() {
}
@Override
public void initSettle() {
ApiFactory.Pay.query().subscribe(
pays -> mView.loadPays(pays),
throwable -> {
}
);
mView.loadSaleorder(mSaleorder);
mView.setSettleFragmentBySettleMode(mSettleMode);
}
@Override
public void clickVipView() {
mView.showVipFragment();
// mView.showVipFragment();
mView.loadVip(Vip.createDefault());
}
@Override
......@@ -81,9 +124,7 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override
public void searchTicket(Long vipId) {
ApiFactory.Ticket.query(vipId).subscribe(
tickets -> {
mView.loadTickets(tickets);
},
tickets -> mView.loadTickets(tickets),
throwable -> {
});
}
......@@ -104,31 +145,25 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override
public void payInCash(Long inputAmt, Long changeAmt) {
}
@Override
public void payInAli(String payCode) {
}
@Override
public void payInWechat(String payCode) {
}
@Override
public void payInBank() {
}
@Override
public void payInCard(Long cardNo, String password) {
}
@Override
public void payInTally() {
}
}
package com.xingdata.zzdpos.ui.settle.adapter;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseAdapter;
......@@ -17,19 +18,41 @@ public class PayAdapter extends BaseAdapter<Pay, ItemPayBinding> {
@Override
protected void convert(ItemPayBinding mViewBinding, Pay item) {
int resLogo, resBackground;
switch (item.getPayType()) {
case C.PAY_CHANNEL.CASH:
resLogo = R.mipmap.pay_cash;
resBackground = R.color.red_diaochan;
break;
case C.PAY_CHANNEL.WECHAT:
resLogo = R.mipmap.pay_wechat;
resBackground = R.color.green_kongrun;
break;
case C.PAY_CHANNEL.ALI:
resLogo = R.mipmap.pay_alipay;
resBackground = R.color.blue_yuefei;
break;
case C.PAY_CHANNEL.BANK:
resLogo = R.mipmap.pay_card;
resBackground = R.color.cyan_liubei;
break;
case C.PAY_CHANNEL.CARD:
resLogo = R.mipmap.pay_membershipcard;
resBackground = R.color.yellow_huangxin;
break;
case C.PAY_CHANNEL.TALLY:
resLogo = R.mipmap.pay_credit;
resBackground = R.color.purple_yanqing;
break;
default:
resLogo = R.mipmap.pay_cash;
resBackground = R.color.red_diaochan;
break;
}
mViewBinding.ivLogo.setImageResource(resLogo);
GenericDraweeHierarchy hierarchy = mViewBinding.ivBackground.getHierarchy();
hierarchy.setBackgroundImage(mContext.getResources().getDrawable(resBackground));
mViewBinding.ivBackground.setHierarchy(hierarchy);
}
}
......@@ -7,9 +7,11 @@ import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentSettleBinding;
import com.xingdata.zzdpos.model.Pay;
import com.xingdata.zzdpos.model.Saleorder;
import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.settle.SettlePresenter;
import com.xingdata.zzdpos.ui.settle.adapter.PayAdapter;
import com.xingdata.zzdpos.util.ConvertUtil;
import com.xingdata.zzdpos.util.RecyclerViewUtil;
import java.util.List;
......@@ -27,15 +29,18 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
public void initView() {
mViewBinding.setDefualtVip(true);
mViewBinding.tvSettle.setOnClickListener(view -> {
BottomSheetBehavior.from(mViewBinding.llSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
});
mPresenter = new SettlePresenter();
// pay adapter
mPayAdapter = new PayAdapter();
mViewBinding.rlPay.setAdapter(mPayAdapter);
mViewBinding.rlPay.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
mViewBinding.rlPay.addItemDecoration(new RecyclerViewUtil.GridSpacingItemDecoration(3, 20, true));
mPayAdapter.setOnItemClickListener((adapter, view, position) -> mPresenter.clickPayChannelView(mPayAdapter.getData().get(position).getPayType()));
// other listener
mViewBinding.clVip.setOnClickListener(view -> mPresenter.clickVipView());
mViewBinding.tvSettle.setOnClickListener(view -> BottomSheetBehavior.from(mViewBinding.llSheet).setState(BottomSheetBehavior.STATE_EXPANDED));
mPresenter.initSettle();
}
/**
......@@ -57,6 +62,15 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
// }
}
/**
* 加载订单信息
*
* @param saleorder 订单信息
*/
public void loadSaleorder(Saleorder saleorder) {
mViewBinding.tvPayAmt.setText(ConvertUtil.fenToYuan(saleorder.getOrderPayAmt()));
}
/**
* 加载支付方式
*/
......
......@@ -55,7 +55,7 @@ public final class SystemUtil {
}
}
// return deviceSN;
return "92209325";
return "548496";
}
......
......@@ -5,5 +5,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -4,7 +4,8 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/settle_pay_item">
android:layout_height="@dimen/settle_pay_item"
android:foreground="?android:attr/selectableItemBackground">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/iv_background"
......
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