This commit is contained in:
PQZ 2024-09-23 21:10:03 +08:00
commit 51ffaf71c2
8 changed files with 139 additions and 4 deletions

View File

@ -58,7 +58,10 @@ public class WechatPayConfig {
* 退款回调地址 * 退款回调地址
*/ */
private String refundNotifyUrl="https://www.nuoyunr.com/jdcJc/notify/refundNotify"; private String refundNotifyUrl="https://www.nuoyunr.com/jdcJc/notify/refundNotify";
/**
* 汽修通知回调地址
*/
private String repairNotifyUrl="https://www.nuoyunr.com/admin-api/repairPayApi/payNotify";
/** /**
* API 证书中的 key.pem * API 证书中的 key.pem
*/ */

View File

@ -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<Map<String, Object>> payTransactions(String orderId){
Map<String, Object> res = repairOrderInfoService.payTransactions(orderId);
return success(res);
}
}

View File

@ -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<Map<String, Object>> payTransactions(String orderId){
Map<String, Object> res = repairOrderInfoService.payTransactions(orderId);
return success(res);
}
}

View File

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/** /**
* 维修模块 订单 Service 接口 * 维修模块 订单 Service 接口
* *
@ -86,4 +88,10 @@ public interface RepairOrderInfoService extends IService<RepairOrderInfo> {
* @param respVO 请求对象 * @param respVO 请求对象
**/ **/
void appraiseOrder(RepairOrderInfoRespVO respVO); void appraiseOrder(RepairOrderInfoRespVO respVO);
} /**
* 支付吊起接口
* @param orderId 订单主键
* @return
*/
Map<String,Object> payTransactions(String orderId);
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.project.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 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.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.project.mapper.RepairOrderInfoMapper; import cn.iocoder.yudao.module.project.mapper.RepairOrderInfoMapper;
import cn.iocoder.yudao.module.project.service.RepairOrderInfoService; 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.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* 维修模块 订单 Service 实现类 * 维修模块 订单 Service 实现类
@ -37,6 +48,10 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
@Resource @Resource
@Lazy @Lazy
private DlRepairTicketsService ticketsService; private DlRepairTicketsService ticketsService;
@Resource
private WechatPayConfig wechatPayConfig;
@Resource
private WechatPayRequest wechatPayRequest;
/** /**
* 保存订单信息 * 保存订单信息
@ -130,4 +145,30 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
baseMapper.updateById(respVO); baseMapper.updateById(respVO);
} }
}
/**
* 支付吊起接口
* @param orderId 订单主键
* @return
*/
public Map<String,Object> payTransactions(String orderId){
RepairOrderInfo orderInfo = this.getById(orderId);
// 统一参数封装
Map<String, Object> 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<String, Object> 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<Map<String, Object>>(){});
}
}

View File

@ -20,5 +20,7 @@ public class RepairOrderInfoRespVO extends RepairOrderInfo {
/** 工单信息(包含子表) */ /** 工单信息(包含子表) */
private DlRepairTicketsRespVO tickets; private DlRepairTicketsRespVO tickets;
//订单描述
private String description;
} }

View File

@ -145,6 +145,7 @@ public class YudaoWebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.GET,"/admin-api/shop/region/**").permitAll() .antMatchers(HttpMethod.GET,"/admin-api/shop/region/**").permitAll()
// 微信支付接口 // 微信支付接口
.antMatchers("/admin-api/notify/**").permitAll() .antMatchers("/admin-api/notify/**").permitAll()
.antMatchers("/userClient/pay/**").permitAll()
.antMatchers("/admin-api/websocket/**").permitAll() .antMatchers("/admin-api/websocket/**").permitAll()
// 小程序首页 // 小程序首页
.antMatchers("/admin-api/system/notice/listWx","/admin-api/system/swiper/listWx","/admin-api/system/shopconfig/listWx").permitAll() .antMatchers("/admin-api/system/notice/listWx","/admin-api/system/swiper/listWx","/admin-api/system/shopconfig/listWx").permitAll()

View File

@ -222,6 +222,7 @@ yudao:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/system/config/configKey/** - /admin-api/system/config/configKey/**
- /websocket/** - /websocket/**
- /userClient/pay/**
- /admin-api/websocket/** - /admin-api/websocket/**
- /admin-api/rescue/wxLoginRescue - /admin-api/rescue/wxLoginRescue
- /admin-api/rescue/wxLoginJc - /admin-api/rescue/wxLoginJc
@ -278,6 +279,7 @@ yudao:
- /admin-api/rescue/loginJcApp - /admin-api/rescue/loginJcApp
- /admin-api/system/tenant/getListByWebsite - /admin-api/system/tenant/getListByWebsite
- /admin-api/websocket/** - /admin-api/websocket/**
- /userClient/pay/**
ignore-tables: ignore-tables:
- system_tenant - system_tenant
- system_tenant_package - system_tenant_package