sync_pay_state

This commit is contained in:
sxu 2025-02-20 18:35:41 +08:00
parent f921ed90d5
commit bf458de8ef
6 changed files with 232 additions and 58 deletions

View File

@ -0,0 +1,11 @@
package com.bonus.core.order.android.business;
import com.bonus.core.order.common.model.OrderInfo;
import java.time.LocalDate;
import java.util.List;
public interface OrderDishesAndroidBusiness {
void initOrderMealCode(OrderInfo orderInfo);
}

View File

@ -0,0 +1,67 @@
package com.bonus.core.order.android.business.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.core.allocation.canteen.model.AllocStall;
import com.bonus.core.customer.constants.OrderTypeEnum;
import com.bonus.core.order.android.business.OrderDishesAndroidBusiness;
import com.bonus.core.order.common.model.OrderInfo;
import com.bonus.core.order.custom.OrderCustomBusiness;
import com.bonus.core.order.utils.LeNumUtil;
import com.bonus.core.supermarket.model.SupermarketInfo;
import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class OrderDishesAndroidBusinessImpl implements OrderDishesAndroidBusiness {
private static final Logger log = LoggerFactory.getLogger(OrderDishesAndroidBusinessImpl.class);
@Autowired
@Lazy
protected OrderCustomBusiness orderCustomBusiness;
public void initOrderMealCode(OrderInfo orderInfo) {
if (!CharSequenceUtil.isNotEmpty(orderInfo.getMealCode())) {
String mealCode = this.createMealCode(orderInfo.getOrderType(), orderInfo.getCanteenId(), orderInfo.getStallId(), orderInfo.getOrderDate(), orderInfo.getMealtimeType());
orderInfo.setMealCode(mealCode);
}
}
public String createMealCode(Integer orderType, Long canteenId, Long stallId, LocalDate orderDate, Integer mealtimeType) {
String mealCode = this.orderCustomBusiness.android().willCreateOrderMealCode(canteenId, stallId, orderDate, mealtimeType);
if (CharSequenceUtil.isNotEmpty(mealCode)) {
return this.orderCustomBusiness.android().didCreateOrderMealCode(canteenId, stallId, orderDate, mealtimeType, mealCode);
} else {
String prefix = null;
if (OrderTypeEnum.isShopCategory(orderType)) {
SupermarketInfo supermarketInfoById = this.supermarketApi.getSupermarketInfoById(canteenId);
prefix = supermarketInfoById != null ? supermarketInfoById.getMealCode() : "";
} else if (OrderTypeEnum.isCanteenCategory(orderType) && LeNumUtil.isValidId(stallId)) {
AllocStall allocStall = this.allocStallApi.getAllocStall(stallId);
if (allocStall != null) {
prefix = OrderTypeEnum.isAndroidCategory(orderType) ? allocStall.getOffLineMealCodePrefix() : allocStall.getOnLineMealCodePrefix();
}
}
mealCode = this.numUtil.getMealCode(prefix, canteenId, stallId, orderDate, mealtimeType);
log.info("创建叫号码:{}", mealCode);
return this.orderCustomBusiness.android().didCreateOrderMealCode(canteenId, stallId, orderDate, mealtimeType, mealCode);
}
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.core.order.common.business;
import com.bonus.core.marketing.coupon.model.MktCouponPayModel; import com.bonus.core.marketing.coupon.model.MktCouponPayModel;
import com.bonus.core.menu.model.AllocMealtimeModel; import com.bonus.core.menu.model.AllocMealtimeModel;
import com.bonus.core.order.common.dto.OrderDidPayInfoDTO;
import com.bonus.core.order.common.model.*; import com.bonus.core.order.common.model.*;
import com.bonus.core.order.common.vo.OrderDeliveryResultVO; import com.bonus.core.order.common.vo.OrderDeliveryResultVO;
import com.bonus.core.order.mq.po.OrderSavePO; import com.bonus.core.order.mq.po.OrderSavePO;
@ -64,7 +65,7 @@ public interface OrderPlaceBusiness {
// //
List<OrderAmountDetail> calcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList); List<OrderAmountDetail> calcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList);
// void updateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO); void updateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO);
// //
// boolean ifUseCall(OrderInfo orderInfo); // boolean ifUseCall(OrderInfo orderInfo);
} }

View File

