From e17708f51dcc212112d1143e3b7aa9e594691597 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Thu, 20 Mar 2025 09:15:21 +0800
Subject: [PATCH 01/23] pom
---
cash-dependencies/pom.xml | 8 ++++----
cash-service/pom.xml | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/cash-dependencies/pom.xml b/cash-dependencies/pom.xml
index 5422a425d..f5bf5ea64 100644
--- a/cash-dependencies/pom.xml
+++ b/cash-dependencies/pom.xml
@@ -163,11 +163,11 @@
dubbo-spring-boot-starter
${dubbo-spring.version}
-
+
- com.alibaba.cloud
- spring-cloud-starter-alibaba-seata
- 2023.0.3.2
+ io.seata
+ seata-spring-boot-starter
+ ${seata.version}
diff --git a/cash-service/pom.xml b/cash-service/pom.xml
index 6d7114ef3..a7ee2b7e1 100644
--- a/cash-service/pom.xml
+++ b/cash-service/pom.xml
@@ -78,8 +78,8 @@
spring-cloud-starter-alibaba-nacos-config
- com.alibaba.cloud
- spring-cloud-starter-alibaba-seata
+ io.seata
+ seata-spring-boot-starter
From 2dcb3a273ed6b019692162072551fcdf51c4c6cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?=
<8605635+zhang3064194730@user.noreply.gitee.com>
Date: Thu, 20 Mar 2025 09:17:31 +0800
Subject: [PATCH 02/23] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../czg/service/account/util/AlipayUtil.java | 88 +++++--------------
.../service/account/util/WechatAuthUtil.java | 40 +++------
2 files changed, 36 insertions(+), 92 deletions(-)
diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/util/AlipayUtil.java b/cash-service/account-service/src/main/java/com/czg/service/account/util/AlipayUtil.java
index b07bf7a8c..cbe452409 100644
--- a/cash-service/account-service/src/main/java/com/czg/service/account/util/AlipayUtil.java
+++ b/cash-service/account-service/src/main/java/com/czg/service/account/util/AlipayUtil.java
@@ -10,16 +10,12 @@ import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipayEncrypt;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
-import com.czg.exception.ApiNotPrintException;
import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SysParamsService;
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
@@ -35,61 +31,6 @@ public class AlipayUtil {
@DubboReference
private SysParamsService sysParamsService;
- /**
- * 网关地址 线上:https://openapi.alipay.com/gateway.do 沙箱:https://openapi.alipaydev.com/gateway.do
- */
-// @Value("${alipay.serverUrl}")
- private String serverUrl;
- /**
- * 应用ID
- */
-// @Value("${alipay.appId}")
- private String appId;
-
- /**
- * 应用私钥
- */
-// @Value("${alipay.privateKey}")
- private String privateKey;
- /**
- * 支付宝公钥
- */
-// @Value("${alipay.alipayPublicKey}")
- private String alipayPublicKey;
- /**
- * 支付宝公钥
- */
-// @Value("${alipay.encryptKey}")
- private String encryptKey;
-
-// @Value("${alipay.account.appId}")
- private String accountAppId;
-// @Value("${alipay.account.privateKey}")
- private String accountPrivateKey;
-// @Value("${alipay.account.publicKey}")
- private String accountPublicKey;
-
-// @PostConstruct
-// private void init() {
-// CzgResult aliGateway = sysParamsService.getParamsByCode("ali_gateway");
-// CzgResult aliMiniAppId = sysParamsService.getParamsByCode("ali_mini_app_id");
-// CzgResult aliMiniPrivateKey = sysParamsService.getParamsByCode("ali_mini_private_key");
-// CzgResult aliMiniPublicKey = sysParamsService.getParamsByCode("ali_mini_public_key");
-// CzgResult aliAccountAppId = sysParamsService.getParamsByCode("ali_account_app_id");
-// CzgResult aliAccountPrivateKey = sysParamsService.getParamsByCode("ali_account_private_key");
-// CzgResult aliAccountPublicKey = sysParamsService.getParamsByCode("ali_account_public_key");
-// CzgResult aliEncryptKey = sysParamsService.getParamsByCode("ali_encrypt_key");
-// serverUrl = aliGateway.getData().getParamValue();
-// appId = aliMiniAppId.getData().getParamValue();
-// privateKey = aliMiniPrivateKey.getData().getParamValue();
-// alipayPublicKey = aliMiniPublicKey.getData().getParamValue();
-// encryptKey = aliEncryptKey.getData().getParamValue();
-// accountAppId = aliAccountAppId.getData().getParamValue();
-// accountPrivateKey = aliAccountPrivateKey.getData().getParamValue();
-// accountPublicKey = aliAccountPublicKey.getData().getParamValue();
-// log.info("支付宝工具类初始化成功, {}", this);
-// }
-
/**
* 创建支付宝客户端
*
@@ -97,6 +38,20 @@ public class AlipayUtil {
*/
@SneakyThrows
public AlipayClient createClient(boolean isAccount) {
+ CzgResult aliGateway = sysParamsService.getParamsByCode("ali_gateway");
+ CzgResult aliMiniAppId = sysParamsService.getParamsByCode("ali_mini_app_id");
+ CzgResult aliMiniPrivateKey = sysParamsService.getParamsByCode("ali_mini_private_key");
+ CzgResult aliMiniPublicKey = sysParamsService.getParamsByCode("ali_mini_public_key");
+ CzgResult aliAccountAppId = sysParamsService.getParamsByCode("ali_account_app_id");
+ CzgResult aliAccountPrivateKey = sysParamsService.getParamsByCode("ali_account_private_key");
+ CzgResult aliAccountPublicKey = sysParamsService.getParamsByCode("ali_account_public_key");
+ String serverUrl = aliGateway.getData().getParamValue();
+ String appId = aliMiniAppId.getData().getParamValue();
+ String privateKey = aliMiniPrivateKey.getData().getParamValue();
+ String alipayPublicKey = aliMiniPublicKey.getData().getParamValue();
+ String accountAppId = aliAccountAppId.getData().getParamValue();
+ String accountPrivateKey = aliAccountPrivateKey.getData().getParamValue();
+ String accountPublicKey = aliAccountPublicKey.getData().getParamValue();
AlipayConfig alipayConfig = new AlipayConfig();
//设置网关地址
alipayConfig.setServerUrl(serverUrl);
@@ -141,27 +96,30 @@ public class AlipayUtil {
}
public String getMobile(String encryptedData) {
- if(StrUtil.isEmpty(encryptedData)){
+ if (StrUtil.isEmpty(encryptedData)) {
throw new RuntimeException("加密数据不能为空");
}
try {
+ CzgResult aliEncryptKey = sysParamsService.getParamsByCode("ali_encrypt_key");
+ String encryptKey = aliEncryptKey.getData().getParamValue();
+
log.info("解密前的数据,返回结果:{}", encryptedData);
String resp = AlipayEncrypt.decryptContent(encryptedData, "AES", encryptKey, "UTF-8");
log.info("解密后的数据,返回结果:{}", resp);
boolean isJson = JSONUtil.isTypeJSON(resp);
- if(!isJson){
+ if (!isJson) {
throw new AlipayApiException("解密后的数据不是json格式");
}
JSONObject jsonObject = JSONUtil.parseObj(resp);
String code = jsonObject.getStr("code");
String msg = jsonObject.getStr("msg");
String mobile = jsonObject.getStr("mobile");
- if("10000".equals(code)){
+ if ("10000".equals(code)) {
return mobile;
- }else{
- throw new AlipayApiException(code,msg);
+ } else {
+ throw new AlipayApiException(code, msg);
}
- }catch (AlipayApiException e){
+ } catch (AlipayApiException e) {
log.error("获取支付宝用户的手机号码失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg());
throw new RuntimeException(e);
}
diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/util/WechatAuthUtil.java b/cash-service/account-service/src/main/java/com/czg/service/account/util/WechatAuthUtil.java
index 6af586598..ede411b10 100644
--- a/cash-service/account-service/src/main/java/com/czg/service/account/util/WechatAuthUtil.java
+++ b/cash-service/account-service/src/main/java/com/czg/service/account/util/WechatAuthUtil.java
@@ -13,7 +13,6 @@ import com.czg.system.dto.SysParamsDTO;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.google.gson.JsonObject;
-import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import lombok.extern.slf4j.Slf4j;
@@ -38,16 +37,6 @@ public class WechatAuthUtil {
@Resource
private AliOssUtil aliOssUtil;
- // @Value("${wx.appId}")
- private String appId;
- // @Value("${wx.secrete}")
- private String secrete;
-
- // @Value("${wx.account.appId}")
- private String accountAppId;
- // @Value("${wx.account.secrete}")
- private String accountSecrete;
-
private static final String TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";
private static final String QR_CODE_URL = "https://api.weixin.qq.com/wxa/getwxacode";
@@ -68,20 +57,11 @@ public class WechatAuthUtil {
}
-// @PostConstruct
-// public void init() {
-// CzgResult wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
-// CzgResult wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
-// CzgResult wxAccountAppId = sysParamsService.getParamsByCode("wx_account_app_id");
-// CzgResult wxAccountSecrete = sysParamsService.getParamsByCode("wx_account_secrete");
-// appId = wxMiniAppId.getData().getParamValue();
-// secrete = wxMiniSecrete.getData().getParamValue();
-// accountAppId = wxAccountAppId.getData().getParamValue();
-// accountSecrete = wxAccountSecrete.getData().getParamValue();
-// log.info("微信工具类初始化成功, appId: {}, secrete: {}, accountAppId: {}, accountSecrete: {}", appId, secrete, accountAppId, accountSecrete);
-// }
-
public String getAccountOpenId(String code) {
+ CzgResult wxAccountAppId = sysParamsService.getParamsByCode("wx_account_app_id");
+ CzgResult wxAccountSecrete = sysParamsService.getParamsByCode("wx_account_secrete");
+ String accountAppId = wxAccountAppId.getData().getParamValue();
+ String accountSecrete = wxAccountSecrete.getData().getParamValue();
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
Map requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
@@ -102,6 +82,10 @@ public class WechatAuthUtil {
//获取小程序token
private String getAccessToken() {
+ CzgResult wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
+ CzgResult wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
+ String appId = wxMiniAppId.getData().getParamValue();
+ String secrete = wxMiniSecrete.getData().getParamValue();
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
String response = HttpUtil.get(url);
com.alibaba.fastjson.JSONObject jsonResponse = com.alibaba.fastjson.JSONObject.parseObject(response);
@@ -114,8 +98,6 @@ public class WechatAuthUtil {
/**
* 生成 小程序码 跳转对应页面
*
- * @param params
- * @return
*/
public String getFetchQrCode(Map params) throws Exception {
String url = aliOssUtil.upload(fetchQrCode(params), aliOssUtil.getPath("shopVip", "png"));
@@ -127,7 +109,7 @@ public class WechatAuthUtil {
private InputStream fetchQrCode(Map params) {
JsonObject jsonObject = new JsonObject();
//路径
- jsonObject.addProperty("path", sysParamsService.getSysParamValue(SysParamCodeEnum.WX_MINI_VIP_URL.getCode())+"?shopId="+params.get("shopId"));
+ jsonObject.addProperty("path", sysParamsService.getSysParamValue(SysParamCodeEnum.WX_MINI_VIP_URL.getCode()) + "?shopId=" + params.get("shopId"));
//是否需要透明底色,为 true 时,生成透明底色的小程序码
jsonObject.addProperty("is_hyaline", true);
//正式版为 release,体验版为 trial,开发版为 develop
@@ -144,6 +126,10 @@ public class WechatAuthUtil {
public JSONObject getSession(String code) {
+ CzgResult wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
+ CzgResult wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
+ String appId = wxMiniAppId.getData().getParamValue();
+ String secrete = wxMiniSecrete.getData().getParamValue();
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
Map requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
From 825a0711043fa7c47f60de946f750ea818084201 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?=
<8605635+zhang3064194730@user.noreply.gitee.com>
Date: Thu, 20 Mar 2025 09:36:45 +0800
Subject: [PATCH 03/23] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E7=A0=81=E6=8E=92?=
=?UTF-8?q?=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/resources/mapper/MerchantRegisterMapper.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/cash-service/account-service/src/main/resources/mapper/MerchantRegisterMapper.xml b/cash-service/account-service/src/main/resources/mapper/MerchantRegisterMapper.xml
index 25868338e..3b06ed81e 100644
--- a/cash-service/account-service/src/main/resources/mapper/MerchantRegisterMapper.xml
+++ b/cash-service/account-service/src/main/resources/mapper/MerchantRegisterMapper.xml
@@ -20,5 +20,6 @@
a.create_time <= #{endTime}
+ order by a.create_time desc
From 1b10a9fb3af1903be1eca9b0ca071d7c5fd5c407 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Thu, 20 Mar 2025 09:38:41 +0800
Subject: [PATCH 04/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=20?=
=?UTF-8?q?=E6=8F=90=E5=87=BA=E7=94=A8=E6=88=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/java/com/czg/sa/MyStpLogic.java | 9 ++++++++-
.../account/service/impl/SysUserServiceImpl.java | 10 ++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/cash-common/cash-common-sa-token/src/main/java/com/czg/sa/MyStpLogic.java b/cash-common/cash-common-sa-token/src/main/java/com/czg/sa/MyStpLogic.java
index 080a4ed87..43e9728b0 100644
--- a/cash-common/cash-common-sa-token/src/main/java/com/czg/sa/MyStpLogic.java
+++ b/cash-common/cash-common-sa-token/src/main/java/com/czg/sa/MyStpLogic.java
@@ -15,6 +15,7 @@ import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpLogic;
import cn.hutool.core.util.StrUtil;
import com.czg.exception.ApiNotPrintException;
+import com.czg.exception.CzgException;
import lombok.Getter;
import java.util.List;
@@ -43,6 +44,7 @@ public class MyStpLogic {
/**
* 校验员工权限
+ *
* @param code 权限码
*/
public void checkStaffPermission(String code) {
@@ -53,7 +55,7 @@ public class MyStpLogic {
/**
* @param id 登录账号id
- * @param shopName 店铺名称
+ * @param shopName 店铺名称
* @param shopId 店铺id
* @param loginType 登录类型枚举
* @param isAdmin 是否为管理员账号
@@ -93,6 +95,7 @@ public class MyStpLogic {
/**
* 获取当前店铺用户名,仅后台可用
+ *
* @return 店铺名称
*/
public String getShopName() {
@@ -113,6 +116,10 @@ public class MyStpLogic {
Long shopId;
int errType;
if ("admin".equals(logic.getLoginType())) {
+ if (logic.getSession() == null) {
+ logout();
+ throw new CzgException("请重新登录");
+ }
Object info = logic.getSession().get("shopId");
shopId = info instanceof Long l ? l : null;
errType = 0;
diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java
index 4653c433c..5cf8e52b4 100644
--- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java
+++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/SysUserServiceImpl.java
@@ -17,6 +17,7 @@ import com.czg.account.vo.SysUserDetailVO;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
+import com.czg.service.RedisService;
import com.czg.service.account.mapper.SysRoleMapper;
import com.czg.service.account.mapper.SysUserMapper;
import com.czg.service.account.mapper.SysUsersRolesMapper;
@@ -47,6 +48,8 @@ public class SysUserServiceImpl extends ServiceImpl impl
private SysRoleMapper sysRoleMapper;
@Resource
private SysUsersRolesMapper sysUsersRolesMapper;
+ @Resource
+ private RedisService redisService;
@Override
public SysUser addUser(String nickname, String accountName, String accountPwd, String phone, Long roleId) {
@@ -232,7 +235,10 @@ public class SysUserServiceImpl extends ServiceImpl impl
}
sysUser.setPassword(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getPassword()));
-
- return updateById(sysUser);
+ boolean isUp = updateById(sysUser);
+ if (isUp) {
+ redisService.del(STR."token:admin:session:\{sysUser.getId()}");
+ }
+ return isUp;
}
}
From 95175c98d5765d49381ee6a86e520f54b688cf6e Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Thu, 20 Mar 2025 09:42:21 +0800
Subject: [PATCH 05/23] =?UTF-8?q?GlobalTransactional=20=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/czg/service/order/service/impl/PayServiceImpl.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java
index 9ec7c9992..1c348c46c 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java
@@ -44,7 +44,6 @@ import com.czg.utils.AssertUtil;
import com.czg.utils.MD5Util;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
-import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import lombok.NonNull;
@@ -557,8 +556,7 @@ public class PayServiceImpl implements PayService {
}
@Override
- @GlobalTransactional
-// @Transactional
+ @Transactional
public CzgResult