Bladeren bron

Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro

YunaiV 1 jaar geleden
bovenliggende
commit
10cc9fa77f

+ 9 - 0
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.crm.enums.product;
 
+import cn.hutool.core.util.ObjUtil;
 import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
@@ -35,4 +36,12 @@ public enum CrmProductStatusEnum implements IntArrayValuable {
         return ARRAYS;
     }
 
+    public static boolean isEnable(Integer status) {
+        return ObjUtil.equal(ENABLE.status, status);
+    }
+
+    public static boolean isDisable(Integer status) {
+        return ObjUtil.equal(DISABLE.status, status);
+    }
+
 }

+ 2 - 2
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java

@@ -1,7 +1,6 @@
 package cn.iocoder.yudao.module.crm.controller.admin.product;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -14,6 +13,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProduc
 import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
+import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum;
 import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService;
 import cn.iocoder.yudao.module.crm.service.product.CrmProductService;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@@ -96,7 +96,7 @@ public class CrmProductController {
     @GetMapping("/simple-list")
     @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项")
     public CommonResult<List<CrmProductRespVO>> getProductSimpleList() {
-        List<CrmProductDO> list = productService.getProductListByStatus(CommonStatusEnum.ENABLE.getStatus());
+        List<CrmProductDO> list = productService.getProductListByStatus(CrmProductStatusEnum.ENABLE.getStatus());
         return success(convertList(list, product -> new CrmProductRespVO().setId(product.getId()).setName(product.getName())
                 .setUnit(product.getUnit()).setNo(product.getNo()).setPrice(product.getPrice())));
     }

+ 3 - 0
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java

@@ -345,6 +345,9 @@ public class CrmContractServiceImpl implements CrmContractService {
             if (config != null && Boolean.FALSE.equals(config.getNotifyEnabled())) {
                 config = null;
             }
+            if (config == null) {
+                return PageResult.empty();
+            }
         }
         // 2. 查询分页
         return contractMapper.selectPage(pageReqVO, userId, config);

+ 2 - 2
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java

@@ -1,7 +1,6 @@
 package cn.iocoder.yudao.module.crm.service.product;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
@@ -11,6 +10,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
 import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductMapper;
 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
 import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
+import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum;
 import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
@@ -165,7 +165,7 @@ public class CrmProductServiceImpl implements CrmProductService {
             if (productMap.get(id) == null) {
                 throw exception(PRODUCT_NOT_EXISTS);
             }
-            if (CommonStatusEnum.isDisable(product.getStatus())) {
+            if (CrmProductStatusEnum.isDisable(product.getStatus())) {
                 throw exception(PRODUCT_NOT_ENABLE, product.getName());
             }
         }

+ 1 - 1
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java

@@ -164,9 +164,9 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
     @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
     public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) {
         Assert.notNull(updateReqVO.getId(), "回款编号不能为空");
-        updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段
         // 1.1 校验可回款金额超过上限
         validateReceivablePriceExceedsLimit(updateReqVO);
+        updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段
         // 1.2 校验存在
         CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId());
         // 1.3 只有草稿、审批中,可以编辑;

+ 8 - 0
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java

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

+ 62 - 0
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxWapPayClient.java

@@ -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);
+    }
+
+}

+ 1 - 0
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java

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