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
02586e4a
Commit
02586e4a
authored
Mar 12, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化结构和流程;
parent
cde96918
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
38 deletions
+94
-38
pay/src/main/java/com/xingdata/zxpay/C.java
pay/src/main/java/com/xingdata/zxpay/C.java
+2
-2
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
+26
-5
pay/src/main/java/com/xingdata/zxpay/api/Response.java
pay/src/main/java/com/xingdata/zxpay/api/Response.java
+13
-1
pay/src/main/java/com/xingdata/zxpay/model/Posppp.java
pay/src/main/java/com/xingdata/zxpay/model/Posppp.java
+6
-6
pay/src/main/java/com/xingdata/zxpay/model/Shopppp.java
pay/src/main/java/com/xingdata/zxpay/model/Shopppp.java
+3
-3
pay/src/main/java/com/xingdata/zxpay/pax/C.java
pay/src/main/java/com/xingdata/zxpay/pax/C.java
+5
-2
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
+16
-9
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
+3
-10
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
+20
-0
No files found.
pay/src/main/java/com/xingdata/zxpay/C.java
View file @
02586e4a
...
...
@@ -67,11 +67,11 @@ public class C {
/**
* 渠道
*/
public
static
final
class
CHANNEL
{
public
static
final
class
HOST
{
/**
* 惠尔丰平台的渠道编号
*/
public
final
static
int
PA
Y_CHANNEL_PAX
=
9
;
public
final
static
int
PA
X
=
10000
;
}
/**
...
...
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
View file @
02586e4a
...
...
@@ -18,7 +18,6 @@ public class PayCenter {
return
PayCenter
.
PayCenterHolder
.
INSTANCE
;
}
/**
* 交易基本信息
*/
...
...
@@ -29,12 +28,34 @@ public class PayCenter {
return
this
;
}
/**
* 支付
*
* @param payChannel 支付渠道
* @param payCode 支付码
* @param orderAmt 金额
* @return 直接结果的Observable
*/
public
Observable
<
Response
>
pay
(
int
payChannel
,
String
payCode
,
Long
orderAmt
)
{
return
Factory
.
pay
(
payChannel
,
payCode
,
Util
.
fenToYuan
(
orderAmt
));
switch
(
mShopppp
.
getHost
().
getHostMapId
())
{
case
C
.
HOST
.
PAX
:
return
Factory
.
pay
(
payChannel
,
payCode
,
Util
.
fenToYuan
(
orderAmt
));
default
:
return
Observable
.
just
(
new
Response
(
C
.
PAY_STATE
.
FAIL_CUSTOM
,
"未知渠道"
));
}
}
public
Observable
query
()
{
return
Observable
.
just
(
""
);
/**
* 查询
*
* @return 查询结果的Observable
*/
public
Observable
<
Response
>
query
()
{
switch
(
mShopppp
.
getHost
().
getHostMapId
())
{
case
C
.
HOST
.
PAX
:
return
Factory
.
query
();
default
:
return
Observable
.
just
(
new
Response
(
C
.
PAY_STATE
.
FAIL_CUSTOM
,
"未知渠道"
));
}
}
}
pay/src/main/java/com/xingdata/zxpay/api/Response.java
View file @
02586e4a
...
...
@@ -4,12 +4,24 @@ package com.xingdata.zxpay.api;
* 和App主体交互的回应包
*/
public
class
Response
{
public
Response
(
String
msg
)
{
public
Response
(
int
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
private
int
code
;
private
String
msg
;
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
...
...
pay/src/main/java/com/xingdata/zxpay/model/Posppp.java
View file @
02586e4a
...
...
@@ -26,10 +26,10 @@ public class Posppp {
private
Long
casherId
;
private
Integer
hshopNo
;
private
String
hshopNo
;
@Nullable
private
Integer
hposNo
;
private
String
hposNo
;
private
Byte
pppFlag
;
...
...
@@ -117,20 +117,20 @@ public class Posppp {
this
.
casherId
=
casherId
;
}
public
Integer
getHshopNo
()
{
public
String
getHshopNo
()
{
return
hshopNo
;
}
public
void
setHshopNo
(
Integer
hshopNo
)
{
public
void
setHshopNo
(
String
hshopNo
)
{
this
.
hshopNo
=
hshopNo
;
}
@Nullable
public
Integer
getHposNo
()
{
public
String
getHposNo
()
{
return
hposNo
;
}
public
void
setHposNo
(
@Nullable
Integer
hposNo
)
{
public
void
setHposNo
(
@Nullable
String
hposNo
)
{
this
.
hposNo
=
hposNo
;
}
...
...
pay/src/main/java/com/xingdata/zxpay/model/Shopppp.java
View file @
02586e4a
...
...
@@ -25,7 +25,7 @@ public class Shopppp {
private
String
hshopNameabcn
;
@Nullable
private
Integer
hshopNo
;
private
String
hshopNo
;
private
Byte
pppFlag
;
...
...
@@ -118,11 +118,11 @@ public class Shopppp {
}
@Nullable
public
Integer
getHshopNo
()
{
public
String
getHshopNo
()
{
return
hshopNo
;
}
public
void
setHshopNo
(
@Nullable
Integer
hshopNo
)
{
public
void
setHshopNo
(
@Nullable
String
hshopNo
)
{
this
.
hshopNo
=
hshopNo
;
}
...
...
pay/src/main/java/com/xingdata/zxpay/pax/C.java
View file @
02586e4a
...
...
@@ -10,6 +10,11 @@ class C {
* 测试数据
*/
class
TEST
{
/**
* 测试URL
*/
final
static
String
BASE_URL
=
"http://114.55.31.38:8008"
;
/**
* 机构号
*/
...
...
@@ -33,8 +38,6 @@ class C {
* 地址
*/
class
URL
{
final
static
String
BASE_URL
=
"http://114.55.31.38:8008"
;
final
static
String
ACTION
=
"/tps/api/instrans"
;
}
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
View file @
02586e4a
package
com
.
xingdata
.
zxpay
.
pax
;
import
com.alibaba.fastjson.JSON
;
import
android.util.SparseArray
;
import
com.blankj.utilcode.util.TimeUtils
;
import
com.xingdata.zxpay.PayCenter
;
import
com.xingdata.zxpay.api.Response
;
import
java.text.SimpleDateFormat
;
import
java.util.Locale
;
...
...
@@ -14,6 +14,7 @@ import io.reactivex.Observable;
public
class
Factory
extends
com
.
xingdata
.
zxpay
.
api
.
Factory
{
private
static
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyymmddhhmmss"
,
Locale
.
getDefault
());
private
static
SparseArray
<
String
>
orderMap
=
new
SparseArray
<>();
/**
* 条码支付
...
...
@@ -42,17 +43,23 @@ public class Factory extends com.xingdata.zxpay.api.Factory {
}
request
.
sign
();
return
run
(
Api
.
getInstance
().
service
.
action
(
request
))
.
flatMap
(
response
->
{
return
Observable
.
just
(
new
Response
(
JSON
.
toJSONString
(
response
)));
});
.
map
(
new
ResultFilter
())
.
doFinally
(()
->
orderMap
.
put
(
request
.
getOutTransactionNo
(),
request
.
getTimeStart
()));
}
public
static
Observable
query
(
String
c
,
String
d
)
{
/**
* 查询
*
* @return 查询结果
*/
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
query
()
{
Request
request
=
Request
.
create
(
C
.
METHOD
.
QUERY
);
request
.
setAgentId
(
c
);
request
.
setExpTime
(
d
);
return
Api
.
getInstance
().
service
.
action
(
request
);
request
.
setOutTransactionNo
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
());
request
.
setTimeStart
(
orderMap
.
get
(
request
.
getOutTransactionNo
()));
request
.
sign
();
return
run
(
Api
.
getInstance
().
service
.
action
(
request
))
.
map
(
new
ResultFilter
());
}
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
View file @
02586e4a
...
...
@@ -14,16 +14,9 @@ class Request {
this
.
signType
=
C
.
SIGN_TYPE
.
MD5
;
this
.
version
=
C
.
VERSION
;
// {//TODO 测试数据
// this.agentId = C.TEST.AGENT_ID;
// this.mchId = C.TEST.MCH_ID;
// this.terId = C.TEST.TER_ID;
// }
{
//TODO 正式数据
this
.
agentId
=
String
.
valueOf
(
PayCenter
.
getInstance
().
mShopppp
.
getHost
().
getHostAcqCode
());
this
.
mchId
=
String
.
valueOf
(
PayCenter
.
getInstance
().
mShopppp
.
getHshopNo
());
this
.
terId
=
String
.
valueOf
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposNo
());
}
this
.
agentId
=
PayCenter
.
getInstance
().
mShopppp
.
getHost
().
getHostAcqCode
();
this
.
mchId
=
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHshopNo
();
this
.
terId
=
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposNo
();
}
/**
...
...
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
0 → 100644
View file @
02586e4a
package
com
.
xingdata
.
zxpay
.
pax
;
import
io.reactivex.functions.Function
;
class
ResultFilter
implements
Function
<
Response
,
com
.
xingdata
.
zxpay
.
api
.
Response
>
{
@Override
public
com
.
xingdata
.
zxpay
.
api
.
Response
apply
(
Response
response
)
throws
Exception
{
switch
(
response
.
getCode
())
{
case
C
.
CODE
.
SUCCESS
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
,
response
.
getMsg
());
case
C
.
CODE
.
USINGPAY
:
case
C
.
CODE
.
UNKONW
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
,
response
.
getMsg
());
default
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
FAIL
,
response
.
getMsg
());
}
}
}
\ No newline at end of file
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