同步 master 的一些 pr 代码变更

This commit is contained in:
YunaiV 2024-03-01 09:00:43 +08:00
parent 8b6bc7c54e
commit 8ff710e49d
7 changed files with 76 additions and 4 deletions

View File

@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.service.contract;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
@ -346,8 +345,8 @@ public class CrmContractServiceImpl implements CrmContractService {
if (config != null && Boolean.FALSE.equals(config.getNotifyEnabled())) { if (config != null && Boolean.FALSE.equals(config.getNotifyEnabled())) {
config = null; config = null;
} }
if(Validator.isNull(config)){ if (config == null) {
return new PageResult<>(); return PageResult.empty();
} }
} }
// 2. 查询分页 // 2. 查询分页

View File

@ -245,7 +245,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
@AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_DELIVERY) @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_DELIVERY)
public void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO) { public void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO) {
// 校验售后单存在并状态未退货 // 校验售后单存在并状态未退货
AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(deliveryReqVO.getId()); AfterSaleDO afterSale = tradeAfterSaleMapper.selectByIdAndUserId(deliveryReqVO.getId(), userId);
if (afterSale == null) { if (afterSale == null) {
throw exception(AFTER_SALE_NOT_FOUND); throw exception(AFTER_SALE_NOT_FOUND);
} }

View File

@ -477,6 +477,14 @@ public class PayOrderServiceImpl implements PayOrderService {
return false; return false;
} }
PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
// 如果查询到订单不存在PayClient 返回的状态为关闭但此时不能关闭订单存在以下一种场景
// 拉起渠道支付后短时间内用户未及时完成支付但是该订单同步定时任务恰巧自动触发了主动查询结果为订单不存在
// 当用户支付成功之后该订单状态在渠道的回调中无法从已关闭改为已支付造成重大影响
// 考虑此定时任务是异常场景的兜底操作因此这里不做变更优先以回调为准
// 让订单自动随着支付渠道那边一起等到过期确保渠道先过期关闭支付入口而后通过订单过期定时任务关闭自己的订单
if (PayOrderStatusRespEnum.isClosed(respDTO.getStatus())) {
return false;
}
// 1.2 回调支付结果 // 1.2 回调支付结果
notifyOrder(orderExtension.getChannelId(), respDTO); notifyOrder(orderExtension.getChannelId(), respDTO);

View File

@ -44,6 +44,7 @@ public class PayClientFactoryImpl implements PayClientFactory {
clientClass.put(WX_APP, WxAppPayClient.class); clientClass.put(WX_APP, WxAppPayClient.class);
clientClass.put(WX_BAR, WxBarPayClient.class); clientClass.put(WX_BAR, WxBarPayClient.class);
clientClass.put(WX_NATIVE, WxNativePayClient.class); clientClass.put(WX_NATIVE, WxNativePayClient.class);
clientClass.put(WX_WAP, WxWapPayClient.class);
// 支付包支付客户端 // 支付包支付客户端
clientClass.put(ALIPAY_WAP, AlipayWapPayClient.class); clientClass.put(ALIPAY_WAP, AlipayWapPayClient.class);
clientClass.put(ALIPAY_QR, AlipayQrPayClient.class); clientClass.put(ALIPAY_QR, AlipayQrPayClient.class);

View File

@ -45,6 +45,7 @@ public class AlipayWapPayClient extends AbstractAlipayPayClient {
request.setNotifyUrl(reqDTO.getNotifyUrl()); request.setNotifyUrl(reqDTO.getNotifyUrl());
request.setReturnUrl(reqDTO.getReturnUrl()); request.setReturnUrl(reqDTO.getReturnUrl());
model.setQuitUrl(reqDTO.getReturnUrl()); model.setQuitUrl(reqDTO.getReturnUrl());
model.setTimeExpire(formatTime(reqDTO.getExpireTime()));
// 2.1 执行请求 // 2.1 执行请求
AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name()); AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name());

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import lombok.extern.slf4j.Slf4j;
/**
* 微信支付H5 网页 PayClient 实现类
*
* 文档<a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_1.shtml">H5下单API</>
*
* @author YYQ
*/
@Slf4j
public class WxWapPayClient extends AbstractWxPayClient {
public WxWapPayClient(Long channelId, WxPayClientConfig config) {
super(channelId, PayChannelEnum.WX_WAP.getCode(), config);
}
protected WxWapPayClient(Long channelId, String channelCode, WxPayClientConfig config) {
super(channelId, channelCode, config);
}
@Override
protected void doInit() {
super.doInit(WxPayConstants.TradeType.MWEB);
}
@Override
protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException {
// 构建 WxPayUnifiedOrderRequest 对象
WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO);
// 执行请求
WxPayMwebOrderResult response = client.createOrder(request);
// 转换结果
return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.URL.getMode(), response.getMwebUrl(),
reqDTO.getOutTradeNo(), response);
}
@Override
protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException {
// 构建 WxPayUnifiedOrderRequest 对象
WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO);
// 执行请求
String response = client.createOrderV3(TradeTypeEnum.H5, request);
// 转换结果
return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.URL.getMode(), response,
reqDTO.getOutTradeNo(), response);
}
}

View File

@ -21,6 +21,7 @@ public enum PayChannelEnum {
WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class), WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class),
WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class), WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class),
WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class), WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class),
WX_WAP("wx_wap", "微信 Wap 网站支付", WxPayClientConfig.class), // H5 网页
WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class), WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class),
ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class),