|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.service.pay.impl;
|
|
package com.cyksj.service.pay.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
import com.alipay.api.AlipayApiException;
|
|
@@ -38,6 +39,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -76,6 +78,8 @@ public class AliPayCommonServiceImpl implements AliPayCommonService {
|
|
|
|
|
|
|
|
private final UserMirrorShopFeeOrderDonMapper feeOrderDonMapper;
|
|
private final UserMirrorShopFeeOrderDonMapper feeOrderDonMapper;
|
|
|
|
|
|
|
|
|
|
+ private final ZfbShopOrderDayLimitMapper zfbShopOrderDayLimitMapper;
|
|
|
|
|
+
|
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -116,14 +120,24 @@ public class AliPayCommonServiceImpl implements AliPayCommonService {
|
|
|
Long orderId = re.getOrderId();
|
|
Long orderId = re.getOrderId();
|
|
|
String returnUrl = re.getReturnUrl();
|
|
String returnUrl = re.getReturnUrl();
|
|
|
OrderDon orderDon = orderDonMapper.selectById(orderId);
|
|
OrderDon orderDon = orderDonMapper.selectById(orderId);
|
|
|
- //获取支付宝默认商户
|
|
|
|
|
- String appId = sysConfigService.getDefaultShopConfigByType("zfb");
|
|
|
|
|
|
|
+ String appId = null;
|
|
|
if (orderDon.getPopularizeId() != null) {
|
|
if (orderDon.getPopularizeId() != null) {
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByChannelPopularizeId(orderDon.getPopularizeId(), "zfb");
|
|
ShopConfig shopConfig = shopConfigMapper.getByChannelPopularizeId(orderDon.getPopularizeId(), "zfb");
|
|
|
if (shopConfig != null) {
|
|
if (shopConfig != null) {
|
|
|
appId = shopConfig.getAppId();
|
|
appId = shopConfig.getAppId();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //排除推广链接
|
|
|
|
|
+ if (StrUtil.isEmpty(appId)) {
|
|
|
|
|
+ //获取每日订单限制 支付宝商户
|
|
|
|
|
+ ZfbShopOrderDayLimit dayLimit = getZfbShopOrdersDayLimit();
|
|
|
|
|
+ if (dayLimit == null) {
|
|
|
|
|
+ //获取支付宝默认商户
|
|
|
|
|
+ appId = sysConfigService.getDefaultShopConfigByType("zfb");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ appId = dayLimit.getAppId();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (OrderDon.Type.ALI_PAY != orderDon.getType()) {
|
|
if (OrderDon.Type.ALI_PAY != orderDon.getType()) {
|
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
}
|
|
}
|
|
@@ -187,6 +201,23 @@ public class AliPayCommonServiceImpl implements AliPayCommonService {
|
|
|
return aliPayParams;
|
|
return aliPayParams;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private ZfbShopOrderDayLimit getZfbShopOrdersDayLimit() {
|
|
|
|
|
+ int hour = DateUtil.hour(DateTime.now(), true);
|
|
|
|
|
+ List<ZfbShopOrderDayLimit> orderDayLimits = zfbShopOrderDayLimitMapper.selectList(Wrappers.lambdaQuery(ZfbShopOrderDayLimit.class)
|
|
|
|
|
+ .le(ZfbShopOrderDayLimit::getHourStart, hour)
|
|
|
|
|
+ .ge(ZfbShopOrderDayLimit::getHourEnd, hour)
|
|
|
|
|
+ .gt(ZfbShopOrderDayLimit::getDayRemainOrders, 0)
|
|
|
|
|
+ .gt(ZfbShopOrderDayLimit::getHourRemainOrders, 0)
|
|
|
|
|
+ .eq(ZfbShopOrderDayLimit::getStatus, 1));
|
|
|
|
|
+ for (ZfbShopOrderDayLimit orderDayLimit : orderDayLimits) {
|
|
|
|
|
+ Integer update = zfbShopOrderDayLimitMapper.decrRemainOrdersById(orderDayLimit.getId());
|
|
|
|
|
+ if (update == 1) {
|
|
|
|
|
+ return orderDayLimit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public AliPayParams builderPayParams(Long orderId, String orderNo, String shopId, BigDecimal money, Date orderCreatedTime, String subject, String productCode, String payMode, String notifyUrl, String returnUrl) throws Exception {
|
|
public AliPayParams builderPayParams(Long orderId, String orderNo, String shopId, BigDecimal money, Date orderCreatedTime, String subject, String productCode, String payMode, String notifyUrl, String returnUrl) throws Exception {
|
|
|
OrderPayBuilderDto orderPayBuilderDto = new OrderPayBuilderDto();
|
|
OrderPayBuilderDto orderPayBuilderDto = new OrderPayBuilderDto();
|
|
|
orderPayBuilderDto.setOrderId(orderId);
|
|
orderPayBuilderDto.setOrderId(orderId);
|