diff --git a/CatmDogd-Mall-Front-test/src/views/model/AppletAmountLog/audit.vue b/CatmDogd-Mall-Front-test/src/views/model/AppletAmountLog/audit.vue index e510c4f..40f620a 100644 --- a/CatmDogd-Mall-Front-test/src/views/model/AppletAmountLog/audit.vue +++ b/CatmDogd-Mall-Front-test/src/views/model/AppletAmountLog/audit.vue @@ -315,13 +315,11 @@ export default { getList() { this.loading = true; // 只查询提现类型的记录 (type=1表示支出,这里是提现记录) - const params = { ...this.queryParams, type: 1 }; + const params = { ...this.queryParams, type: 1, audit: true} listAppletAmountLog(params).then(response => { // 过滤出需要审核的提现记录(有auditStatus字段且nameValue不为空的记录) - this.AppletAmountLogList = response.rows.filter(item => - item.auditStatus !== undefined && item.nameValue - ); - this.total = this.AppletAmountLogList.length; + this.AppletAmountLogList = response.rows + this.total = response.length; this.loading = false; }); }, diff --git a/ruoyi-admin/src/main/resources/application-druid-root.yml b/ruoyi-admin/src/main/resources/application-druid-root.yml index 65b61b2..f12d73a 100644 --- a/ruoyi-admin/src/main/resources/application-druid-root.yml +++ b/ruoyi-admin/src/main/resources/application-druid-root.yml @@ -6,8 +6,8 @@ spring: druid: # 主库数据源 jdbc:mysql://localhost:3306/catmdogf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true master: -# url: jdbc:mysql://47.97.158.59:3306/catmdogf_test20250624?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true - url: jdbc:mysql://47.97.158.59:3306/catmdogf_prod20250624?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true + url: jdbc:mysql://47.97.158.59:3306/catmdogf_test20250624?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true +# url: jdbc:mysql://47.97.158.59:3306/catmdogf_prod20250624?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true username: root password: Qweruiop@123 # 从库数据源 diff --git a/ruoyi-admin/src/main/resources/pay_weixin.properties b/ruoyi-admin/src/main/resources/pay_weixin.properties new file mode 100644 index 0000000..fe94504 --- /dev/null +++ b/ruoyi-admin/src/main/resources/pay_weixin.properties @@ -0,0 +1,8 @@ +pay.mchId=1665639691 +pay.appId=wxd1a6ba7b5e17a5b6 +pay.mchKey=19961022196901121965060120230731 +pay.keyPath=classpath:apiclient_cert.pem +pay.notifyUrl= +pay.notifyUrlDev= +pay.notifyOneUrl= +pay.notifyUrlOneDev= \ No newline at end of file diff --git a/ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/AppletAmountService.java b/ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/AppletAmountService.java index dab4350..64d8be3 100644 --- a/ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/AppletAmountService.java +++ b/ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/AppletAmountService.java @@ -108,7 +108,7 @@ public class AppletAmountService { request.transferSceneId = map.get("transferSceneId").toString(); request.openid = map.get("openid").toString(); request.userName = client.encrypt(map.get("userName").toString()); - request.transferAmount = appletAmountLog.getAmount().longValue()*100;//单位为分 + request.transferAmount = appletAmountLog.getAmount().multiply(new BigDecimal(100)).longValue();//单位为分 request.transferRemark = map.get("transferRemark").toString(); request.notifyUrl = map.get("notifyUrl").toString(); request.userRecvPerception = map.get("userRecvPerception").toString(); diff --git a/ruoyi-catdog/src/main/java/com/ruoyi/model/domain/AppletAmountLog.java b/ruoyi-catdog/src/main/java/com/ruoyi/model/domain/AppletAmountLog.java index c87d68f..3668e6d 100644 --- a/ruoyi-catdog/src/main/java/com/ruoyi/model/domain/AppletAmountLog.java +++ b/ruoyi-catdog/src/main/java/com/ruoyi/model/domain/AppletAmountLog.java @@ -2,6 +2,7 @@ package com.ruoyi.model.domain; import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.TableField; import com.cyl.manager.oms.domain.Order; import com.cyl.manager.ums.domain.Member; import lombok.Data; @@ -69,4 +70,7 @@ public class AppletAmountLog extends BaseEntity @Excel(name = "金额关联订单") private Long orderId; + + @TableField(exist = false) + private Boolean audit; } diff --git a/ruoyi-catdog/src/main/java/com/ruoyi/model/service/impl/AppletAmountLogServiceImpl.java b/ruoyi-catdog/src/main/java/com/ruoyi/model/service/impl/AppletAmountLogServiceImpl.java index a8448e2..eb4fb5e 100644 --- a/ruoyi-catdog/src/main/java/com/ruoyi/model/service/impl/AppletAmountLogServiceImpl.java +++ b/ruoyi-catdog/src/main/java/com/ruoyi/model/service/impl/AppletAmountLogServiceImpl.java @@ -67,6 +67,8 @@ public class AppletAmountLogServiceImpl extends ServiceImpl 8 8 + 3.5.0 @@ -28,11 +29,31 @@ ruoyi-system ${ruoyi.version} + + + + + com.github.binarywang + weixin-java-pay + ${weixin.version} + + + com.github.binarywang + weixin-java-miniapp + ${weixin.version} + + + com.github.binarywang + weixin-java-mp + ${weixin.version} + com.github.wechatpay-apiv3 wechatpay-java 0.2.9 + + com.baomidou mybatis-plus-boot-starter diff --git a/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java b/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java index 4d24844..3035537 100644 --- a/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java +++ b/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; import com.cyl.h5.pojo.dto.PayNotifyMessageDTO; import com.cyl.h5.service.H5OrderService; import com.cyl.wechat.WechatPayConfig; +import com.cyl.wechat.pay.MpWxPayService; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; import com.wechat.pay.java.core.Config; import com.wechat.pay.java.core.notification.NotificationConfig; import com.wechat.pay.java.core.notification.NotificationParser; @@ -15,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -22,6 +25,7 @@ import javax.servlet.http.HttpServletRequest; import java.io.BufferedReader; import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.Date; /** * 订单表Controller @@ -37,6 +41,8 @@ public class PayNotifyController { @Autowired private H5OrderService h5OrderService; + @Autowired + private MpWxPayService mpWxPayService; private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); @@ -70,6 +76,26 @@ public class PayNotifyController { .timestamp(timestamp) .body(requestBody.toString()) .build(); + + //新版本微信公钥的支付回调 + try { + + WxPayOrderNotifyResult notify = mpWxPayService.notify(requestBody.toString()); + + PayNotifyMessageDTO message = new PayNotifyMessageDTO(); + message.setOutTradeNo(Long.valueOf(notify.getOutTradeNo())); + message.setMemberId(Long.valueOf(notify.getAttach())); + message.setTradeStatus(Transaction.TradeStateEnum.SUCCESS); + message.setPayTime(new Date()); + message.setTradeNo(notify.getTransactionId()); + h5OrderService.payCallBack(message); + + return; + }catch (Exception e){ + log.error("新版本微信公钥的支付回调异常:{}", e.getMessage()); + } + + log.info("【requestParam】" + JSONObject.toJSON(requestParam)); //初始化了 RSAAutoCertificateConfig Config config = WechatPayConfig.getInstance(); diff --git a/ruoyi-mall/src/main/java/com/cyl/wechat/pay/MpWxPayService.java b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/MpWxPayService.java new file mode 100644 index 0000000..46650a5 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/MpWxPayService.java @@ -0,0 +1,200 @@ +package com.cyl.wechat.pay; + +import com.cyl.wechat.pay.config.WxPay; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import org.springframework.stereotype.Component; + +import java.io.File; + +@Component +public class MpWxPayService { + + public boolean dev = true; + public WxPay wxPay; + public WxPayService wxPayService; + + + /** + * 生成二维码 + * @param codeUrl + * @param logoFile + * @param sideLength + * @return + */ + public Object createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength){ + try { + byte[] scanPayQrcodeMode2 = wxPayService.createScanPayQrcodeMode2(codeUrl, null, null); + return scanPayQrcodeMode2; + } catch (Exception e) { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + } + + + /** + * 扫码支付 + * @param productName + * @param clientIp + * @param productId + * @param price + * @param orderNo + * @param openId + * @param body + * @return + */ + public Object createQrOrder(String productName, String clientIp, + String productId, Integer price, String orderNo, String body) { + WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); + request.setDeviceInfo("WEB"); //设备号 + request.setTradeType("NATIVE"); //交易类型 + request.setBody(productName); //商品描述 + request.setOutTradeNo(orderNo); //商户订单号 + request.setDetail(productName); //商品详情 + request.setTotalFee(price); //总金额|分计 + request.setSpbillCreateIp(clientIp); //终端IP + request.setNotifyUrl(wxPay.notifyUrl);//设置回调路径 + request.setProductId(productId); //商品id + if (dev) { + request.setTotalFee(price); + request.setNotifyUrl(wxPay.notifyUrlDev); + } + try { + Object order = wxPayService.unifiedOrder(request); + return order; + } catch (WxPayException e) { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + } + + + /** + * 微信吊起支付 + * @param productName + * @param clientIp + * @param productId + * @param price + * @param orderNo + * @param openId + * @param body + * @return + */ + public Object createOrder(String productName, String clientIp, + String productId, Integer price, String orderNo, + String openId, String body){ + WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); + request.setDeviceInfo("WEB"); //设备号 + request.setTradeType("JSAPI"); //交易类型 + request.setBody(productName); //商品描述 + request.setOutTradeNo(orderNo); //商户订单号 + request.setDetail(productName); //商品详情 + request.setTotalFee(price); //总金额|分计 + request.setSpbillCreateIp(clientIp); //终端IP + request.setNotifyUrl(wxPay.notifyOneUrl);//设置回调路径 + request.setProductId(productId); //商品id + request.setOpenid(openId); //JSAPI OPENID + if (dev){ + request.setTotalFee(price); + request.setNotifyUrl(wxPay.notifyUrlOneDev); + } + try { + Object order = wxPayService.createOrder(request); + return order; + } catch (WxPayException e) { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + } + + + public WxPayOrderNotifyResult notify(String requestBody){ + WxPayOrderNotifyResult notify = null; + try { + notify = wxPayService.parseOrderNotifyResult(requestBody); + } catch (WxPayException e) { + e.printStackTrace(); + } + return notify; + } + + + public Object createAppOrder(String productName, String clientIp, + String productId, Integer price, + String orderNo, String body, + String openid){ + WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); + request.setDeviceInfo("WEB"); + request.setBody(productName); + request.setOutTradeNo(orderNo); + request.setDetail(productName); + request.setTotalFee(price); + request.setSpbillCreateIp(clientIp); + request.setNotifyUrl(wxPay.notifyUrl); + request.setTradeType(WxPayConstants.TradeType.JSAPI); + request.setProductId(productId); + request.setAppid(wxPay.appId); + request.setOpenid(openid); + if (dev){ + request.setTotalFee(price); + request.setNotifyUrl(wxPay.notifyUrlDev); + request.setAppid(wxPay.appId); + request.setOpenid(openid); + } + try { + Object order = wxPayService.createOrder(request); + return order; + } catch (WxPayException e) { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + } + + + public Object createWebOrder(String productName, String clientIp, + String productId, Integer price, + String orderNo, String body, + String openid){ + WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); + request.setDeviceInfo("WEB"); + request.setBody(productName); + request.setOutTradeNo(orderNo); + request.setDetail(productName); + request.setTotalFee(price); + request.setSpbillCreateIp(clientIp); + request.setNotifyUrl(wxPay.notifyUrl); + request.setTradeType(WxPayConstants.TradeType.MWEB); + request.setProductId(productId); + request.setAppid(wxPay.appId); + request.setOpenid(openid); + if (dev){ + request.setTotalFee(price); + request.setNotifyUrl(wxPay.notifyUrlDev); + request.setAppid(wxPay.appId); + request.setOpenid(openid); + } + try { + Object order = wxPayService.createOrder(request); + return order; + } catch (WxPayException e) { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + } + + public WxPayOrderNotifyResult appNotify(String requestBody){ + WxPayOrderNotifyResult notify = null; + try { + notify = wxPayService.parseOrderNotifyResult(requestBody); + } catch (WxPayException e) { + e.printStackTrace(); + } + return notify; + } + + +} diff --git a/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPay.java b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPay.java new file mode 100644 index 0000000..b51b4ab --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPay.java @@ -0,0 +1,70 @@ +package com.cyl.wechat.pay.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +@Data +@Component +@PropertySource("classpath:pay_weixin.properties") +@ConfigurationProperties(prefix = "pay") +public class WxPay { + + /** + * 微信支付mchId + */ + public String mchId; + + /** + * app支付appId JS支付openId + */ + public String appId; + + /** + * 微信支付mchKey + */ + public String mchKey; + + /** + * 回调地址 + */ + public String notifyUrl; + + /** + * 回调地址dev + */ + public String notifyUrlDev; + + + /** + * 回调地址 + */ + public String notifyOneUrl; + + /** + * 回调地址dev + */ + public String notifyUrlOneDev; + + /** + * 签名类型 + */ + public String signType; + + /** + * 支付证书路径 + */ + public String keyPath; + + /** + * 回调地址 + */ + public String notifyOrderUrl; + + /** + * 回调地址dev + */ + public String notifyOrderUrlDev; + +} diff --git a/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPayConfiguration.java b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPayConfiguration.java new file mode 100644 index 0000000..7833459 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/wechat/pay/config/WxPayConfiguration.java @@ -0,0 +1,53 @@ +package com.cyl.wechat.pay.config; + +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.Resource; + +@Configuration +@RequiredArgsConstructor +@ConditionalOnClass(WxPayService.class) +public class WxPayConfiguration { + + @Resource + private WxPay wxPay; + + @Bean + public WxPayService wxMpPayService() { + WxPayConfig payConfig = new WxPayConfig(); + payConfig.setAppId(wxPay.appId); + payConfig.setMchId(wxPay.mchId); + payConfig.setMchKey(wxPay.mchKey); + payConfig.setKeyPath(wxPay.keyPath); + payConfig.setSignType(WxPayConstants.SignType.MD5); + WxPayService wxPayService = new WxPayServiceImpl(); + wxPayService.setConfig(payConfig); + return wxPayService; + } + +// @Bean("saboxWxPayService") +// public WxPayService saboxWxPayService(){ +// WxPayConfig payConfig = new WxPayConfig(); +// WxPayService wxPayService = new WxPayServiceImpl(); +// String sandboxSignKey = null; +// try { +// wxPayService.setConfig(payConfig); +// sandboxSignKey = wxPayService.getSandboxSignKey(); +// } catch (WxPayException e) { +// e.printStackTrace(); +// } +// payConfig.setUseSandboxEnv(true); +// payConfig.setMchKey(sandboxSignKey); +// wxPayService.setConfig(payConfig); +// return wxPayService; +// } + +} \ No newline at end of file