fix:登录相关逻辑修复

This commit is contained in:
2025-06-02 00:31:47 +08:00
parent 9b7fa58fcf
commit 44f4745b70
20 changed files with 206 additions and 194 deletions
@@ -471,7 +471,8 @@ public class OrderController {
@PostMapping("/update/order")
public Result updateOrder(@RequestBody Order order) {
LoginAppUser loginAppUser = LoginUserContextHolder.getUser();
if (loginAppUser.getId() == 1){
//
if (loginAppUser.getId() == 1 || loginAppUser.getId() == 1073) {
boolean res = orderService.updateOrder(order);
if (res){
return Result.succeed("已更新");
@@ -16,7 +16,6 @@ import com.central.order.model.OrderFile;
import com.central.order.model.OrderRanking;
import com.central.order.service.IOrderService;
import com.central.order.util.DateUtils;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,9 +50,6 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
private final ExecutorService executorService = Executors.newFixedThreadPool(10); // 线程池,可根据实际并发量调整大小
@Autowired
private JsapiServiceExtension service;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@Autowired
private OrderMapper orderMapper;
@@ -117,12 +117,3 @@ wx:
video-complete: TEMPLATE_ID_2 # 视频完成通知模板ID
video-failure: TEMPLATE_ID_3 # 视频失败通知模板ID
mini:
app-id: ${zlt.wxpay.appId}
secret: ${zlt.security.tencent.app-secret}
template:
pay-success: nSy7NGq1443YCfhgR81fgkeOVv9cSM5Ysp3nMoQYVpc
service-process: rgQCI3fMKPpgO-9nO3TzP-omohraGxX2suVioq7hQhk
activity-start: lgwkRnbdDc3mEwk3RMob43LpLHnLfglZtTkbFRPsPCA
order-complete: ZeIlAA6ImQLxBiLmo-53lM7wkL4KnuKKTGKWBZwYAdM
video-edit-complete: IXpL-Voztm3GM-zFj3sxA39qy8oRtAcxTiT7_Qsyz9Q
@@ -6,7 +6,7 @@ import com.central.common.model.Result;
import com.central.user.service.PrivateKeyService;
import com.central.user.service.WechatConfigService;
import com.central.user.service.WechatPayService;
import com.zlt.wechat.entity.WechatConfig;
import com.central.wechat.wechat.entity.WechatConfig;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -48,14 +48,14 @@ public class SysWechatConfigController {
@Operation(summary = "获取微信配置")
@GetMapping("/{type}")
public Result<WechatConfig> getConfig(@PathVariable String type) {
return Result.succeed(wechatConfigService.getConfig(type, TenantContextHolder.getTenant()));
public WechatConfig getConfig(@PathVariable String type) {
return wechatConfigService.getConfig(type, TenantContextHolder.getTenant());
}
@Operation(summary = "获取微信配置")
@GetMapping("/app/{id}")
public Result<WechatConfig> getConfigByAppId(@PathVariable String appId) {
return Result.succeed(wechatConfigService.getConfig(appId));
public WechatConfig getConfigByAppId(@PathVariable("id") String appId) {
return wechatConfigService.getConfig(appId);
}
@Operation(summary = "保存微信配置")
@@ -2,7 +2,7 @@ package com.central.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zlt.wechat.entity.WechatConfig;
import com.central.wechat.wechat.entity.WechatConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -2,7 +2,7 @@ package com.central.user.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.central.common.model.PageResult;
import com.zlt.wechat.entity.WechatConfig;
import com.central.wechat.wechat.entity.WechatConfig;
import java.util.Map;
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.central.common.model.PageResult;
import com.central.user.mapper.WechatConfigMapper;
import com.central.user.service.WechatConfigService;
import com.zlt.wechat.entity.WechatConfig;
import com.central.wechat.wechat.entity.WechatConfig;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.springframework.cache.annotation.CacheEvict;
@@ -1,130 +1,154 @@
package com.central.user.service.impl;//package com.zlt.wechat.service.impl;
//
//import com.wechat.pay.java.core.Config;
//import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
//import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
//import com.wechat.pay.java.service.payments.model.Transaction;
//import com.wechat.pay.java.service.refund.RefundService;
//import com.wechat.pay.java.service.refund.model.Refund;
//import com.wechat.pay.java.service.refund.model.RefundNotification;
//import com.wechat.pay.java.service.refund.model.RefundRequest;
//import com.wechat.pay.java.service.refund.model.RefundResponse;
//import com.zlt.wechat.entity.WechatConfig;
//import com.zlt.wechat.service.PrivateKeyService;
//import com.zlt.wechat.service.WechatConfigService;
//import com.zlt.wechat.service.WechatPayService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.io.ByteArrayInputStream;
//import java.util.Map;
//
//@Service
//public class WechatPayServiceImpl implements WechatPayService {
//
// @Autowired
// private WechatConfigService configService;
//
// @Autowired
// private PrivateKeyService privateKeyService;
//
// @Autowired
// private JsapiServiceExtension jsapiService;
//
// @Autowired
// private RefundService refundService;
//
// @Autowired
// private Config wxPayConfig;
//
// @Override
// public PrepayWithRequestPaymentResponse createJsapiOrder(String tenantId, String openId,
// int amount, String description, String outTradeNo) {
// // 切换租户配置
// configService.switchConfig("PAY", tenantId);
//
// // 创建支付订单
// /*return jsapiService.prepayWithRequestPayment(
// openId,
// description,
// outTradeNo,
// amount,
// "CNY"
// );*/
// return new PrepayWithRequestPaymentResponse();
// }
//
// @Override
// public Transaction queryOrder(String tenantId, String outTradeNo) {
// configService.switchConfig("PAY", tenantId);
// return jsapiService.queryOrderByOutTradeNo(outTradeNo);
// }
//
// @Override
// public void closeOrder(String tenantId, String outTradeNo) {
// configService.switchConfig("PAY", tenantId);
// jsapiService.closeOrder(outTradeNo);
// }
//
// @Override
// public RefundResponse refund(String tenantId, String outTradeNo, String outRefundNo,
// int amount, String reason) {
// configService.switchConfig("PAY", tenantId);
//
// RefundRequest request = new RefundRequest();
// request.setOutTradeNo(outTradeNo);
// request.setOutRefundNo(outRefundNo);
// request.setAmount(new RefundRequest.Amount(amount, "CNY"));
// request.setReason(reason);
//
// return refundService.refund(request);
// }
//
// @Override
// public Refund queryRefund(String tenantId, String outRefundNo) {
// configService.switchConfig("PAY", tenantId);
// return refundService.queryByOutRefundNo(outRefundNo);
// }
//
// @Override
// public RefundNotification parseRefundNotify(String tenantId, String notifyData) {
// configService.switchConfig("PAY", tenantId);
// return refundService.parseRefundNotification(notifyData);
// }
//
// @Override
// public boolean uploadPrivateKey(String tenantId, String privateKey) {
// try {
// privateKeyService.uploadPrivateKey(tenantId, "PAY",
// new ByteArrayInputStream(privateKey.getBytes()));
// return true;
// } catch (Exception e) {
// return false;
// }
// }
//
// @Override
// public boolean updatePayConfig(String tenantId, Map<String, String> config) {
// try {
// WechatConfig wechatConfig = configService.getConfig("PAY", tenantId);
// if (wechatConfig == null) {
// wechatConfig = new WechatConfig();
// wechatConfig.setType("PAY");
// wechatConfig.setTenantId(tenantId);
// }
//
// // 更新配置信息
// wechatConfig.setMerchantId(config.get("merchantId"));
// wechatConfig.setAppId(config.get("appId"));
// wechatConfig.setMchKey(config.get("mchKey"));
// wechatConfig.setMchSerialNo(config.get("mchSerialNo"));
// wechatConfig.setApiV3Key(config.get("apiV3Key"));
// wechatConfig.setNotifyUrl(config.get("notifyUrl"));
// wechatConfig.setStatus(1);
//
// return configService.saveOrUpdate(wechatConfig);
// } catch (Exception e) {
// return false;
// }
// }
//}
import com.central.user.service.WechatPayService;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.model.Refund;
import com.wechat.pay.java.service.refund.model.RefundNotification;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class WechatPayServiceImpl implements WechatPayService {
@Override
public PrepayWithRequestPaymentResponse createJsapiOrder(String tenantId, String openId, int amount, String description, String outTradeNo) {
return null;
}
@Override
public Transaction queryOrder(String tenantId, String outTradeNo) {
return null;
}
@Override
public void closeOrder(String tenantId, String outTradeNo) {
}
@Override
public Refund queryRefund(String tenantId, String outRefundNo) {
return null;
}
@Override
public RefundNotification parseRefundNotify(String tenantId, String notifyData) {
return null;
}
@Override
public boolean uploadPrivateKey(String tenantId, String privateKey) {
return false;
}
@Override
public boolean updatePayConfig(String tenantId, Map<String, String> config) {
return false;
}
/*@Autowired
private WechatConfigService configService;
@Autowired
private PrivateKeyService privateKeyService;
@Autowired
private JsapiServiceExtension jsapiService;
@Autowired
private RefundService refundService;
@Autowired
private Config wxPayConfig;
@Override
public PrepayWithRequestPaymentResponse createJsapiOrder(String tenantId, String openId,
int amount, String description, String outTradeNo) {
// 切换租户配置
configService.switchConfig("PAY", tenantId);
// 创建支付订单
*//*return jsapiService.prepayWithRequestPayment(
openId,
description,
outTradeNo,
amount,
"CNY"
);*//*
return new PrepayWithRequestPaymentResponse();
}
@Override
public Transaction queryOrder(String tenantId, String outTradeNo) {
configService.switchConfig("PAY", tenantId);
return jsapiService.queryOrderByOutTradeNo(outTradeNo);
}
@Override
public void closeOrder(String tenantId, String outTradeNo) {
configService.switchConfig("PAY", tenantId);
jsapiService.closeOrder(outTradeNo);
}
@Override
public RefundResponse refund(String tenantId, String outTradeNo, String outRefundNo,
int amount, String reason) {
configService.switchConfig("PAY", tenantId);
RefundRequest request = new RefundRequest();
request.setOutTradeNo(outTradeNo);
request.setOutRefundNo(outRefundNo);
request.setAmount(new RefundRequest.Amount(amount, "CNY"));
request.setReason(reason);
return refundService.refund(request);
}
@Override
public Refund queryRefund(String tenantId, String outRefundNo) {
configService.switchConfig("PAY", tenantId);
return refundService.queryByOutRefundNo(outRefundNo);
}
@Override
public RefundNotification parseRefundNotify(String tenantId, String notifyData) {
configService.switchConfig("PAY", tenantId);
return refundService.parseRefundNotification(notifyData);
}
@Override
public boolean uploadPrivateKey(String tenantId, String privateKey) {
try {
privateKeyService.uploadPrivateKey(tenantId, "PAY",
new ByteArrayInputStream(privateKey.getBytes()));
return true;
} catch (Exception e) {
return false;
}
}
@Override
public boolean updatePayConfig(String tenantId, Map<String, String> config) {
try {
WechatConfig wechatConfig = configService.getConfig("PAY", tenantId);
if (wechatConfig == null) {
wechatConfig = new WechatConfig();
wechatConfig.setType("PAY");
wechatConfig.setTenantId(tenantId);
}
// 更新配置信息
wechatConfig.setMerchantId(config.get("merchantId"));
wechatConfig.setAppId(config.get("appId"));
wechatConfig.setMchKey(config.get("mchKey"));
wechatConfig.setMchSerialNo(config.get("mchSerialNo"));
wechatConfig.setApiV3Key(config.get("apiV3Key"));
wechatConfig.setNotifyUrl(config.get("notifyUrl"));
wechatConfig.setStatus(1);
return configService.saveOrUpdate(wechatConfig);
} catch (Exception e) {
return false;
}
}*/
}
@@ -1,4 +1,4 @@
package com.zlt.wechat.config;
package com.central.wechat.wechat.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -10,12 +10,12 @@ public class WechatProperties {
* 微信公众号配置
*/
private Mp mp = new Mp();
/**
* 微信小程序配置
*/
private MiniApp miniApp = new MiniApp();
/**
* 微信支付配置
*/
@@ -32,22 +32,22 @@ public class WechatProperties {
* 微信公众号appId
*/
private String appId;
/**
* 微信公众号appSecret
*/
private String appSecret;
/**
* 微信公众号token
*/
private String token;
/**
* 微信公众号aesKey
*/
private String aesKey;
/**
* 微信公众号消息模板ID
*/
@@ -60,12 +60,12 @@ public class WechatProperties {
* 支付成功通知模板ID
*/
private String paymentSuccess;
/**
* 视频处理完成通知模板ID
*/
private String videoComplete;
/**
* 视频处理失败通知模板ID
*/
@@ -78,7 +78,7 @@ public class WechatProperties {
* 小程序appId
*/
private String appId;
/**
* 小程序appSecret
*/
@@ -91,27 +91,27 @@ public class WechatProperties {
* 商户号
*/
private String mchId;
/**
* 商户API密钥
*/
private String mchKey;
/**
* 商户证书序列号
*/
private String mchSerialNo;
/**
* 商户私钥文件路径
*/
private String privateKeyPath;
/**
* APIv3密钥
*/
private String apiV3Key;
/**
* 支付回调地址
*/
@@ -135,4 +135,4 @@ public class WechatProperties {
*/
private int asyncPoolSize = 5;
}
}
}
@@ -1,4 +1,4 @@
package com.zlt.wechat.entity;
package com.central.wechat.wechat.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -1,7 +1,7 @@
package com.zlt.wechat.feign;
package com.central.wechat.wechat.feign;
import com.central.common.constant.ServiceNameConstants;
import com.zlt.wechat.feign.fallback.PrivateKeyServiceFallbackFactory;
import com.central.wechat.wechat.feign.fallback.PrivateKeyServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -1,8 +1,8 @@
package com.zlt.wechat.feign;
package com.central.wechat.wechat.feign;
import com.central.common.constant.ServiceNameConstants;
import com.zlt.wechat.entity.WechatConfig;
import com.zlt.wechat.feign.fallback.WechatConfigServiceFallbackFactory;
import com.central.wechat.wechat.entity.WechatConfig;
import com.central.wechat.wechat.feign.fallback.WechatConfigServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -22,8 +22,8 @@ public interface WechatConfigService {
@GetMapping(value = "/wechat/config/{type}")
WechatConfig getConfig(@PathVariable("type") String type,String tenantId);
@GetMapping(value = "/app/{id}")
WechatConfig getConfig(String appId);
@GetMapping(value = "/wechat/config/app/{id}")
WechatConfig getConfigByAppId(@PathVariable("id") String appId);
}
@@ -1,6 +1,6 @@
package com.zlt.wechat.feign.fallback;
package com.central.wechat.wechat.feign.fallback;
import com.zlt.wechat.feign.PrivateKeyService;
import com.central.wechat.wechat.feign.PrivateKeyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -1,7 +1,7 @@
package com.zlt.wechat.feign.fallback;
package com.central.wechat.wechat.feign.fallback;
import com.zlt.wechat.entity.WechatConfig;
import com.zlt.wechat.feign.WechatConfigService;
import com.central.wechat.wechat.entity.WechatConfig;
import com.central.wechat.wechat.feign.WechatConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -23,7 +23,7 @@ public class WechatConfigServiceFallbackFactory implements FallbackFactory<Wecha
}
@Override
public WechatConfig getConfig(String appId) {
public WechatConfig getConfigByAppId(String appId) {
return null;
}
@@ -1,4 +1,4 @@
com.zlt.wechat.feign.fallback.PrivateKeyServiceFallbackFactory
com.zlt.wechat.feign.fallback.WechatConfigServiceFallbackFactory
com.central.wechat.wechat.feign.fallback.PrivateKeyServiceFallbackFactory
com.central.wechat.wechat.feign.fallback.WechatConfigServiceFallbackFactory
@@ -4,6 +4,10 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.central.common.context.TenantContextHolder;
import com.central.wechat.wechat.config.WechatProperties;
import com.central.wechat.wechat.entity.WechatConfig;
import com.central.wechat.wechat.feign.PrivateKeyService;
import com.central.wechat.wechat.feign.WechatConfigService;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;
@@ -12,9 +16,6 @@ import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo;
import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
import com.wechat.pay.java.service.refund.RefundService;
import com.zlt.wechat.entity.WechatConfig;
import com.zlt.wechat.feign.PrivateKeyService;
import com.zlt.wechat.feign.WechatConfigService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
@@ -7,10 +7,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
/**
* @author zlt
*/
@EnableFeignClients(basePackages = {"com.central", "com.zlt.wechat.feign"})
@EnableFeignClients(basePackages = {"com.central"})
@MapperScan(basePackages = "com.central.oauth.mapper")
@EnableFeignInterceptor
@EnableDiscoveryClient
@@ -1,6 +1,6 @@
package com.central.oauth.service;
import com.zlt.wechat.entity.WechatConfig;
import com.central.wechat.wechat.entity.WechatConfig;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
@@ -5,8 +5,8 @@ import com.central.common.feign.UserService;
import com.central.common.model.SysUser;
import com.central.common.utils.LoginUserUtils;
import com.central.oauth.service.ZltUserDetailsService;
import com.zlt.wechat.entity.WechatConfig;
import com.zlt.wechat.feign.WechatConfigService;
import com.central.wechat.wechat.entity.WechatConfig;
import com.central.wechat.wechat.feign.WechatConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
@@ -64,8 +64,7 @@ public class UserDetailServiceImpl implements ZltUserDetailsService {
@Override
public WechatConfig loadMiniAppConfig(String appId) {
// return wechatConfigService.getConfig(appId);
return null;
return wechatConfigService.getConfigByAppId(appId);
}
@Override
@@ -6,8 +6,8 @@ import com.central.oauth.service.impl.UserDetailServiceFactory;
import com.central.oauth.support.base.BaseAuthenticationProvider;
import com.central.oauth2.common.properties.SecurityProperties;
import com.central.oauth2.common.token.TencentAuthenticationToken;
import com.central.wechat.wechat.entity.WechatConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zlt.wechat.entity.WechatConfig;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;