Compare commits

...

3 Commits

Author SHA1 Message Date
perry 12228e7d09 Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product_new 2023-05-18 19:28:21 +08:00
perry 46563efd16 微信支付 2023-05-18 19:28:02 +08:00
perry 18909d4c2c 微信支付 2023-05-18 18:49:43 +08:00
9 changed files with 1164 additions and 905 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

@ -28,7 +28,7 @@ public class PhoneRecordDO extends BaseDO {
/**
*
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* id

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.shop.service.order.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.StrUtil;
@ -1281,15 +1282,15 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
@Override
public Boolean wxPayNotify(WxPayOrderNotifyV3Result.DecryptNotifyResult result) {
log.info("支付通知=" + JSONUtil.toJsonPrettyStr(result));
if (StringUtils.equals("SUCCESS", result.getTradeType())) {
if (StringUtils.equals("SUCCESS", result.getTradeState())) {
log.info("WXPAY====result===>");
// 验证相关参数-金额
String outTradeNo = result.getOutTradeNo();
// 用户支付金额
Integer payerTotal = result.getAmount().getPayerTotal() / 100;
BigDecimal payerTotal = NumberUtil.div(result.getAmount().getPayerTotal()+"","100",2);
// 处理相关逻辑
RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getOrderId, outTradeNo));
if (new BigDecimal(payerTotal).compareTo(orderDO.getPayPrice()) != 0) {
if (payerTotal.compareTo(orderDO.getPayPrice()) != 0) {
log.error("支付金额不匹配,订单实际支付金额:{},微信入参验证金额:{}", orderDO.getPayPrice(), payerTotal);
return Boolean.FALSE;
}
@ -1332,7 +1333,8 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
orderDO.setUserPhone(StringUtils.isEmpty(request.getUserPhone()) ? user.getMobile() : request.getUserPhone());
orderDO.setConfirmPhone(StringUtils.isEmpty(request.getConfirmPhone()) ? user.getMobile() : request.getConfirmPhone());
orderDO.setTotalNum(orderInfos.size());
BigDecimal sum = new BigDecimal(orderInfos.stream().mapToDouble(OrderContentRequest.OrderInfo::getGearAmount).sum());
// BigDecimal sum = new BigDecimal(orderInfos.stream().mapToDouble(OrderContentRequest.OrderInfo::getGearAmount).sum());
BigDecimal sum = new BigDecimal("0.01");
orderDO.setTotalPrice(sum);
orderDO.setPayPrice(sum);
orderDO.setPayTime(LocalDateTime.now());

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