Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TangKuPos
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王海
TangKuPos
Commits
cde96918
Commit
cde96918
authored
Mar 12, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整合新的支付模块;
parent
332b953f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
92 deletions
+145
-92
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
...in/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
+2
-2
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleContract.java
...in/java/com/xingdata/zzdpos/ui/settle/SettleContract.java
+1
-1
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
...n/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
+142
-83
app/src/main/java/com/xingdata/zzdpos/ui/settle/dialog/PayingDialog.java
...va/com/xingdata/zzdpos/ui/settle/dialog/PayingDialog.java
+0
-6
No files found.
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
View file @
cde96918
...
...
@@ -190,8 +190,8 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
}
@Override
public
void
showPayingDialog
(
int
payType
,
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
response
)
{
mPayingDialog
.
setType
(
payType
).
s
etResponse
(
response
).
s
how
(
this
);
public
void
showPayingDialog
(
int
payType
)
{
mPayingDialog
.
setType
(
payType
).
show
(
this
);
}
@Override
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleContract.java
View file @
cde96918
...
...
@@ -130,7 +130,7 @@ interface SettleContract {
/**
* 显示支付中页面
*/
void
showPayingDialog
(
int
payType
,
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
response
);
void
showPayingDialog
(
int
payType
);
/**
* 获取备注
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
View file @
cde96918
package
com
.
xingdata
.
zzdpos
.
ui
.
settle
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.zxpay.PayCenter
;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.api.ApiFactory
;
import
com.xingdata.zzdpos.api.JniFactory
;
import
com.xingdata.zzdpos.db.DBFactory
;
import
com.xingdata.zzdpos.model.HandoverInfo
;
import
com.xingdata.zzdpos.model.Ms
;
...
...
@@ -218,79 +217,117 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override
public
void
payInCash
(
Long
inputAmt
,
Long
changeAmt
)
{
mView
.
showLoadingDialog
();
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
CASH
))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
));
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
CASH
))));
}
@Override
public
void
payInAli
(
String
payCode
)
{
mView
.
showLoadingDialog
();
commitOrder
()
.
flatMap
(
orderNo
->
JniFactory
.
Settle
.
pay
(
C
.
PAY_CHANNEL
.
ALI
,
payCode
,
mSaleorder
.
getOrderPayAmt
(),
orderNo
))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
subscribe
(
response
->
{
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
r1
=
JSON
.
parseObject
(
response
.
replace
(
"\\"
,
""
),
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
.
class
);
switch
(
r1
.
getResponseCode
())
{
case
"0000"
:
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
ALI
)).
doFinally
(()
->
mView
.
dismissLoadingDialog
())));
break
;
case
"0098"
:
mView
.
showPayingDialog
(
C
.
PAY_CHANNEL
.
ALI
,
r1
);
break
;
default
:
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
));
// commitOrder()
// .flatMap(orderNo ->
PayCenter.getInstance().pay(C.PAY_CHANNEL.ALI, payCode, mSaleorder.getOrderPayAmt()
))
// .flatMap(orderNo ->
JniFactory.Settle.pay(C.PAY_CHANNEL.ALI, payCode, mSaleorder.getOrderPayAmt(), orderNo
))
// .doFinally(() -> mView.dismissLoadingDialog())
// .subscribe(
// response -> {
// LogUtils.e(response.getMsg());
// com.xingdata.zzdpos.api.Pay.Response r1 = JSON.parseObject(response.replace("\\", ""), com.xingdata.zzdpos.api.Pay.Response.class);
// switch (r1.getResponseCode()) {
// case "0000":
// subscribePay(commitOrder().flatMap(orderNo -> ApiFactory.Saleorder.addOrderPayMis(mSaleorder.pay(orderNo, C.PAY_CHANNEL.ALI)).doFinally(() -> mView.dismissLoadingDialog())));
// break;
// case "0098":
// mView.showPayingDialog(C.PAY_CHANNEL.ALI, r1);
// break;
// default:
// mView.showPayFailFragment(null, mSaleorder);
// break;
// }
// },
// throwable -> {
// mView.showPayFailFragment(throwable, mSaleorder);
// });
// throwable -> mView.showPayFailFragment(throwable, mSaleorder));
commitOrder
(
).
flatMap
(
orderNo
->
{
//获取支付中心参数
return
ApiFactory
.
Pay
.
getPayKey
();
}).
flatMap
(
json
->
{
//初始化支付中心,并发送支付指令
return
PayCenter
.
getInstance
().
init
(
json
).
pay
(
C
.
PAY_CHANNEL
.
ALI
,
payCode
,
mSaleorder
.
getOrderPayAmt
());
}).
doFinally
(()
->
{
mView
.
dismissLoadingDialog
();
}).
subscribe
(
response
->
{
switch
(
response
.
getCode
())
{
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
:
//支付中, 显示支付对话框
mView
.
showPayingDialog
(
C
.
PAY_CHANNEL
.
ALI
);
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
:
//支付成功, 发送完成订单指令
subscribePay
(
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
mSaleorder
.
getOrderNo
(),
C
.
PAY_CHANNEL
.
ALI
)));
break
;
default
:
//支付失败
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
{
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
);
}
);
}
@Override
public
void
payInWechat
(
String
payCode
)
{
mView
.
showLoadingDialog
();
commitOrder
()
.
flatMap
(
orderNo
->
JniFactory
.
Settle
.
pay
(
C
.
PAY_CHANNEL
.
WECHAT
,
payCode
,
mSaleorder
.
getOrderPayAmt
(),
orderNo
))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
subscribe
(
response
->
{
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
r1
=
JSON
.
parseObject
(
response
.
replace
(
"\\"
,
""
),
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
.
class
);
switch
(
r1
.
getResponseCode
())
{
case
C
.
PAY_STATE
.
SUCC
:
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
WECHAT
)).
doFinally
(()
->
mView
.
dismissLoadingDialog
())));
break
;
case
C
.
PAY_STATE
.
PAYING
:
mView
.
showPayingDialog
(
C
.
PAY_CHANNEL
.
WECHAT
,
r1
);
break
;
default
:
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
));
// ApiFactory.Pay.getPayKey().flatMap(s -> {
// return Observable.just(commitOrder()
// .flatMap(orderNo -> PayCenter.getInstance().init(s).pay(C.PAY_CHANNEL.WECHAT, payCode, mSaleorder.getOrderPayAmt()))
// .doFinally(() -> mView.dismissLoadingDialog())
// .subscribe(
// response -> {
// LogUtils.e(response.getMsg());
// },
// throwable -> {
// mView.showPayFailFragment(throwable, mSaleorder);
// })
// );
// }).subscribe();
// commitOrder()
// .flatMap(orderNo -> JniFactory.Settle.pay(C.PAY_CHANNEL.WECHAT, payCode, mSaleorder.getOrderPayAmt(), orderNo))
// .doFinally(() -> mView.dismissLoadingDialog())
// .subscribe(
// response -> {
// com.xingdata.zzdpos.api.Pay.Response r1 = JSON.parseObject(response.replace("\\", ""), com.xingdata.zzdpos.api.Pay.Response.class);
// switch (r1.getResponseCode()) {
// case C.PAY_STATE.SUCC:
// subscribePay(commitOrder().flatMap(orderNo -> ApiFactory.Saleorder.addOrderPayMis(mSaleorder.pay(orderNo, C.PAY_CHANNEL.WECHAT)).doFinally(() -> mView.dismissLoadingDialog())));
// break;
// case C.PAY_STATE.PAYING:
// mView.showPayingDialog(C.PAY_CHANNEL.WECHAT, r1);
// break;
// default:
// mView.showPayFailFragment(null, mSaleorder);
// break;
// }
// },
// throwable -> mView.showPayFailFragment(throwable, mSaleorder));
//提交订单
commitOrder
(
).
flatMap
(
orderNo
->
{
//获取支付中心参数
return
ApiFactory
.
Pay
.
getPayKey
();
}).
flatMap
(
json
->
{
//初始化支付中心,并发送支付指令
return
PayCenter
.
getInstance
().
init
(
json
).
pay
(
C
.
PAY_CHANNEL
.
WECHAT
,
payCode
,
mSaleorder
.
getOrderPayAmt
());
}).
doFinally
(()
->
{
mView
.
dismissLoadingDialog
();
}).
subscribe
(
response
->
{
switch
(
response
.
getCode
())
{
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
:
//支付中, 显示支付对话框
mView
.
showPayingDialog
(
C
.
PAY_CHANNEL
.
WECHAT
);
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
:
//支付成功, 发送完成订单指令
subscribePay
(
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
mSaleorder
.
getOrderNo
(),
C
.
PAY_CHANNEL
.
WECHAT
)));
break
;
default
:
//支付失败
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
{
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
);
}
);
}
@Override
...
...
@@ -303,7 +340,7 @@ public class SettlePresenter extends SettleContract.Presenter {
b
->
{
mView
.
dismissPasswordDialog
();
mView
.
showLoadingDialog
();
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
CARD
,
String
.
valueOf
(
cardNo
)))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
));
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
CARD
,
String
.
valueOf
(
cardNo
)))));
},
throwable
->
mView
.
showMsg
(
throwable
.
getMessage
())
);
...
...
@@ -315,7 +352,7 @@ public class SettlePresenter extends SettleContract.Presenter {
b
->
{
mView
.
dismissPasswordDialog
();
mView
.
showLoadingDialog
();
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
TALLY
))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
));
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
TALLY
))));
},
throwable
->
mView
.
showMsg
(
throwable
.
getMessage
())
);
...
...
@@ -324,23 +361,41 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override
public
void
checkPayState
(
int
payType
)
{
mView
.
showLoadingDialog
();
JniFactory
.
Settle
.
query
()
// JniFactory.Settle.query()
// .doFinally(() -> mView.dismissLoadingDialog())
// .subscribe(s -> {
// com.xingdata.zzdpos.api.Pay.Response r1 = JSON.parseObject(s.replace("\\", ""), com.xingdata.zzdpos.api.Pay.Response.class);
// switch (r1.getResponseCode()) {
// case C.PAY_STATE.SUCC:
// subscribePay(commitOrder().flatMap(orderNo -> ApiFactory.Saleorder.addOrderPayMis(mSaleorder.pay(orderNo, payType))));
// break;
// case C.PAY_STATE.PAYING:
// mView.showMsg("交易处理中");
// break;
// default:
// mView.showPayFailFragment(null, mSaleorder);
// break;
// }
// },
// throwable -> mView.showPayFailFragment(throwable, mSaleorder));
PayCenter
.
getInstance
().
query
()
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
subscribe
(
s
->
{
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
r1
=
JSON
.
parseObject
(
s
.
replace
(
"\\"
,
""
),
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
.
class
);
switch
(
r1
.
getResponseCode
())
{
case
C
.
PAY_STATE
.
SUCC
:
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
payType
)).
doFinally
(()
->
mView
.
dismissLoadingDialog
())));
break
;
case
C
.
PAY_STATE
.
PAYING
:
mView
.
showMsg
(
"交易处理中"
);
break
;
default
:
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
));
.
subscribe
(
response
->
{
switch
(
response
.
getCode
())
{
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
:
//支付中, Toast提示
mView
.
showMsg
(
"交易处理中"
);
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
:
//支付成功, 发送完成订单指令
subscribePay
(
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
mSaleorder
.
getOrderNo
(),
payType
)));
break
;
default
:
//支付失败
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
});
}
@Override
...
...
@@ -386,11 +441,15 @@ public class SettlePresenter extends SettleContract.Presenter {
* 提交订单
*/
private
Observable
<
String
>
commitOrder
()
{
return
ApiFactory
.
Saleorder
.
addOrderMis
(
createSaleorderParam
())
.
doAfterNext
(
s
->
{
mSaleorder
.
setOrderNo
(
s
);
mView
.
changeLockState
(
true
);
});
if
(
StringUtils
.
isEmpty
(
mSaleorder
.
getOrderNo
()))
{
return
ApiFactory
.
Saleorder
.
addOrderMis
(
createSaleorderParam
())
.
doAfterNext
(
s
->
{
mSaleorder
.
setOrderNo
(
s
);
mView
.
changeLockState
(
true
);
});
}
else
{
return
Observable
.
just
(
mSaleorder
.
getOrderNo
());
}
}
/**
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/dialog/PayingDialog.java
View file @
cde96918
...
...
@@ -4,7 +4,6 @@ import android.content.DialogInterface;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.R
;
import
com.xingdata.zzdpos.api.Pay
;
import
com.xingdata.zzdpos.base.BaseDialog
;
import
com.xingdata.zzdpos.databinding.DialogSettlePayingBinding
;
import
com.xingdata.zzdpos.ui.settle.SettlePresenter
;
...
...
@@ -12,7 +11,6 @@ import com.xingdata.zzdpos.ui.settle.SettlePresenter;
public
class
PayingDialog
extends
BaseDialog
<
SettlePresenter
,
DialogSettlePayingBinding
>
{
private
int
mType
;
private
Pay
.
Response
mResponse
;
@Override
protected
boolean
isEasy
()
{
...
...
@@ -47,8 +45,4 @@ public class PayingDialog extends BaseDialog<SettlePresenter, DialogSettlePaying
return
this
;
}
public
PayingDialog
setResponse
(
Pay
.
Response
response
)
{
this
.
mResponse
=
response
;
return
this
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment