sync_pay_state

This commit is contained in:
sxu 2025-02-20 18:58:08 +08:00
parent bf458de8ef
commit 4f7505ec52
6 changed files with 83 additions and 44 deletions

View File

@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.bonus.core.allocation.api.AllocStallApi;
import com.bonus.core.allocation.canteen.model.AllocStall; import com.bonus.core.allocation.canteen.model.AllocStall;
import com.bonus.core.customer.constants.OrderTypeEnum; import com.bonus.core.customer.constants.OrderTypeEnum;
import com.bonus.core.order.android.business.OrderDishesAndroidBusiness; import com.bonus.core.order.android.business.OrderDishesAndroidBusiness;
import com.bonus.core.order.common.model.OrderInfo; import com.bonus.core.order.common.model.OrderInfo;
import com.bonus.core.order.custom.OrderCustomBusiness; import com.bonus.core.order.custom.OrderCustomBusiness;
import com.bonus.core.order.utils.LeNumUtil; import com.bonus.core.order.utils.LeNumUtil;
import com.bonus.core.supermarket.api.SupermarketApi;
import com.bonus.core.supermarket.model.SupermarketInfo; import com.bonus.core.supermarket.model.SupermarketInfo;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -35,6 +37,16 @@ public class OrderDishesAndroidBusinessImpl implements OrderDishesAndroidBusines
@Lazy @Lazy
protected OrderCustomBusiness orderCustomBusiness; protected OrderCustomBusiness orderCustomBusiness;
@Autowired
@Lazy
protected AllocStallApi allocStallApi;
@Autowired
@Lazy
protected SupermarketApi supermarketApi;
@Lazy
@Autowired
protected LeNumUtil numUtil;
public void initOrderMealCode(OrderInfo orderInfo) { public void initOrderMealCode(OrderInfo orderInfo) {
if (!CharSequenceUtil.isNotEmpty(orderInfo.getMealCode())) { if (!CharSequenceUtil.isNotEmpty(orderInfo.getMealCode())) {
String mealCode = this.createMealCode(orderInfo.getOrderType(), orderInfo.getCanteenId(), orderInfo.getStallId(), orderInfo.getOrderDate(), orderInfo.getMealtimeType()); String mealCode = this.createMealCode(orderInfo.getOrderType(), orderInfo.getCanteenId(), orderInfo.getStallId(), orderInfo.getOrderDate(), orderInfo.getMealtimeType());

View File

@ -38,7 +38,7 @@ public interface OrderInfoService {
// //
// long existReserveOrderUnPrint(Long canteenId, Long stallId, Integer mealtimeType); // long existReserveOrderUnPrint(Long canteenId, Long stallId, Integer mealtimeType);
// //
// String getMaxMealCodeOfDate(@NotNull LocalDate orderDate, Integer mealtimeType, Long canteenId, Long stallId); String getMaxMealCodeOfDate(@NotNull LocalDate orderDate, Integer mealtimeType, Long canteenId, Long stallId);
// //
// OrderInfo getById(Long id, LocalDate... orderDates); // OrderInfo getById(Long id, LocalDate... orderDates);

View File

@ -392,11 +392,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
// public long existReserveOrderUnPrint(Long canteenId, Long stallId, Integer mealtimeType) { // public long existReserveOrderUnPrint(Long canteenId, Long stallId, Integer mealtimeType) {
// return this.count((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(ObjectUtil.isNotNull(canteenId), OrderInfo::getCanteenId, canteenId)).eq(ObjectUtil.isNotNull(stallId), OrderInfo::getStallId, stallId)).eq(ObjectUtil.isNotNull(mealtimeType), OrderInfo::getMealtimeType, mealtimeType)).between(OrderInfo::getOrderDate, LocalDate.now(), LeOrderUtil.queryDateRange().get(1))).eq(OrderInfo::getOrderType, OrderTypeEnum.RESERVE_MEAL.getKey())).eq(OrderInfo::getOrderState, OrderStateEnum.PLACE.getKey())); // return this.count((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(ObjectUtil.isNotNull(canteenId), OrderInfo::getCanteenId, canteenId)).eq(ObjectUtil.isNotNull(stallId), OrderInfo::getStallId, stallId)).eq(ObjectUtil.isNotNull(mealtimeType), OrderInfo::getMealtimeType, mealtimeType)).between(OrderInfo::getOrderDate, LocalDate.now(), LeOrderUtil.queryDateRange().get(1))).eq(OrderInfo::getOrderType, OrderTypeEnum.RESERVE_MEAL.getKey())).eq(OrderInfo::getOrderState, OrderStateEnum.PLACE.getKey()));
// } // }
//
// public String getMaxMealCodeOfDate(LocalDate orderDate, Integer mealtimeType, Long canteenId, Long stallId) { public String getMaxMealCodeOfDate(LocalDate orderDate, Integer mealtimeType, Long canteenId, Long stallId) {
// OrderInfo orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).select(new SFunction[]{OrderInfo::getMealCode}).eq(OrderInfo::getOrderDate, orderDate)).eq(OrderInfo::getCanteenId, LeNumUtil.isValidId(canteenId) ? canteenId : LeConstants.DATA_DEFAULT_LONG)).eq(OrderInfo::getStallId, LeNumUtil.isValidId(stallId) ? stallId : LeConstants.DATA_DEFAULT_LONG)).eq(LeNumUtil.isValidId(mealtimeType), OrderInfo::getMealtimeType, mealtimeType)).in(!LeNumUtil.isValidId(mealtimeType), OrderInfo::getMealtimeType, AllocMealtimeTypeEnum.allTypeList())).in(OrderInfo::getOrderType, OrderTypeEnum.allTypeList())).orderByDesc(OrderInfo::getOrderId)).last("limit 1")); OrderInfo orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).select(new SFunction[]{OrderInfo::getMealCode}).eq(OrderInfo::getOrderDate, orderDate)).eq(OrderInfo::getCanteenId, LeNumUtil.isValidId(canteenId) ? canteenId : LeConstants.DATA_DEFAULT_LONG)).eq(OrderInfo::getStallId, LeNumUtil.isValidId(stallId) ? stallId : LeConstants.DATA_DEFAULT_LONG)).eq(LeNumUtil.isValidId(mealtimeType), OrderInfo::getMealtimeType, mealtimeType)).in(!LeNumUtil.isValidId(mealtimeType), OrderInfo::getMealtimeType, AllocMealtimeTypeEnum.allTypeList())).in(OrderInfo::getOrderType, OrderTypeEnum.allTypeList())).orderByDesc(OrderInfo::getOrderId)).last("limit 1"));
// return orderInfo != null ? orderInfo.getMealCode() : null; return orderInfo != null ? orderInfo.getMealCode() : null;
// } }
protected LambdaQueryWrapper<OrderInfo> getOrderSelectWrappers() { protected LambdaQueryWrapper<OrderInfo> getOrderSelectWrappers() {
return Wrappers.lambdaQuery(OrderInfo.class).select(OrderInfo::getOrderId, OrderInfo::getCustId, OrderInfo::getSourceType, OrderInfo::getCanteenId, OrderInfo::getStallId, OrderInfo::getMealtimeType, OrderInfo::getCanteenName, OrderInfo::getStallName, OrderInfo::getMealtimeName, OrderInfo::getOrderDate, OrderInfo::getCouponId, OrderInfo::getPayableAmount, OrderInfo::getRealAmount, OrderInfo::getAccPayAmount, OrderInfo::getOutPayAmount, OrderInfo::getOrderTime, OrderInfo::getOrderType, OrderInfo::getOrderState, OrderInfo::getPayTime, OrderInfo::getPayType, OrderInfo::getPayState, OrderInfo::getDeliveryType, OrderInfo::getDishesState, OrderInfo::getOrderRefundState); return Wrappers.lambdaQuery(OrderInfo.class).select(OrderInfo::getOrderId, OrderInfo::getCustId, OrderInfo::getSourceType, OrderInfo::getCanteenId, OrderInfo::getStallId, OrderInfo::getMealtimeType, OrderInfo::getCanteenName, OrderInfo::getStallName, OrderInfo::getMealtimeName, OrderInfo::getOrderDate, OrderInfo::getCouponId, OrderInfo::getPayableAmount, OrderInfo::getRealAmount, OrderInfo::getAccPayAmount, OrderInfo::getOutPayAmount, OrderInfo::getOrderTime, OrderInfo::getOrderType, OrderInfo::getOrderState, OrderInfo::getPayTime, OrderInfo::getPayType, OrderInfo::getPayState, OrderInfo::getDeliveryType, OrderInfo::getDishesState, OrderInfo::getOrderRefundState);

View File

@ -8,6 +8,7 @@ import com.bonus.core.marketing.coupon.model.MktCouponPayModel;
import com.bonus.core.marketing.v2.rule.price.dto.RulePriceDTO; import com.bonus.core.marketing.v2.rule.price.dto.RulePriceDTO;
import com.bonus.core.menu.dto.MenuRecipeChangeSurplusNum; import com.bonus.core.menu.dto.MenuRecipeChangeSurplusNum;
import com.bonus.core.order.common.constants.ChangeDetailTypeEnum; import com.bonus.core.order.common.constants.ChangeDetailTypeEnum;
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;
@ -138,8 +139,8 @@ public class OrderCustomPlaceBusiness implements CustomBusiness {
public void didCalcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList, List<OrderAmountDetail> orderAmountDetailList) { public void didCalcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList, List<OrderAmountDetail> orderAmountDetailList) {
} }
// public void didUpdateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO) { public void didUpdateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO) {
// } }
public boolean willHandleOrderDidFailed(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, public boolean willHandleOrderDidFailed(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList,
Integer payState, boolean orderExists) { Integer payState, boolean orderExists) {

View File

@ -1,15 +1,28 @@
package com.bonus.core.order.utils; package com.bonus.core.order.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.constant.LeConstants; import com.bonus.constant.LeConstants;
import com.bonus.core.common.utils.TenantContextHolder;
import com.bonus.core.order.common.service.OrderInfoService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Function; import java.util.function.Function;
@ -18,6 +31,16 @@ import java.util.stream.Collectors;
@Component @Component
public class LeNumUtil { public class LeNumUtil {
private static final Logger log = LoggerFactory.getLogger(LeNumUtil.class); private static final Logger log = LoggerFactory.getLogger(LeNumUtil.class);
@Autowired
@Lazy
private OrderInfoService orderInfoService;
@Autowired
@Lazy
private RedisTemplate<Object, Object> redisTemplate;
@Value("${system.order.call.max-num:}")
private Long callMaxNum;
private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
// @Autowired // @Autowired
// @Lazy // @Lazy
@ -50,41 +73,41 @@ public class LeNumUtil {
// //
// return differentFlag ? superNum + "-" + latestNum : superNum + latestNum; // return differentFlag ? superNum + "-" + latestNum : superNum + latestNum;
// } // }
//
// public String getMealCode(String prefix, Long canteenId, Long stallId, LocalDate orderDate, Integer mealtimeType) { public String getMealCode(String prefix, Long canteenId, Long stallId, LocalDate orderDate, Integer mealtimeType) {
// if (!isValidId(canteenId) && !isValidId(stallId)) { if (!isValidId(canteenId) && !isValidId(stallId)) {
// return ""; return "";
// } else if (LocalDate.now().isAfter(orderDate)) { } else if (LocalDate.now().isAfter(orderDate)) {
// return ""; return "";
// } else { } else {
// String callNumPrefix = CharSequenceUtil.isNotBlank(prefix) ? prefix : ""; String callNumPrefix = CharSequenceUtil.isNotBlank(prefix) ? prefix : "";
// Long merchantId = TenantContextHolder.getTenantId(); Long merchantId = TenantContextHolder.getTenantId();
// String dateStr = orderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String dateStr = orderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// String shopIdStr = isValidId(stallId) ? String.valueOf(stallId) : String.valueOf(canteenId); String shopIdStr = isValidId(stallId) ? String.valueOf(stallId) : String.valueOf(canteenId);
// String mealtimeStr = isValidId(mealtimeType) ? String.valueOf(mealtimeType) : "-1"; String mealtimeStr = isValidId(mealtimeType) ? String.valueOf(mealtimeType) : "-1";
// String redisKey = CharSequenceUtil.format("yst:{}:meal-code:{}:{}:{}:{}", new Object[]{merchantId, shopIdStr, dateStr, mealtimeStr, callNumPrefix}); String redisKey = CharSequenceUtil.format("yst:{}:meal-code:{}:{}:{}:{}", new Object[]{merchantId, shopIdStr, dateStr, mealtimeStr, callNumPrefix});
// log.info("叫号缓存key{}", redisKey); log.info("叫号缓存key{}", redisKey);
// BoundValueOperations<Object, Object> valueOperations = this.redisTemplate.boundValueOps(redisKey); BoundValueOperations<Object, Object> valueOperations = this.redisTemplate.boundValueOps(redisKey);
// Object s = valueOperations.get(); Object s = valueOperations.get();
// if (ObjectUtil.isNull(s)) { if (ObjectUtil.isNull(s)) {
// String maxMealCodeOfDate = this.orderInfoService.getMaxMealCodeOfDate(orderDate, mealtimeType, canteenId, stallId); String maxMealCodeOfDate = this.orderInfoService.getMaxMealCodeOfDate(orderDate, mealtimeType, canteenId, stallId);
// log.info("当前最大叫号:{}", maxMealCodeOfDate); log.info("当前最大叫号:{}", maxMealCodeOfDate);
// maxMealCodeOfDate = CharSequenceUtil.removePrefix(maxMealCodeOfDate, callNumPrefix); maxMealCodeOfDate = CharSequenceUtil.removePrefix(maxMealCodeOfDate, callNumPrefix);
// int currentNum = NumberUtil.isNumber(maxMealCodeOfDate) ? NumberUtil.parseInt(maxMealCodeOfDate) : 0; int currentNum = NumberUtil.isNumber(maxMealCodeOfDate) ? NumberUtil.parseInt(maxMealCodeOfDate) : 0;
// Duration expireDuration = LocalDateTimeUtil.between(LocalDateTimeUtil.now(), LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.now())); Duration expireDuration = LocalDateTimeUtil.between(LocalDateTimeUtil.now(), LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.now()));
// valueOperations.setIfAbsent(currentNum, expireDuration); valueOperations.setIfAbsent(currentNum, expireDuration);
// } }
//
// Long increment = valueOperations.increment(1L); Long increment = valueOperations.increment(1L);
// if (this.callMaxNum != null && increment != null && increment > this.callMaxNum) { if (this.callMaxNum != null && increment != null && increment > this.callMaxNum) {
// increment = increment % this.callMaxNum; increment = increment % this.callMaxNum;
// } }
//
// String format = String.format("%03d", increment); String format = String.format("%03d", increment);
// log.info("叫的多少号{}", callNumPrefix + format); log.info("叫的多少号{}", callNumPrefix + format);
// return callNumPrefix + format; return callNumPrefix + format;
// } }
// } }
public static boolean isValidId(Long id) { public static boolean isValidId(Long id) {
return id != null && id != -1L && id != 0L; return id != null && id != -1L && id != 0L;

View File

@ -92,6 +92,9 @@ system:
sqbqrapi: ${SQB_QR_API:https://qr.shouqianba.com/gateway} #收钱吧网关地址 sqbqrapi: ${SQB_QR_API:https://qr.shouqianba.com/gateway} #收钱吧网关地址
alismsdomain: ${API_ALI_SMS_DOMAIN:dysmsapi.aliyuncs.com} #阿里云短信请求地址 alismsdomain: ${API_ALI_SMS_DOMAIN:dysmsapi.aliyuncs.com} #阿里云短信请求地址
feieapi: ${API_FEI_E:http://api.feieyun.cn} #飞鹅api feieapi: ${API_FEI_E:http://api.feieyun.cn} #飞鹅api
order:
call:
max-num: ${ORDER_CALL_MAX_NUM:999}
data-config: data-config:
sm4-key: ${SENSITIVE_SM4KEY:jY7bZz6Pjml+H/WZYfNSNA==} sm4-key: ${SENSITIVE_SM4KEY:jY7bZz6Pjml+H/WZYfNSNA==}