Commit 151b12fa authored by zhang_z's avatar zhang_z

提交;

parent 7d15e35b
......@@ -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')
}
......@@ -64,12 +64,12 @@ public class C {
* <p>
* sn:test2019 设备型号 AECRC10 (收银机)
*/
private static final String URL_TEST = "http://121.40.56.52:80/";
public static final String URL_TEST = "http://121.40.56.52:80/";
/**
* 开发平台(开发人员使用)
*/
private static final String URL_DEMO = "http://demo.51zzd.cn/";
public 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/";
......
......@@ -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 -> {
......
......@@ -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;
......
......@@ -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";
}
/**
......
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;
}
}
......@@ -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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment