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
267a1186
Commit
267a1186
authored
Apr 19, 2018
by
王海
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改支付
parent
be649677
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
45 deletions
+136
-45
app/src/main/java/com/xingdata/zzdpos/C.java
app/src/main/java/com/xingdata/zzdpos/C.java
+1
-1
neptune/src/main/java/com/xingdata/pay/neptune/NeptuneCenter.java
...src/main/java/com/xingdata/pay/neptune/NeptuneCenter.java
+10
-13
neptune/src/main/java/com/xingdata/pay/neptune/ipc/C.java
neptune/src/main/java/com/xingdata/pay/neptune/ipc/C.java
+1
-1
neptune/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
...e/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
+124
-30
No files found.
app/src/main/java/com/xingdata/zzdpos/C.java
View file @
267a1186
...
...
@@ -79,7 +79,7 @@ public class C {
/**
* 地址
*/
public
static
final
String
BASE_URL
=
URL_
DEMO
;
public
static
final
String
BASE_URL
=
URL_
TEST
;
private
static
final
String
PKG
=
"/tk/"
;
...
...
neptune/src/main/java/com/xingdata/pay/neptune/NeptuneCenter.java
View file @
267a1186
...
...
@@ -3,10 +3,8 @@ package com.xingdata.pay.neptune;
import
android.content.Context
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.xingdata.pay.neptune.ipc.Factory
;
import
com.xingdata.pay.neptune.model.Shopppp
;
import
io.reactivex.Observable
;
...
...
@@ -18,28 +16,27 @@ public class NeptuneCenter {
/**
* 交易基本信息
*/
public
Shopppp
mShopppp
;
public
static
NeptuneCenter
getInstance
()
{
return
NeptuneCenter
.
NeptuneCenterHolder
.
INSTANCE
;
}
public
NeptuneCenter
init
(
Context
context
,
String
json
)
{
public
NeptuneCenter
init
(
Context
context
)
{
LogUtils
.
e
(
"初始化NeptuneCenter"
);
Factory
.
getInstance
().
init
(
context
);
mShopppp
=
JSON
.
parseObject
(
json
,
Shopppp
.
class
);
return
this
;
}
/**
* 支付
*
* @param orderNo 订单号
* @param payChannel 支付渠道
* @param orderAmt 金额
* @return 支付结果的Observable
*/
public
Observable
<
Response
>
pay
(
int
payChannel
,
Long
orderAmt
)
{
return
Factory
.
pay
(
payChannel
,
orderAmt
);
public
Observable
<
Response
>
pay
(
String
orderNo
,
int
payChannel
,
Long
orderAmt
)
{
return
Factory
.
pay
(
orderNo
,
payChannel
,
orderAmt
);
}
/**
...
...
@@ -47,10 +44,10 @@ public class NeptuneCenter {
*
* @param payChannel 支付渠道
* @param orderAmt 金额
* @return
支付
结果的Observable
* @return
退款
结果的Observable
*/
public
Observable
<
Response
>
refund
(
int
payChannel
,
Long
orderAmt
)
{
return
Factory
.
refund
(
payChannel
,
orderAmt
);
public
Observable
<
Response
>
refund
(
String
orderNo
,
int
payChannel
,
Long
orderAmt
)
{
return
Factory
.
refund
(
orderNo
,
payChannel
,
orderAmt
);
}
/**
...
...
@@ -59,10 +56,10 @@ public class NeptuneCenter {
* @param orderAmt 原交易金额,为null则不参与查询
* @param origOrderNo 原订单号
* @param transUniqueId 原交易流水号, 为null则不参与查询
* @return
* @return
查询结果的Observable
*/
public
Observable
<
Response
>
query
(
Long
orderAmt
,
String
origOrderNo
,
String
transUniqueId
)
{
return
Factory
.
query
(
orderAmt
,
origOrderNo
,
transUniqueId
);
public
Observable
<
Response
>
query
(
String
orderNo
,
Long
orderAmt
,
String
origOrderNo
,
String
transUniqueId
)
{
return
Factory
.
query
(
order
No
,
order
Amt
,
origOrderNo
,
transUniqueId
);
}
}
...
...
neptune/src/main/java/com/xingdata/pay/neptune/ipc/C.java
View file @
267a1186
...
...
@@ -34,7 +34,7 @@ public class C {
/**
* 银联支付
*/
final
static
String
UNIONPAY
=
"
UNIO
NPAY"
;
final
static
String
UNIONPAY
=
"
CHA
NPAY"
;
/**
* 微信支付
*/
...
...
neptune/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
View file @
267a1186
...
...
@@ -5,12 +5,12 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.ServiceConnection
;
import
android.os.IBinder
;
import
android.os.RemoteException
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.pax.pay.service.aidl.PayService
;
import
com.xingdata.pay.neptune.NeptuneCenter
;
import
com.xingdata.pay.neptune.Response
;
import
io.reactivex.Observable
;
...
...
@@ -19,14 +19,12 @@ import io.reactivex.schedulers.Schedulers;
public
class
Factory
{
private
static
PayService
mPayService
;
private
static
ServiceConnection
serviceConnection
;
private
static
int
mRetry
;
private
static
class
FactoryHolder
{
private
static
final
Factory
INSTANCE
=
new
Factory
();
}
private
static
int
mRetry
;
public
static
Factory
getInstance
()
{
return
Factory
.
FactoryHolder
.
INSTANCE
;
}
...
...
@@ -34,7 +32,7 @@ public class Factory {
public
void
init
(
Context
context
)
{
if
(
mPayService
==
null
)
{
Intent
intent
=
new
Intent
(
"com.pax.cashier.SERVICE"
);
serviceConnection
=
new
ServiceConnection
()
{
ServiceConnection
serviceConnection
=
new
ServiceConnection
()
{
@Override
public
void
onServiceConnected
(
ComponentName
name
,
IBinder
service
)
{
mPayService
=
PayService
.
Stub
.
asInterface
(
service
);
...
...
@@ -46,7 +44,7 @@ public class Factory {
}
};
context
.
bindService
(
intent
,
serviceConnection
,
c
ontext
.
BIND_AUTO_CREATE
);
context
.
bindService
(
intent
,
serviceConnection
,
C
ontext
.
BIND_AUTO_CREATE
);
}
}
...
...
@@ -54,13 +52,14 @@ public class Factory {
* 交易状态查询
*
* @param orderAmt 交易金额
* @param origOrderNo
* @param origOrderNo
原订单号
* @param transUniqueId
* @return
* @return
查询结果
*/
public
static
Observable
<
Response
>
query
(
Long
orderAmt
,
String
origOrderNo
,
String
transUniqueId
)
{
public
static
Observable
<
Response
>
query
(
String
orderNo
,
Long
orderAmt
,
String
origOrderNo
,
String
transUniqueId
)
{
mRetry
=
0
;
IRequest
iRequest
=
IRequest
.
create
();
iRequest
.
setOrderNo
(
String
.
valueOf
(
NeptuneCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
())
);
iRequest
.
setOrderNo
(
orderNo
);
if
(
orderAmt
>
0
)
{
iRequest
.
setTransAmount
(
orderAmt
+
""
);
}
...
...
@@ -97,18 +96,102 @@ public class Factory {
* @return 交易结果
*/
public
static
Observable
<
Response
>
refund
(
int
payChannel
,
Long
orderAmt
)
{
// public static Observable<Response> refund(String orderNo, int payChannel, Long orderAmt) {
// mRetry = 0;
// IRequest iRequest = IRequest.create();
// orderNo="180418192206048340";
// iRequest.setOrderNo(orderNo);
// iRequest.setTransType(C.TRANS_TYPE.REFUND);
// iRequest.setTransAmount(orderAmt + "");
// if (payChannel == com.xingdata.pay.neptune.C.PAY_CHANNEL.BANK) {
// //银行卡退款
// iRequest.setPayMode(com.xingdata.pay.neptune.ipc.C.PAY_MODE.UNIONPAY);
// } else if (payChannel == com.xingdata.pay.neptune.C.PAY_CHANNEL.WECHAT) {
// //微信退款
// iRequest.setPayMode(com.xingdata.pay.neptune.ipc.C.PAY_MODE.WECHAT);
// } else if (payChannel == com.xingdata.pay.neptune.C.PAY_CHANNEL.ALI) {
// //支付宝退款
// iRequest.setPayMode(com.xingdata.pay.neptune.ipc.C.PAY_MODE.ALIPAY);
// }
// return run(Observable.just(iRequest).flatMap(iRequest1 -> {
// while (mPayService == null) {
// LogUtils.e("PayService获取失败," + C.RETRY_DELAY_TIME + "ms后尝试重连");
// if (mRetry < C.RETRY_COUNT) {
// Thread.sleep(C.RETRY_DELAY_TIME);
// } else {
// return Observable.just(new IResponse(C.CODE.FAIL_CUSTOM, "初始化失败"));
// }
// }
// IResponse iResponse;
// String str = mPayService.doTrans(JSON.toJSONString(iRequest1));
// try {
// iResponse = JSON.parseObject(str, IResponse.class);
// } catch (Exception e) {
// iResponse = new IResponse();
// }
// return Observable.just(iResponse);
// }).map(new ResultFilter()));
// }
/**
* @param payChannel 支付渠道
* @param orderAmt 支付金额
* @return 交易结果
*/
public
static
Observable
<
Response
>
refund
(
String
orderNo
,
int
payChannel
,
Long
orderAmt
)
{
mRetry
=
0
;
IRequest
iRequest
=
IRequest
.
create
();
iRequest
.
setOrderNo
(
String
.
valueOf
(
NeptuneCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
()));
orderNo
=
"180418192206048340"
;
iRequest
.
setOrderNo
(
orderNo
);
iRequest
.
setTransType
(
C
.
TRANS_TYPE
.
REFUND
);
iRequest
.
setTransAmount
(
orderAmt
+
""
);
if
(
payChannel
==
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
BANK
)
{
//银行卡退款
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
UNIONPAY
);
}
else
{
//微信支付宝退款
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
WECHAT
);
iRequest
.
setTransAmount
(
String
.
valueOf
(
orderAmt
));
iRequest
.
setOrderInfo
(
"测试信息,扫码消费"
+
String
.
valueOf
(
orderAmt
)
+
"分"
);
switch
(
payChannel
)
{
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
ALI
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
ALIPAY
);
}
break
;
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
WECHAT
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
WECHAT
);
}
break
;
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
BANK
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
UNIONPAY
);
}
break
;
}
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(
mPayService
==
null
)
{
LogUtils
.
e
(
"PayService获取失败,"
+
C
.
RETRY_DELAY_TIME
+
"ms后尝试重连"
);
if
(
mRetry
<
C
.
RETRY_COUNT
)
{
try
{
Thread
.
sleep
(
C
.
RETRY_DELAY_TIME
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
IResponse
iResponse
;
String
str
=
null
;
try
{
str
=
mPayService
.
doTrans
(
JSON
.
toJSONString
(
iRequest
));
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
}
try
{
iResponse
=
JSON
.
parseObject
(
str
,
IResponse
.
class
);
}
catch
(
Exception
e
)
{
iResponse
=
new
IResponse
();
}
}
}).
start
();
return
run
(
Observable
.
just
(
iRequest
).
flatMap
(
iRequest1
->
{
while
(
mPayService
==
null
)
{
LogUtils
.
e
(
"PayService获取失败,"
+
C
.
RETRY_DELAY_TIME
+
"ms后尝试重连"
);
...
...
@@ -129,25 +212,36 @@ public class Factory {
}).
map
(
new
ResultFilter
()));
}
/**
* @param payChannel 支付渠道
* @param orderAmt 支付金额
* @return 交易结果
*/
public
static
Observable
<
Response
>
pay
(
int
payChannel
,
Long
orderAmt
)
{
public
static
Observable
<
Response
>
pay
(
String
orderNo
,
int
payChannel
,
Long
orderAmt
)
{
mRetry
=
0
;
IRequest
iRequest
=
IRequest
.
create
();
iRequest
.
setOrderNo
(
String
.
valueOf
(
NeptuneCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
())
);
iRequest
.
setOrderNo
(
orderNo
);
iRequest
.
setTransType
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
TRANS_TYPE
.
SALE
);
switch
(
payChannel
)
{
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
ALI
:
// iRequest.setPayMode(C.PAY_MODE.ALIPAY);
break
;
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
WECHAT
:
// iRequest.setPayMode(C.PAY_MODE.WECHAT);
break
;
}
iRequest
.
setTransAmount
(
String
.
valueOf
(
orderAmt
));
iRequest
.
setOrderInfo
(
"测试信息,扫码消费"
+
String
.
valueOf
(
orderAmt
)
+
"分"
);
switch
(
payChannel
)
{
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
ALI
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
ALIPAY
);
}
break
;
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
WECHAT
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
WECHAT
);
}
break
;
case
com
.
xingdata
.
pay
.
neptune
.
C
.
PAY_CHANNEL
.
BANK
:
{
iRequest
.
setPayMode
(
com
.
xingdata
.
pay
.
neptune
.
ipc
.
C
.
PAY_MODE
.
UNIONPAY
);
}
break
;
}
return
run
(
Observable
.
just
(
iRequest
).
flatMap
(
iRequest1
->
{
while
(
mPayService
==
null
)
{
LogUtils
.
e
(
"PayService获取失败,"
+
C
.
RETRY_DELAY_TIME
+
"ms后尝试重连"
);
...
...
@@ -169,7 +263,7 @@ public class Factory {
}
p
ublic
static
<
T
>
Observable
<
T
>
run
(
Observable
<
T
>
observable
)
{
p
rivate
static
<
T
>
Observable
<
T
>
run
(
Observable
<
T
>
observable
)
{
return
observable
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
());
}
...
...
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