已修改版
This commit is contained in:
parent
05db572c36
commit
87ee1333de
|
|
@ -21,7 +21,7 @@ import org.easydarwin.easypusher.R;
|
|||
import org.easydarwin.easypusher.databinding.CanteenBusinessDataBinding;
|
||||
|
||||
public class BusinessDataActivity extends BaseActivity<CanteenBusinessDataBinding> {
|
||||
public OkHttpService service = new OkHttpService();
|
||||
public final OkHttpService service = new OkHttpService();
|
||||
|
||||
@Override
|
||||
protected CanteenBusinessDataBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ public class InitializationActivity extends BaseActivity<InitializationMainBindi
|
|||
handler.sendMessage(msg);
|
||||
}
|
||||
|
||||
private final Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
private Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == UPDATE_ADAPTER) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import android.media.MediaRouter;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
|
@ -122,7 +123,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
|
||||
private SecondPresentation myPresentation;
|
||||
|
||||
public OkHttpService service = new OkHttpService();
|
||||
public final OkHttpService service = new OkHttpService();
|
||||
//补价金额
|
||||
private StringBuilder premiumAmount = new StringBuilder();
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
private GridView dishListView;
|
||||
AlertDialog alertDialog, pickUpYourMealDialog, loginDialog, balanceDialog, balanceResultDialog;
|
||||
|
||||
private Handler mHandler = new Handler();
|
||||
private Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private TextView timeShow;
|
||||
private View decorView = null;
|
||||
private PopupWindow mPopupWindow = null;
|
||||
|
|
@ -242,11 +243,16 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
*
|
||||
* @param nuClearMode 0:记账 1:刷卡 2:刷脸 3:扫码 4:补扣
|
||||
* orderType 订单类型 1 当餐 2 预订餐 3 报餐 4 商城 11 设备 12 自助餐 21 补扣 22 外部订单
|
||||
* consumMode 消费模式 1:手动 2:定额 3:类别 4:当面付
|
||||
* ifOnline 在线状态 1:在线 2:离线
|
||||
* payType 支付方式 1:账户支付 2:现金支付 10:支付宝扫码 20:微信扫码
|
||||
*/
|
||||
public void combineData(int nuClearMode, String carryGinseng, Long userId) {
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
if (deviceInfo == null) {
|
||||
showErrorAndPlaySound("设备信息异常!", -100001);
|
||||
return;
|
||||
}
|
||||
//获取当前餐次
|
||||
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(this).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMealTimesInfo == null) {
|
||||
showErrorAndPlaySound("请在餐次内进行支付", R.raw.not_time);
|
||||
|
|
@ -255,34 +261,36 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.paying));
|
||||
UserInfo userInfo = AppDatabase.getDatabase(this).userDao().getUserInfoById(String.valueOf(userId));
|
||||
if (userInfo == null) {
|
||||
showErrorAndPlaySound("用户信息异常!", -100001);
|
||||
return;
|
||||
}
|
||||
//计算个人钱包余额和补贴余额的总和
|
||||
BigDecimal balance = calculateBalance(userInfo);
|
||||
//获取支付金额
|
||||
BigDecimal payAmount = getPayAmount();
|
||||
|
||||
//判断账户信息
|
||||
if (judgeAccInfo(userInfo, balance, payAmount)) return;
|
||||
|
||||
List<OrderPayAndroidDTO> orderList = new ArrayList<>();
|
||||
List<OrderDetailsInfo> orderDetailsInfoList = new ArrayList<>();
|
||||
//生成订单号
|
||||
String orderId = generateOrderId();
|
||||
BigDecimal num = getOrderData(nuClearMode, orderList, orderId, orderDetailsInfoList);
|
||||
//获取订单数据、存储订单数据
|
||||
BigDecimal num = getOrderData(nuClearMode, orderList, orderId, orderDetailsInfoList, deviceInfo);
|
||||
|
||||
try {
|
||||
JSONObject json = createPaymentJson(userId, orderList);
|
||||
RequestBody body = createRequestBody(json);
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
|
||||
if (deviceInfo == null) {
|
||||
showErrorAndPlaySound("设备信息异常!", -100001);
|
||||
return;
|
||||
}
|
||||
|
||||
String url = WorkConfig.getBaseUrl() + UrlConfig.PLACE_AND_PAY;
|
||||
Request request = createRequest(url, body, deviceInfo);
|
||||
|
||||
OfflineOrderInfo offlineOrderInfo = createOfflineOrderInfo(orderId, userId, num, cookMealTimesInfo, json.toString());
|
||||
BusinessDataInfo businessDataInfo = updateBusinessData(cookMealTimesInfo, payAmount);
|
||||
|
||||
// 保存订单到本地
|
||||
saveOrderToLocal(offlineOrderInfo, orderDetailsInfoList);
|
||||
|
||||
// 判断网络连接状态--处理在线支付或离线支付
|
||||
if (NetworkUtils.isNetworkConnected(this)) {
|
||||
handleOnlinePayment(url, body, request, businessDataInfo, orderId);
|
||||
} else {
|
||||
|
|
@ -294,9 +302,13 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
|
||||
private BigDecimal calculateBalance(UserInfo userInfo) {
|
||||
return userInfo.getPersonalWalletBalance() != null && userInfo.getSubsidiesBalance() != null
|
||||
? new BigDecimal(userInfo.getPersonalWalletBalance()).add(new BigDecimal(userInfo.getSubsidiesBalance()))
|
||||
BigDecimal personalWalletBalance = userInfo.getPersonalWalletBalance() != null
|
||||
? new BigDecimal(userInfo.getPersonalWalletBalance())
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal subsidiesBalance = userInfo.getSubsidiesBalance() != null
|
||||
? new BigDecimal(userInfo.getSubsidiesBalance())
|
||||
: BigDecimal.ZERO;
|
||||
return subsidiesBalance.add(personalWalletBalance);
|
||||
}
|
||||
|
||||
private BigDecimal getPayAmount() {
|
||||
|
|
@ -441,7 +453,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
private void showErrorAndPlaySound(String message, int soundResId) {
|
||||
runOnUiThread(() -> {
|
||||
XToastUtils.error(message);
|
||||
if (soundResId != 100001) {
|
||||
if (soundResId != -100001) {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(soundResId));
|
||||
}
|
||||
});
|
||||
|
|
@ -496,11 +508,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, DeviceInfo deviceInfo) {
|
||||
int num = 0;
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
//获取当前餐次
|
||||
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(this).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
OrderPayAndroidDTO orderPayAndroidDTO = new OrderPayAndroidDTO();
|
||||
|
|
@ -1083,7 +1093,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
));
|
||||
|
||||
TextView exitApp = view.findViewById(R.id.exitApp);
|
||||
exitApp.setOnClickListener(v3 -> DialogLoader.getInstance().showConfirmDialog(
|
||||
exitApp.setOnClickListener(v3 ->
|
||||
DialogLoader.getInstance().showConfirmDialog(
|
||||
this,
|
||||
"是否确认退出程序?",
|
||||
getString(R.string.lab_yes),
|
||||
|
|
@ -1111,8 +1122,6 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
binding.pickUpYourMeal.setOnClickListener(vi -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(OperationActivity.this);
|
||||
View view = LayoutInflater.from(OperationActivity.this).inflate(R.layout.dialog_pick_up_meals, null);
|
||||
TextView tipTitle = view.findViewById(R.id.tip_title);
|
||||
TextView pickUpMealsContentTip = view.findViewById(R.id.pick_up_meals_content_tip);
|
||||
TextView close = view.findViewById(R.id.btn_close);
|
||||
builder.setView(view);
|
||||
pickUpYourMealDialog = builder.create();
|
||||
|
|
@ -1151,7 +1160,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
payCancel.setText("取消");
|
||||
builder.setView(view);
|
||||
balanceDialog = builder.create();
|
||||
//取消支付
|
||||
//取消查询
|
||||
payCancel.setOnClickListener(v -> {
|
||||
FaceScanUtil.stopReadMealCard(OperationActivity.this);
|
||||
myPresentation.closeScan();
|
||||
|
|
@ -1166,7 +1175,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void openBalanceResultDialog(UserInfo userInfo, CustPhotoFulInfo custPhotoFulInfo) {
|
||||
Log.d("Dialog", "openBalanceResultDialog: 进入:" + userInfo);
|
||||
Log.d(TAG, "openBalanceResultDialog: 进入:" + userInfo);
|
||||
runOnUiThread(() -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(OperationActivity.this);
|
||||
View view = LayoutInflater.from(OperationActivity.this).inflate(R.layout.dialog_person_balance, null);
|
||||
|
|
@ -1286,7 +1295,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
public void login(String name, String password, EditText etNameInput) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
UserInfo userInfo = AppDatabase.getDatabase(this).userDao().getUserInfoByPhone(name);
|
||||
if (userInfo == null || !userInfo.getLoginType().contains("0")) {
|
||||
if (userInfo == null || !userInfo.getLoginType().contains("3")) {
|
||||
runOnUiThread(() -> {
|
||||
XToastUtils.warning("该账号不支持登录!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.accont_not_to_login));
|
||||
|
|
|
|||
|
|
@ -119,6 +119,12 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
}
|
||||
});
|
||||
|
||||
binding.macReset.setOnClickListener(v-> {
|
||||
binding.macQueryKeyword.setText("");
|
||||
binding.macQueryTime.setText("");
|
||||
initData(null, DateTimeHelper.getNowDate(), type);
|
||||
});
|
||||
|
||||
binding.macQueryTime.setOnClickListener(v -> mDatePicker.show());
|
||||
|
||||
initData(null,null,type);
|
||||
|
|
@ -227,6 +233,8 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
View.OnClickListener listener = v -> {
|
||||
// 获取当前点击控件的 ID
|
||||
int viewId = v.getId();
|
||||
String keyWord = binding.macQueryKeyword.getText().toString();
|
||||
String data = binding.macQueryTime.getText().toString();
|
||||
// 根据 ID 判断是哪一个按钮被点击了
|
||||
switch (viewId) {
|
||||
case R.id.mac_back:
|
||||
|
|
@ -240,35 +248,35 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
changeView();
|
||||
findViewById(R.id.mac_make_all).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 1;
|
||||
initData(null,null,1);
|
||||
initData(keyWord,data,1);
|
||||
break;
|
||||
case R.id.mac_inline:
|
||||
// 处理 button3 被点击的逻辑
|
||||
changeView();
|
||||
findViewById(R.id.mac_inline).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 2;
|
||||
initData(null,null,2);
|
||||
initData(keyWord,data,2);
|
||||
break;
|
||||
case R.id.mac_hold_receive:
|
||||
// 处理 button3 被点击的逻辑
|
||||
changeView();
|
||||
findViewById(R.id.mac_hold_receive).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 3;
|
||||
initData(null,null,3);
|
||||
initData(keyWord,data,3);
|
||||
break;
|
||||
case R.id.mac_already_receive:
|
||||
// 处理 button3 被点击的逻辑
|
||||
changeView();
|
||||
findViewById(R.id.mac_already_receive).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 4;
|
||||
initData(null,null,4);
|
||||
initData(keyWord,data,4);
|
||||
break;
|
||||
case R.id.mac_offline:
|
||||
// 处理 button3 被点击的逻辑
|
||||
changeView();
|
||||
findViewById(R.id.mac_offline).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 6;
|
||||
initData(null,null,6);
|
||||
initData(keyWord,data,6);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ public class MealTimeActivity extends BaseActivity<AcvtivitySettingMealTimeBindi
|
|||
XUI.initTheme(this);
|
||||
setupImmersiveMode();
|
||||
intView();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
ListView listView = findViewById(R.id.list_view_meal_time);
|
||||
ThreadPoolManager.getExecutor().execute(()->{
|
||||
List<MealTimeInfo> lists = AppDatabase.getDatabase(this).mealTimeDao().getMealTime();
|
||||
|
|
@ -62,6 +66,7 @@ public class MealTimeActivity extends BaseActivity<AcvtivitySettingMealTimeBindi
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void setupImmersiveMode() {
|
||||
View decorView = getWindow().getDecorView();
|
||||
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public class NativeInfoActivity extends BaseActivity<ActivityCanteenNativeInfoBi
|
|||
XUI.initTheme(this);
|
||||
setupImmersiveMode();
|
||||
intView();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void setupImmersiveMode() {
|
||||
|
|
@ -74,7 +75,6 @@ public class NativeInfoActivity extends BaseActivity<ActivityCanteenNativeInfoBi
|
|||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -95,6 +95,7 @@ public class NativeInfoActivity extends BaseActivity<ActivityCanteenNativeInfoBi
|
|||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
ThreadPoolManager.shutdown();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ public class ParamSettingsActivity extends BaseActivity<ActivityCanteenParamSett
|
|||
XUI.initTheme(this);
|
||||
setupImmersiveMode();
|
||||
intView();
|
||||
initData();
|
||||
initListeners();
|
||||
}
|
||||
|
||||
private void setupImmersiveMode() {
|
||||
|
|
@ -122,8 +124,6 @@ public class ParamSettingsActivity extends BaseActivity<ActivityCanteenParamSett
|
|||
},
|
||||
getString(R.string.lab_no),
|
||||
(dialog, which) -> dialog.dismiss()));
|
||||
initData();
|
||||
initListeners();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -174,21 +174,15 @@ public class ParamSettingsActivity extends BaseActivity<ActivityCanteenParamSett
|
|||
.contentGravity(GravityEnum.CENTER)
|
||||
.inputType(type == 1 ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_NUMBER)
|
||||
.autoDismiss(false)
|
||||
.input(
|
||||
"请输入内容", content,
|
||||
.input("请输入内容", content,
|
||||
false,
|
||||
((dialog, input) -> {
|
||||
//保存输入的内容到paramSettingInfo
|
||||
toChangeParam(message, dialog, input);
|
||||
}))
|
||||
((dialog, input) -> toChangeParam(message, dialog, input)))//保存输入的内容到paramSettingInfo
|
||||
.inputRange(1, type == 1 ? 100 : 4)
|
||||
.positiveText("确定")
|
||||
.onPositive((dialog, which) -> {
|
||||
})
|
||||
.negativeText("取消")
|
||||
.onNegative((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.onNegative((dialog, which) -> dialog.dismiss())
|
||||
.cancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ public class SettingsActivity extends BaseActivity<AcvtivityCanteenSettingBindin
|
|||
XUI.initTheme(this);
|
||||
setupImmersiveMode();
|
||||
intView();
|
||||
List<String> lists = new ArrayList<>();
|
||||
initSimpleData(lists);
|
||||
ListView listView = findViewById(R.id.list_view);
|
||||
listView.setAdapter(new SettingAdapter(this, lists));
|
||||
}
|
||||
|
||||
private void setupImmersiveMode() {
|
||||
|
|
@ -66,20 +70,16 @@ public class SettingsActivity extends BaseActivity<AcvtivityCanteenSettingBindin
|
|||
}
|
||||
|
||||
private void intView() {
|
||||
List<String> lists;
|
||||
Log.i("SettingActivity", "-===============================SettingActivity");
|
||||
TextView tvTitle = findViewById(R.id.page_title);
|
||||
TextView ivBack = findViewById(R.id.page_back);
|
||||
lists = new ArrayList<>();
|
||||
tvTitle.setText("设置");
|
||||
ivBack.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(this, OperationActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
initSimpleData(lists);
|
||||
ListView listView = findViewById(R.id.list_view);
|
||||
listView.setAdapter(new SettingAdapter(this, lists));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
|
@ -45,10 +44,10 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class UserInfoActivity extends BaseActivity<AcvtivitySettingUserInfoBinding> {
|
||||
|
||||
private ListView listView;
|
||||
private UserInfoAdapter adapter;
|
||||
|
||||
private List<UserInfo> lists = new ArrayList<>();
|
||||
@Override
|
||||
protected AcvtivitySettingUserInfoBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
return AcvtivitySettingUserInfoBinding.inflate(inflater);
|
||||
|
|
@ -61,12 +60,9 @@ public class UserInfoActivity extends BaseActivity<AcvtivitySettingUserInfoBindi
|
|||
intView();
|
||||
listView = findViewById(R.id.list_view_user);
|
||||
ThreadPoolManager.getExecutor().execute(()->{
|
||||
List<UserInfo> lists = AppDatabase.getDatabase(this).userDao().getUserList();
|
||||
Log.i("UserInfoActivity", "lists size = " + lists);
|
||||
|
||||
List<UserInfo> list = AppDatabase.getDatabase(this).userDao().getUserList();
|
||||
runOnUiThread(()->{
|
||||
Log.i("UserInfoActivity", "adapter size = " + lists);
|
||||
adapter = new UserInfoAdapter(this, lists);
|
||||
adapter = new UserInfoAdapter(this, list);
|
||||
listView.setAdapter(adapter);
|
||||
});
|
||||
});
|
||||
|
|
@ -93,20 +89,15 @@ public class UserInfoActivity extends BaseActivity<AcvtivitySettingUserInfoBindi
|
|||
finish();
|
||||
});
|
||||
binding.macQuery.setOnClickListener(view -> {
|
||||
Log.i("UserInfoActivity", "mac_query_keyword");
|
||||
EditText editText = findViewById(R.id.mac_query_keyword);
|
||||
String keyWord = editText.getText().toString();
|
||||
lists = new ArrayList<>();
|
||||
ThreadPoolManager.getExecutor().execute(()->{
|
||||
List<UserInfo> list = AppDatabase.getDatabase(this).userDao().getUserList();
|
||||
Log.i("UserInfoActivity", "lists size = " + list);
|
||||
List<UserInfo> newList = new ArrayList<>();
|
||||
newList = list.stream().filter(userInfo ->
|
||||
userInfo.getUserName().contains(keyWord)
|
||||
|| userInfo.getPhone().contains(keyWord)
|
||||
|| userInfo.getNickName().contains(keyWord)).collect(Collectors.toList());
|
||||
Log.i("UserInfoActivity", "newList size = " + newList.size());
|
||||
Log.i("UserInfoActivity", "list size = " + list.size());
|
||||
List<UserInfo> finalNewList = newList;
|
||||
runOnUiThread(()-> {
|
||||
adapter = new UserInfoAdapter(this, finalNewList);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.canteen.adapter.order;
|
||||
|
||||
import static com.xuexiang.xutil.XUtil.runOnUiThread;
|
||||
import static com.xuexiang.xutil.resource.ResUtils.getString;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
|
@ -15,6 +16,7 @@ import android.widget.TextView;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.canteen.activity.order.MachineSaleActivity;
|
||||
import com.bonus.canteen.constants.AppConstants;
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
import com.bonus.canteen.db.entity.base.CookMealTimesInfo;
|
||||
import com.bonus.canteen.db.entity.base.LoginInfo;
|
||||
|
|
@ -28,11 +30,13 @@ import com.bonus.canteen.utils.WorkConfig;
|
|||
import com.bonus.canteen.utils.sound.Sound;
|
||||
import com.bonus.canteen.utils.sound.SoundManager;
|
||||
import com.xuexiang.xui.utils.XToastUtils;
|
||||
import com.xuexiang.xui.widget.dialog.DialogLoader;
|
||||
|
||||
import org.easydarwin.easypusher.R;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -51,7 +55,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
|
||||
private OrderDetailsAdapter orderDetailsAdapter;
|
||||
|
||||
public OkHttpService service = new OkHttpService();
|
||||
public final OkHttpService service = new OkHttpService();
|
||||
|
||||
public OrderAdapter(Context ctx, List<OfflineOrderInfo> lst, OrderDetailsAdapter orderDetailsAdapter, List<OrderDetailsInfo> lstDetails) {
|
||||
super();
|
||||
|
|
@ -84,7 +88,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
return position;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@SuppressLint({"SetTextI18n", "InflateParams"})
|
||||
@Override
|
||||
public View getView(int i, View convertView, ViewGroup parent) {
|
||||
ViewHolder holder = null;
|
||||
|
|
@ -105,127 +109,50 @@ public class OrderAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
OfflineOrderInfo bean = list.get(i);
|
||||
holder.machineOrdId.setText(bean.getOrderId() + "");
|
||||
holder.machineOrderTime.setText(bean.getOrderTime() + "");
|
||||
holder.machinePersonName.setText(bean.getUserName() + "");
|
||||
holder.machineTotalAmount.setText(new BigDecimal(bean.getAmountDue()).divide(new BigDecimal(100)) + "");
|
||||
holder.machineRealAmount.setText(new BigDecimal(bean.getAmountDue()).divide(new BigDecimal(100)) + "");
|
||||
holder.machineOrdId.setText(bean.getOrderId());
|
||||
holder.machineOrderTime.setText(bean.getOrderTime());
|
||||
holder.machinePersonName.setText(bean.getUserName());
|
||||
holder.machineTotalAmount.setText(new BigDecimal(bean.getAmountDue()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) + "");
|
||||
holder.machineRealAmount.setText(new BigDecimal(bean.getAmountDue()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) + "");
|
||||
if ("1".equals(bean.getPayStatus())) {
|
||||
if ("1".equals(bean.getIsOnline())){
|
||||
if ("1".equals(bean.getIsOnline()) || "2".equals(bean.getIsOnline())) {
|
||||
holder.machineOrState.setText("【消费成功】");
|
||||
holder.machineOrState.setTextColor(Color.parseColor("#3CB371"));
|
||||
}else if ("0".equals(bean.getIsOnline())){
|
||||
holder.machineOrState.setText("【未支付】");
|
||||
} else if ("0".equals(bean.getIsOnline())) {
|
||||
holder.machineOrState.setText("【未扣费】");
|
||||
holder.machineOrState.setTextColor(Color.RED);
|
||||
}else if ("2".equals(bean.getIsOnline())){
|
||||
holder.machineOrState.setText("【消费成功】");
|
||||
holder.machineOrState.setTextColor(Color.parseColor("#3CB371"));
|
||||
}
|
||||
} else if ("4".equals(bean.getPayStatus())) {
|
||||
holder.machineOrState.setText("【已退单】");
|
||||
// 斜体
|
||||
holder.machineOrState.getPaint().setTextSkewX(-0.25f);
|
||||
// 加粗
|
||||
holder.machineOrState.getPaint().setFakeBoldText(true);
|
||||
//设置中划线
|
||||
holder.machineOrState.getPaint().setFlags(android.graphics.Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.machineOrState.setTextColor(Color.GRAY);
|
||||
holder.machineRefund.setVisibility(View.GONE);
|
||||
}
|
||||
holder.machineRefund.setOnClickListener(v -> {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
LoginInfo loginInfo = AppDatabase.getDatabase(context).loginInfoDao().getLoginInfoOne();
|
||||
if (ObjectUtil.isNull(loginInfo)) {
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_login));
|
||||
XToastUtils.warning("请先登录");
|
||||
});
|
||||
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())) {
|
||||
Log.d("getOrderTime", offlineOrderInfo.getOrderTime() + "");
|
||||
if (ObjectUtil.isNotNull(offlineOrderInfo.getOrderTime())){
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate + "");
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId());
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
});
|
||||
}else{
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
XToastUtils.error("当前暂未获取到餐次,请连线后在进行重试");
|
||||
});
|
||||
}
|
||||
|
||||
}else {
|
||||
//调用后台退单接口
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("deviceOrderId", bean.getOrderId());
|
||||
json.put("operationUser", loginInfo.getUserName());
|
||||
String jsonString = json.toString();
|
||||
Log.i("getPersonMessage jsonString", jsonString);
|
||||
// 定义 JSON 的 MediaType
|
||||
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
// 创建 RequestBody
|
||||
RequestBody body = RequestBody.create(JSON, jsonString);
|
||||
String url = WorkConfig.getBaseUrl() + UrlConfig.ORDER_REFUND;
|
||||
Request request = new Request.Builder().url(url)
|
||||
.post(body).build();
|
||||
String result = service.httpPost(url, body, context, request);
|
||||
Log.d("退单 result", result);
|
||||
if (ObjectUtil.isEmpty(result)) {
|
||||
runOnUiThread(() -> {
|
||||
XToastUtils.error("退单失败");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
});
|
||||
} else {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
Log.d("退单 firstJson", firstJson.toJSONString());
|
||||
if (firstJson.getIntValue("code") == 200) {
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId());
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate + "");
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
Log.d("退单", "在当天");
|
||||
//判断是否在当餐
|
||||
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMealTimesInfo.getIntervalId().equals(offlineOrderInfo.getIntervalId())) {
|
||||
Log.d("退单", "在当餐");
|
||||
//修改当餐数据
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateCurrent(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateToday(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
Log.d("退单", "更新UI");
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
});
|
||||
} else if (firstJson.getIntValue("code") == 500) {
|
||||
runOnUiThread(() -> {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
XToastUtils.error(firstJson.getString("msg"));
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(() -> {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
Log.d("退单", "出现错误进入catch");
|
||||
XToastUtils.error("退单失败");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String money = new BigDecimal(bean.getAmountDue()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) + "";
|
||||
sb.append("姓名:").append(bean.getUserName()).append("(金额:").append(money).append("元)");
|
||||
DialogLoader.getInstance().showConfirmDialog(context, "是否确认退单?\n"+sb, getString(R.string.lab_yes), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
LoginInfo loginInfo = AppDatabase.getDatabase(context).loginInfoDao().getLoginInfoOne();
|
||||
if (ObjectUtil.isNull(loginInfo)) {
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_login));
|
||||
XToastUtils.warning("请先登录");
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 进行退单操作
|
||||
refundOrder(bean, loginInfo, v);
|
||||
});
|
||||
}, getString(R.string.lab_no), (dialog, which) -> dialog.dismiss());
|
||||
});
|
||||
|
||||
holder.linearLayout.setOnClickListener(v -> {
|
||||
lstDetails = new ArrayList<>();
|
||||
|
|
@ -236,11 +163,125 @@ public class OrderAdapter extends BaseAdapter {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private void refundOrder(OfflineOrderInfo bean, LoginInfo loginInfo, View v) {
|
||||
runOnUiThread(() -> v.setVisibility(View.GONE));
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(bean.getOrderId());
|
||||
String money = new BigDecimal(offlineOrderInfo.getAmountDue()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) + "";
|
||||
if ("0".equals(offlineOrderInfo.getIsOnline())) {
|
||||
refundOffOnlineOrder(bean, loginInfo, offlineOrderInfo, money);
|
||||
} else {
|
||||
//调用后台退单接口
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("deviceOrderId", bean.getOrderId());
|
||||
json.put("operationUser", loginInfo.getUserName());
|
||||
String jsonString = json.toString();
|
||||
Log.i("getPersonMessage jsonString", jsonString);
|
||||
// 定义 JSON 的 MediaType
|
||||
MediaType mediaType = MediaType.parse(AppConstants.MEDIA_TYPE);
|
||||
// 创建 RequestBody
|
||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||
String url = WorkConfig.getBaseUrl() + UrlConfig.ORDER_REFUND;
|
||||
Request request = new Request.Builder().url(url).post(body).build();
|
||||
String result = service.httpPost(url, body, context, request);
|
||||
if (ObjectUtil.isEmpty(result)) {
|
||||
showToastError(v, "退单失败");
|
||||
} else {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
if (firstJson.getIntValue("code") == 200) {
|
||||
refundOnlineOrder(bean, loginInfo, offlineOrderInfo, money);
|
||||
} else if (firstJson.getIntValue("code") == 500) {
|
||||
showToastError(v, firstJson.getString("msg"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
showToastError(v, "退单失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理离线订单的退款逻辑
|
||||
*
|
||||
* @param bean 离线订单信息
|
||||
* @param loginInfo 登录信息
|
||||
* @param offlineOrderInfo 离线订单信息
|
||||
* @param money 退款金额
|
||||
*/
|
||||
private void refundOffOnlineOrder(OfflineOrderInfo bean, LoginInfo loginInfo, OfflineOrderInfo offlineOrderInfo, String money) {
|
||||
Log.d("getOrderTime", offlineOrderInfo.getOrderTime());
|
||||
if (ObjectUtil.isNotNull(offlineOrderInfo.getOrderTime())) {
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate);
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId(), loginInfo.getUserName());
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
});
|
||||
} else {
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
XToastUtils.error("当前暂未获取到餐次,请连线后在进行重试");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理在线订单的退款逻辑
|
||||
*
|
||||
* @param bean 离线订单信息
|
||||
* @param loginInfo 登录信息
|
||||
* @param offlineOrderInfo 离线订单信息
|
||||
* @param money 退款金额
|
||||
*/
|
||||
private void refundOnlineOrder(OfflineOrderInfo bean, LoginInfo loginInfo, OfflineOrderInfo offlineOrderInfo, String money) {
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId(), loginInfo.getUserName());
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate);
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
Log.d("退单", "在当天");
|
||||
if ("2".equals(offlineOrderInfo.getIsOnline())) {
|
||||
// 离线订单或在线订单
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
//判断是否在当餐
|
||||
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMealTimesInfo.getIntervalId().equals(offlineOrderInfo.getIntervalId())) {
|
||||
Log.d("退单", "在当餐");
|
||||
//修改当餐数据
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateCurrent(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateToday(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
Log.d("退单", "更新UI");
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示错误提示
|
||||
*
|
||||
* @param v 视图
|
||||
* @param msg 错误信息
|
||||
*/
|
||||
private static void showToastError(View v, String msg) {
|
||||
runOnUiThread(() -> {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
XToastUtils.error(msg);
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
});
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
LinearLayout linearLayout;
|
||||
|
|
|
|||
|
|
@ -1,29 +1,77 @@
|
|||
/*
|
||||
* Copyright (C) 2025 xuexiangjys(xuexiangjys@163.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bonus.canteen.constants;
|
||||
|
||||
public class AppConstants {
|
||||
public static final int PAY_TYPE_ACCOUNT = 1;
|
||||
public static final int PAY_MODE_FACE = 2;
|
||||
public static final int PAY_MODE_QRCODE = 3;
|
||||
public static final int ORDER_TYPE_DEVICE = 11;
|
||||
public static final String MEDIA_TYPE = "application/json; charset=utf-8";
|
||||
private AppConstants(){
|
||||
throw new UnsupportedOperationException("Utility class");
|
||||
}
|
||||
|
||||
public static final String MEDIA_TYPE = "application/json; charset=utf-8";
|
||||
public static final String BALANCE = "balance";
|
||||
public static final String SUCCESS = "success";
|
||||
public static final String FAIL = "fail";
|
||||
public static final String ERROR = "error";
|
||||
public static final String EMPTY = "";
|
||||
public static final String NULL = "null";
|
||||
public static final String COLON = ":";
|
||||
public static final String COMMA = ",";
|
||||
public static final String SPACE = " ";
|
||||
public static final String SLASH = "/";
|
||||
public static final String BACKSLASH = "\\";
|
||||
public static final String DOT = ".";
|
||||
public static final String UNDERLINE = "_";
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
public static final String ENCODING = "encoding";
|
||||
|
||||
//int数字常量开始
|
||||
public static final int ZERO = 0;
|
||||
public static final int ONE = 1;
|
||||
public static final int TWO = 2;
|
||||
public static final int THREE = 3;
|
||||
public static final int FOUR = 4;
|
||||
public static final int FIVE = 5;
|
||||
public static final int SIX = 6;
|
||||
public static final int SEVEN = 7;
|
||||
public static final int EIGHT = 8;
|
||||
public static final int NINE = 9;
|
||||
public static final int TEN = 10;
|
||||
public static final int ELEVEN = 11;
|
||||
public static final int TWELVE = 12;
|
||||
public static final int THIRTEEN = 13;
|
||||
public static final int FOURTEEN = 14;
|
||||
public static final int FIFTEEN = 15;
|
||||
public static final int SIXTEEN = 16;
|
||||
public static final int SEVENTEEN = 17;
|
||||
public static final int EIGHTEEN = 18;
|
||||
public static final int NINETEEN = 19;
|
||||
public static final int TWENTY = 20;
|
||||
public static final int HUNDRED = 100;
|
||||
public static final int THOUSAND = 1000;
|
||||
//int数字常量结束
|
||||
|
||||
//字符串数字常量开始
|
||||
public static final String ZERO_STR = "0";
|
||||
public static final String ONE_STR = "1";
|
||||
public static final String TWO_STR = "2";
|
||||
public static final String THREE_STR = "3";
|
||||
public static final String FOUR_STR = "4";
|
||||
public static final String FIVE_STR = "5";
|
||||
public static final String SIX_STR = "6";
|
||||
public static final String SEVEN_STR = "7";
|
||||
public static final String EIGHT_STR = "8";
|
||||
public static final String NINE_STR = "9";
|
||||
public static final String TEN_STR = "10";
|
||||
public static final String ELEVEN_STR = "11";
|
||||
public static final String TWELVE_STR = "12";
|
||||
public static final String THIRTEEN_STR = "13";
|
||||
public static final String FOURTEEN_STR = "14";
|
||||
public static final String FIFTEEN_STR = "15";
|
||||
public static final String SIXTEEN_STR = "16";
|
||||
public static final String SEVENTEEN_STR = "17";
|
||||
public static final String EIGHTEEN_STR = "18";
|
||||
public static final String NINETEEN_STR = "19";
|
||||
public static final String TWENTY_STR = "20";
|
||||
public static final String HUNDRED_STR = "100";
|
||||
public static final String THOUSAND_STR = "1000";
|
||||
//字符串数字常量结束
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ public interface BusinessDataInfoDao {
|
|||
@Update
|
||||
void update(BusinessDataInfo businessDataInfo); // 更新数据
|
||||
@Query("update business_data_info set offlineMoney = offlineMoney - :money,offlineOrderNum = offlineOrderNum - :orderNum where orderDate = :date")
|
||||
void updateOffLine(String money,String orderNum,String date); // 更新数据
|
||||
void updateOffLine(String money,String orderNum,String date); // 更新离线数据
|
||||
@Query("update business_data_info set todayMoney = todayMoney - :money,todayOrderNum = todayOrderNum - :orderNum where orderDate = :date")
|
||||
void updateToday(String money,String orderNum,String date); // 更新数据
|
||||
void updateToday(String money,String orderNum,String date); // 更新当天数据
|
||||
@Query("update business_data_info set currentMoney = currentMoney - :money,currentOrderNum = currentOrderNum - :orderNum where orderDate = :date")
|
||||
void updateCurrent(String money,String orderNum,String date); // 更新数据
|
||||
void updateCurrent(String money,String orderNum,String date); // 更新当餐数据
|
||||
|
||||
@Delete
|
||||
void delete(BusinessDataInfo businessDataInfo); // 删除数据
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ public interface OfflineOrderInfoDao {
|
|||
@Query("select * from offline_order_info where orderId=:orderId")
|
||||
OfflineOrderInfo getOfflineOrderById(String orderId);
|
||||
|
||||
@Query("select * from offline_order_info where (isOnline = 0 or isOnline = 2) and strftime('%Y-%m-%d', orderTime) = :data")
|
||||
@Query("select * from offline_order_info where (isOnline = 0 or isOnline = 2) and strftime('%Y-%m-%d', orderTime) = :data order by orderId desc")
|
||||
List<OfflineOrderInfo> getOfflineOrder(String data);
|
||||
@Query("select * from offline_order_info where isOnline = 0 and payStatus = 1")
|
||||
@Query("select * from offline_order_info where isOnline = 0 and payStatus = 1 order by orderId desc")
|
||||
List<OfflineOrderInfo> getOfflineOrderAndToPush();
|
||||
@Query("select * from offline_order_info where isOnline = 1 and strftime('%Y-%m-%d', orderTime) = :data")
|
||||
@Query("select * from offline_order_info where isOnline = 1 and strftime('%Y-%m-%d', orderTime) = :data order by orderId desc")
|
||||
List<OfflineOrderInfo> getInlineOrder(String data);
|
||||
@Query("select * from offline_order_info where strftime('%Y-%m-%d', orderTime) = :data")
|
||||
@Query("select * from offline_order_info where strftime('%Y-%m-%d', orderTime) = :data order by orderId desc")
|
||||
List<OfflineOrderInfo> getOrderList(String data);
|
||||
|
||||
@Insert
|
||||
|
|
@ -47,8 +47,8 @@ public interface OfflineOrderInfoDao {
|
|||
void update(OfflineOrderInfo meal); // 更新数据
|
||||
@Query("update offline_order_info set isOnline=:isOnline where orderId = :orderId")
|
||||
void updateIsOnline(String isOnline,String orderId); // 更新数据
|
||||
@Query("update offline_order_info set payStatus=:payStatus where orderId = :orderId")
|
||||
void updatePayStatus(String payStatus,String orderId); // 更新数据
|
||||
@Query("update offline_order_info set payStatus=:payStatus,refundOperator =:userName where orderId = :orderId")
|
||||
void updatePayStatus(String payStatus,String orderId,String userName); // 更新数据
|
||||
|
||||
@Delete
|
||||
void delete(OfflineOrderInfo meal); // 删除数据
|
||||
|
|
|
|||
|
|
@ -48,10 +48,19 @@ public class OfflineOrderInfo {
|
|||
private String isOnline; //0: 离线-已消费,未推送,1:在线消费成功 2:离线-推送成功
|
||||
@ColumnInfo
|
||||
private String intervalId;
|
||||
|
||||
@ColumnInfo
|
||||
private String refundOperator; //退款操作人
|
||||
@ColumnInfo
|
||||
private String jsonStr;
|
||||
|
||||
public String getRefundOperator() {
|
||||
return refundOperator;
|
||||
}
|
||||
|
||||
public void setRefundOperator(String refundOperator) {
|
||||
this.refundOperator = refundOperator;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.upgrade;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ public class UpdateDown {
|
|||
}
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
private Handler handler = new Handler() {
|
||||
private final Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 1) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import com.bonus.canteen.SmartCanteenApp;
|
|||
import com.bonus.canteen.db.ConfigRepository;
|
||||
|
||||
public class WorkConfig {
|
||||
private WorkConfig() {
|
||||
throw new UnsupportedOperationException("Cannot instantiate utility class");
|
||||
}
|
||||
//本地
|
||||
// protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
|
||||
// protected static String prefixesUrl = "http://192.168.0.34:48380";
|
||||
|
|
|
|||
|
|
@ -249,9 +249,16 @@ public class RabbitMqMqttHelper {
|
|||
try {
|
||||
if (json.getIntValue(field) > 0 && desc.equals("人员照片")) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
service.getFacePhoto(json.getString("currentTime"), json.getIntValue(UPDATE_PERSON));
|
||||
runOnUiThread(() -> FaceServer.getInstance().loadFace(context));
|
||||
if (json.getString("type").equals("del")) {
|
||||
int userId = json.getIntValue(field);
|
||||
Log.d(TAG, "userId: " + userId);
|
||||
AppDatabase.getDatabase(context).userDao().delete(new UserInfo(Long.parseLong(String.valueOf(userId))));
|
||||
AppDatabase.getDatabase(context).custPhotoFulDao().delete(new CustPhotoFulInfo(Long.parseLong(String.valueOf(userId))));
|
||||
} else {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
service.getFacePhoto(json.getString("currentTime"), json.getIntValue(UPDATE_PERSON));
|
||||
runOnUiThread(() -> FaceServer.getInstance().loadFace(context));
|
||||
}
|
||||
});
|
||||
} else if (json.getIntValue(field) > 0 && desc.equals("人员信息")) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
|
|
@ -272,6 +279,7 @@ public class RabbitMqMqttHelper {
|
|||
}
|
||||
|
||||
private void handleDeviceUpdateInfo(JSONObject json) {
|
||||
Log.d(TAG, "设备更新信息: " + json.toJSONString());
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
service.getDeviceBase();
|
||||
|
|
@ -282,7 +290,7 @@ public class RabbitMqMqttHelper {
|
|||
if (!StringUtils.isEmpty(orderId)) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(orderId);
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", orderId);
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", orderId,"后台操作");
|
||||
String money = new BigDecimal(offlineOrderInfo.getAmountDue()).divide(new BigDecimal(100),2, RoundingMode.HALF_UP) + "";
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate);
|
||||
|
|
|
|||
|
|
@ -100,11 +100,21 @@
|
|||
android:layout_height="50dp"
|
||||
android:layout_marginTop="@dimen/config_margin_10dp"
|
||||
android:layout_marginLeft="@dimen/config_margin_20dp"
|
||||
android:layout_marginRight="@dimen/config_margin_20dp"
|
||||
android:layout_marginRight="@dimen/config_margin_10dp"
|
||||
android:text="查询"
|
||||
android:id="@+id/mac_query"
|
||||
android:background="@drawable/btn_border_yes_bg"
|
||||
/>
|
||||
<Button
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="@dimen/config_margin_10dp"
|
||||
android:layout_marginStart="@dimen/config_margin_10dp"
|
||||
android:layout_marginEnd="@dimen/config_margin_20dp"
|
||||
android:text="重置"
|
||||
android:id="@+id/mac_reset"
|
||||
android:background="@drawable/btn_border_yes_bg"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue