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
88dc5b5e
Commit
88dc5b5e
authored
Mar 12, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG修改;
parent
992b09bd
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
514 additions
and
201 deletions
+514
-201
.idea/dictionaries/Eurus.xml
.idea/dictionaries/Eurus.xml
+4
-0
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
...n/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
+59
-41
app/src/main/java/com/xingdata/zzdpos/ui/store/StoreActivity.java
...main/java/com/xingdata/zzdpos/ui/store/StoreActivity.java
+5
-2
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-0
pay/src/main/java/com/xingdata/zxpay/C.java
pay/src/main/java/com/xingdata/zxpay/C.java
+10
-1
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
+6
-8
pay/src/main/java/com/xingdata/zxpay/Util.java
pay/src/main/java/com/xingdata/zxpay/Util.java
+152
-0
pay/src/main/java/com/xingdata/zxpay/api/Api.java
pay/src/main/java/com/xingdata/zxpay/api/Api.java
+3
-26
pay/src/main/java/com/xingdata/zxpay/api/ConverterFactory.java
...rc/main/java/com/xingdata/zxpay/api/ConverterFactory.java
+2
-4
pay/src/main/java/com/xingdata/zxpay/api/Factory.java
pay/src/main/java/com/xingdata/zxpay/api/Factory.java
+0
-1
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
+4
-3
pay/src/main/java/com/xingdata/zxpay/pax/C.java
pay/src/main/java/com/xingdata/zxpay/pax/C.java
+123
-41
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
+38
-7
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
+94
-53
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
+11
-11
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
+2
-3
No files found.
.idea/dictionaries/Eurus.xml
View file @
88dc5b5e
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<w>
invalidmerno
</w>
<w>
invalidmerno
</w>
<w>
invalidstore
</w>
<w>
invalidstore
</w>
<w>
jsonpay
</w>
<w>
jsonpay
</w>
<w>
jspay
</w>
<w>
kongming
</w>
<w>
kongming
</w>
<w>
kongrong
</w>
<w>
kongrong
</w>
<w>
kongrun
</w>
<w>
kongrun
</w>
...
@@ -27,11 +28,13 @@
...
@@ -27,11 +28,13 @@
<w>
lvzhi
</w>
<w>
lvzhi
</w>
<w>
mawu
</w>
<w>
mawu
</w>
<w>
mernoblocked
</w>
<w>
mernoblocked
</w>
<w>
micropay
</w>
<w>
nong
</w>
<w>
nong
</w>
<w>
noti
</w>
<w>
noti
</w>
<w>
parametererror
</w>
<w>
parametererror
</w>
<w>
patt
</w>
<w>
patt
</w>
<w>
posppp
</w>
<w>
posppp
</w>
<w>
qrpay
</w>
<w>
shixiu
</w>
<w>
shixiu
</w>
<w>
shopppp
</w>
<w>
shopppp
</w>
<w>
signerror
</w>
<w>
signerror
</w>
...
@@ -48,6 +51,7 @@
...
@@ -48,6 +51,7 @@
<w>
yanqing
</w>
<w>
yanqing
</w>
<w>
yuefei
</w>
<w>
yuefei
</w>
<w>
yuji
</w>
<w>
yuji
</w>
<w>
yyyymmddhhmmss
</w>
<w>
zhangfei
</w>
<w>
zhangfei
</w>
<w>
zhouyu
</w>
<w>
zhouyu
</w>
<w>
zzdpos
</w>
<w>
zzdpos
</w>
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
View file @
88dc5b5e
...
@@ -2,9 +2,11 @@ package com.xingdata.zzdpos.ui.settle;
...
@@ -2,9 +2,11 @@ package com.xingdata.zzdpos.ui.settle;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.zxpay.PayCenter
;
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.api.JniFactory
;
import
com.xingdata.zzdpos.api.JniFactory
;
...
@@ -90,14 +92,6 @@ public class SettlePresenter extends SettleContract.Presenter {
...
@@ -90,14 +92,6 @@ public class SettlePresenter extends SettleContract.Presenter {
//这一版不作处理
//这一版不作处理
}
}
};
};
// ApiFactory.Pay.getPayKey().subscribe(LogUtils::d, throwable -> LogUtils.e(throwable.getMessage()));
// PayCenter.getInstance().init();
// PayCenter.getInstance().pay().subscribe(response -> {
// LogUtils.e(response.getMsg());
// }, throwable -> {
// LogUtils.e(throwable.getMessage());
// });
}
}
/**
/**
...
@@ -232,49 +226,73 @@ public class SettlePresenter extends SettleContract.Presenter {
...
@@ -232,49 +226,73 @@ public class SettlePresenter extends SettleContract.Presenter {
@Override
@Override
public
void
payInAli
(
String
payCode
)
{
public
void
payInAli
(
String
payCode
)
{
mView
.
showLoadingDialog
();
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
()
commitOrder
()
.
flatMap
(
orderNo
->
JniFactory
.
Settle
.
pay
(
C
.
PAY_CHANNEL
.
ALI
,
payCode
,
mSaleorder
.
getOrderPayAmt
(),
orderNo
))
.
flatMap
(
orderNo
->
PayCenter
.
getInstance
().
pay
(
C
.
PAY_CHANNEL
.
ALI
,
payCode
,
mSaleorder
.
getOrderPayAmt
()
))
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
subscribe
(
.
subscribe
(
response
->
{
response
->
{
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
r1
=
JSON
.
parseObject
(
response
.
replace
(
"\\"
,
""
),
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
.
class
);
LogUtils
.
e
(
response
.
getMsg
());
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
);
});
}
}
@Override
@Override
public
void
payInWechat
(
String
payCode
)
{
public
void
payInWechat
(
String
payCode
)
{
mView
.
showLoadingDialog
();
mView
.
showLoadingDialog
();
commitOrder
()
// commitOrder()
.
flatMap
(
orderNo
->
JniFactory
.
Settle
.
pay
(
C
.
PAY_CHANNEL
.
WECHAT
,
payCode
,
mSaleorder
.
getOrderPayAmt
(),
orderNo
))
// .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
())
.
doFinally
(()
->
mView
.
dismissLoadingDialog
())
.
subscribe
(
.
subscribe
(
response
->
{
response
->
{
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
r1
=
JSON
.
parseObject
(
response
.
replace
(
"\\"
,
""
),
com
.
xingdata
.
zzdpos
.
api
.
Pay
.
Response
.
class
);
LogUtils
.
e
(
response
.
getMsg
());
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
));
throwable
->
{
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
);
})
);
}).
subscribe
();
}
}
@Override
@Override
...
...
app/src/main/java/com/xingdata/zzdpos/ui/store/StoreActivity.java
View file @
88dc5b5e
...
@@ -102,7 +102,7 @@ public class StoreActivity extends BaseActivity<StorePresenter, ActivityStoreBin
...
@@ -102,7 +102,7 @@ public class StoreActivity extends BaseActivity<StorePresenter, ActivityStoreBin
});
});
mScanFragment
.
setOnScanCompletedListener
(
barcode
->
mPresenter
.
scanComplete
(
barcode
));
mScanFragment
.
setOnScanCompletedListener
(
barcode
->
mPresenter
.
scanComplete
(
barcode
));
mScanFragment
.
setOnBackPressedListener
(
this
::
backToStoreFragment
);
}
}
@Override
@Override
...
@@ -214,7 +214,10 @@ public class StoreActivity extends BaseActivity<StorePresenter, ActivityStoreBin
...
@@ -214,7 +214,10 @@ public class StoreActivity extends BaseActivity<StorePresenter, ActivityStoreBin
@Override
@Override
public
void
showScanFragment
()
{
public
void
showScanFragment
()
{
if
(!
mScanFragment
.
isAdded
())
this
.
start
(
mScanFragment
);
if
(!
mScanFragment
.
isAdded
())
{
mViewBinding
.
tvTitle
.
setText
(
R
.
string
.
store_scanner
);
this
.
start
(
mScanFragment
);
}
}
}
@Override
@Override
...
...
app/src/main/res/values/strings.xml
View file @
88dc5b5e
...
@@ -601,6 +601,7 @@
...
@@ -601,6 +601,7 @@
<string
name=
"store_clear_all"
>
全部清空
</string>
<string
name=
"store_clear_all"
>
全部清空
</string>
<string
name=
"store_ms_dis"
>
已减
</string>
<string
name=
"store_ms_dis"
>
已减
</string>
<string
name=
"store_scan"
>
扫描
</string>
<string
name=
"store_scan"
>
扫描
</string>
<string
name=
"store_scanner"
>
扫描商品
</string>
<string
name=
"store_search_hint"
>
请输入商品名称/助记码/条码
</string>
<string
name=
"store_search_hint"
>
请输入商品名称/助记码/条码
</string>
<string
name=
"store_reduce"
>
减少
</string>
<string
name=
"store_reduce"
>
减少
</string>
<string
name=
"store_increase"
>
添加
</string>
<string
name=
"store_increase"
>
添加
</string>
...
...
pay/src/main/java/com/xingdata/zxpay/C.java
View file @
88dc5b5e
...
@@ -54,11 +54,20 @@ public class C {
...
@@ -54,11 +54,20 @@ public class C {
public
final
static
int
QUERY
=
400
;
public
final
static
int
QUERY
=
400
;
}
}
public
final
class
PAY_CHANNEL
{
public
static
final
int
CASH
=
1
;
public
static
final
int
WECHAT
=
2
;
public
static
final
int
ALI
=
3
;
public
static
final
int
BANK
=
4
;
public
static
final
int
CARD
=
5
;
public
static
final
int
TALLY
=
9
;
}
/**
/**
* 渠道
* 渠道
*/
*/
public
static
final
class
CHANNEL
{
public
static
final
class
CHANNEL
{
/**
/**
* 惠尔丰平台的渠道编号
* 惠尔丰平台的渠道编号
*/
*/
...
...
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
;
package
com
.
xingdata
.
zxpay
;
import
com.alibaba.fastjson.JSON
;
import
com.xingdata.zxpay.api.Response
;
import
com.xingdata.zxpay.api.Response
;
import
com.xingdata.zxpay.model.Shopppp
;
import
com.xingdata.zxpay.model.Shopppp
;
import
com.xingdata.zxpay.pax.Factory
;
import
com.xingdata.zxpay.pax.Factory
;
...
@@ -23,16 +24,13 @@ public class PayCenter {
...
@@ -23,16 +24,13 @@ public class PayCenter {
*/
*/
public
Shopppp
mShopppp
;
public
Shopppp
mShopppp
;
public
void
init
(
)
{
public
PayCenter
init
(
String
json
)
{
mShopppp
=
new
Shopppp
(
);
mShopppp
=
JSON
.
parseObject
(
json
,
Shopppp
.
class
);
mShopppp
.
setHshopKeyUnipay
(
"http://114.55.31.38:8008"
)
;
return
this
;
}
}
public
Observable
<
Response
>
pay
()
{
public
Observable
<
Response
>
pay
(
int
payChannel
,
String
payCode
,
Long
orderAmt
)
{
//TODO 判断当前渠道
return
Factory
.
pay
(
payChannel
,
payCode
,
Util
.
fenToYuan
(
orderAmt
));
//TODO 返回执行结果
return
Factory
.
pay
(
"111"
,
"333"
);
}
}
public
Observable
query
()
{
public
Observable
query
()
{
...
...
pay/src/main/java/com/xingdata/zxpay/Util.java
0 → 100644
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
;
import
com.blankj.utilcode.util.StringUtils
;
import
java.math.BigDecimal
;
class
Util
{
/**
* 分转元
*
* @param fen 分
* @return 元
*/
public
static
String
fenToYuan
(
Long
fen
)
{
if
(
fen
==
null
||
fen
==
0
)
return
"0.00"
;
BigDecimal
decimal
=
new
BigDecimal
(
fen
);
return
decimal
.
divide
(
new
BigDecimal
(
100
),
2
,
BigDecimal
.
ROUND_DOWN
).
toString
();
}
// /**
// * 分转元
// *
// * @param fen 分
// * @return 元
// */
// public static String fenToYuan(Long fen) {
// if (fen == null || fen == 0) return "0.00";
// java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");
// return String.valueOf(df.format((double) fen / 100));
// }
/**
* 分转元
*
* @param fen 分
* @return 元
*/
public
static
String
fenToYuanNoPoint
(
Long
fen
)
{
if
(
fen
==
null
)
return
"0"
;
return
String
.
valueOf
(
fen
/
100
);
}
/**
* 折扣率转换
*
* @param dis 分
* @return 元
*/
public
static
String
discount
(
int
dis
)
{
String
strFen
=
String
.
valueOf
((
double
)
dis
/
10
);
return
noZero
(
strFen
);
}
/**
* 分转元
*
* @param fen 分
* @param isMonetary 是否有货币单位
* @return 元
*/
public
static
String
fenToYuan
(
Long
fen
,
boolean
isMonetary
)
{
return
(
isMonetary
?
"¥"
:
""
)
+
fenToYuan
(
fen
);
}
/**
* 元转分
*
* @param yuan 元
* @return 分
*/
public
static
Long
yuanToFen
(
String
yuan
)
{
yuan
=
StringUtils
.
isEmpty
(
yuan
)
?
"0"
:
yuan
;
BigDecimal
b
=
new
BigDecimal
(
Double
.
valueOf
(
yuan
)
*
100
);
return
b
.
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
longValue
();
}
/**
* 字符串转数字
*
* @param str 字符串
* @return 数字
*/
public
static
Long
stringToLong
(
String
str
)
{
str
=
StringUtils
.
isEmpty
(
str
)
?
"0"
:
str
;
return
Long
.
valueOf
(
str
);
}
/**
* 数字转字符串
*
* @param l 数字
* @return 字符串
*/
public
static
String
longToString
(
Long
l
)
{
if
(
l
==
null
)
return
"0"
;
return
String
.
valueOf
(
l
);
}
/**
* 分转元去掉.0 ROUND_DOWN
*
* @param fen 分
* @return 元
*/
public
static
String
fenToYuanNoZero
(
Long
fen
)
{
String
ss
=
fenToYuan2
(
fen
);
return
noZero
(
ss
);
}
private
static
String
noZero
(
String
ss
)
{
if
(
ss
.
endsWith
(
".00"
))
{
ss
=
ss
.
replace
(
".00"
,
""
);
}
else
if
(
ss
.
endsWith
(
".0"
))
{
ss
=
ss
.
replace
(
".0"
,
""
);
}
else
if
(
ss
.
endsWith
(
"0"
))
{
ss
=
ss
.
substring
(
0
,
ss
.
length
()
-
1
);
}
return
ss
;
}
/**
* 分转元保留2位小數
*
* @param fen 分
* @return 元
*/
public
static
String
fenToYuan2
(
Long
fen
)
{
if
(
fen
==
null
)
{
return
"0.00"
;
}
BigDecimal
decimal
=
new
BigDecimal
(
fen
);
return
decimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_DOWN
).
toString
();
}
/**
* 折扣率转换最大100
*
* @param dis 分
* @return 元
*/
public
static
String
discount
(
Long
dis
)
{
if
(
dis
>
100
)
{
return
"10"
;
}
BigDecimal
decimal
=
new
BigDecimal
(
dis
);
return
decimal
.
divide
(
new
BigDecimal
(
10
)).
setScale
(
0
,
BigDecimal
.
ROUND_DOWN
).
toString
();
}
}
pay/src/main/java/com/xingdata/zxpay/api/Api.java
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
.
api
;
package
com
.
xingdata
.
zxpay
.
api
;
import
android.support.annotation.NonNull
;
import
com.xingdata.zxpay.C
;
import
com.xingdata.zxpay.C
;
import
java.util.ArrayList
;
import
java.util.concurrent.TimeUnit
;
import
java.util.HashMap
;
import
java.util.List
;
import
okhttp3.Cookie
;
import
okhttp3.CookieJar
;
import
okhttp3.HttpUrl
;
import
okhttp3.Interceptor
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
okhttp3.logging.HttpLoggingInterceptor
;
...
@@ -31,28 +24,12 @@ public abstract class Api {
...
@@ -31,28 +24,12 @@ public abstract class Api {
.
addHeader
(
"Content-Type"
,
C
.
HEAD
.
CONTENT_TYPE
)
.
addHeader
(
"Content-Type"
,
C
.
HEAD
.
CONTENT_TYPE
)
.
build
());
.
build
());
//COOKIE
CookieJar
cookieJar
=
new
CookieJar
()
{
private
HashMap
<
String
,
Cookie
>
cookieMap
=
new
HashMap
<>();
@Override
public
void
saveFromResponse
(
@NonNull
HttpUrl
url
,
@NonNull
List
<
Cookie
>
cookies
)
{
for
(
int
i
=
0
;
i
<
cookies
.
size
();
i
++)
{
cookieMap
.
put
(
cookies
.
get
(
i
).
name
(),
cookies
.
get
(
i
));
}
}
@Override
public
List
<
Cookie
>
loadForRequest
(
@NonNull
HttpUrl
url
)
{
return
new
ArrayList
<>(
cookieMap
.
values
());
}
};
//Client
//Client
OkHttpClient
okHttpClient
=
new
OkHttpClient
.
Builder
()
OkHttpClient
okHttpClient
=
new
OkHttpClient
.
Builder
()
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
addInterceptor
(
headInterceptor
)
.
addInterceptor
(
headInterceptor
)
.
addInterceptor
(
logInterceptor
)
.
addInterceptor
(
logInterceptor
)
.
cookieJar
(
cookieJar
)
.
build
();
.
build
();
...
...
pay/src/main/java/com/xingdata/zxpay/api/ConverterFactory.java
View file @
88dc5b5e
...
@@ -3,7 +3,6 @@ package com.xingdata.zxpay.api;
...
@@ -3,7 +3,6 @@ package com.xingdata.zxpay.api;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.annotation.Annotation
;
import
java.lang.annotation.Annotation
;
...
@@ -17,7 +16,7 @@ import okio.Okio;
...
@@ -17,7 +16,7 @@ import okio.Okio;
import
retrofit2.Converter
;
import
retrofit2.Converter
;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
public
class
ConverterFactory
extends
Converter
.
Factory
{
class
ConverterFactory
extends
Converter
.
Factory
{
public
static
ConverterFactory
create
()
{
public
static
ConverterFactory
create
()
{
return
new
ConverterFactory
();
return
new
ConverterFactory
();
...
@@ -40,8 +39,7 @@ public class ConverterFactory extends Converter.Factory {
...
@@ -40,8 +39,7 @@ public class ConverterFactory extends Converter.Factory {
@Override
@Override
public
RequestBody
convert
(
@NonNull
T
value
)
throws
IOException
{
public
RequestBody
convert
(
@NonNull
T
value
)
throws
IOException
{
return
RequestBody
.
create
(
MEDIA_TYPE
,
JSON
.
toJSONBytes
(
value
,
SerializerFeature
return
RequestBody
.
create
(
MEDIA_TYPE
,
JSON
.
toJSONBytes
(
value
));
.
WriteMapNullValue
));
}
}
}
}
...
...
pay/src/main/java/com/xingdata/zxpay/api/Factory.java
View file @
88dc5b5e
...
@@ -6,7 +6,6 @@ import io.reactivex.schedulers.Schedulers;
...
@@ -6,7 +6,6 @@ import io.reactivex.schedulers.Schedulers;
public
class
Factory
{
public
class
Factory
{
protected
static
<
T
>
Observable
<
T
>
run
(
Observable
<
T
>
observable
)
{
protected
static
<
T
>
Observable
<
T
>
run
(
Observable
<
T
>
observable
)
{
return
observable
.
subscribeOn
(
Schedulers
.
io
())
return
observable
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
());
.
observeOn
(
AndroidSchedulers
.
mainThread
());
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
.
pax
;
package
com
.
xingdata
.
zxpay
.
pax
;
public
class
Api
extends
com
.
xingdata
.
zxpay
.
api
.
Api
{
import
com.xingdata.zxpay.PayCenter
;
class
Api
extends
com
.
xingdata
.
zxpay
.
api
.
Api
{
Service
service
;
Service
service
;
private
static
class
ApiHolder
{
private
static
class
ApiHolder
{
private
static
final
Api
INSTANCE
=
new
Api
();
private
static
final
Api
INSTANCE
=
new
Api
();
}
}
public
static
Api
getInstance
()
{
static
Api
getInstance
()
{
return
ApiHolder
.
INSTANCE
;
return
ApiHolder
.
INSTANCE
;
}
}
...
@@ -20,6 +21,6 @@ public class Api extends com.xingdata.zxpay.api.Api {
...
@@ -20,6 +21,6 @@ public class Api extends com.xingdata.zxpay.api.Api {
@Override
@Override
protected
String
getBaseUrl
()
{
protected
String
getBaseUrl
()
{
return
C
.
BASE_URL
;
return
PayCenter
.
getInstance
().
mShopppp
.
getHost
().
getHostAddr
()
;
}
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/C.java
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
.
pax
;
package
com
.
xingdata
.
zxpay
.
pax
;
class
C
{
class
C
{
/**
* 版本
*/
static
final
String
VERSION
=
"V1.0"
;
/**
* 测试数据
*/
class
TEST
{
/**
* 机构号
*/
static
final
String
AGENT_ID
=
"88888881"
;
/**
* 商户号
*/
static
final
String
MCH_ID
=
"888888888888881"
;
/**
* 终端号
*/
static
final
String
TER_ID
=
"00000001"
;
/**
* KEY
*/
static
final
String
KEY
=
"Abcdef1234567890"
;
}
/**
* 地址
*/
class
URL
{
final
static
String
BASE_URL
=
"http://114.55.31.38:8008"
;
final
static
String
BASE_URL
=
"http://114.55.31.38:8008"
;
final
static
String
ACTION
=
"/tps/api/instrans"
;
final
static
String
ACTION
=
"/tps/api/instrans"
;
}
/**
* 返回的状态CODE
*/
class
CODE
{
/**
/**
* 当前交易成功
* 当前交易成功
*/
*/
...
@@ -65,4 +101,50 @@ class C {
...
@@ -65,4 +101,50 @@ class C {
* 交易失败
* 交易失败
*/
*/
static
final
String
FAIL
=
"FAIL"
;
static
final
String
FAIL
=
"FAIL"
;
}
/**
* 交易码
*/
class
METHOD
{
/**
* 刷卡支付
*/
static
final
String
MICROPAY
=
"micropay"
;
/**
* 二维码支付
*/
static
final
String
QRPAY
=
"qrpay"
;
/**
* 公众号支付
*/
static
final
String
JSPAY
=
"jspay"
;
/**
* 退款
*/
static
final
String
REFUND
=
"refund"
;
/**
* 撤销
*/
static
final
String
CANCEL
=
"cancel"
;
/**
* 查询
*/
static
final
String
QUERY
=
"query"
;
}
/**
* 签名类型
*/
class
SIGN_TYPE
{
/**
* MD5
*/
static
final
String
MD5
=
"MD5"
;
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
View file @
88dc5b5e
...
@@ -2,23 +2,54 @@ package com.xingdata.zxpay.pax;
...
@@ -2,23 +2,54 @@ package com.xingdata.zxpay.pax;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.TimeUtils
;
import
com.xingdata.zxpay.PayCenter
;
import
com.xingdata.zxpay.api.Response
;
import
com.xingdata.zxpay.api.Response
;
import
java.text.SimpleDateFormat
;
import
java.util.Locale
;
import
io.reactivex.Observable
;
import
io.reactivex.Observable
;
public
class
Factory
extends
com
.
xingdata
.
zxpay
.
api
.
Factory
{
public
class
Factory
extends
com
.
xingdata
.
zxpay
.
api
.
Factory
{
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
pay
(
String
a
,
String
b
)
{
private
static
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyymmddhhmmss"
,
Locale
.
getDefault
());
Request
request
=
new
Request
();
request
.
setReserved
(
a
);
/**
request
.
setMethod
(
b
);
* 条码支付
*
* @param payChannel 支付渠道
* @param authCode 支付码
* @param totalAmount 总金额(单位元)
* @return 交易结果
*/
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
pay
(
int
payChannel
,
String
authCode
,
String
totalAmount
)
{
Request
request
=
Request
.
create
(
C
.
METHOD
.
MICROPAY
);
request
.
setOutTransactionNo
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
());
request
.
setTimeStart
(
TimeUtils
.
getNowString
(
format
));
request
.
setAuthCode
(
authCode
);
request
.
setTotalAmount
(
totalAmount
);
switch
(
payChannel
)
{
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
ALI
:
request
.
setKey
(
PayCenter
.
getInstance
().
mShopppp
.
getHshopKeyAlipay
());
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
WECHAT
:
request
.
setKey
(
PayCenter
.
getInstance
().
mShopppp
.
getHshopKeyWechat
());
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
BANK
:
request
.
setKey
(
PayCenter
.
getInstance
().
mShopppp
.
getHshopKeyUnipay
());
break
;
}
request
.
sign
();
return
run
(
Api
.
getInstance
().
service
.
action
(
request
))
return
run
(
Api
.
getInstance
().
service
.
action
(
request
))
.
flatMap
(
response
->
Observable
.
just
(
new
Response
(
JSON
.
toJSONString
(
response
))));
.
flatMap
(
response
->
{
return
Observable
.
just
(
new
Response
(
JSON
.
toJSONString
(
response
)));
});
}
}
public
static
Observable
query
(
String
c
,
String
d
)
{
public
static
Observable
query
(
String
c
,
String
d
)
{
Request
request
=
new
Request
(
);
Request
request
=
Request
.
create
(
C
.
METHOD
.
QUERY
);
request
.
setAgentId
(
c
);
request
.
setAgentId
(
c
);
request
.
setExpTime
(
d
);
request
.
setExpTime
(
d
);
return
Api
.
getInstance
().
service
.
action
(
request
);
return
Api
.
getInstance
().
service
.
action
(
request
);
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
View file @
88dc5b5e
package
com
.
xingdata
.
zxpay
.
pax
;
package
com
.
xingdata
.
zxpay
.
pax
;
import
android.support.annotation.Nullable
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.blankj.utilcode.util.EncryptUtils
;
import
com.xingdata.zxpay.PayCenter
;
class
Request
{
@JSONField
(
serialize
=
false
)
private
String
key
;
private
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
());
}
}
public
class
Request
{
/**
* 条码支付
*
* @return 条码支付基本对象
*/
static
Request
create
(
String
method
)
{
Request
request
=
new
Request
();
request
.
setMethod
(
method
);
return
request
;
}
/**
/**
* 版本
* 签名
*/
void
sign
()
{
String
json
=
JSON
.
toJSONString
(
this
);
json
=
json
.
replace
(
":"
,
"="
).
replace
(
","
,
"&"
).
replace
(
"\""
,
""
).
replace
(
"{"
,
""
).
replace
(
"}"
,
""
);
this
.
sign
=
EncryptUtils
.
encryptMD5ToString
(
json
+
"&key="
+
key
).
toUpperCase
();
}
/**
* 版本-
*/
*/
@JSONField
(
name
=
"version"
)
@JSONField
(
name
=
"version"
)
@Nullable
private
String
version
;
private
String
version
;
/**
/**
...
@@ -53,14 +93,12 @@ public class Request {
...
@@ -53,14 +93,12 @@ public class Request {
* 订单标题
* 订单标题
*/
*/
@JSONField
(
name
=
"subject"
)
@JSONField
(
name
=
"subject"
)
@Nullable
private
String
subject
;
private
String
subject
;
/**
/**
* 商品描述
* 商品描述
*/
*/
@JSONField
(
name
=
"body"
)
@JSONField
(
name
=
"body"
)
@Nullable
private
String
body
;
private
String
body
;
/**
/**
...
@@ -73,33 +111,29 @@ public class Request {
...
@@ -73,33 +111,29 @@ public class Request {
* 货币种类
* 货币种类
*/
*/
@JSONField
(
name
=
"currency"
)
@JSONField
(
name
=
"currency"
)
@Nullable
private
String
currency
;
private
String
currency
;
/**
/**
* 订单金额
* 订单金额
*/
*/
@JSONField
(
name
=
"
auth_code
"
)
@JSONField
(
name
=
"
total_amount
"
)
private
String
totalAmount
;
private
String
totalAmount
;
/**
/**
* 小费金额
* 小费金额
*/
*/
@JSONField
(
name
=
"fee_amount"
)
@JSONField
(
name
=
"fee_amount"
)
@Nullable
private
String
feeAmount
;
private
String
feeAmount
;
/**
/**
* 商户保留域
* 商户保留域
*/
*/
@JSONField
(
name
=
"reserved"
)
@JSONField
(
name
=
"reserved"
)
@Nullable
private
String
reserved
;
private
String
reserved
;
/**
/**
* 超时等待时间(秒)
* 超时等待时间(秒)
*/
*/
@JSONField
(
name
=
"exp_time"
)
@JSONField
(
name
=
"exp_time"
)
@Nullable
private
String
expTime
;
private
String
expTime
;
/**
/**
...
@@ -115,146 +149,153 @@ public class Request {
...
@@ -115,146 +149,153 @@ public class Request {
private
String
sign
;
private
String
sign
;
@Nullable
String
getVersion
()
{
public
String
getVersion
()
{
return
version
;
return
version
;
}
}
public
void
setVersion
(
@Nullable
String
version
)
{
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
this
.
version
=
version
;
}
}
public
String
getMethod
()
{
String
getMethod
()
{
return
method
;
return
method
;
}
}
public
void
setMethod
(
String
method
)
{
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
this
.
method
=
method
;
}
}
public
String
getAgentId
()
{
String
getAgentId
()
{
return
agentId
;
return
agentId
;
}
}
public
void
setAgentId
(
String
agentId
)
{
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
}
}
public
String
getMchId
()
{
String
getMchId
()
{
return
mchId
;
return
mchId
;
}
}
public
void
setMchId
(
String
mchId
)
{
void
setMchId
(
String
mchId
)
{
this
.
mchId
=
mchId
;
this
.
mchId
=
mchId
;
}
}
public
String
getTerId
()
{
String
getTerId
()
{
return
terId
;
return
terId
;
}
}
public
void
setTerId
(
String
terId
)
{
void
setTerId
(
String
terId
)
{
this
.
terId
=
terId
;
this
.
terId
=
terId
;
}
}
public
int
getOutTransactionNo
()
{
int
getOutTransactionNo
()
{
return
outTransactionNo
;
return
outTransactionNo
;
}
}
public
void
setOutTransactionNo
(
int
outTransactionNo
)
{
void
setOutTransactionNo
(
int
outTransactionNo
)
{
this
.
outTransactionNo
=
outTransactionNo
;
this
.
outTransactionNo
=
outTransactionNo
;
}
}
public
String
getTimeStart
()
{
String
getTimeStart
()
{
return
timeStart
;
return
timeStart
;
}
}
public
void
setTimeStart
(
String
timeStart
)
{
void
setTimeStart
(
String
timeStart
)
{
this
.
timeStart
=
timeStart
;
this
.
timeStart
=
timeStart
;
}
}
@Nullable
public
String
getSubject
()
{
String
getSubject
()
{
return
subject
;
return
subject
;
}
}
public
void
setSubject
(
@Nullable
String
subject
)
{
void
setSubject
(
String
subject
)
{
this
.
subject
=
subject
;
this
.
subject
=
subject
;
}
}
@Nullable
public
String
getBody
()
{
String
getBody
()
{
return
body
;
return
body
;
}
}
public
void
setBody
(
@Nullable
String
body
)
{
void
setBody
(
String
body
)
{
this
.
body
=
body
;
this
.
body
=
body
;
}
}
public
String
getAuthCode
()
{
String
getAuthCode
()
{
return
authCode
;
return
authCode
;
}
}
public
void
setAuthCode
(
String
authCode
)
{
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
this
.
authCode
=
authCode
;
}
}
@Nullable
public
String
getCurrency
()
{
String
getCurrency
()
{
return
currency
;
return
currency
;
}
}
public
void
setCurrency
(
@Nullable
String
currency
)
{
void
setCurrency
(
String
currency
)
{
this
.
currency
=
currency
;
this
.
currency
=
currency
;
}
}
public
String
getTotalAmount
()
{
String
getTotalAmount
()
{
return
totalAmount
;
return
totalAmount
;
}
}
public
void
setTotalAmount
(
String
totalAmount
)
{
void
setTotalAmount
(
String
totalAmount
)
{
this
.
totalAmount
=
totalAmount
;
this
.
totalAmount
=
totalAmount
;
}
}
@Nullable
public
String
getFeeAmount
()
{
String
getFeeAmount
()
{
return
feeAmount
;
return
feeAmount
;
}
}
public
void
setFeeAmount
(
@Nullable
String
feeAmount
)
{
void
setFeeAmount
(
String
feeAmount
)
{
this
.
feeAmount
=
feeAmount
;
this
.
feeAmount
=
feeAmount
;
}
}
@Nullable
public
String
getReserved
()
{
String
getReserved
()
{
return
reserved
;
return
reserved
;
}
}
public
void
setReserved
(
@Nullable
String
reserved
)
{
void
setReserved
(
String
reserved
)
{
this
.
reserved
=
reserved
;
this
.
reserved
=
reserved
;
}
}
@Nullable
public
String
getExpTime
()
{
String
getExpTime
()
{
return
expTime
;
return
expTime
;
}
}
public
void
setExpTime
(
@Nullable
String
expTime
)
{
void
setExpTime
(
String
expTime
)
{
this
.
expTime
=
expTime
;
this
.
expTime
=
expTime
;
}
}
public
String
getSignType
()
{
String
getSignType
()
{
return
signType
;
return
signType
;
}
}
public
void
setSignType
(
String
signType
)
{
void
setSignType
(
String
signType
)
{
this
.
signType
=
signType
;
this
.
signType
=
signType
;
}
}
public
String
getSign
()
{
String
getSign
()
{
return
sign
;
return
sign
;
}
}
public
void
setSign
(
String
sign
)
{
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
this
.
sign
=
sign
;
}
}
String
getKey
()
{
return
key
;
}
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
View file @
88dc5b5e
...
@@ -2,7 +2,7 @@ package com.xingdata.zxpay.pax;
...
@@ -2,7 +2,7 @@ package com.xingdata.zxpay.pax;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
Response
{
class
Response
{
/**
/**
* 交易码
* 交易码
*/
*/
...
@@ -33,43 +33,43 @@ public class Response {
...
@@ -33,43 +33,43 @@ public class Response {
@JSONField
(
name
=
"msg"
)
@JSONField
(
name
=
"msg"
)
private
String
msg
;
private
String
msg
;
public
String
getMethod
()
{
String
getMethod
()
{
return
method
;
return
method
;
}
}
public
void
setMethod
(
String
method
)
{
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
this
.
method
=
method
;
}
}
public
String
getAgentId
()
{
String
getAgentId
()
{
return
agentId
;
return
agentId
;
}
}
public
void
setAgentId
(
String
agentId
)
{
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
}
}
public
String
getMchId
()
{
String
getMchId
()
{
return
mchId
;
return
mchId
;
}
}
public
void
setMchId
(
String
mchId
)
{
void
setMchId
(
String
mchId
)
{
this
.
mchId
=
mchId
;
this
.
mchId
=
mchId
;
}
}
public
String
getCode
()
{
String
getCode
()
{
return
code
;
return
code
;
}
}
public
void
setCode
(
String
code
)
{
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
String
getMsg
()
{
String
getMsg
()
{
return
msg
;
return
msg
;
}
}
public
void
setMsg
(
String
msg
)
{
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
View file @
88dc5b5e
...
@@ -4,8 +4,7 @@ import io.reactivex.Observable;
...
@@ -4,8 +4,7 @@ import io.reactivex.Observable;
import
retrofit2.http.Body
;
import
retrofit2.http.Body
;
import
retrofit2.http.POST
;
import
retrofit2.http.POST
;
public
interface
Service
{
interface
Service
{
@POST
(
C
.
URL
.
ACTION
)
@POST
(
C
.
ACTION
)
Observable
<
Response
>
action
(
@Body
com
.
xingdata
.
zxpay
.
pax
.
Request
request
);
Observable
<
Response
>
action
(
@Body
com
.
xingdata
.
zxpay
.
pax
.
Request
request
);
}
}
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