部分退款
This commit is contained in:
parent
87ee1333de
commit
1f587d2d93
|
|
@ -329,6 +329,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
json.put("placeDate", DateTimeHelper.getNowDate());
|
||||
json.put("sourceType", 20);
|
||||
json.put("payType", 1);
|
||||
json.put("refundAmount", 0);
|
||||
json.put("orderList", orderList);
|
||||
return json;
|
||||
}
|
||||
|
|
@ -359,6 +360,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
offlineOrderInfo.setNum(num.toString());
|
||||
offlineOrderInfo.setIsOnline("0");
|
||||
offlineOrderInfo.setPayStatus("1");
|
||||
offlineOrderInfo.setRefundAmount("0");
|
||||
offlineOrderInfo.setRefundNum("0");
|
||||
offlineOrderInfo.setIntervalId(cookMealTimesInfo.getIntervalId());
|
||||
offlineOrderInfo.setJsonStr(jsonString);
|
||||
return offlineOrderInfo;
|
||||
|
|
@ -544,6 +547,10 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
orderDetailList.add(orderDetailPayDTO);
|
||||
OrderDetailsInfo orderDetailsInfo = new OrderDetailsInfo();
|
||||
orderDetailsInfo.setOrderId(orderId);
|
||||
orderDetailsInfo.setGoodsDishesId(bean.getId());
|
||||
orderDetailsInfo.setStatus("0");
|
||||
orderDetailsInfo.setRefundNum("0");
|
||||
orderDetailsInfo.setRefundMoney("0");
|
||||
orderDetailsInfo.setGoodsDishesName(isKeyBoard ? "按键金额" : cookMealInfo.getProductName());
|
||||
orderDetailsInfo.setNum(String.valueOf(bean.getNum()));
|
||||
orderDetailsInfo.setPrice(String.valueOf(bean.getPrice()));
|
||||
|
|
|
|||
|
|
@ -143,11 +143,12 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
}
|
||||
public void refreshData(){
|
||||
initData(null,null,type);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
XToastUtils.success("退单成功!");
|
||||
}
|
||||
private void initData(String keyWord,String data,Integer type){
|
||||
lstDetails.clear();
|
||||
if (data == null){
|
||||
if (data == null || data.isEmpty()) {
|
||||
data = DateTimeHelper.getNowDate();
|
||||
}
|
||||
String finalData = data;
|
||||
|
|
@ -213,11 +214,14 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
TextView tvMachineAllMoney = findViewById(R.id.machine_all_money);
|
||||
TextView tvMachineDiscountMoney = findViewById(R.id.machine_discount_money);
|
||||
TextView tvMachineRealMoney = findViewById(R.id.machine_real_money);
|
||||
|
||||
tvMachineUnit.setText(bean.getNum());
|
||||
tvMachineAllMoney.setText(Utils.conversionMoney(bean.getAmountDue())+" 元");
|
||||
tvMachineDiscountMoney.setText(Utils.conversionMoney(bean.getDiscountAmount())+" 元");
|
||||
tvMachineRealMoney.setText(Utils.conversionMoney(bean.getAmountDue())+" 元");
|
||||
TextView tvRefundNum = findViewById(R.id.refund_unit);
|
||||
TextView tvRefundMoney = findViewById(R.id.refund_money);
|
||||
tvMachineUnit.setText(Utils.conversionMoney(bean.getNum(),false));
|
||||
tvMachineAllMoney.setText(Utils.conversionMoney(bean.getAmountDue(),true)+" 元");
|
||||
tvMachineDiscountMoney.setText(Utils.conversionMoney(bean.getDiscountAmount(),true)+" 元");
|
||||
tvMachineRealMoney.setText(Utils.conversionMoney(bean.getAmountDue(),true)+" 元");
|
||||
tvRefundNum.setText(Utils.conversionMoney(bean.getRefundNum(),false));
|
||||
tvRefundMoney.setText(bean.getRefundAmount()+" 元");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +253,7 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
findViewById(R.id.mac_make_all).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 1;
|
||||
initData(keyWord,data,1);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
break;
|
||||
case R.id.mac_inline:
|
||||
// 处理 button3 被点击的逻辑
|
||||
|
|
@ -256,6 +261,7 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
findViewById(R.id.mac_inline).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 2;
|
||||
initData(keyWord,data,2);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
break;
|
||||
case R.id.mac_hold_receive:
|
||||
// 处理 button3 被点击的逻辑
|
||||
|
|
@ -263,6 +269,7 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
findViewById(R.id.mac_hold_receive).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 3;
|
||||
initData(keyWord,data,3);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
break;
|
||||
case R.id.mac_already_receive:
|
||||
// 处理 button3 被点击的逻辑
|
||||
|
|
@ -270,6 +277,7 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
findViewById(R.id.mac_already_receive).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 4;
|
||||
initData(keyWord,data,4);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
break;
|
||||
case R.id.mac_offline:
|
||||
// 处理 button3 被点击的逻辑
|
||||
|
|
@ -277,6 +285,7 @@ public class MachineSaleActivity extends BaseActivity<MachineSaleOrderMainBindi
|
|||
findViewById(R.id.mac_offline).setBackgroundResource(R.drawable.btn_border_yes_bg);
|
||||
type = 6;
|
||||
initData(keyWord,data,6);
|
||||
updateDate(new ArrayList<>(), new OfflineOrderInfo());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
holder.machineRealAmount = convertView.findViewById(R.id.machine_real_amount);
|
||||
holder.machineOrState = convertView.findViewById(R.id.machine_ord_state);
|
||||
holder.machineRefund = convertView.findViewById(R.id.machine_refund);
|
||||
holder.refundAmount = convertView.findViewById(R.id.refund_amount);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
|
|
@ -114,6 +115,8 @@ public class OrderAdapter extends BaseAdapter {
|
|||
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) + "");
|
||||
holder.refundAmount.setText(bean.getRefundAmount());
|
||||
|
||||
if ("1".equals(bean.getPayStatus())) {
|
||||
if ("1".equals(bean.getIsOnline()) || "2".equals(bean.getIsOnline())) {
|
||||
holder.machineOrState.setText("【消费成功】");
|
||||
|
|
@ -122,8 +125,15 @@ public class OrderAdapter extends BaseAdapter {
|
|||
holder.machineOrState.setText("【未扣费】");
|
||||
holder.machineOrState.setTextColor(Color.RED);
|
||||
}
|
||||
} else if ("4".equals(bean.getPayStatus())) {
|
||||
} else if ("4".equals(bean.getPayStatus()) || "5".equals(bean.getPayStatus())) {
|
||||
holder.machineOrState.setText("【已退单】");
|
||||
if ("5".equals(bean.getPayStatus())) {
|
||||
if (bean.getRefundNum().equals(bean.getNum())){
|
||||
holder.machineOrState.setText("【全退款】");
|
||||
} else {
|
||||
holder.machineOrState.setText("【部分退款】");
|
||||
}
|
||||
}
|
||||
// 斜体
|
||||
holder.machineOrState.getPaint().setTextSkewX(-0.25f);
|
||||
// 加粗
|
||||
|
|
@ -220,6 +230,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId(), loginInfo.getUserName());
|
||||
AppDatabase.getDatabase(context).orderDetailsDao().updateStatus("1", bean.getOrderId());
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
|
|
@ -243,6 +254,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
*/
|
||||
private void refundOnlineOrder(OfflineOrderInfo bean, LoginInfo loginInfo, OfflineOrderInfo offlineOrderInfo, String money) {
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId(), loginInfo.getUserName());
|
||||
AppDatabase.getDatabase(context).orderDetailsDao().updateStatus("1", bean.getOrderId());
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate);
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
|
|
@ -291,6 +303,7 @@ public class OrderAdapter extends BaseAdapter {
|
|||
TextView machinePersonName;
|
||||
TextView machineTotalAmount;
|
||||
TextView machineRealAmount;
|
||||
TextView refundAmount;
|
||||
TextView machineOrState;
|
||||
TextView machineDeliveryState;
|
||||
TextView machineRefund;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.canteen.adapter.order;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -58,6 +59,7 @@ public class OrderDetailsAdapter extends BaseAdapter {
|
|||
holder.quantity = convertView.findViewById(R.id.machine_dish_quantity);
|
||||
holder.price = convertView.findViewById(R.id.machine_dish_price);
|
||||
holder.menuDetailId = convertView.findViewById(R.id.machine_dish_menu_detailId);
|
||||
holder.status = convertView.findViewById(R.id.machine_dish_status);
|
||||
convertView.setTag(holder);
|
||||
}else {
|
||||
holder = (ViewHolder)convertView.getTag();
|
||||
|
|
@ -69,6 +71,26 @@ public class OrderDetailsAdapter extends BaseAdapter {
|
|||
holder.quantity.setText(bean.getNum()+"");
|
||||
holder.price.setText(bean.getPrice()+"");
|
||||
holder.menuDetailId.setText(bean.getSubTotal());
|
||||
if ("0".equals(bean.getStatus())) {
|
||||
holder.status.setText("已付款");
|
||||
holder.status.setTextColor(Color.parseColor("#3CB371"));
|
||||
} else if ("1".equals(bean.getStatus()) || "2".equals(bean.getStatus())) {
|
||||
holder.status.setText("已退款");
|
||||
if ("2".equals(bean.getStatus())) {
|
||||
if (!bean.getRefundNum().equals(bean.getNum())){
|
||||
holder.status.setText("部分退款");
|
||||
}else{
|
||||
holder.status.setText("全退款");
|
||||
}
|
||||
}
|
||||
// 斜体
|
||||
holder.status.getPaint().setTextSkewX(-0.25f);
|
||||
// 加粗
|
||||
holder.status.getPaint().setFakeBoldText(true);
|
||||
//设置中划线
|
||||
holder.status.getPaint().setFlags(android.graphics.Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.status.setTextColor(Color.GRAY);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +99,7 @@ public class OrderDetailsAdapter extends BaseAdapter {
|
|||
TextView quantity;
|
||||
TextView price;
|
||||
TextView menuDetailId;
|
||||
TextView status;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.adapter.order.entity;
|
||||
|
||||
public class RefundDetailsBean {
|
||||
private Long goodsId;
|
||||
private Integer quantity;
|
||||
|
||||
public Long getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public void setGoodsId(Long goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,8 +47,10 @@ 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,refundOperator =:userName where orderId = :orderId")
|
||||
@Query("update offline_order_info set payStatus=:payStatus,refundOperator =:userName,refundNum = num,refundAmount = amountDue,refundTime = CURRENT_TIMESTAMP where orderId = :orderId")
|
||||
void updatePayStatus(String payStatus,String orderId,String userName); // 更新数据
|
||||
@Query("update offline_order_info set payStatus=:payStatus,refundOperator =:userName,refundNum = :num+refundNum,refundAmount = :amountDue+refundAmount,refundTime = CURRENT_TIMESTAMP where orderId = :orderId")
|
||||
void updatePayStatusAndRefundInfo(String payStatus,String orderId,String userName,String num,String amountDue ); // 更新数据
|
||||
|
||||
@Delete
|
||||
void delete(OfflineOrderInfo meal); // 删除数据
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ public interface OrderDetailsDao {
|
|||
|
||||
@Query("select * from order_details_info where orderId =:orderId")
|
||||
List<OrderDetailsInfo> getOrderInfoListByOrderId(String orderId);
|
||||
@Query("select * from order_details_info where orderId =:orderId and goodsDishesId =:goodsDishesId")
|
||||
OrderDetailsInfo getOrderInfoListByOrderId(String orderId, String goodsDishesId);
|
||||
|
||||
@Insert
|
||||
void insert(OrderDetailsInfo orderInfo); // 插入数据
|
||||
|
|
@ -36,4 +38,8 @@ public interface OrderDetailsDao {
|
|||
@Query("delete from order_details_info")
|
||||
void deleteAll(); // 删除数据
|
||||
|
||||
@Query("update order_details_info set refundNum=num,refundMoney = subTotal,status = :status where orderId = :orderId")
|
||||
void updateStatus(String status, String orderId);
|
||||
@Query("update order_details_info set refundNum=:num + refundNum,refundMoney = :subTotal + refundMoney,status = :status where orderId = :orderId and goodsDishesId = :goodsDishesId")
|
||||
void updateStatusAndRefundInfo(String status, String orderId,String num, String subTotal,String goodsDishesId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class OfflineOrderInfo {
|
|||
@ColumnInfo
|
||||
private String num;
|
||||
@ColumnInfo
|
||||
private String payStatus;
|
||||
private String payStatus; //0:未支付 1:已支付 4:已退款 5:部分退款
|
||||
@ColumnInfo
|
||||
private String isOnline; //0: 离线-已消费,未推送,1:在线消费成功 2:离线-推送成功
|
||||
@ColumnInfo
|
||||
|
|
@ -53,6 +53,37 @@ public class OfflineOrderInfo {
|
|||
@ColumnInfo
|
||||
private String jsonStr;
|
||||
|
||||
@ColumnInfo
|
||||
private String refundTime; //退款时间
|
||||
@ColumnInfo
|
||||
private String refundAmount; //退款金额
|
||||
@ColumnInfo
|
||||
private String refundNum; //退单数量
|
||||
|
||||
public String getRefundTime() {
|
||||
return refundTime;
|
||||
}
|
||||
|
||||
public void setRefundTime(String refundTime) {
|
||||
this.refundTime = refundTime;
|
||||
}
|
||||
|
||||
public String getRefundAmount() {
|
||||
return refundAmount;
|
||||
}
|
||||
|
||||
public void setRefundAmount(String refundAmount) {
|
||||
this.refundAmount = refundAmount;
|
||||
}
|
||||
|
||||
public String getRefundNum() {
|
||||
return refundNum;
|
||||
}
|
||||
|
||||
public void setRefundNum(String refundNum) {
|
||||
this.refundNum = refundNum;
|
||||
}
|
||||
|
||||
public String getRefundOperator() {
|
||||
return refundOperator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ public class OrderDetailsInfo {
|
|||
|
||||
@ColumnInfo
|
||||
private String orderId;
|
||||
|
||||
@ColumnInfo
|
||||
private String goodsDishesId;//菜品id
|
||||
@ColumnInfo
|
||||
private String goodsDishesName;//菜品名称
|
||||
|
||||
|
|
@ -24,6 +25,43 @@ public class OrderDetailsInfo {
|
|||
|
||||
@ColumnInfo
|
||||
private String subTotal;
|
||||
@ColumnInfo
|
||||
private String refundNum;//退款数量
|
||||
@ColumnInfo
|
||||
private String refundMoney;//退款金额
|
||||
@ColumnInfo
|
||||
private String status;//状态 0:未退款 1:已退款 2:部分退款
|
||||
public String getRefundNum() {
|
||||
return refundNum;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setRefundNum(String refundNum) {
|
||||
this.refundNum = refundNum;
|
||||
}
|
||||
|
||||
public String getRefundMoney() {
|
||||
return refundMoney;
|
||||
}
|
||||
|
||||
public void setRefundMoney(String refundMoney) {
|
||||
this.refundMoney = refundMoney;
|
||||
}
|
||||
|
||||
public String getGoodsDishesId() {
|
||||
return goodsDishesId;
|
||||
}
|
||||
|
||||
public void setGoodsDishesId(String goodsDishesId) {
|
||||
this.goodsDishesId = goodsDishesId;
|
||||
}
|
||||
|
||||
public String getSubTotal() {
|
||||
return subTotal;
|
||||
|
|
|
|||
|
|
@ -96,8 +96,7 @@ public class UpLoadDataService extends Service {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
builder.setChannelId(notificationId);
|
||||
}
|
||||
Notification notification = builder.build();
|
||||
return notification;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -64,9 +64,12 @@ public final class Utils {
|
|||
|
||||
|
||||
|
||||
public static String conversionMoney(String money){
|
||||
public static String conversionMoney(String money,boolean isMoney){
|
||||
if(StringHelper.isEmpty(money)){
|
||||
return "-1";
|
||||
return "0";
|
||||
}
|
||||
if (!isMoney){
|
||||
return money;
|
||||
}
|
||||
BigDecimal bigDecimalDiscount = new BigDecimal(money);
|
||||
BigDecimal result = bigDecimalDiscount.divide(BigDecimal.valueOf(100));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ 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://192.168.0.34:48380/smart-canteen";
|
||||
protected static String baseUrl = "http://192.168.0.244:48380/smart-canteen";
|
||||
protected static String prefixesUrl = "http://192.168.0.34:48380";
|
||||
protected static String fileUrl = "http://192.168.0.244:48380/lnyst/";
|
||||
protected static String updateUrl = "https://www.baidu.com";
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ import android.util.Log;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.canteen.adapter.order.entity.RefundDetailsBean;
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
import com.bonus.canteen.db.entity.base.BusinessDataInfo;
|
||||
import com.bonus.canteen.db.entity.base.CookMealTimesInfo;
|
||||
import com.bonus.canteen.db.entity.base.CustPhotoFulInfo;
|
||||
import com.bonus.canteen.db.entity.base.OfflineOrderInfo;
|
||||
import com.bonus.canteen.db.entity.base.OrderDetailsInfo;
|
||||
import com.bonus.canteen.db.entity.base.UserInfo;
|
||||
import com.bonus.canteen.face.util.FaceServer;
|
||||
import com.bonus.canteen.service.data.GetBasicDataService;
|
||||
|
|
@ -38,6 +40,7 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
|
|
@ -287,25 +290,79 @@ public class RabbitMqMqttHelper {
|
|||
}
|
||||
private void handleOrderStateUpdate(JSONObject json) {
|
||||
String orderId = json.getString("deviceOrderId");
|
||||
String type = json.getString("type");
|
||||
if (!StringUtils.isEmpty(orderId)) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(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);
|
||||
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());
|
||||
if ("1".equals(type)){
|
||||
cancelTheOrderAsAWhole(orderId);
|
||||
}else{
|
||||
//部分退单 处理单个订单
|
||||
Log.e(TAG, "部分退单处理:" + json.toJSONString());
|
||||
String orderDetailsList = json.getString("deviceRefundOrderDetailBOList");
|
||||
if (!StringUtils.isEmpty(orderDetailsList)) {
|
||||
partialOrderCancellations(orderDetailsList, orderId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 取消整个订单
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
private void cancelTheOrderAsAWhole(String orderId) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(orderId);
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", orderId,"后台操作");
|
||||
AppDatabase.getDatabase(context).orderDetailsDao().updateStatus("1", 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);
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
Log.d("退单", "在当天");
|
||||
//判断是否在当餐
|
||||
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMealTimesInfo != null && 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());
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 处理部分退单
|
||||
* @param orderDetailsList 订单详情列表
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
private void partialOrderCancellations(String orderDetailsList, String orderId) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
try {
|
||||
List<RefundDetailsBean> refundDetailsBeans = JSON.parseArray(orderDetailsList, RefundDetailsBean.class);
|
||||
int refundNumber = 0;
|
||||
BigDecimal refundMoney = BigDecimal.ZERO;
|
||||
for (RefundDetailsBean refundDetailsBean : refundDetailsBeans) {
|
||||
String dishesId = String.valueOf(refundDetailsBean.getGoodsId());
|
||||
int refundNum = refundDetailsBean.getQuantity();
|
||||
refundNumber += refundNum;
|
||||
OrderDetailsInfo orderDetailsInfo = AppDatabase.getDatabase(context)
|
||||
.orderDetailsDao().getOrderInfoListByOrderId(orderId, dishesId);
|
||||
if (orderDetailsInfo != null) {
|
||||
BigDecimal price = new BigDecimal(orderDetailsInfo.getPrice());
|
||||
BigDecimal money = price.multiply(BigDecimal.valueOf(refundNum)).setScale(2, RoundingMode.HALF_UP);
|
||||
refundMoney = refundMoney.add(money);
|
||||
// 更新订单详情状态
|
||||
AppDatabase.getDatabase(context).orderDetailsDao()
|
||||
.updateStatusAndRefundInfo("2", orderId, String.valueOf(refundNum), money.toString(),dishesId);
|
||||
} else {
|
||||
Log.w(TAG, "未找到订单详情,dishesId: " + dishesId);
|
||||
}
|
||||
}
|
||||
// 更新订单状态
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatusAndRefundInfo("5", orderId, "后台操作",refundNumber + "",refundMoney + "");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "处理部分退单异常", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@
|
|||
android:layout_height="match_parent"
|
||||
android:text="@string/machine_real_amount"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/config_margin_20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/refund_amount"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
|
@ -72,7 +80,7 @@
|
|||
/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/config_margin_20dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,14 @@
|
|||
android:textSize="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/refund_amount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<HorizontalScrollView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -84,7 +92,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:id="@+id/machine_refund"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:layout_weight="1.5"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="@string/machine_dish"
|
||||
android:textSize="@dimen/config_margin_20dp" />
|
||||
|
|
@ -40,6 +40,13 @@
|
|||
android:gravity="center"
|
||||
android:text="@string/machine_dish_count"
|
||||
android:textSize="@dimen/config_margin_20dp" />
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="状态"
|
||||
android:textSize="@dimen/config_margin_20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -52,7 +59,7 @@
|
|||
android:id="@+id/machine_right_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="10"></ListView>
|
||||
android:layout_weight="8"></ListView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -118,6 +125,64 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/config_margin_40dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="@dimen/config_margin_40dp"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/refund_num" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/refund_unit"
|
||||
android:layout_width="30dp"
|
||||
android:gravity="center"
|
||||
android:textSize="22sp"
|
||||
android:layout_height="@dimen/config_margin_40dp"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/refund_unit_name"
|
||||
android:layout_width="20dp"
|
||||
android:gravity="center"
|
||||
android:textSize="22sp"
|
||||
android:layout_height="@dimen/config_margin_40dp"
|
||||
android:text="@string/machine_unit" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="@dimen/config_margin_40dp"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/refund_money" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/refund_money"
|
||||
android:layout_width="100dp"
|
||||
android:gravity="center"
|
||||
android:textSize="22sp"
|
||||
android:layout_height="@dimen/config_margin_40dp"
|
||||
android:text="0.00元" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
|
@ -130,7 +195,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/btn_border_no_bg"
|
||||
android:gravity="center"
|
||||
|
|
@ -159,7 +224,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/btn_border_yes_bg"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<TextView
|
||||
android:id="@+id/machine_dish_good_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_weight="1.5"
|
||||
android:textSize="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -44,6 +44,14 @@
|
|||
android:textSize="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/machine_dish_status"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -117,6 +117,7 @@
|
|||
<string name="machine_mobile">手机号</string>
|
||||
<string name="machine_total_amount">应付金额</string>
|
||||
<string name="machine_real_amount">实付金额</string>
|
||||
<string name="refund_amount">退单金额</string>
|
||||
<string name="machine_mac_ord_id">叫号码</string>
|
||||
<string name="machine_ord_state">订单状态</string>
|
||||
<string name="machine_delivery_state">制作状态</string>
|
||||
|
|
@ -128,8 +129,10 @@
|
|||
<string name="machine_dish_price">单价</string>
|
||||
<string name="machine_dish_count">小计</string>
|
||||
<string name="machine_all_num">总数量:</string>
|
||||
<string name="refund_num">退单数:</string>
|
||||
<string name="machine_unit">份</string>
|
||||
<string name="machine_all_money">总金额:</string>
|
||||
<string name="refund_money">退单金额:</string>
|
||||
<string name="machine_discount_money">优惠金额</string>
|
||||
|
||||
<string name="machine_query_keyword">请输入姓名</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue