第二版可部署提交
This commit is contained in:
parent
0d627a6809
commit
dec654096c
|
|
@ -28,6 +28,7 @@ import android.widget.GridView;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ import org.easydarwin.easypusher.R;
|
|||
import org.easydarwin.easypusher.databinding.ActivityCanteenOperationBinding;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
|
@ -136,6 +138,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
private Handler mHandler;
|
||||
private TextView timeShow;
|
||||
private View decorView = null;
|
||||
private PopupWindow mPopupWindow = null;
|
||||
|
||||
@Override
|
||||
protected ActivityCanteenOperationBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
|
|
@ -244,8 +247,12 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
UserInfo userInfo = AppDatabase.getDatabase(this).userDao().getUserInfoById(userId + "");
|
||||
// 判断账户信息
|
||||
if (judgeAccInfo(userInfo)) return;
|
||||
BigDecimal balance = new BigDecimal(userInfo.getPersonalWalletBalance()).add(new BigDecimal(userInfo.getSubsidiesBalance()));
|
||||
BigDecimal payAmount = new BigDecimal(binding.salesAmountDue.getText().toString());
|
||||
BigDecimal balance = userInfo.getPersonalWalletBalance() != null && userInfo.getSubsidiesBalance() != null
|
||||
? new BigDecimal(userInfo.getPersonalWalletBalance()).add(new BigDecimal(userInfo.getSubsidiesBalance()))
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal payAmount = binding.salesAmountDue.getText() != null && !binding.salesAmountDue.getText().toString().isEmpty()
|
||||
? new BigDecimal(binding.salesAmountDue.getText().toString())
|
||||
: BigDecimal.ZERO;
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(this).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMeetTimesInfo == null) {
|
||||
runOnUiThread(() -> {
|
||||
|
|
@ -269,8 +276,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
//调用后台支付接口
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("payableAmount", new BigDecimal(binding.salesDiscountAmount.getText().toString()).multiply(new BigDecimal(100)));
|
||||
json.put("realAmount", new BigDecimal(binding.salesAmountDue.getText().toString()).multiply(new BigDecimal(100)));
|
||||
json.put("payableAmount", new BigDecimal(binding.salesDiscountAmount.getText().toString()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.DOWN));
|
||||
json.put("realAmount", new BigDecimal(binding.salesAmountDue.getText().toString()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.DOWN));
|
||||
json.put("userId", userId);
|
||||
json.put("placeDate", DateTimeHelper.getNowDate());
|
||||
json.put("sourceType", 20);
|
||||
|
|
@ -378,6 +385,13 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
closePayWay();
|
||||
AppDatabase.getDatabase(this).businessDataDao().update(businessDataInfo);
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.pay_success_new));
|
||||
runOnUiThread(() -> {
|
||||
salesMenuEntityList.clear();
|
||||
setViewData(salesMenuEntityList, false);
|
||||
mSalesMenuAdapter.notifyDataSetChanged();
|
||||
XToastUtils.success("支付成功");
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -423,7 +437,9 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
return false;
|
||||
}
|
||||
|
||||
private BigDecimal getOrderData(int identityVerification, List<OrderPayAndroidDTO> orderList, String orderId, List<OrderDetailsInfo> orderDetailsInfoList) {
|
||||
private BigDecimal getOrderData(int identityVerification, List<
|
||||
OrderPayAndroidDTO> orderList, String
|
||||
orderId, List<OrderDetailsInfo> orderDetailsInfoList) {
|
||||
int num = 0;
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
//获取当前餐次
|
||||
|
|
@ -559,6 +575,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
Log.e("Dialog", "balanceDialog: ");
|
||||
balanceDialog.dismiss();
|
||||
balanceDialog = null;
|
||||
mPopupWindow.dismiss();
|
||||
mPopupWindow = null;
|
||||
FaceScanUtil.stopReadMealCard(OperationActivity.this);
|
||||
myPresentation.closeScan();
|
||||
new Handler().postDelayed(() -> openBalanceResultDialog(userInfo, custPhotoFulInfo), 500);
|
||||
|
|
@ -961,12 +979,14 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
.setView(R.layout.popup_window_more)
|
||||
.setBackgroundAlpha(0.6f) //设置你的背景透明度
|
||||
.show(v, 200, (view, popupWindow) -> {
|
||||
mPopupWindow = popupWindow;
|
||||
TextView setting = view.findViewById(R.id.setting);
|
||||
setting.setOnClickListener(v1 -> {
|
||||
if (binding.loginName.getText().toString().equals("未登录")) {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_login));
|
||||
XToastUtils.warning("请先登录!");
|
||||
popupWindow.dismiss();
|
||||
mPopupWindow.dismiss();
|
||||
mPopupWindow = null;
|
||||
} else {
|
||||
Intent intent = new Intent(OperationActivity.this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
|
|
@ -1014,6 +1034,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
myPresentation.closeScan();
|
||||
balanceDialog.dismiss();
|
||||
balanceDialog = null;
|
||||
mPopupWindow.dismiss();
|
||||
mPopupWindow = null;
|
||||
});
|
||||
balanceDialog.setCancelable(false);
|
||||
balanceDialog.show();
|
||||
|
|
@ -1507,8 +1529,26 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
if (ObjectUtil.isEmpty(userId) || "null".equals(userId) || "".equals(userId)) {
|
||||
userId = "0";
|
||||
}
|
||||
String finalUserId = userId;
|
||||
ThreadPoolManager.getExecutor().execute(() -> combineData(2, finalUserId, Long.valueOf(finalUserId)));
|
||||
String type = intent.getStringExtra("type");
|
||||
Log.d(TAG, "onReceive type: " + type);
|
||||
if (ObjectUtil.isEmpty(type) || "null".equals(type) || "".equals(type)) {
|
||||
String finalUserId = userId;
|
||||
ThreadPoolManager.getExecutor().execute(() -> combineData(2, finalUserId, Long.valueOf(finalUserId)));
|
||||
} else if ("balance".equals(type)) {
|
||||
String finalUserId1 = userId;
|
||||
Log.e("Dialog", "balanceDialog: ");
|
||||
balanceDialog.dismiss();
|
||||
balanceDialog = null;
|
||||
mPopupWindow.dismiss();
|
||||
mPopupWindow = null;
|
||||
FaceScanUtil.stopReadMealCard(OperationActivity.this);
|
||||
myPresentation.closeScan();
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
UserInfo userInfo = AppDatabase.getDatabase(context).userDao().getUserInfoById(finalUserId1);
|
||||
CustPhotoFulInfo custPhotoFulInfo = AppDatabase.getDatabase(context).custPhotoFulDao().getCustPhotoById(Integer.parseInt(finalUserId1));
|
||||
runOnUiThread(() -> new Handler().postDelayed(() -> openBalanceResultDialog(userInfo, custPhotoFulInfo), 500));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class ParamSettingsActivity extends BaseActivity<ActivityCanteenParamSett
|
|||
binding.mqttPassWord.setOnClickListener(v -> openDialog("MQTT密码", "mqttPassWord", paramSettingInfo.getMqttPassword(),1));
|
||||
binding.appId.setOnClickListener(v -> openDialog("AppId", "appId", paramSettingInfo.getAppId(),1));
|
||||
binding.appKey.setOnClickListener(v -> openDialog("AppKey", "appKey", paramSettingInfo.getAppKey(),1));
|
||||
binding.facePassRate.setOnClickListener(v -> openDialog("人脸识别通过率(请输入0-1之间的数字)", "facePassRate", paramSettingInfo.getFacePassRate(),2));
|
||||
binding.facePassRate.setOnClickListener(v -> openDialog("人脸识别通过率\n提示:请输入 0.8 - 1 之间的数字", "facePassRate", paramSettingInfo.getFacePassRate(),2));
|
||||
binding.photoPrefix.setOnClickListener(v -> openDialog("图片前缀", "photoPrefix", paramSettingInfo.getPhotoPrefixes(),1));
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ public class ParamSettingsActivity extends BaseActivity<ActivityCanteenParamSett
|
|||
dialog.dismiss();
|
||||
break;
|
||||
case "facePassRate":
|
||||
if (Float.parseFloat(input.toString()) > 1 || Float.parseFloat(input.toString()) < 0){
|
||||
if (Float.parseFloat(input.toString()) > 1 || Float.parseFloat(input.toString()) < 0.8){
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_input_correct_param));
|
||||
XToastUtils.warning("请输入正确的参数!");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ public class OrderAdapter extends BaseAdapter {
|
|||
holder.machineRefund.setVisibility(View.GONE);
|
||||
}
|
||||
holder.machineRefund.setOnClickListener(v -> {
|
||||
v.setVisibility(View.GONE);
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
LoginInfo loginInfo = AppDatabase.getDatabase(context).loginInfoDao().getLoginInfoOne();
|
||||
if (ObjectUtil.isNull(loginInfo)) {
|
||||
|
|
@ -127,6 +126,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
});
|
||||
return;
|
||||
}
|
||||
runOnUiThread(() -> v.setVisibility(View.GONE));
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(bean.getOrderId());
|
||||
String money = new BigDecimal(offlineOrderInfo.getAmountDue()).divide(new BigDecimal(100)) + "";
|
||||
if ("0".equals(offlineOrderInfo.getIsOnline())) {
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class SecondPresentation extends Presentation {
|
|||
|
||||
private RelativeLayout personBalancePresentation;
|
||||
|
||||
private String type;
|
||||
private String faceScanType;
|
||||
public void setSalesData(List<SalesMenuEntity> rawData) {
|
||||
this.salesMenuEntityList = rawData;
|
||||
// 更新列表
|
||||
|
|
@ -624,7 +624,7 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
|
||||
public void openScan(String type) {
|
||||
this.type = type;
|
||||
this.faceScanType = type;
|
||||
runOnUiThread(() -> {
|
||||
faceImg.setVisibility(View.GONE);
|
||||
faceScan.setVisibility(View.VISIBLE);
|
||||
|
|
@ -868,6 +868,9 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
Intent intent = new Intent("FACE_SCAN_SUCCESS");
|
||||
intent.putExtra("userId", compareResult.getCustId());
|
||||
if ("balance".equals(faceScanType)){
|
||||
intent.putExtra("type", "balance");
|
||||
}
|
||||
context.sendBroadcast(intent);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public class UpLoadDataService extends Service {
|
|||
private UploadThread uploadThread;
|
||||
public boolean isRunning;
|
||||
public OkHttpService service = new OkHttpService();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
|
@ -76,11 +77,11 @@ public class UpLoadDataService extends Service {
|
|||
super.onCreate();
|
||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
//创建NotificationChannel
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_LOW);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
startForeground(1,getNotification());
|
||||
startForeground(1, getNotification());
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, UpLoadDataService.class.getName());
|
||||
wakeLock.acquire();
|
||||
|
|
@ -121,7 +122,7 @@ public class UpLoadDataService extends Service {
|
|||
boolean netTf = NetworkUtils.isNetworkConnected(UpLoadDataService.this);
|
||||
Log.e(TAG, "netTf:" + netTf);
|
||||
if (netTf) {
|
||||
Log.e("服务:","UpLoadDataService");
|
||||
Log.e("服务:", "UpLoadDataService");
|
||||
uploadData();
|
||||
}
|
||||
Thread.sleep(1000 * 300);
|
||||
|
|
@ -131,6 +132,7 @@ public class UpLoadDataService extends Service {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.e(TAG, "onDestroy:");
|
||||
|
|
@ -146,7 +148,7 @@ public class UpLoadDataService extends Service {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
public synchronized void uploadData(){
|
||||
public synchronized void uploadData() {
|
||||
uploadOrder();//上传订单
|
||||
}
|
||||
|
||||
|
|
@ -157,12 +159,64 @@ public class UpLoadDataService extends Service {
|
|||
return;
|
||||
}
|
||||
for (OfflineOrderInfo orderInfo : orderList) {
|
||||
uploadOrderInfo(orderInfo);
|
||||
//判断是否有订单
|
||||
int code = checkIsExistOrder(orderInfo);
|
||||
if (code == 1) {
|
||||
//订单已存在
|
||||
uploadOrderToPay(orderInfo);
|
||||
}
|
||||
if (code == 0) {
|
||||
//订单不存在
|
||||
uploadOrderInfo(orderInfo);
|
||||
}
|
||||
}
|
||||
stopSelf();
|
||||
stopService(new Intent(this, UpLoadDataService.class));
|
||||
}
|
||||
private void uploadOrderToPay(OfflineOrderInfo orderInfo) {
|
||||
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
JSONObject json = new JSONObject();
|
||||
String jsonString = json.toString();
|
||||
RequestBody body = RequestBody.create(JSON, jsonString);
|
||||
String url = WorkConfig.getBaseUrl() + "/order/device/pay/" + orderInfo.getOrderId();
|
||||
Request request = new Request.Builder().url(url)
|
||||
.post(body).build();
|
||||
String result = service.httpPost(url, body, this, request);
|
||||
Log.d("uploadOrderToPay", "result:" + result);
|
||||
if (!StringHelper.isEmptyAndNull(result)) {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
String code = firstJson.getString("code");
|
||||
if (code.equals("200")) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> AppDatabase.getDatabase(this).offlineOrderDao().updateIsOnline("1", orderInfo.getOrderId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int checkIsExistOrder(OfflineOrderInfo orderInfo) {
|
||||
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
JSONObject json = new JSONObject();
|
||||
String jsonString = json.toString();
|
||||
RequestBody body = RequestBody.create(JSON, jsonString);
|
||||
String url = WorkConfig.getBaseUrl() + "/order/device/" + orderInfo.getOrderId();
|
||||
Request request = new Request.Builder().url(url)
|
||||
.post(body).build();
|
||||
String result = service.httpPost(url, body, this, request);
|
||||
Log.d("checkIsExistOrder checkIsExistOrder", "result:" + result);
|
||||
if (StringHelper.isEmptyAndNull(result)) {
|
||||
return -1;
|
||||
}
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
String code = firstJson.getString("code");
|
||||
String msg = firstJson.getString("msg");
|
||||
if (code.equals("200")) {
|
||||
return 1;
|
||||
}
|
||||
if (code.equals("500") && "订单不存在".equals(msg)) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private void uploadOrderInfo(OfflineOrderInfo orderInfo) {
|
||||
String jsonString = orderInfo.getJsonStr().toString();
|
||||
Log.d("combineData jsonString", jsonString);
|
||||
|
|
@ -177,7 +231,7 @@ public class UpLoadDataService extends Service {
|
|||
.addHeader("MERCHANT-ID", AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne().getTenantId())
|
||||
.addHeader("source-type", "20")
|
||||
.post(body).build();
|
||||
String result = service.httpPost(url, body,this, request);
|
||||
String result = service.httpPost(url, body, this, request);
|
||||
Log.i("getPersonMessage result", result);
|
||||
if (!StringHelper.isEmptyAndNull(result)) {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
|
|
|
|||
|
|
@ -120,12 +120,9 @@ public class SimplePopupWindow {
|
|||
//显示软键盘
|
||||
private void showInPut() {
|
||||
if (mIsShowInput) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
new Handler().postDelayed(() -> {
|
||||
InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import com.bonus.canteen.db.entity.base.ParamSettingInfo;
|
|||
|
||||
public class WorkConfig {
|
||||
//本地
|
||||
protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
|
||||
protected static String prefixesUrl = "http://192.168.0.34:48380";
|
||||
protected static String baseUrl = "http://36.33.26.201:48380/smart-canteen";
|
||||
protected static String prefixesUrl = "http://36.33.26.201:48380";
|
||||
|
||||
protected static String fileUrl = "http://192.168.0.14:9090/lnyst/";
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="@dimen/config_margin_20dp"
|
||||
android:layout_marginTop="@dimen/config_margin_10dp"
|
||||
android:background="@drawable/btn_border_no_bg"
|
||||
android:textColor="@color/black"
|
||||
android:background="@drawable/btn_login_border_bg"
|
||||
android:text="返回"/>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
Loading…
Reference in New Issue