fix
This commit is contained in:
+1
@@ -143,6 +143,7 @@ public class MultiUserDetailsAuthenticationProvider extends AbstractUserDetailsA
|
|||||||
if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix())
|
if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix())
|
||||||
|| request.getRequestURI().startsWith("/common/")
|
|| request.getRequestURI().startsWith("/common/")
|
||||||
|| request.getRequestURI().startsWith("/bxg")
|
|| request.getRequestURI().startsWith("/bxg")
|
||||||
|
|| request.getRequestURI().startsWith("/api/upload")
|
||||||
) {
|
) {
|
||||||
return UserTypeEnum.ADMIN;
|
return UserTypeEnum.ADMIN;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-18
@@ -9,6 +9,7 @@
|
|||||||
package co.yixiang.app.modules.wechat.rest.controller;
|
package co.yixiang.app.modules.wechat.rest.controller;
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import co.yixiang.annotation.AnonymousAccess;
|
import co.yixiang.annotation.AnonymousAccess;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.ApiResult;
|
import cn.iocoder.yudao.framework.common.pojo.ApiResult;
|
||||||
import co.yixiang.constant.SystemConfigConstants;
|
import co.yixiang.constant.SystemConfigConstants;
|
||||||
@@ -45,11 +46,7 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
|||||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -95,9 +92,10 @@ public class WechatController {
|
|||||||
/**
|
/**
|
||||||
* jssdk配置
|
* jssdk配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/wechat/config")
|
@GetMapping("/wechat/config/{tenantCode}")
|
||||||
@ApiOperation(value = "jssdk配置",notes = "jssdk配置")
|
@ApiOperation(value = "jssdk配置",notes = "jssdk配置")
|
||||||
public ApiResult<Map<String,Object>> jsConfig(HttpServletRequest request) throws WxErrorException {
|
public ApiResult<Map<String,Object>> jsConfig(HttpServletRequest request,@PathVariable String tenantCode) throws WxErrorException {
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
||||||
String url = request.getParameter("url");
|
String url = request.getParameter("url");
|
||||||
log.info("url:"+url);
|
log.info("url:"+url);
|
||||||
@@ -118,14 +116,15 @@ public class WechatController {
|
|||||||
/**
|
/**
|
||||||
* 微信小程序接口能力配置
|
* 微信小程序接口能力配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/wxapp/config")
|
@GetMapping("/wxapp/config/{tenantCode}")
|
||||||
@ApiOperation(value = "微信小程序接口能力配置",notes = "微信小程序接口能力配置",produces = "text/plain;charset=utf-8")
|
@ApiOperation(value = "微信小程序接口能力配置",notes = "微信小程序接口能力配置",produces = "text/plain;charset=utf-8")
|
||||||
public String wxAppConfig(@RequestParam(value = "signature") String signature,
|
public String wxAppConfig(@RequestParam(value = "signature") String signature,
|
||||||
@RequestParam(value = "timestamp") String timestamp,
|
@RequestParam(value = "timestamp") String timestamp,
|
||||||
@RequestParam(value = "nonce") String nonce,
|
@RequestParam(value = "nonce") String nonce,
|
||||||
|
@PathVariable String tenantCode,
|
||||||
@RequestParam(name = "echostr", required = false) String echostr) throws WxErrorException {
|
@RequestParam(name = "echostr", required = false) String echostr) throws WxErrorException {
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
WxMaService wxService = WxMaConfiguration.getWxMaService();
|
WxMaService wxService = WxMaConfiguration.getWxMaService();
|
||||||
|
|
||||||
if( wxService.checkSignature(timestamp,nonce,signature)){
|
if( wxService.checkSignature(timestamp,nonce,signature)){
|
||||||
return echostr;
|
return echostr;
|
||||||
}
|
}
|
||||||
@@ -136,9 +135,11 @@ public class WechatController {
|
|||||||
* 微信支付/充值回调
|
* 微信支付/充值回调
|
||||||
*/
|
*/
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@PostMapping("/wechat/notify")
|
@PostMapping("/wechat/notify/{tenantCode}")
|
||||||
@ApiOperation(value = "微信支付充值回调",notes = "微信支付充值回调")
|
@ApiOperation(value = "微信支付充值回调",notes = "微信支付充值回调")
|
||||||
public String renotify(@RequestBody String xmlData) {
|
public String renotify(@RequestBody String xmlData, @PathVariable String tenantCode) {
|
||||||
|
log.info("tenantCode:{}",tenantCode);
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
try {
|
try {
|
||||||
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
|
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
|
||||||
if(wxPayService == null) {
|
if(wxPayService == null) {
|
||||||
@@ -174,6 +175,7 @@ public class WechatController {
|
|||||||
|
|
||||||
return WxPayNotifyResponse.success("处理成功!");
|
return WxPayNotifyResponse.success("处理成功!");
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
|
e.printStackTrace();
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return WxPayNotifyResponse.fail(e.getMessage());
|
return WxPayNotifyResponse.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -184,8 +186,10 @@ public class WechatController {
|
|||||||
* 微信退款回调
|
* 微信退款回调
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "退款回调通知处理",notes = "退款回调通知处理")
|
@ApiOperation(value = "退款回调通知处理",notes = "退款回调通知处理")
|
||||||
@PostMapping("/notify/refund")
|
@PostMapping("/notify/refund/{tenantCode}")
|
||||||
public String parseRefundNotifyResult(@RequestBody String xmlData) {
|
public String parseRefundNotifyResult(@RequestBody String xmlData,@PathVariable String tenantCode) {
|
||||||
|
log.info("tenantCode:{}",tenantCode);
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
try {
|
try {
|
||||||
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
|
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
|
||||||
if(wxPayService == null) {
|
if(wxPayService == null) {
|
||||||
@@ -225,13 +229,15 @@ public class WechatController {
|
|||||||
/**
|
/**
|
||||||
* 微信验证消息
|
* 微信验证消息
|
||||||
*/
|
*/
|
||||||
@GetMapping( value = "/wechat/serve",produces = "text/plain;charset=utf-8")
|
@GetMapping( value = "/wechat/serve/{tenantCode}",produces = "text/plain;charset=utf-8")
|
||||||
@ApiOperation(value = "微信验证消息",notes = "微信验证消息")
|
@ApiOperation(value = "微信验证消息",notes = "微信验证消息")
|
||||||
public String authGet(@RequestParam(name = "signature", required = false) String signature,
|
public String authGet(@RequestParam(name = "signature", required = false) String signature,
|
||||||
@RequestParam(name = "timestamp", required = false) String timestamp,
|
@RequestParam(name = "timestamp", required = false) String timestamp,
|
||||||
@RequestParam(name = "nonce", required = false) String nonce,
|
@RequestParam(name = "nonce", required = false) String nonce,
|
||||||
@RequestParam(name = "echostr", required = false) String echostr){
|
@RequestParam(name = "echostr", required = false) String echostr,
|
||||||
|
@PathVariable String tenantCode
|
||||||
|
){
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
final WxMpService wxService = WxMpConfiguration.getWxMpService();
|
final WxMpService wxService = WxMpConfiguration.getWxMpService();
|
||||||
if (wxService == null) {
|
if (wxService == null) {
|
||||||
throw new IllegalArgumentException("未找到对应配置的服务,请核实!");
|
throw new IllegalArgumentException("未找到对应配置的服务,请核实!");
|
||||||
@@ -247,7 +253,7 @@ public class WechatController {
|
|||||||
/**
|
/**
|
||||||
*微信获取消息
|
*微信获取消息
|
||||||
*/
|
*/
|
||||||
@PostMapping("/wechat/serve")
|
@PostMapping("/wechat/serve/{tenantCode}")
|
||||||
@ApiOperation(value = "微信获取消息",notes = "微信获取消息")
|
@ApiOperation(value = "微信获取消息",notes = "微信获取消息")
|
||||||
public void post(@RequestBody String requestBody,
|
public void post(@RequestBody String requestBody,
|
||||||
@RequestParam("signature") String signature,
|
@RequestParam("signature") String signature,
|
||||||
@@ -256,11 +262,12 @@ public class WechatController {
|
|||||||
@RequestParam("openid") String openid,
|
@RequestParam("openid") String openid,
|
||||||
@RequestParam(name = "encrypt_type", required = false) String encType,
|
@RequestParam(name = "encrypt_type", required = false) String encType,
|
||||||
@RequestParam(name = "msg_signature", required = false) String msgSignature,
|
@RequestParam(name = "msg_signature", required = false) String msgSignature,
|
||||||
|
@PathVariable String tenantCode,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
|
TenantContextHolder.setTenantId(Long.valueOf(tenantCode));
|
||||||
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
||||||
|
|
||||||
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
||||||
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
|
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class WxPayConfiguration {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static WxPayService getPayService(PayMethodEnum payMethodEnum) {
|
public static WxPayService getPayService(PayMethodEnum payMethodEnum) {
|
||||||
WxPayService wxPayService = payServices.get(ShopKeyUtils.getYshopWeiXinPayService()+payMethodEnum.getValue());
|
String payKey = ShopKeyUtils.getYshopWeiXinPayService() +":"+ payMethodEnum.getValue();
|
||||||
|
WxPayService wxPayService = payServices.get(payKey);
|
||||||
if(wxPayService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinPayService()) == null) {
|
if(wxPayService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinPayService()) == null) {
|
||||||
WxPayConfig payConfig = new WxPayConfig();
|
WxPayConfig payConfig = new WxPayConfig();
|
||||||
switch (payMethodEnum){
|
switch (payMethodEnum){
|
||||||
@@ -64,7 +65,7 @@ public class WxPayConfiguration {
|
|||||||
payConfig.setUseSandboxEnv(false);
|
payConfig.setUseSandboxEnv(false);
|
||||||
wxPayService = new WxPayServiceImpl();
|
wxPayService = new WxPayServiceImpl();
|
||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
payServices.put(ShopKeyUtils.getYshopWeiXinPayService()+payMethodEnum.getValue(), wxPayService);
|
payServices.put(payKey, wxPayService);
|
||||||
|
|
||||||
//增加标识
|
//增加标识
|
||||||
redisUtils.set(ShopKeyUtils.getYshopWeiXinPayService(),"yshop");
|
redisUtils.set(ShopKeyUtils.getYshopWeiXinPayService(),"yshop");
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import cn.hutool.core.lang.UUID;
|
|||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import co.yixiang.api.BusinessException;
|
import co.yixiang.api.BusinessException;
|
||||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||||
import co.yixiang.enums.AppFromEnum;
|
import co.yixiang.enums.AppFromEnum;
|
||||||
@@ -125,7 +126,7 @@ public class WeixinPayService {
|
|||||||
orderRequest.setOutTradeNo(orderId);
|
orderRequest.setOutTradeNo(orderId);
|
||||||
orderRequest.setTotalFee(payPrice);
|
orderRequest.setTotalFee(payPrice);
|
||||||
orderRequest.setSpbillCreateIp(IpUtil.getLocalIP());
|
orderRequest.setSpbillCreateIp(IpUtil.getLocalIP());
|
||||||
orderRequest.setNotifyUrl(this.getApiUrl() + "/xiaohuiapp/wechat/notify");
|
orderRequest.setNotifyUrl(this.getApiUrl() + "/bxgApp/wechat/notify/"+ TenantContextHolder.getTenantId().toString());
|
||||||
orderRequest.setBody(body);
|
orderRequest.setBody(body);
|
||||||
orderRequest.setAttach(attach);
|
orderRequest.setAttach(attach);
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ public class WeixinPayService {
|
|||||||
wxPayRefundRequest.setOutRefundNo(orderSn);
|
wxPayRefundRequest.setOutRefundNo(orderSn);
|
||||||
//退款金额
|
//退款金额
|
||||||
wxPayRefundRequest.setRefundFee(refundFee);
|
wxPayRefundRequest.setRefundFee(refundFee);
|
||||||
wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/xiaohuiapp/notify/refund");
|
wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/bxgApp/notify/refund/"+ TenantContextHolder.getTenantId().toString());
|
||||||
try {
|
try {
|
||||||
wxPayService.refundV2(wxPayRefundRequest);
|
wxPayService.refundV2(wxPayRefundRequest);
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package co.yixiang.utils;
|
package co.yixiang.utils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import co.yixiang.constant.ShopConstants;
|
import co.yixiang.constant.ShopConstants;
|
||||||
import co.yixiang.constant.SystemConfigConstants;
|
import co.yixiang.constant.SystemConfigConstants;
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ public class ShopKeyUtils {
|
|||||||
* 微信支付service
|
* 微信支付service
|
||||||
*/
|
*/
|
||||||
public static String getYshopWeiXinPayService(){
|
public static String getYshopWeiXinPayService(){
|
||||||
String yshopWeiXinPayService= ShopConstants.ZSW_WEIXIN_PAY_SERVICE;
|
String yshopWeiXinPayService= TenantContextHolder.getTenantId().toString() + ":"+ShopConstants.ZSW_WEIXIN_PAY_SERVICE;
|
||||||
return yshopWeiXinPayService+getExtendValue();
|
return yshopWeiXinPayService+getExtendValue();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -120,14 +121,14 @@ public class ShopKeyUtils {
|
|||||||
* 微信支付小程序service
|
* 微信支付小程序service
|
||||||
*/
|
*/
|
||||||
public static String getYshopWeiXinMiniPayService(){
|
public static String getYshopWeiXinMiniPayService(){
|
||||||
String yshopWeiXinMiniPayService= ShopConstants.ZSW_WEIXIN_MINI_PAY_SERVICE;
|
String yshopWeiXinMiniPayService= TenantContextHolder.getTenantId().toString() + ":" + ShopConstants.ZSW_WEIXIN_MINI_PAY_SERVICE;
|
||||||
return yshopWeiXinMiniPayService+getExtendValue();
|
return yshopWeiXinMiniPayService+getExtendValue();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 微信支付app service
|
* 微信支付app service
|
||||||
*/
|
*/
|
||||||
public static String getYshopWeiXinAppPayService(){
|
public static String getYshopWeiXinAppPayService(){
|
||||||
String yshopWeiXinAppPayService= ShopConstants.ZSW_WEIXIN_APP_PAY_SERVICE;
|
String yshopWeiXinAppPayService= TenantContextHolder.getTenantId().toString() + ":" + ShopConstants.ZSW_WEIXIN_APP_PAY_SERVICE;
|
||||||
return yshopWeiXinAppPayService+getExtendValue();
|
return yshopWeiXinAppPayService+getExtendValue();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -173,7 +174,7 @@ public class ShopKeyUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getYshopWeiXinMaSevice() {
|
public static String getYshopWeiXinMaSevice() {
|
||||||
String yshopWeiXinMaSevice= ShopConstants.ZSW_WEIXIN_MA_SERVICE;
|
String yshopWeiXinMaSevice= TenantContextHolder.getTenantId().toString() + ":" + ShopConstants.ZSW_WEIXIN_MA_SERVICE;
|
||||||
return yshopWeiXinMaSevice+getExtendValue();
|
return yshopWeiXinMaSevice+getExtendValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user