ソースを参照

Merge remote-tracking branch 'origin/master'

zouxuan 4 年 前
コミット
73cd00c288

+ 2 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/AuthorizationServerConfig.java

@@ -16,6 +16,7 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Aut
 import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
 import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
 
+import com.ym.mec.auth.core.service.CustomAuthenticationKeyGenerator;
 import com.ym.mec.auth.core.service.CustomTokenServices;
 import com.ym.mec.common.constant.CommonConstants;
 
@@ -65,6 +66,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 	@Bean
 	public RedisTokenStore redisTokenStore() {
 		RedisTokenStore tokenStore = new RedisTokenStore(connectionFactory);
+		tokenStore.setAuthenticationKeyGenerator(new CustomAuthenticationKeyGenerator());
 		tokenStore.setPrefix(CommonConstants.OAUTH_PREFIX);
 		return tokenStore;
 	}

+ 35 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/service/CustomAuthenticationKeyGenerator.java

@@ -0,0 +1,35 @@
+package com.ym.mec.auth.core.service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.oauth2.common.util.OAuth2Utils;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.OAuth2Request;
+import org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator;
+
+public class CustomAuthenticationKeyGenerator extends DefaultAuthenticationKeyGenerator {
+	
+	private static final String CLIENT_ID = "client_id";
+
+	private static final String SCOPE = "scope";
+
+	private static final String USERNAME = "username";
+
+	@Override
+	public String extractKey(OAuth2Authentication authentication) {
+		Map<String, String> values = new LinkedHashMap<String, String>();
+		OAuth2Request authorizationRequest = authentication.getOAuth2Request();
+		if (!authentication.isClientOnly()) {
+			values.put(USERNAME, StringUtils.substringAfter(authentication.getName(), ":"));
+		}
+		values.put(CLIENT_ID, authorizationRequest.getClientId());
+		if (authorizationRequest.getScope() != null) {
+			values.put(SCOPE, OAuth2Utils.formatParameterList(new TreeSet<String>(authorizationRequest.getScope())));
+		}
+		return generateKey(values);
+	}
+
+}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -367,7 +367,8 @@ public class ExportServiceImpl implements ExportService {
                     transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
                 }
                 if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
-                    transferFee = row.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                    BigDecimal totalTransferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                    transferFee = totalTransferFee.multiply(row.getRouteAmount()).divide(row.getActualAmount(), 2, BigDecimal.ROUND_HALF_UP);
                 }
             }
             row.setTransferFee(transferFee);