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
151b12fa
Commit
151b12fa
authored
Apr 08, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交;
parent
7d15e35b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
58 deletions
+128
-58
app/build.gradle
app/build.gradle
+1
-0
app/src/main/java/com/xingdata/zzdpos/C.java
app/src/main/java/com/xingdata/zzdpos/C.java
+3
-3
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
...n/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
+37
-39
app/src/main/java/com/xingdata/zzdpos/ui/store/StorePresenter.java
...ain/java/com/xingdata/zzdpos/ui/store/StorePresenter.java
+0
-1
app/src/main/java/com/xingdata/zzdpos/util/SystemUtil.java
app/src/main/java/com/xingdata/zzdpos/util/SystemUtil.java
+24
-12
neptune/src/main/java/com/xingdata/pay/neptune/Util.java
neptune/src/main/java/com/xingdata/pay/neptune/Util.java
+30
-0
neptune/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
...e/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
+33
-3
No files found.
app/build.gradle
View file @
151b12fa
...
...
@@ -87,4 +87,5 @@ dependencies {
implementation
'com.google.zxing:core:3.3.1'
implementation
(
name:
'zx_print_library-debug'
,
ext:
'aar'
)
implementation
project
(
':pay'
)
implementation
project
(
':neptune'
)
}
app/src/main/java/com/xingdata/zzdpos/C.java
View file @
151b12fa
...
...
@@ -64,12 +64,12 @@ public class C {
* <p>
* sn:test2019 设备型号 AECRC10 (收银机)
*/
p
rivate
static
final
String
URL_TEST
=
"http://121.40.56.52:80/"
;
p
ublic
static
final
String
URL_TEST
=
"http://121.40.56.52:80/"
;
/**
* 开发平台(开发人员使用)
*/
p
rivate
static
final
String
URL_DEMO
=
"http://demo.51zzd.cn/"
;
p
ublic
static
final
String
URL_DEMO
=
"http://demo.51zzd.cn/"
;
/**
* 生产平台
...
...
@@ -79,7 +79,7 @@ public class C {
/**
* 地址
*/
public
static
final
String
BASE_URL
=
URL_
TEST
;
public
static
final
String
BASE_URL
=
URL_
DEMO
;
private
static
final
String
PKG
=
"/tk/"
;
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
View file @
151b12fa
...
...
@@ -5,7 +5,9 @@ import com.blankj.utilcode.util.LogUtils;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.pay.neptune.NeptuneCenter
;
import
com.xingdata.zxpay.PayCenter
;
import
com.xingdata.zzdpos.App
;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.api.ApiFactory
;
import
com.xingdata.zzdpos.db.DBFactory
;
...
...
@@ -217,32 +219,47 @@ 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))));
mView
.
showLoadingDialog
();
subscribePay
(
commitOrder
().
flatMap
(
orderNo
->
ApiFactory
.
Saleorder
.
addOrderPayMis
(
mSaleorder
.
pay
(
orderNo
,
C
.
PAY_CHANNEL
.
CASH
))));
commitOrder
(
).
flatMap
(
orderNo
->
{
//获取支付中心参数
return
ApiFactory
.
Pay
.
getPayKey
();
}).
flatMap
(
json
->
{
//初始化支付中心,并发送支付指令
return
NeptuneCenter
.
getInstance
().
init
(
App
.
instance
,
json
).
pay
(
C
.
PAY_CHANNEL
.
ALI
,
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
:
//支付失败
subscribeRemark
(
ApiFactory
.
Saleorder
.
addRemark
(
mSaleorder
.
getOrderNo
(),
response
.
getMsg
()));
mView
.
showPayFailFragment
(
null
,
mSaleorder
);
break
;
}
},
throwable
->
{
subscribeRemark
(
ApiFactory
.
Saleorder
.
addRemark
(
mSaleorder
.
getOrderNo
(),
throwable
.
getMessage
()));
mView
.
showPayFailFragment
(
throwable
,
mSaleorder
);
}
);
}
@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
->
{
//获取支付中心参数
...
...
@@ -280,25 +297,6 @@ public class SettlePresenter extends SettleContract.Presenter {
@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));
//提交订单
commitOrder
(
).
flatMap
(
orderNo
->
{
...
...
app/src/main/java/com/xingdata/zzdpos/ui/store/StorePresenter.java
View file @
151b12fa
...
...
@@ -11,7 +11,6 @@ import com.xingdata.zzdpos.model.Sskugrp;
import
com.xingdata.zzdpos.model.Sssku
;
import
com.xingdata.zzdpos.model.Ussku
;
import
com.xingdata.zzdpos.model.Vip
;
import
com.xingdata.zzdpos.ui.main.MainPresenter
;
import
com.xingdata.zzdpos.util.StringUtil
;
import
java.util.ArrayList
;
...
...
app/src/main/java/com/xingdata/zzdpos/util/SystemUtil.java
View file @
151b12fa
...
...
@@ -6,6 +6,7 @@ import android.content.res.Resources;
import
com.blankj.utilcode.util.AppUtils
;
import
com.blankj.utilcode.util.DeviceUtils
;
import
com.blankj.utilcode.util.ScreenUtils
;
import
com.xingdata.zzdpos.C
;
import
java.lang.reflect.Method
;
...
...
@@ -28,8 +29,13 @@ public final class SystemUtil {
* @return 设备型号
*/
public
static
String
getDeviceModel
()
{
// return DeviceUtils.getModel();
return
"X990"
;
switch
(
C
.
URL
.
BASE_URL
)
{
case
C
.
URL
.
URL_DEMO
:
case
C
.
URL
.
URL_TEST
:
return
"X990"
;
default
:
return
DeviceUtils
.
getModel
();
}
}
...
...
@@ -48,17 +54,23 @@ public final class SystemUtil {
* @return 设备SN号
*/
public
static
String
getDeviceSN
()
{
if
(
deviceSN
==
null
)
{
try
{
Class
<?>
c
=
Class
.
forName
(
"android.os.SystemProperties"
);
Method
get
=
c
.
getMethod
(
"get"
,
String
.
class
);
deviceSN
=
(
String
)
get
.
invoke
(
c
,
"ro.serialno"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
switch
(
C
.
URL
.
BASE_URL
)
{
case
C
.
URL
.
URL_DEMO
:
return
"0818562"
;
case
C
.
URL
.
URL_TEST
:
return
"test2018"
;
default
:
if
(
deviceSN
==
null
)
{
try
{
Class
<?>
c
=
Class
.
forName
(
"android.os.SystemProperties"
);
Method
get
=
c
.
getMethod
(
"get"
,
String
.
class
);
deviceSN
=
(
String
)
get
.
invoke
(
c
,
"ro.serialno"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
deviceSN
;
}
// return deviceSN;
return
"test2018"
;
}
/**
...
...
neptune/src/main/java/com/xingdata/pay/neptune/Util.java
View file @
151b12fa
package
com
.
xingdata
.
pay
.
neptune
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
com.blankj.utilcode.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.util.List
;
class
Util
{
...
...
@@ -135,5 +142,28 @@ class Util {
BigDecimal
decimal
=
new
BigDecimal
(
dis
);
return
decimal
.
divide
(
new
BigDecimal
(
10
)).
setScale
(
0
,
BigDecimal
.
ROUND_DOWN
).
toString
();
}
/**
* 创建显式intent
*
* @param context context
* @param implicitIntent 隐式intent
* @return 显示intent
*/
public
static
Intent
createExplicitFromImplicitIntent
(
Context
context
,
Intent
implicitIntent
)
{
PackageManager
pm
=
context
.
getPackageManager
();
List
<
ResolveInfo
>
resolveInfo
=
pm
.
queryIntentServices
(
implicitIntent
,
0
);
if
(
resolveInfo
==
null
||
resolveInfo
.
size
()
!=
1
)
{
return
null
;
}
ResolveInfo
serviceInfo
=
resolveInfo
.
get
(
0
);
String
packageName
=
serviceInfo
.
serviceInfo
.
packageName
;
String
className
=
serviceInfo
.
serviceInfo
.
name
;
ComponentName
component
=
new
ComponentName
(
packageName
,
className
);
Intent
explicitIntent
=
new
Intent
(
implicitIntent
);
explicitIntent
.
setComponent
(
component
);
return
explicitIntent
;
}
}
neptune/src/main/java/com/xingdata/pay/neptune/ipc/Factory.java
View file @
151b12fa
...
...
@@ -5,6 +5,8 @@ import android.content.ComponentName;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.ServiceConnection
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.os.IBinder
;
import
android.os.RemoteException
;
...
...
@@ -14,6 +16,8 @@ import com.pax.pay.service.aidl.PayService;
import
com.xingdata.pay.neptune.NeptuneCenter
;
import
com.xingdata.pay.neptune.Response
;
import
java.util.List
;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.schedulers.Schedulers
;
...
...
@@ -46,8 +50,9 @@ public class Factory {
LogUtils
.
e
(
"Service Disconnected!"
);
}
};
Intent
intent
=
new
Intent
();
intent
.
setAction
(
"com.pax.cashier.PayService"
);
final
Intent
i
=
new
Intent
();
i
.
setAction
(
"com.pax.cashier.PayService"
);
Intent
intent
=
new
Intent
(
createExplicitFromImplicitIntent
(
conqueryAndSputext
,
i
));
context
.
bindService
(
intent
,
conn
,
Service
.
BIND_AUTO_CREATE
);
}
...
...
@@ -76,7 +81,7 @@ public class Factory {
if
(
mRetry
<
C
.
RETRY_COUNT
)
{
Thread
.
sleep
(
C
.
RETRY_DELAY_TIME
);
}
else
{
return
Observable
.
just
(
new
IResponse
(
C
.
CODE
.
SUCC
,
"初始化失败"
));
return
Observable
.
just
(
new
IResponse
(
C
.
CODE
.
FAIL_CUSTOM
,
"初始化失败"
));
}
}
IResponse
iResponse
;
...
...
@@ -95,4 +100,29 @@ public class Factory {
.
observeOn
(
AndroidSchedulers
.
mainThread
());
}
public
static
Intent
createExplicitFromImplicitIntent
(
Context
context
,
Intent
implicitIntent
)
{
// Retrieve all services that can match the given intent
PackageManager
pm
=
context
.
getPackageManager
();
List
<
ResolveInfo
>
resolveInfo
=
pm
.
queryIntentServices
(
implicitIntent
,
0
);
// Make sure only one match was found
if
(
resolveInfo
==
null
||
resolveInfo
.
size
()
!=
1
)
{
return
null
;
}
// Get component info and create ComponentName
ResolveInfo
serviceInfo
=
resolveInfo
.
get
(
0
);
String
packageName
=
serviceInfo
.
serviceInfo
.
packageName
;
String
className
=
serviceInfo
.
serviceInfo
.
name
;
ComponentName
component
=
new
ComponentName
(
packageName
,
className
);
// Create a new intent. Use the old one for extras and such reuse
Intent
explicitIntent
=
new
Intent
(
implicitIntent
);
// Set the component to be explicit
explicitIntent
.
setComponent
(
component
);
return
explicitIntent
;
}
}
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