@ -7,6 +7,7 @@ import cn.hutool.core.util.NumberUtil;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.constant.LeConstants; import com.bonus.constant.LeConstants;
import com.bonus.constant.RetCodeEnum; import com.bonus.constant.RetCodeEnum;
import com.bonus.constant.SourceTypeEnum;
import com.bonus.core.account.v3.api.AccTradeApi; import com.bonus.core.account.v3.api.AccTradeApi;
import com.bonus.core.account.v3.api.vo.AccTradeOrderBalanceVO; import com.bonus.core.account.v3.api.vo.AccTradeOrderBalanceVO;
import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryDTO; import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryDTO;
@ -31,6 +32,7 @@ import com.bonus.core.menu.api.MenuRecipeApi;
import com.bonus.core.menu.dto.MenuRecipeChangeSurplusNum; import com.bonus.core.menu.dto.MenuRecipeChangeSurplusNum;
import com.bonus.core.menu.dto.OrderRecipeDishesDto; import com.bonus.core.menu.dto.OrderRecipeDishesDto;
import com.bonus.core.menu.model.AllocMealtimeModel; import com.bonus.core.menu.model.AllocMealtimeModel;
import com.bonus.core.order.android.business.OrderDishesAndroidBusiness;
import com.bonus.core.order.client.OrderModuleClient; import com.bonus.core.order.client.OrderModuleClient;
import com.bonus.core.order.client.po.MealtimeCheckNowParam; import com.bonus.core.order.client.po.MealtimeCheckNowParam;
import com.bonus.core.order.client.po.MealtimeQueryParam; import com.bonus.core.order.client.po.MealtimeQueryParam;
@ -38,6 +40,7 @@ import com.bonus.core.order.client.po.MetaDataValueParam;
import com.bonus.core.order.client.po.OrderConfigQueryParam; import com.bonus.core.order.client.po.OrderConfigQueryParam;
import com.bonus.core.order.common.business.OrderPlaceBusiness; import com.bonus.core.order.common.business.OrderPlaceBusiness;
import com.bonus.core.order.common.constants.*; import com.bonus.core.order.common.constants.*;
import com.bonus.core.order.common.dto.OrderDidPayInfoDTO;
import com.bonus.core.order.common.model.*; import com.bonus.core.order.common.model.*;
import com.bonus.core.order.common.service.*; import com.bonus.core.order.common.service.*;
import com.bonus.core.order.common.vo.OrderDeliveryResultVO; import com.bonus.core.order.common.vo.OrderDeliveryResultVO;
@ -86,9 +89,9 @@ public class OrderPlaceBusinessImpl implements OrderPlaceBusiness {
@Autowired @Autowired
@Lazy @Lazy
protected OrderCustomBusiness orderCustomBusiness; protected OrderCustomBusiness orderCustomBusiness;
// @Autowired @Autowired
// @Lazy @Lazy
// protected OrderDishesAndroidBusiness orderDishesAndroidBusiness; protected OrderDishesAndroidBusiness orderDishesAndroidBusiness;
@Autowired @Autowired
@Lazy @Lazy
protected OrderInfoService orderInfoService; protected OrderInfoService orderInfoService;
@ -931,54 +934,54 @@ public class OrderPlaceBusinessImpl implements OrderPlaceBusiness {
} }
} }
// public void updateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO) { public void updateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO) {
// orderInfo.setPayState(didPayInfoDTO.getPayState()); orderInfo.setPayState(didPayInfoDTO.getPayState());
// orderInfo.setPayTime(didPayInfoDTO.getPayTime() != null ? didPayInfoDTO.getPayTime() : LocalDateTime.now()); orderInfo.setPayTime(didPayInfoDTO.getPayTime() != null ? didPayInfoDTO.getPayTime() : LocalDateTime.now());
// orderInfo.setPayType(didPayInfoDTO.getPayType()); orderInfo.setPayType(didPayInfoDTO.getPayType());
// orderInfo.setPayChannel(didPayInfoDTO.getPayChannel()); orderInfo.setPayChannel(didPayInfoDTO.getPayChannel());
// this.orderDishesAndroidBusiness.initOrderMealCode(orderInfo); this.orderDishesAndroidBusiness.initOrderMealCode(orderInfo);
// boolean callFlag = this.ifUseCall(orderInfo); boolean callFlag = this.ifUseCall(orderInfo);
// OrderStateEnum orderStateEnum = OrderStateEnum.PLACE; OrderStateEnum orderStateEnum = OrderStateEnum.PLACE;
// DishesStateEnum dishesStateEnum = DishesStateEnum.UN_MAKE; DishesStateEnum dishesStateEnum = DishesStateEnum.UN_MAKE;
// if (OrderTypeEnum.isAndroidType(orderInfo.getOrderType())) { if (OrderTypeEnum.isAndroidType(orderInfo.getOrderType())) {
// if (this.ifMealtimeAfterCurrent(orderInfo)) { if (this.ifMealtimeAfterCurrent(orderInfo)) {
// log.info("[当餐点餐下单] 当前餐次之后的订单"); log.info("[当餐点餐下单] 当前餐次之后的订单");
// } else if (callFlag) { } else if (callFlag) {
// dishesStateEnum = DishesStateEnum.MAKING; dishesStateEnum = DishesStateEnum.MAKING;
// } else if (DeliveryTypeEnum.isNeedDeliveryType(orderInfo.getDeliveryType())) { } else if (DeliveryTypeEnum.isNeedDeliveryType(orderInfo.getDeliveryType())) {
// dishesStateEnum = DishesStateEnum.WAIT_DELIVERY; dishesStateEnum = DishesStateEnum.WAIT_DELIVERY;
// } else { } else {
// dishesStateEnum = DishesStateEnum.ALREADY_TAKE; dishesStateEnum = DishesStateEnum.ALREADY_TAKE;
// orderStateEnum = OrderStateEnum.FINISH; orderStateEnum = OrderStateEnum.FINISH;
// } }
// } else if (OrderTypeEnum.isCurrMealType(orderInfo.getOrderType())) { } else if (OrderTypeEnum.isCurrMealType(orderInfo.getOrderType())) {
// if (callFlag) { if (callFlag) {
// dishesStateEnum = DishesStateEnum.MAKING; dishesStateEnum = DishesStateEnum.MAKING;
// } else if (DeliveryTypeEnum.isNeedDeliveryType(orderInfo.getDeliveryType())) { } else if (DeliveryTypeEnum.isNeedDeliveryType(orderInfo.getDeliveryType())) {
// dishesStateEnum = DishesStateEnum.WAIT_DELIVERY; dishesStateEnum = DishesStateEnum.WAIT_DELIVERY;
// } else { } else {
// dishesStateEnum = DishesStateEnum.WAIT_TAKE; dishesStateEnum = DishesStateEnum.WAIT_TAKE;
// } }
// } else if (OrderTypeEnum.isShopType(orderInfo.getOrderType())) { } else if (OrderTypeEnum.isShopType(orderInfo.getOrderType())) {
// if (SourceTypeEnum.getAppTypeList().contains(orderInfo.getSourceType())) { if (SourceTypeEnum.getAppTypeList().contains(orderInfo.getSourceType())) {
// dishesStateEnum = DishesStateEnum.WAIT_TAKE; dishesStateEnum = DishesStateEnum.WAIT_TAKE;
// } else { } else {
// orderStateEnum = OrderStateEnum.FINISH; orderStateEnum = OrderStateEnum.FINISH;
// dishesStateEnum = DishesStateEnum.ALREADY_TAKE; dishesStateEnum = DishesStateEnum.ALREADY_TAKE;
// } }
// } else if (OrderTypeEnum.isBuffetType(orderInfo.getOrderType()) || OrderTypeEnum.isRoomCategory(orderInfo.getOrderType()) || OrderTypeEnum.isMobileScanCategory(orderInfo.getOrderType())) { } else if (OrderTypeEnum.isBuffetType(orderInfo.getOrderType()) || OrderTypeEnum.isRoomCategory(orderInfo.getOrderType()) || OrderTypeEnum.isMobileScanCategory(orderInfo.getOrderType())) {
// orderStateEnum = OrderStateEnum.FINISH; orderStateEnum = OrderStateEnum.FINISH;
// dishesStateEnum = DishesStateEnum.ALREADY_TAKE; dishesStateEnum = DishesStateEnum.ALREADY_TAKE;
// } }
//
// if (!OrderStateEnum.isFinishState(orderInfo.getOrderState())) { if (!OrderStateEnum.isFinishState(orderInfo.getOrderState())) {
// orderInfo.setOrderState(orderStateEnum.getKey()); orderInfo.setOrderState(orderStateEnum.getKey());
// orderInfo.setDishesState(dishesStateEnum.getKey()); orderInfo.setDishesState(dishesStateEnum.getKey());
// } }
//
// this.orderCustomBusiness.place().didUpdateOrderFieldAfterPay(orderInfo, didPayInfoDTO); this.orderCustomBusiness.place().didUpdateOrderFieldAfterPay(orderInfo, didPayInfoDTO);
// } }
//
// public boolean ifUseCall(OrderInfo orderInfo) { // public boolean ifUseCall(OrderInfo orderInfo) {
// if (LocalDate.now().isAfter(orderInfo.getOrderDate())) { // if (LocalDate.now().isAfter(orderInfo.getOrderDate())) {
// log.warn("[叫号] 今天之前的订单不叫号"); // log.warn("[叫号] 今天之前的订单不叫号");

