From e3801e9595dca364afafe9d051fa601e77fecfe0 Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Mon, 23 Sep 2024 21:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/util/WechatPayConfig.java | 5 ++- .../yudao/module/app/apy/RepairPayApi.java | 35 +++++++++++++++ .../controller/admin/RepairPayController.java | 43 +++++++++++++++++++ .../service/RepairOrderInfoService.java | 10 ++++- .../impl/RepairOrderInfoServiceImpl.java | 43 ++++++++++++++++++- .../project/vo/RepairOrderInfoRespVO.java | 4 +- .../YudaoWebSecurityConfigurerAdapter.java | 1 + .../src/main/resources/application.yaml | 2 + 8 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/apy/RepairPayApi.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairPayController.java diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/util/WechatPayConfig.java b/dl-module-base/src/main/java/cn/iocoder/yudao/util/WechatPayConfig.java index 3ea5f9ad..1b903314 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/util/WechatPayConfig.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/util/WechatPayConfig.java @@ -58,7 +58,10 @@ public class WechatPayConfig { * 退款回调地址 */ private String refundNotifyUrl="https://www.nuoyunr.com/jdcJc/notify/refundNotify"; - + /** + * 汽修通知回调地址 + */ + private String repairNotifyUrl="https://www.nuoyunr.com/admin-api/repairPayApi/payNotify"; /** * API 证书中的 key.pem */ diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/apy/RepairPayApi.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/apy/RepairPayApi.java new file mode 100644 index 00000000..2938981e --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/apy/RepairPayApi.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.app.apy; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.project.service.RepairOrderInfoService; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 维修模块 支付模块") +@RestController +@RequestMapping("/userClient/pay") +@Validated +public class RepairPayApi { + @Resource + private RepairOrderInfoService repairOrderInfoService; + + /** + * 支付吊起接口 + * @param orderId 订单主键 + * @return + */ + @GetMapping("/toPay") + public CommonResult> payTransactions(String orderId){ + Map res = repairOrderInfoService.payTransactions(orderId); + return success(res); + } + +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairPayController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairPayController.java new file mode 100644 index 00000000..668513a1 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairPayController.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.project.controller.admin; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.project.service.RepairOrderInfoService; +import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; +import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 维修模块 支付模块") +@RestController +@RequestMapping("/admin-api/pay") +@Validated +public class RepairPayController { + @Resource + private RepairOrderInfoService repairOrderInfoService; + + /** + * 支付吊起接口 + * @param orderId 订单主键 + * @return + */ + @GetMapping("/toPay") + public CommonResult> payTransactions(String orderId){ + Map res = repairOrderInfoService.payTransactions(orderId); + return success(res); + } + +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairOrderInfoService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairOrderInfoService.java index d0b193e1..01c3beb1 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairOrderInfoService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairOrderInfoService.java @@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.Map; + /** * 维修模块 订单 Service 接口 * @@ -86,4 +88,10 @@ public interface RepairOrderInfoService extends IService { * @param respVO 请求对象 **/ void appraiseOrder(RepairOrderInfoRespVO respVO); -} \ No newline at end of file + /** + * 支付吊起接口 + * @param orderId 订单主键 + * @return + */ + Map payTransactions(String orderId); +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairOrderInfoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairOrderInfoServiceImpl.java index 32776ac2..2c9cee9f 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairOrderInfoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairOrderInfoServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.project.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.project.entity.RepairOrderInfo; import cn.iocoder.yudao.module.project.mapper.RepairOrderInfoMapper; import cn.iocoder.yudao.module.project.service.RepairOrderInfoService; @@ -12,15 +13,25 @@ import cn.iocoder.yudao.module.project.vo.RepairOrderInfoSaveReqVO; import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO; +import cn.iocoder.yudao.util.WechatPayConfig; +import cn.iocoder.yudao.util.WechatPayRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * 维修模块 订单 Service 实现类 @@ -37,6 +48,10 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl payTransactions(String orderId){ + RepairOrderInfo orderInfo = this.getById(orderId); + // 统一参数封装 + Map params = new HashMap<>(8); + params.put("appid", wechatPayConfig.getAppId()); + params.put("mchid", wechatPayConfig.getMchId()); + params.put("description", orderInfo.getPayRemark()); + params.put("out_trade_no", orderInfo.getOrderNo()); + params.put("notify_url", wechatPayConfig.getRepairNotifyUrl()); + Map amountMap = new HashMap<>(4); + // 金额单位为分 + amountMap.put("total", orderInfo.getPayMoney()); + //人民币 + amountMap.put("currency", "CNY"); + params.put("amount", amountMap); + String paramsStr = JSON.toJSONString(params); + String resStr = wechatPayRequest.wechatHttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/native",paramsStr); + return JSONObject.parseObject(resStr, new TypeReference>(){}); + } + +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairOrderInfoRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairOrderInfoRespVO.java index 93496159..ac138373 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairOrderInfoRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairOrderInfoRespVO.java @@ -20,5 +20,7 @@ public class RepairOrderInfoRespVO extends RepairOrderInfo { /** 工单信息(包含子表) */ private DlRepairTicketsRespVO tickets; + //订单描述 + private String description; -} \ No newline at end of file +} diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index b192f511..beb47d3a 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -145,6 +145,7 @@ public class YudaoWebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET,"/admin-api/shop/region/**").permitAll() // 微信支付接口 .antMatchers("/admin-api/notify/**").permitAll() + .antMatchers("/userClient/pay/**").permitAll() .antMatchers("/admin-api/websocket/**").permitAll() // 小程序首页 .antMatchers("/admin-api/system/notice/listWx","/admin-api/system/swiper/listWx","/admin-api/system/shopconfig/listWx").permitAll() diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index ff6900d0..067b502c 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -222,6 +222,7 @@ yudao: - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - /admin-api/system/config/configKey/** - /websocket/** + - /userClient/pay/** - /admin-api/websocket/** - /admin-api/rescue/wxLoginRescue - /admin-api/rescue/wxLoginJc @@ -278,6 +279,7 @@ yudao: - /admin-api/rescue/loginJcApp - /admin-api/system/tenant/getListByWebsite - /admin-api/websocket/** + - /userClient/pay/** ignore-tables: - system_tenant - system_tenant_package