From dda268997ca8f8a364f7c19b45d7a43a50a98efe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 25 十月 2022 18:00:11 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java | 136 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 111 insertions(+), 25 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java
index 879409a..29f7391 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java
@@ -17,6 +17,7 @@
import com.sandu.ximon.dao.mapper.UsrWxPayConfigMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -39,19 +40,34 @@
throw new BusinessException("鐏潌id閿欒鎴栫伅鏉嗕笉瀛樺湪");
}
WxConfigEntity config;
- if (pole.getClientId() == null) {
- config = getById(0);
- }
- config = getOne(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId()));
+ //鏈缃敮浠樺弬鏁帮紝鍒欎娇鐢ㄩ粯璁ゆ敮浠樺弬鏁�
+ config = getOne(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, pole.getClientId()).eq(WxConfigEntity::getState, 1));
+// if (pole.getClientId() == null) {
+ //娌℃湁褰掑睘鐨勭伅鏉嗕娇鐢ㄩ粯璁ら厤缃�
+// config = getById(15);
+// }
if (config == null) {
throw new BusinessException("鐢ㄦ埛鏈厤缃敮浠橀厤缃�,璇烽厤缃悗閲嶈瘯");
}
return config;
}
+ public WxConfigEntity getConfigByAppId(String appId) {
+ if (appId == null) {
+ throw new BusinessException("鍥炶皟澶辫触,鏈В鏋愬埌appid");
+ }
+ WxConfigEntity config;
+ //鏈缃敮浠樺弬鏁帮紝鍒欎娇鐢ㄩ粯璁ゆ敮浠樺弬鏁�
+ config = getOne(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getAppappid, appId).eq(WxConfigEntity::getState, 1));
- public static UsrWxPayConfigService getBean() {
- return (UsrWxPayConfigService) SpringContextUtil.getBean("UsrWxPayConfigService");
+ if (config == null) {
+ throw new BusinessException("鏈壘鍒版敮浠橀厤缃垨閰嶇疆鏈惎鐢�,璇疯仈绯荤鐞嗗憳!");
+ }
+// if (pole.getClientId() == null) {
+ //娌℃湁褰掑睘鐨勭伅鏉嗕娇鐢ㄩ粯璁ら厤缃�
+// config = getById(15);
+// }
+ return config;
}
@@ -60,11 +76,16 @@
BeanUtil.copyProperties(configParam, config);
config.setAppid(configParam.getAppId());
config.setAppappid(configParam.getAppAppId());
- if(SecurityUtils.getClientId()!=null){
- config.setCreateUserId(SecurityUtils.getUserId());
- if(clientService.findClientId()){
+ if (SecurityUtils.getClientId() != null) {
+ if (clientService.findClientId()) {
config.setClientId(clientService.getClientId());
+ } else {
+ config.setClientId(SecurityUtils.getUserId());
}
+ config.setCreateUserId(SecurityUtils.getUserId());
+ } else {
+ config.setClientId(SecurityUtils.getUserId());
+ config.setCreateUserId(SecurityUtils.getUserId());
}
return save(config);
}
@@ -91,42 +112,107 @@
}
- public List<WxConfigEntity> configList(BaseConditionVO baseConditionVO,String keyword) {
+ public List<WxConfigEntity> configList(BaseConditionVO baseConditionVO, String keyword) {
LambdaQueryWrapper<WxConfigEntity> wrapper = new LambdaQueryWrapper<>();
System.out.println("----------------------------" + clientService.findClientId());
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
- if (SecurityUtils.getClientId() != null) {//瀹㈡埛
- if (clientService.findClientId()) {//浜岀骇瀹㈡埛
+ if (SecurityUtils.getClientId() != null) {
+ //瀹㈡埛
+ if (clientService.findClientId()) {
+ //浜岀骇瀹㈡埛
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
wrapper = Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
- } else if (!clientService.findClientId()) {//涓�绾у鎴�
+ } else if (!clientService.findClientId()) {
+ //涓�绾у鎴�
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
wrapper = Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, SecurityUtils.getUserId());
}
- } else {//绠$悊
+ } else {
+ //绠$悊
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
wrapper = Wrappers.lambdaQuery(WxConfigEntity.class);
}
- if(!keyword.isEmpty()){
- wrapper= wrapper.like(WxConfigEntity::getConfigId,keyword).or(
- appid->{
- appid.like(WxConfigEntity::getAppid,keyword);
+ if (keyword != null && !keyword.isEmpty()) {
+ wrapper = wrapper.like(WxConfigEntity::getConfigId, keyword).or(
+ appid -> {
+ appid.like(WxConfigEntity::getAppid, keyword);
}
).or(
- appappid->{
- appappid.like(WxConfigEntity::getAppappid,keyword);
+ appappid -> {
+ appappid.like(WxConfigEntity::getAppappid, keyword);
}
).or(
- mchId->{
- mchId.like(WxConfigEntity::getMchId,keyword);
+ mchId -> {
+ mchId.like(WxConfigEntity::getMchId, keyword);
}
).or(
- privateKey->{
- privateKey.like(WxConfigEntity::getPrivateKey,keyword);
+ privateKey -> {
+ privateKey.like(WxConfigEntity::getPrivateKey, keyword);
}
);
}
- return list(wrapper);
+ List<WxConfigEntity> list = list(wrapper);
+// list.forEach(
+// wxConfigEntity -> {
+// //璁剧疆鏀粯鍙傛暟涓殑appid鍜宎ppappid mchId鍜宲rivateKey涓殑閮ㄥ垎鏇挎崲涓�*
+// wxConfigEntity.setAppid(wxConfigEntity.getAppid().replaceAll("(?<=.{4}).*(?=.{4})", "*"));
+// wxConfigEntity.setAppappid(wxConfigEntity.getAppappid().replaceAll("(?<=.{4}).*(?=.{4})", "*"));
+// wxConfigEntity.setMchId(wxConfigEntity.getMchId().replaceAll("(?<=.{4}).*(?=.{4})", "*"));
+// wxConfigEntity.setPrivateKey(wxConfigEntity.getPrivateKey().replaceAll("(?<=.{4}).*(?=.{4})", "*"));
+// wxConfigEntity.setAppSecret(wxConfigEntity.getAppSecret().replaceAll("(?<=.{4}).*(?=.{4})", "*"));
+// }
+// );
+ return list;
+ }
+
+ /**
+ * 鏀粯鍙傛暟閰嶇疆鐨勫仠鐢�/鍚敤
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public boolean updateState(Long id, Integer state) {
+ WxConfigEntity byId = getById(id);
+ if (byId == null) {
+ throw new BusinessException("閰嶇疆id閿欒鎴栭厤缃笉瀛樺湪");
+ }
+ /**
+ * 鑾峰彇褰撳墠鐢ㄦ埛鎵�鏈夌殑wx鏀粯閰嶇疆
+ */
+ List<WxConfigEntity> configList;
+ if (SecurityUtils.getClientId() != null) {
+ //瀹㈡埛
+ configList = list(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, SecurityUtils.getUserId())
+ .or(
+ user -> {
+ user.eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
+ }
+ ));
+ } else {
+ //绠$悊
+ configList = list(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, byId.getCreateUserId())
+ .or(
+ user -> {
+ user.eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
+ }
+ ));
+ }
+ if (configList.size() == 1 && state == 0) {
+ throw new BusinessException("褰撳墠鐢ㄦ埛鍙湁涓�涓敮浠橀厤缃�,涓嶈兘鍋滅敤");
+ }
+ //璁剧疆褰撳墠鐢ㄦ埛鎵�鏈夌殑鏀粯閰嶇疆涓哄仠鐢�
+ configList.forEach(
+ wxConfigEntity -> {
+ wxConfigEntity.setState(0);
+ }
+ );
+ boolean b = updateBatchById(configList);
+ if (!b) {
+ throw new BusinessException("鏇存柊澶辫触");
+ }
+
+ WxConfigEntity config = new WxConfigEntity();
+ config.setConfigId(id);
+ config.setState(state);
+ return updateById(config);
}
}
--
Gitblit v1.9.3