View File

@ -0,0 +1,92 @@
package com.bonus.core.order.custom;
import cn.hutool.core.collection.CollUtil;
import com.bonus.core.common.custom.business.CustomBusiness;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
public class OrderCustomAndroidBusiness implements CustomBusiness {
public String name() {
return "订单(设备)";
}
public List<CustomBusiness.Version> versions() {
return CollUtil.newArrayList(new CustomBusiness.Version[]{CustomBusiness.Version.of("3.7.0", "初版"), CustomBusiness.Version.of("3.11.2", "叫号添加日期入参"), CustomBusiness.Version.of("3.11.4", "添加试算埋点"), CustomBusiness.Version.of("3.11.5", "叫号码改造")});
}
// public boolean willPlaceParamCheck(OrderPayAndroidTotalDTO androidTotalDTO) {
// return true;
// }
//
// public void didPlaceParamCheck(OrderPayAndroidTotalDTO androidTotalDTO) {
// }
//
// public void didCreatePay(OrderPayAndroidTotalDTO androidTotalDTO, UnifyPayDTO unifyPayDTO) {
// }
//
// public void didPackageOrderInfo(OrderPayAndroidTotalDTO androidTotalDTO, DeviceInfoVO deviceInfoVO, UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderDelivery> orderDeliveryList) {
// }
//
// public OrderPayAndroidVO didPayResultHandler(UnifyPayDTO payDTO, UnifyPayVO payVO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, OrderPayAndroidVO orderPayAndroidVO) {
// return orderPayAndroidVO;
// }
//
// public OrderPayAndroidVO didTrialResultHandler(OrderSavePO orderSavePO, OrderPayAndroidVO orderPayAndroidVO) {
// return orderPayAndroidVO;
// }
//
// public OrderPayAndroidVO willOrderPay(OrderSavePO orderSavePO) {
// return null;
// }
public String willCreateOrderMealCode(Long canteenId, Long stallId, LocalDate orderDate, Integer mealtimeType) {
return null;
}
public String didCreateOrderMealCode(Long canteenId, Long stallId, LocalDate orderDate, Integer mealtimeType, String mealCode) {
return mealCode;
}
// public OrderAndroidSignInVO willSignIn(OrderInfo orderInfo, OrderSignInAndroidDTO param) {
// return null;
// }
//
// public OrderAndroidSignInVO didSignIn(OrderInfo orderInfo, OrderSignInAndroidDTO param, OrderAndroidSignInVO result) {
// return result;
// }
//
// public boolean willUpdateOrderDishesStateV2(OrderInfo orderInfo, OrderDishesUpdateDTO dishesUpdateDTO) {
// return true;
// }
//
// public void didUpdateOrderDishesStateV2(OrderInfo orderInfo, Integer dishesStateBeforeUpdated) {
// }
//
// public OrderTakeAndroidVO willCustTakeMeal(OrderTakeAndroidDTO takeAndroidDTO) {
// return null;
// }
//
// public OrderTakeAndroidVO didCustTakeMeal(OrderTakeAndroidDTO takeAndroidDTO, OrderTakeAndroidVO takeAndroidVO) {
// return takeAndroidVO;
// }
//
// public void didQueryOrderCallPage(OrderCallQueryDTO queryDTO, PageVO<OrderCallListVO> pageVO) {
// }
//
// public void didQueryOrderPage(OrderListAndroidQueryDTO queryDTO, PageVO<OrderListAndroidVO> pageVO) {
// }
//
// public void didSaveOrderPhotoV2(List<OrderPhoto> orderPhotoList) {
// }
//
// public OrderPayAndroidVO willQueryPayResult(String macOrderId) {
// return null;
// }
//
// public OrderPayAndroidVO didQueryPayResult(String macOrderId, OrderPayAndroidVO orderPayAndroidVO) {
// return orderPayAndroidVO;
// }
}

View File

@ -6,9 +6,9 @@ import org.springframework.stereotype.Service;
@Service @Service
public class OrderCustomBusiness { public class OrderCustomBusiness {
// @Autowired @Autowired
// @Lazy @Lazy
// protected OrderCustomAndroidBusiness orderCustomAndroidBusiness; protected OrderCustomAndroidBusiness orderCustomAndroidBusiness;
@Autowired @Autowired
@Lazy @Lazy
protected OrderCustomMobileBusiness orderCustomMobileBusiness; protected OrderCustomMobileBusiness orderCustomMobileBusiness;
@ -40,9 +40,9 @@ public class OrderCustomBusiness {
// @Lazy // @Lazy
// protected OrderCustomPrintBusiness orderCustomPrintBusiness; // protected OrderCustomPrintBusiness orderCustomPrintBusiness;
// public OrderCustomAndroidBusiness android() { public OrderCustomAndroidBusiness android() {
// return this.orderCustomAndroidBusiness; return this.orderCustomAndroidBusiness;
// } }
public OrderCustomMobileBusiness mobile() { public OrderCustomMobileBusiness mobile() {
return this.orderCustomMobileBusiness; return this.orderCustomMobileBusiness;