微信支付

pull/2/head
perry 2023-05-18 18:49:43 +08:00
parent 3a0fd70313
commit 18909d4c2c
7 changed files with 1157 additions and 900 deletions

View File

@ -30,4 +30,22 @@ public class InitOrderResponse implements Serializable {
@Schema(description ="支付宝返回参数")
private String body;
@Schema(description ="jsapi返回参数")
private JsapiResult jsapiResult;
@Data
@Accessors(chain = true)
public static class JsapiResult implements Serializable {
private static final long serialVersionUID = 4465376277943307271L;
private String appId;
private String timeStamp;
private String nonceStr;
private String packageValue;
private String signType;
private String paySign;
private String getSignStr() {
return String.format("%s\n%s\n%s\n%s\n", appId, timeStamp, nonceStr, packageValue);
}
}
}

View File

@ -43,7 +43,8 @@ public class WxPayStrategy implements IPayStrategy{
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
Assert.notNull(wxPayService, "获取微信支付配置失败!");
WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request();
int sum = orderDO.getPayPrice().multiply(new BigDecimal("100")).intValue();
// int sum = orderDO.getPayPrice().multiply(new BigDecimal("100")).intValue();
int sum = 1;
wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum));
wxPayRequest.setDescription("会员充值");
wxPayRequest.setOutTradeNo(orderDO.getOrderId());
@ -54,6 +55,10 @@ public class WxPayStrategy implements IPayStrategy{
wxPayRequest.setMchid(payProperties.getMchId());
try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = wxPayUnifiedOrderV3Result.getPayInfo(TradeTypeEnum.JSAPI, payProperties.getAppId(), payProperties.getMchId(), wxPayService.getConfig().getPrivateKey());
InitOrderResponse.JsapiResult jsapiResultNew = new InitOrderResponse.JsapiResult();
BeanUtils.copyProperties(jsapiResult, jsapiResultNew);
response.setJsapiResult(jsapiResultNew);
BeanUtils.copyProperties(wxPayUnifiedOrderV3Result, response);
} catch (Exception e) {
log.error(e.getMessage());

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.api.user;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.member.convert.user.UserConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
@ -27,22 +28,26 @@ public class MemberUserApiImpl implements MemberUserApi {
private MemberUserService userService;
@Override
@TenantIgnore
public MemberUserRespDTO getUser(Long id) {
MemberUserDO user = userService.getUser(id);
return UserConvert.INSTANCE.convert2(user);
}
@Override
@TenantIgnore
public List<MemberUserRespDTO> getUsers(Collection<Long> ids) {
return UserConvert.INSTANCE.convertList2(userService.getUserList(ids));
}
@Override
@TenantIgnore
public List<MemberUserRespDTO> getUserListByNickname(String nickname) {
return UserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname));
}
@Override
@TenantIgnore
public MemberUserRespDTO getUserByMobile(String mobile) {
return UserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile));
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.member.controller.admin.user.dto.AdminUserQueryDTO;
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobileReqVO;
@ -114,6 +115,7 @@ public class MemberUserServiceImpl implements MemberUserService {
}
@Override
@TenantIgnore
public MemberUserDO getUser(Long id) {
return memberUserMapper.selectById(id);
}

View File

@ -186,7 +186,7 @@ wx:
private-cert-path: classpath:/1/apiclient_cert.pem
private-key-path: classpath:/1/apiclient_key.pem
key-path: classpath:/1/apiclient_cert.p12
cert-serial-no: 58FDB503F92B6C0E258C9940BB726C2BF6022E56
cert-serial-no: 7F76A4ADC52CA0B440C4E5698F8A5CD1633A0FCD
notify-url: http://yuxy.perrymake.com/admin-api/notify/wxpay/pay_notify
refund-notify-url: http://yuxy.perrymake.com/admin-api/notify/wxpay/refund_notify
two:

View File

@ -107,7 +107,7 @@ yudao:
security:
permit-all_urls:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/notice/wxpay/**
- /admin-api/notify/wxpay/**
websocket:
enable: true # websocket的开关
path: /websocket/message # 路径

File diff suppressed because it is too large Load Diff