sync_pay_state
This commit is contained in:
parent
28a6f85579
commit
f921ed90d5
|
|
@ -1,14 +1,28 @@
|
|||
package com.bonus.core.account.v3.api;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.bonus.core.account.v3.api.dto.AccRechargeSumApiDTO;
|
||||
import com.bonus.core.account.v3.api.vo.AccRechargeSumApiVO;
|
||||
import com.bonus.core.account.v3.api.vo.AccTradeOrderBalanceVO;
|
||||
import com.bonus.core.account.v3.api.vo.AccTradeOrderWalletPayVO;
|
||||
import com.bonus.core.account.v3.model.AccTrade;
|
||||
import com.bonus.core.account.v3.model.AccTradeWalletDetail;
|
||||
import com.bonus.core.account.v3.service.AccTradeService;
|
||||
import com.bonus.core.account.v3.service.AccTradeWalletDetailService;
|
||||
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 javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class AccTradeApi {
|
||||
|
|
@ -16,8 +30,32 @@ public class AccTradeApi {
|
|||
@Resource
|
||||
@Lazy
|
||||
private AccTradeService accTradeService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AccTradeWalletDetailService accTradeWalletDetailService;
|
||||
|
||||
|
||||
public AccRechargeSumApiVO getAccRechargeSum(AccRechargeSumApiDTO accRechargeSumApiDTO) {
|
||||
return this.accTradeService.getAccRechargeSum(accRechargeSumApiDTO);
|
||||
}
|
||||
|
||||
public Map<Long, AccTradeOrderBalanceVO> listOrderAccPayDetail(List<Long> leOrdNos) {
|
||||
List<AccTrade> accTradeList = this.accTradeService.list((Wrapper) Wrappers.lambdaQuery(AccTrade.class).select(new SFunction[]{AccTrade::getId, AccTrade::getLeOrdNo, AccTrade::getWalletBalTotal}).in(AccTrade::getLeOrdNo, leOrdNos));
|
||||
if (CollUtil.isEmpty(accTradeList)) {
|
||||
return MapUtil.empty();
|
||||
} else {
|
||||
Map<Long, List<AccTrade>> leOrdNo_accTrade = (Map)accTradeList.stream().collect(Collectors.groupingBy(AccTrade::getLeOrdNo));
|
||||
Map<Long, List<AccTradeWalletDetail>> accTradeId_walletDetail = this.accTradeWalletDetailService.queryAccTradeWalletDetailByTradeIdList(accTradeList.stream().map(AccTrade::getId).toList());
|
||||
Map<Long, AccTradeOrderBalanceVO> resultMap = MapUtil.newHashMap();
|
||||
leOrdNo_accTrade.keySet().forEach((leOrdNo) -> {
|
||||
AccTrade accTrade = (AccTrade)((List)leOrdNo_accTrade.get(leOrdNo)).get(0);
|
||||
List<AccTradeOrderWalletPayVO> walletPayVOList = (List)((List)accTradeId_walletDetail.get(accTrade.getId())).stream().map((item) -> {
|
||||
return (new AccTradeOrderWalletPayVO()).setWalletId(item.getWalletId()).setAmount(item.getAmount()).setWalletBal(item.getWalletBal());
|
||||
}).collect(Collectors.toList());
|
||||
resultMap.put(leOrdNo, (new AccTradeOrderBalanceVO()).setAccTradeId(accTrade.getId()).setLeOrdNo(accTrade.getLeOrdNo()).setWalletBalTotal(accTrade.getWalletBalTotal()).setWalletPayDetail(walletPayVOList));
|
||||
});
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ public interface AccTradeWalletDetailMapper extends BaseMapper<AccTradeWalletDet
|
|||
|
||||
List<AccOrdTradeDetailPO> queryAccTradeOrderDetailByLeOrderNo(@Param("leOrderNo") Long leOrderNo, @Param("leOrderNoList") List<Long> leOrderNoList);
|
||||
|
||||
|
||||
List<AccTradeWalletDetail> queryAccTradeWalletDetailByTradeIdList(@Param("tradeIdList") List<Long> tradeIdList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.bonus.core.account.v3.web.vo.AccOrdTradeVO;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AccTradeWalletDetailService {
|
||||
|
||||
|
|
@ -29,4 +30,6 @@ public interface AccTradeWalletDetailService {
|
|||
List<AccTradeWalletDetail> queryAccTradeWalletDetailByOriginTradeId(Long originTradeId, Integer tradeType);
|
||||
|
||||
AccOrdTradeVO queryAccTradeOrderDetailByLeOrderNo(Long leOrderNo);
|
||||
|
||||
Map<Long, List<AccTradeWalletDetail>> queryAccTradeWalletDetailByTradeIdList(List<Long> tradeIdList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.bonus.core.account.v3.service.AccTradeWalletDetailService;
|
|||
import com.bonus.core.account.v3.web.vo.AccOrdTradeVO;
|
||||
import com.bonus.core.account.v3.po.AccWalletPayPO;
|
||||
import com.bonus.i18n.I18n;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -111,4 +112,9 @@ public class AccTradeWalletDetailServiceImpl extends ServiceImpl<AccTradeWalletD
|
|||
}
|
||||
}
|
||||
|
||||
public Map<Long, List<AccTradeWalletDetail>> queryAccTradeWalletDetailByTradeIdList(List<Long> tradeIdList) {
|
||||
List<AccTradeWalletDetail> list = ((AccTradeWalletDetailMapper)this.baseMapper).queryAccTradeWalletDetailByTradeIdList(tradeIdList);
|
||||
return (Map)(ObjectUtil.isEmpty(list) ? Maps.newHashMap() : (Map)list.stream().collect(Collectors.groupingBy(AccTradeWalletDetail::getTradeId)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.NumberUtil;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.constant.LeConstants;
|
||||
import com.bonus.constant.RetCodeEnum;
|
||||
import com.bonus.core.account.v3.api.AccTradeApi;
|
||||
import com.bonus.core.account.v3.api.vo.AccTradeOrderBalanceVO;
|
||||
import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryDTO;
|
||||
import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryModel;
|
||||
|
|
@ -43,6 +44,7 @@ import com.bonus.core.order.common.vo.OrderDeliveryResultVO;
|
|||
import com.bonus.core.order.custom.OrderCustomBusiness;
|
||||
import com.bonus.core.order.mq.po.OrderSavePO;
|
||||
import com.bonus.core.order.utils.LeNumUtil;
|
||||
import com.bonus.core.order.utils.LeOrderUtil;
|
||||
import com.bonus.core.pay.api.PayApi;
|
||||
import com.bonus.core.pay.api.dto.UnifyPayDTO;
|
||||
import com.bonus.core.pay.api.vo.UnifyPayVO;
|
||||
|
|
@ -135,9 +137,9 @@ public class OrderPlaceBusinessImpl implements OrderPlaceBusiness {
|
|||
// @Autowired
|
||||
// @Lazy
|
||||
// protected AllocStallApi allocStallApi;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// protected AccTradeApi accTradeApi;
|
||||
@Autowired
|
||||
@Lazy
|
||||
protected AccTradeApi accTradeApi;
|
||||
|
||||
public void checkOrderSubmitted(String repeatedId) {
|
||||
if (!CharSequenceUtil.isEmpty(repeatedId)) {
|
||||
|
|
@ -1022,26 +1024,26 @@ public class OrderPlaceBusinessImpl implements OrderPlaceBusiness {
|
|||
// return OrderAmountChange.newInstance(orderId, orderDate, changeDetailType, changeAmount, remark);
|
||||
// }
|
||||
|
||||
protected RulePriceDTO packageRulePriceDTO(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, boolean isTrail) {
|
||||
RulePriceDTO rulePriceDTO = new RulePriceDTO();
|
||||
rulePriceDTO.setTryFlag(isTrail ? LeConstants.COMMON_YES : LeConstants.COMMON_NO);
|
||||
rulePriceDTO.setVerifyFlag(LeConstants.COMMON_NO);
|
||||
List<RulePriceOrderDTO> ruleOrderList = (List<RulePriceOrderDTO>)orderInfoList.stream().map((orderInfo) -> {
|
||||
RulePriceOrderDTO orderDTO = (new RulePriceOrderDTO()).setOrderId(orderInfo.getOrderId()).setMacOrderId(orderInfo.getMacOrderId()).setCustId(LeNumUtil.isValidId(orderInfo.getCustId()) ? orderInfo.getCustId() : LeConstants.DATA_DEFAULT_LONG).setOrderType(orderInfo.getOrderType()).setDeviceSn(orderInfo.getMachineSn()).setMealtimeType(orderInfo.getMealtimeType()).setOrderDate(orderInfo.getOrderDate()).setOrderTime(orderInfo.getOrderTime()).setCanteenId(orderInfo.getCanteenId()).setStallId(orderInfo.getStallId()).setPayableAmount(orderInfo.calcNeedPayAmount()).setIfOnline(orderInfo.getIfOnline());
|
||||
List<RulePriceOrderDetailDTO> detailDtoList = (List<RulePriceOrderDetailDTO>)orderDetailList.stream().filter((s) -> {
|
||||
return s.getOrderId().equals(orderDTO.getOrderId());
|
||||
}).map((s) -> {
|
||||
return (new RulePriceOrderDetailDTO()).setDetailId(s.getDetailId()).setGoodsDishesId(s.getGoodsDishesId()).setPrice(s.getPrice()).setQuantity(s.getQuantity()).setCalcTotalAmount(s.getCalcTotalAmount());
|
||||
}).collect(Collectors.toList());
|
||||
orderDTO.setDetails(detailDtoList);
|
||||
return orderDTO;
|
||||
}).collect(Collectors.toList());
|
||||
rulePriceDTO.setOrders(ruleOrderList);
|
||||
rulePriceDTO.setCustId(LeNumUtil.isValidId(((OrderInfo)orderInfoList.get(0)).getCustId()) ? ((OrderInfo)orderInfoList.get(0)).getCustId() : LeConstants.DATA_DEFAULT_LONG);
|
||||
rulePriceDTO.setPayChannel(((OrderInfo)orderInfoList.get(0)).getPayChannel());
|
||||
return rulePriceDTO;
|
||||
}
|
||||
//
|
||||
// protected RulePriceDTO packageRulePriceDTO(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, boolean isTrail) {
|
||||
// RulePriceDTO rulePriceDTO = new RulePriceDTO();
|
||||
// rulePriceDTO.setTryFlag(isTrail ? LeConstants.COMMON_YES : LeConstants.COMMON_NO);
|
||||
// rulePriceDTO.setVerifyFlag(LeConstants.COMMON_NO);
|
||||
// List<RulePriceOrderDTO> ruleOrderList = (List<RulePriceOrderDTO>)orderInfoList.stream().map((orderInfo) -> {
|
||||
// RulePriceOrderDTO orderDTO = (new RulePriceOrderDTO()).setOrderId(orderInfo.getOrderId()).setMacOrderId(orderInfo.getMacOrderId()).setCustId(LeNumUtil.isValidId(orderInfo.getCustId()) ? orderInfo.getCustId() : LeConstants.DATA_DEFAULT_LONG).setOrderType(orderInfo.getOrderType()).setDeviceSn(orderInfo.getMachineSn()).setMealtimeType(orderInfo.getMealtimeType()).setOrderDate(orderInfo.getOrderDate()).setOrderTime(orderInfo.getOrderTime()).setCanteenId(orderInfo.getCanteenId()).setStallId(orderInfo.getStallId()).setPayableAmount(orderInfo.calcNeedPayAmount()).setIfOnline(orderInfo.getIfOnline());
|
||||
// List<RulePriceOrderDetailDTO> detailDtoList = (List<RulePriceOrderDetailDTO>)orderDetailList.stream().filter((s) -> {
|
||||
// return s.getOrderId().equals(orderDTO.getOrderId());
|
||||
// }).map((s) -> {
|
||||
// return (new RulePriceOrderDetailDTO()).setDetailId(s.getDetailId()).setGoodsDishesId(s.getGoodsDishesId()).setPrice(s.getPrice()).setQuantity(s.getQuantity()).setCalcTotalAmount(s.getCalcTotalAmount());
|
||||
// }).collect(Collectors.toList());
|
||||
// orderDTO.setDetails(detailDtoList);
|
||||
// return orderDTO;
|
||||
// }).collect(Collectors.toList());
|
||||
// rulePriceDTO.setOrders(ruleOrderList);
|
||||
// rulePriceDTO.setCustId(LeNumUtil.isValidId(((OrderInfo)orderInfoList.get(0)).getCustId()) ? ((OrderInfo)orderInfoList.get(0)).getCustId() : LeConstants.DATA_DEFAULT_LONG);
|
||||
// rulePriceDTO.setPayChannel(((OrderInfo)orderInfoList.get(0)).getPayChannel());
|
||||
// return rulePriceDTO;
|
||||
// }
|
||||
|
||||
// protected boolean ifMealtimeAfterCurrent(OrderInfo orderInfo) {
|
||||
// if (orderInfo.getOrderDate().isBefore(LocalDate.now())) {
|
||||
// return false;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.bonus.core.order.common.model.OrderInfo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.*;
|
||||
|
|
@ -94,9 +95,9 @@ public class LeOrderUtil {
|
|||
// }).collect(Collectors.joining("+"));
|
||||
// }
|
||||
//
|
||||
// public static void calcOrderAmount(List<OrderInfo> orderInfoList, BigDecimal totalAmount, BiConsumer<OrderInfo, BigDecimal> saveField) {
|
||||
// LeNumUtil.calcShareAmount(orderInfoList, totalAmount, OrderInfo::calcNeedPayAmount, saveField);
|
||||
// }
|
||||
public static void calcOrderAmount(List<OrderInfo> orderInfoList, BigDecimal totalAmount, BiConsumer<OrderInfo, BigDecimal> saveField) {
|
||||
LeNumUtil.calcShareAmount(orderInfoList, totalAmount, OrderInfo::calcNeedPayAmount, saveField);
|
||||
}
|
||||
//
|
||||
// public static boolean checkNowTimeWithin(String startTimeStr, String endTimeStr) {
|
||||
// LocalTime startTime = null;
|
||||
|
|
|
|||
|
|
@ -126,4 +126,21 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryAccTradeWalletDetailByTradeIdList"
|
||||
resultType="com.bonus.core.account.v3.model.AccTradeWalletDetail">
|
||||
SELECT trade_id,
|
||||
cust_id,
|
||||
wallet_id,
|
||||
amount,
|
||||
wallet_bal,
|
||||
trade_type,
|
||||
validate_time
|
||||
FROM acc_trade_wallet_detail
|
||||
WHERE
|
||||
trade_id in
|
||||
<foreach collection="tradeIdList" item="tradeId" separator="," open="(" close=")">
|
||||
#{tradeId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Reference in New Issue