Browse Source

first commit

lei.chen@allpayx.com 5 years ago
commit
db756c5f57
54 changed files with 3520 additions and 0 deletions
  1. BIN
      Charge.zip
  2. BIN
      Charge/.DS_Store
  3. 31 0
      Charge/.gitignore
  4. 46 0
      Charge/nbactions.xml
  5. 146 0
      Charge/pom.xml
  6. 52 0
      Charge/src/main/java/com/allpay/charge/ApiCharge.java
  7. 17 0
      Charge/src/main/java/com/allpay/charge/ChargeApplication.java
  8. 113 0
      Charge/src/main/java/com/allpay/charge/ChargeMp.java
  9. 18 0
      Charge/src/main/java/com/allpay/charge/annoation/GetUserInfo.java
  10. 26 0
      Charge/src/main/java/com/allpay/charge/annoation/PermissionRequire.java
  11. 105 0
      Charge/src/main/java/com/allpay/charge/aop/WebLogAspect.java
  12. 220 0
      Charge/src/main/java/com/allpay/charge/calc/core/CalcUnit.java
  13. 655 0
      Charge/src/main/java/com/allpay/charge/calc/core/Charge.java
  14. 94 0
      Charge/src/main/java/com/allpay/charge/calc/define/AlgoCfg.java
  15. 55 0
      Charge/src/main/java/com/allpay/charge/calc/define/CalcResult.java
  16. 37 0
      Charge/src/main/java/com/allpay/charge/calc/define/Const.java
  17. 68 0
      Charge/src/main/java/com/allpay/charge/calc/define/ResultVO.java
  18. 76 0
      Charge/src/main/java/com/allpay/charge/calc/define/StaticData.java
  19. 34 0
      Charge/src/main/java/com/allpay/charge/config/InterceptorConfig.java
  20. 111 0
      Charge/src/main/java/com/allpay/charge/config/ResourceServerConfig.java
  21. 151 0
      Charge/src/main/java/com/allpay/charge/db/controller/AbstractController.java
  22. 19 0
      Charge/src/main/java/com/allpay/charge/db/controller/SaChargeDiscAlgoController.java
  23. 19 0
      Charge/src/main/java/com/allpay/charge/db/controller/SaChargeDiscCdController.java
  24. 13 0
      Charge/src/main/java/com/allpay/charge/db/entity/DiscSingleFix.java
  25. 22 0
      Charge/src/main/java/com/allpay/charge/db/entity/Page.java
  26. 200 0
      Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscAlgo.java
  27. 89 0
      Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscAlgoPK.java
  28. 170 0
      Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscCd.java
  29. 20 0
      Charge/src/main/java/com/allpay/charge/db/exceptions/IllegalOrphanException.java
  30. 10 0
      Charge/src/main/java/com/allpay/charge/db/exceptions/NonexistentEntityException.java
  31. 10 0
      Charge/src/main/java/com/allpay/charge/db/exceptions/PreexistingEntityException.java
  32. 27 0
      Charge/src/main/java/com/allpay/charge/exception/BadRequestException.java
  33. 27 0
      Charge/src/main/java/com/allpay/charge/exception/IllegalOperationException.java
  34. 27 0
      Charge/src/main/java/com/allpay/charge/exception/ProcessingFailureException.java
  35. 27 0
      Charge/src/main/java/com/allpay/charge/exception/UnauthenticatedException.java
  36. 33 0
      Charge/src/main/java/com/allpay/charge/exception/handler/ApiError.java
  37. 46 0
      Charge/src/main/java/com/allpay/charge/exception/handler/ApiSuccess.java
  38. 108 0
      Charge/src/main/java/com/allpay/charge/exception/handler/GlobalExceptionHandler.java
  39. 35 0
      Charge/src/main/java/com/allpay/charge/helper/RefreshData.java
  40. 107 0
      Charge/src/main/java/com/allpay/charge/interceptor/PermissionsInterceptor.java
  41. 57 0
      Charge/src/main/java/com/allpay/charge/tools/SHA256Util.java
  42. 164 0
      Charge/src/main/java/com/allpay/charge/tools/SignatureUtil.java
  43. 20 0
      Charge/src/main/java/com/allpay/charge/tools/StringTools.java
  44. 18 0
      Charge/src/main/java/com/allpay/charge/tools/ThreadLocalUtil.java
  45. 28 0
      Charge/src/main/java/com/allpay/charge/tools/ThrowableUtil.java
  46. 36 0
      Charge/src/main/java/com/allpay/charge/tools/TimeConsuming.java
  47. 37 0
      Charge/src/main/java/com/allpay/charge/tools/pageUtil.java
  48. 44 0
      Charge/src/main/resources/META-INF/persistence.xml
  49. 7 0
      Charge/src/main/resources/application-local.yml
  50. 7 0
      Charge/src/main/resources/application-test.yml
  51. 6 0
      Charge/src/main/resources/application.yml
  52. 19 0
      Charge/src/main/resources/log4j.properties
  53. 13 0
      Charge/src/test/java/com/allpay/charge/ChargeApplicationTests.java
  54. 0 0
      README.md

BIN
Charge.zip


BIN
Charge/.DS_Store


+ 31 - 0
Charge/.gitignore

@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/

+ 46 - 0
Charge/nbactions.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+    <action>
+        <actionName>run</actionName>
+        <packagings>
+            <packaging>jar</packaging>
+        </packagings>
+        <goals>
+            <goal>spring-boot:run</goal>
+        </goals>
+        <properties>
+            <spring-boot.run.jvmArguments>-noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
+            <spring-boot.run.mainClass>com.allpay.charge.ChargeApplication</spring-boot.run.mainClass>
+            <Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
+        </properties>
+    </action>
+    <action>
+        <actionName>debug</actionName>
+        <packagings>
+            <packaging>jar</packaging>
+        </packagings>
+        <goals>
+            <goal>spring-boot:run</goal>
+        </goals>
+        <properties>
+            <spring-boot.run.jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
+            <spring-boot.run.mainClass>com.allpay.charge.ChargeApplication</spring-boot.run.mainClass>
+            <Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
+            <jpda.listen>true</jpda.listen>
+        </properties>
+    </action>
+    <action>
+        <actionName>profile</actionName>
+        <packagings>
+            <packaging>jar</packaging>
+        </packagings>
+        <goals>
+            <goal>process-classes</goal>
+            <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+        </goals>
+        <properties>
+            <exec.args>-classpath %classpath com.allpay.charge.ChargeApplication</exec.args>
+            <exec.executable>java</exec.executable>
+        </properties>
+    </action>
+</actions>

+ 146 - 0
Charge/pom.xml

@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.2.1.RELEASE</version>
+		<!--<version>2.0.4.RELEASE</version>-->
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+	<groupId>com.allpay</groupId>
+	<artifactId>charge</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>charge</name>
+	<description>Allpay charge</description>
+
+	<properties>
+		<java.version>1.8</java.version>
+		<spring-security-oauth.version>2.0.16.RELEASE</spring-security-oauth.version>
+		<spring-security-jwt.version>1.0.9.RELEASE</spring-security-jwt.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<scope>runtime</scope>
+		 <version>8.0.18</version>
+		</dependency>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>fastjson</artifactId>
+			<version>1.2.49</version>
+		</dependency>
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+			<optional>true</optional>
+		</dependency>
+		<!-- spring-security-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-security</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.security.oauth</groupId>
+			<artifactId>spring-security-oauth2</artifactId>
+			<version>${spring-security-oauth.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.security</groupId>
+			<artifactId>spring-security-jwt</artifactId>
+			<version>${spring-security-jwt.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-aop</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>4.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>org.junit.vintage</groupId>
+					<artifactId>junit-vintage-engine</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+	 <dependency>
+	  <groupId>log4j</groupId>
+	  <artifactId>log4j</artifactId>
+	  <version>1.2.17</version>
+	  <type>jar</type>
+	 </dependency>
+	 <dependency>
+	  <groupId>org.json</groupId>
+	  <artifactId>json</artifactId>
+	  <version>20180813</version>
+	  <type>jar</type>
+	 </dependency>
+	 <!--<dependency>-->
+	  <!--<groupId>org.eclipse.persistence</groupId>-->
+	  <!--<artifactId>org.eclipse.persistence.core</artifactId>-->
+	  <!--<version>2.5.2</version>-->
+	 <!--</dependency>-->
+	 <!--<dependency>-->
+	  <!--<groupId>org.eclipse.persistence</groupId>-->
+	  <!--<artifactId>org.eclipse.persistence.asm</artifactId>-->
+	  <!--<version>2.5.2</version>-->
+	 <!--</dependency>-->
+	 <!--<dependency>-->
+	  <!--<groupId>org.eclipse.persistence</groupId>-->
+	  <!--<artifactId>org.eclipse.persistence.antlr</artifactId>-->
+	  <!--<version>2.5.2</version>-->
+	 <!--</dependency>-->
+	 <dependency>
+	  <groupId>org.eclipse.persistence</groupId>
+	  <artifactId>org.eclipse.persistence.jpa</artifactId>
+	  <version>2.5.2</version>
+	 </dependency>
+	 <!--<dependency>-->
+	  <!--<groupId>org.eclipse.persistence</groupId>-->
+	  <!--<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>-->
+	  <!--<version>2.5.2</version>-->
+	 <!--</dependency>-->
+	 <dependency>
+	  <groupId>org.eclipse.persistence</groupId>
+	  <artifactId>javax.persistence</artifactId>
+	  <version>2.1.0</version>
+	 </dependency>
+	 <!--<dependency>-->
+	  <!--<groupId>org.eclipse.persistence</groupId>-->
+	  <!--<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>-->
+	  <!--<version>2.5.2</version>-->
+	  <!--<scope>provided</scope>-->
+	 <!--</dependency>-->
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

+ 52 - 0
Charge/src/main/java/com/allpay/charge/ApiCharge.java

@@ -0,0 +1,52 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge;
+
+import com.allpay.charge.annoation.PermissionRequire;
+import com.allpay.charge.calc.define.CalcResult;
+import static com.allpay.charge.calc.define.StaticData.charge;
+
+import com.allpay.charge.calc.define.ResultVO;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Brian
+ */
+
+@RestController
+@CrossOrigin
+public class ApiCharge {
+
+    /**
+     *
+     * @param discCd
+     * @param settAmt
+     * @param brandLastMonthUsdAmt
+     * @return
+     */
+    @RequestMapping("/charge/merchant")
+    public @ResponseBody String chargeMerchant (@RequestParam long discCd, @RequestParam long settAmt,@RequestParam /*(required = false,defaultValue = "0")*/long brandLastMonthUsdAmt) {
+        // TODO code application logic here
+         CalcResult r = charge.calcMerchantChargeByLastMonth(discCd, settAmt, brandLastMonthUsdAmt);
+        return  r.getForJson();
+     }
+
+
+     @RequestMapping("/charge/codeList")
+     public @ResponseBody String chargeCodeList (@RequestBody(required = false) List<Long> discCdList) {
+         CalcResult calcResult = charge.selectChargeCodeList(discCdList);
+         return  calcResult.getForMessageJson();
+     }
+
+
+}
+
+

+ 17 - 0
Charge/src/main/java/com/allpay/charge/ChargeApplication.java

@@ -0,0 +1,17 @@
+package com.allpay.charge;
+
+import com.allpay.charge.helper.RefreshData;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ChargeApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(ChargeApplication.class, args);
+
+                RefreshData refreshData =new RefreshData();
+                refreshData.start();
+	}
+
+}

+ 113 - 0
Charge/src/main/java/com/allpay/charge/ChargeMp.java

@@ -0,0 +1,113 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge;
+
+import com.allpay.charge.annoation.PermissionRequire;
+import com.allpay.charge.calc.define.CalcResult;
+import com.allpay.charge.calc.define.ResultVO;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+import static com.allpay.charge.calc.define.StaticData.charge;
+
+/**
+ *
+ * @author Brian
+ */
+
+@RestController
+@CrossOrigin
+public class ChargeMp {
+
+    /**
+     *
+     * @param discCd
+     * @param settAmt
+     * @param brandLastMonthUsdAmt
+     * @return
+     */
+    @PermissionRequire(value = "cg001")
+    @RequestMapping("/mp/charge/merchant")
+    public @ResponseBody String chargeMerchant (@RequestParam long discCd, @RequestParam long settAmt,@RequestParam /*(required = false,defaultValue = "0")*/long brandLastMonthUsdAmt) {
+        // TODO code application logic here
+         CalcResult r = charge.calcMerchantChargeByLastMonth(discCd, settAmt, brandLastMonthUsdAmt);
+        return  r.getForJson();
+     }
+
+
+     @PermissionRequire(value = "cg002")
+     @RequestMapping("/mp/charge/codeList")
+     public @ResponseBody String chargeCodeList (@RequestBody(required = false) List<Long> discCdList) {
+         CalcResult calcResult = charge.selectChargeCodeList(discCdList);
+         return  calcResult.getForMessageJson();
+     }
+
+    @PermissionRequire(value = "cg003")
+    @RequestMapping("/mp/charge/createDiscSingleFix")
+    public @ResponseBody ResultVO createDiscSingleFix (@RequestParam long fix) throws Exception {
+        //创建特殊计费(单笔固定金额)
+        ResultVO resultVO = charge.createDiscSingleFix(fix);
+        return resultVO;
+    }
+
+    @PermissionRequire(value = "cg004")
+    @RequestMapping("mp/charge/createDiscSingleFixAndPercent")
+    public @ResponseBody ResultVO createDiscSingleFixAndPercent (@RequestParam long fix,@RequestParam double percent) throws Exception {
+        //创建特殊计费(单笔固定金额+百分比)
+        ResultVO resultVO = charge.createDiscSingleFixAndPercent(fix,percent);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg005")
+    @RequestMapping("/mp/charge/createDiscMonthLadder2")
+    public @ResponseBody ResultVO createDiscMonthLadder2 (@RequestParam long monthAmount1,@RequestParam double percent1,@RequestParam long monthAmount2,@RequestParam double percent2) throws Exception {
+        //创建特殊计费(按上月交易额2级阶梯)
+        ResultVO resultVO = charge.createDiscMonthLadder2(monthAmount1,percent1,monthAmount2,percent2);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg006")
+    @RequestMapping("/mp/charge/createDiscMonthLadder3")
+    public @ResponseBody ResultVO createDiscMonthLadder3 (@RequestParam long monthAmount1,@RequestParam double percent1,@RequestParam long monthAmount2,@RequestParam double percent2,@RequestParam long monthAmount3,@RequestParam double percent3) throws Exception {
+        //创建特殊计费(按上月交易额3级阶梯)
+        ResultVO resultVO = charge.createDiscMonthLadder3(monthAmount1,percent1,monthAmount2,percent2,monthAmount3,percent3);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg007")
+    @RequestMapping("/mp/charge/createDiscMonthLadder4")
+    public @ResponseBody ResultVO createDiscMonthLadder4 (@RequestParam long monthAmount1,@RequestParam double percent1,@RequestParam long monthAmount2,@RequestParam double percent2,@RequestParam long monthAmount3,@RequestParam double percent3,@RequestParam long monthAmount4,@RequestParam double percent4) throws Exception {
+        //创建特殊计费(按上月交易额4级阶梯)
+        ResultVO resultVO = charge.createDiscMonthLadder4(monthAmount1,percent1,monthAmount2,percent2,monthAmount3,percent3,monthAmount4,percent4);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg008")
+    @RequestMapping("/mp/charge/releaseDisc")
+    public @ResponseBody ResultVO releaseDisc (@RequestParam long discCd) throws Exception {
+        //生效特殊计费代码
+        ResultVO resultVO = charge.releaseDisc(discCd);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg009")
+    @RequestMapping("/mp/charge/deleteDisc")
+    public @ResponseBody ResultVO deleteDisc (@RequestParam long discCd) throws Exception {
+        //删除特殊计费代码
+        ResultVO resultVO = charge.deleteDisc(discCd);
+        return resultVO;
+    }
+    @PermissionRequire(value = "cg010")
+    @RequestMapping("/mp/charge/findCode")
+    public @ResponseBody ResultVO findCode (@RequestParam (required = false)Long discCd,
+                                            @RequestParam (required = false)String nm,
+                                            @RequestParam (required = false)Integer status,
+                                            @RequestParam ()Integer pageNum,
+                                            @RequestParam ()Integer pageSize
+    ) {
+        //验签
+        ResultVO resultVO = charge.selectFindCode(discCd,nm,status,pageNum,pageSize);
+        return  resultVO;
+    }
+}
+
+

+ 18 - 0
Charge/src/main/java/com/allpay/charge/annoation/GetUserInfo.java

@@ -0,0 +1,18 @@
+package com.allpay.charge.annoation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:25
+ * @Version : V0.0.1
+ */
+@Target(value = ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface GetUserInfo {
+}
+

+ 26 - 0
Charge/src/main/java/com/allpay/charge/annoation/PermissionRequire.java

@@ -0,0 +1,26 @@
+package com.allpay.charge.annoation;
+
+import org.springframework.core.annotation.AliasFor;
+
+import java.lang.annotation.*;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/19 09:57
+ * @Version : V0.0.1
+ */
+@Target(value = {
+        ElementType.METHOD
+})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PermissionRequire {
+
+    @AliasFor("functionId")
+    String value() default "";
+
+    /**  功能ID */
+    @AliasFor("value")
+    String functionId() default "";
+}

+ 105 - 0
Charge/src/main/java/com/allpay/charge/aop/WebLogAspect.java

@@ -0,0 +1,105 @@
+package com.allpay.charge.aop;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @Description : 监控接口日志
+ * @Author : Simon.shi
+ * @Date : 2018/11/29 14:31
+ * @Version : V0.0.1
+ */
+@Configuration
+@Slf4j
+@Aspect
+public class WebLogAspect {
+
+	@Pointcut(value = "@annotation(org.springframework.web.bind.annotation.RequestMapping)")
+	public void webLog() {
+	}
+
+	@Around("webLog()")
+	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
+		RequestAttributes ra = RequestContextHolder.getRequestAttributes();
+		ServletRequestAttributes sra = (ServletRequestAttributes) ra;
+		HttpServletRequest request = sra.getRequest();
+		String ip = null;
+		//X-Forwarded-For:Squid 服务代理
+		String ipAddresses = request.getHeader("X-Forwarded-For");
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//Proxy-Client-IP:apache 服务代理
+			ipAddresses = request.getHeader("Proxy-Client-IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//WL-Proxy-Client-IP:weblogic 服务代理
+			ipAddresses = request.getHeader("WL-Proxy-Client-IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//HTTP_CLIENT_IP:有些代理服务器
+			ipAddresses = request.getHeader("HTTP_CLIENT_IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//X-Real-IP:nginx服务代理
+			ipAddresses = request.getHeader("X-Real-IP");
+		}
+
+		//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
+		if (ipAddresses != null && ipAddresses.length() != 0) {
+			ip = ipAddresses.split(",")[0];
+		}
+		//还是不能获取到,最后再通过request.getRemoteAddr();获取
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			ip = request.getRemoteAddr();
+		}
+
+		String url = request.getRequestURL().toString();
+		String method = request.getMethod();
+		String uri = request.getRequestURI();
+		String queryString = "";
+		if (method.equalsIgnoreCase("GET") || method.equalsIgnoreCase("DELETE")) {
+			queryString = request.getQueryString();
+		} else {
+			String header = request.getHeader("Content-Type");
+			Map<String, String[]> map = request.getParameterMap();
+			//通过keySet遍历集合
+			Set<String> keySet = map.keySet();
+			HashMap<String, String> hashMap = new HashMap<>();
+			for (String key : keySet) {
+				//通过key值获取所有value值
+				String[] values = map.get(key);
+				for (String value : values) {
+					hashMap.put(key, value);
+				}
+			}
+			queryString = hashMap.toString();
+           /* if(header.equalsIgnoreCase("application/x-www-form-urlencoded")){
+                queryString = request.getParameterMap().toString();
+            }*/
+		}
+		log.info("请求开始============》ip: {},url: {}, method: {}, uri: {}, params: {}", ip, url, method, uri, queryString);
+
+		// result的值就是被拦截方法的返回值
+		Object result = pjp.proceed();
+		ObjectMapper mapper = new ObjectMapper();
+		log.info("请求结束============》接口的返回值是 " + mapper.writeValueAsString(result));
+		return result;
+	}
+
+}

+ 220 - 0
Charge/src/main/java/com/allpay/charge/calc/core/CalcUnit.java

@@ -0,0 +1,220 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.core;
+
+import com.allpay.charge.calc.define.AlgoCfg;
+import com.allpay.charge.calc.define.Const;
+import com.allpay.charge.calc.define.StaticData;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author Brian
+ */
+public class CalcUnit {
+    private static Logger logger = Logger.getLogger(CalcUnit.class);
+    protected long data[]=
+                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    		,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+    protected void initData(){
+        for(int i=0;i<data.length;i++) data[i]=0L;
+    }
+
+   /***
+     * 计算步骤算法
+     * @param object1
+     * @param operator1
+     * @param object2
+     * @param operator2
+     * @param object3
+     * @return
+     */
+    private long calcStep(long object1,char operator1,long object2,char operator2,long object3){
+        long result = Const.Calc.ERR_CALC_STEP_L;
+        switch (operator1) {
+                case '*':
+                    result = object1 * object2;
+                    break;
+                case '/':
+                    result = (object1+5000) / object2;
+                    break;
+                case '+':
+                    result = object1 + object2;
+                    break;
+                case '-':
+                    result = object1 - object2;
+                    break;
+                case '>':
+                    result = (object1 > object2) ? object2 : object1;
+                    break;
+                case '<':
+                    result = (object1 < object2) ? object2 : object1;
+                    break;
+                case '=':
+                    result = object1;
+                    break;
+                default:
+                    break;
+            }
+
+        switch (operator2) {
+                case '*':
+                    result = result * object3;
+                    break;
+                case '/':
+                    result = (result + object3 / 2)/ object3;
+                    break;
+                case '+':
+                    result = result + object3;
+                    break;
+                case '-':
+                    result = result - object3;
+                    break;
+                case '>':
+                    result = (result > object3) ? object3 : object1;
+                    break;
+                case '<':
+                    result = (result < object2) ? object3 : object1;
+                    break;
+                case '=':
+                    result = object3;
+                    break;
+                default:
+                    break;
+            }
+
+        return result;
+    }
+
+    /***
+     * 计算手续费主过程
+     * @param discCd
+     * @param data
+     * @return
+     */
+    public int calcOpr(long discCd, long[] data){
+        long  pstepNo = 0;
+        long pObject1,pObject2,pObject3,pResult;
+        long calcRslt;
+        List<AlgoCfg> list =searchDichotomy(StaticData.listAlgoCfg,discCd);
+        if(list == null) return Const.Calc.ERR_ALGO_NULL;
+        AlgoCfg algoCfg;
+        while(pstepNo < list.size()){
+            algoCfg = this.getAlgoCfg(list, (int)pstepNo);
+            logger.debug("calcOpr() calc stepNo:" + pstepNo + "  algoCfg:" + algoCfg.getValues());
+            if(algoCfg ==  null) {
+                logger.fatal("calcOpr() return Const.Calc.ERR_ALGO_NULL /" + discCd);
+                return Const.Calc.ERR_ALGO_NULL;
+            }
+
+            if(algoCfg.getOperRslt() == 0  && algoCfg.getOperator1() =='$') return Const.Calc.SUCCEED;
+
+            //替换参数(正数不变,负数替换data数组的参数
+            pObject1 = getConvertValue(algoCfg.getObject1(),data);
+            pObject2 = getConvertValue(algoCfg.getObject2(),data);
+            pObject3 = getConvertValue(algoCfg.getObject3(),data);
+            if(pObject1==Const.Calc.ERR_CALC_STEP_L || pObject2==Const.Calc.ERR_CALC_STEP_L ||pObject3==Const.Calc.ERR_CALC_STEP_L) {
+                logger.fatal("calcOpr() return  Const.Calc.ERR_CALC_STEP /" + discCd);
+                return (int)Const.Calc.ERR_CALC_STEP;
+            }
+
+            pResult  = algoCfg.getOperRslt();
+            if(pResult > list.size()) {     //算法配置错误,跳转目标位置超限
+                logger.fatal("calcOpr() return Const.Calc.ERR_OPERRSLT_OVERLIMIT_1 /" + discCd);
+                return Const.Calc.ERR_OPERRSLT_OVERLIMIT_1;
+            }
+            if(pResult< 0 && Math.abs(pResult)>data.length){    //算法变量参数,大于data数组数;
+                logger.fatal("calcOpr() return Const.Calc.ERR_OPERRSLT_OVERLIMIT_2 /" + discCd);
+                return Const.Calc.ERR_OPERRSLT_OVERLIMIT_2;
+            }
+
+            //System.out.println(algoCfg.getValues());
+
+            if(algoCfg.getOperator1() =='L' && algoCfg.getOperator2()=='L'){//条件式比较跳转目标行
+                if(pObject1 <= pObject2 && pObject2 < pObject3)  {//比较成功,转到目标行              //if(pObject1 < pObject2 && pObject2<=pObject3)  {//比较成功,转到目标行
+                    pstepNo =  pResult;
+                }  else {
+                    pstepNo ++;                 //比较失败,顺序执行下一行
+                }
+            } else {//计算步骤
+                calcRslt = this.calcStep(pObject1, algoCfg.getOperator1(), pObject2, algoCfg.getOperator2(), pObject3);
+                if(calcRslt == Const.Calc.ERR_CALC_STEP_L) {//计算步骤中出现异常;
+                    logger.fatal("calcOpr() return  Const.Calc.ERR_CALC_STEP /" + discCd);
+                    return Const.Calc.ERR_CALC_STEP;
+                }
+                data[(int)pResult * (-1)] = calcRslt;
+                pstepNo ++;
+            }
+        }
+        logger.fatal("calcOpr() return Const.Calc.ERR_OTHER /" + discCd);
+        return Const.Calc.ERR_OTHER;    //没有正常结束过程
+    }
+
+    /**
+     * 转换参数过程
+     * @param pObject1
+     * @param data
+     * @return
+     */
+    private long getConvertValue(long pObject1,long[] data){
+        if(pObject1 < 0)  //如果参数为负数,则为参数,需要转换
+        {   if(pObject1 * (-1)>= data.length) return Const.Calc.ERR_CALC_STEP_L;
+            return  data[(int)pObject1 * (-1)];
+        }
+        else return pObject1;
+    }
+
+    /***
+     * 返回计算方法列表的指定序号
+     * @param list
+     * @param stepNo
+     * @return
+     */
+    private AlgoCfg getAlgoCfg(List<AlgoCfg> list,int stepNo){
+        for(AlgoCfg algoCfg:list ){
+            if(algoCfg.getStepNo() == stepNo) return algoCfg;
+        }
+        return null;
+    }
+
+/**
+     * 二分法查找数据
+     * @param list
+     * @param find
+     * @return
+     */
+    private List<AlgoCfg> searchDichotomy(List<AlgoCfg> list,long find){
+      int low = 0;
+      int high = list.size();
+      int mid ;
+      int algoSize;
+      AlgoCfg algoCfg;
+
+      while(low <= high) {
+          mid = (low + high)/2;
+          if(mid>=high) break;      //没有找到
+          algoCfg = list.get(mid);
+          if(algoCfg.getDiscCd() > find){
+              high = mid -1;
+          }else if(algoCfg.getDiscCd() <find){
+              low = mid +1;
+          }else {
+              algoSize =(int) getAlgoSize(list,mid+1);
+              return list.subList(mid - algoCfg.getStepNo(), mid + algoSize - algoCfg.getStepNo());
+          }
+      }
+      return null;
+    }
+
+private  long getAlgoSize(List<AlgoCfg> list,int idx){
+    if( idx>=list.size() || list.get(idx).getStepNo()==0 )            //如果不前行号=0,或找到列表最后一行,则返回上一行的序号(+1)
+        return list.get(idx-1).getStepNo()+1;
+    else return getAlgoSize(list,idx+1);
+}
+
+}

+ 655 - 0
Charge/src/main/java/com/allpay/charge/calc/core/Charge.java

@@ -0,0 +1,655 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.core;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.allpay.charge.calc.define.*;
+import com.allpay.charge.db.controller.SaChargeDiscAlgoController;
+import com.allpay.charge.db.controller.SaChargeDiscCdController;
+import com.allpay.charge.db.entity.DiscSingleFix;
+import com.allpay.charge.db.entity.SaChargeDiscAlgo;
+import com.allpay.charge.db.entity.SaChargeDiscAlgoPK;
+import com.allpay.charge.db.entity.SaChargeDiscCd;
+import com.allpay.charge.helper.RefreshData;
+import com.allpay.charge.tools.StringTools;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import com.allpay.charge.tools.pageUtil;
+import org.apache.log4j.Logger;
+
+
+
+/**
+ *
+ * @author Brian
+ */
+public class Charge extends CalcUnit {
+     private static final Logger logger = Logger.getLogger(Charge.class);
+
+/*
+     public Charge(List<AlgoCfg> list){
+          StaticData.initList(list);
+        }
+*/
+
+   /**
+    * 计算商户手续费(标准计算)
+    * @param discCd
+     * @param TRANS_SETTLE_AMT      交易清算金额
+    * @return
+    */
+   public CalcResult calcMerchantCharge(long discCd,long TRANS_SETTLE_AMT){
+     CalcResult v = new CalcResult();
+     //固定百分比,直接计算,代码范围:1000001~1999999
+     if(discCd > 1000000 && discCd < 2000000){//固定百分比计算
+         long mdr= discCd - 1000000;
+         v.setResult(TRANS_SETTLE_AMT * mdr/1000000);
+         v.setStatus(Const.Calc.SUCCEED);
+     }else{
+         data[Const.AmountIdx.TRANS_SETTLE_AMT] = TRANS_SETTLE_AMT;                        //2号位置,作为清算金额;
+         data[Const.AmountIdx.MER_DISC_CODE]    = discCd;
+         v.setStatus(super.calcOpr(discCd, data));
+         v.setResult(data[1]);
+     }
+    logger.debug("calcMerchantCharge() discCd/TRANS_SETTLE_AMT/Status/Result - " +StringTools.toSplit("/", discCd,TRANS_SETTLE_AMT,v.getStatus(),v.getResult()));
+    return v;
+   }
+
+   /**
+    * 计算商户手续费(标准计算)
+    * @param discCd
+     * @param TRANS_SETTLE_AMT              交易清算金额
+     * @param BRAND_LAST_MONTH_USD_AMT      商户当前交易品牌上月(美元)交易额
+    * @return
+    */
+   public CalcResult calcMerchantChargeByLastMonth(long discCd,long TRANS_SETTLE_AMT,long BRAND_LAST_MONTH_USD_AMT){
+     CalcResult v = new CalcResult();
+       if(TRANS_SETTLE_AMT < 0 || TRANS_SETTLE_AMT > 999999999999L){
+           v.setStatus(Const.Calc.ERR_AMOUNT_OVERLIMIT);
+           return v;
+       }
+     //固定百分比,直接计算,代码范围:1000001~1999999
+     if(discCd >=1000000 && discCd < 2000000){
+         //固定百分比计算
+         long mdr= discCd - 1000000;
+         v.setResult((TRANS_SETTLE_AMT * mdr+500000)/1000000);
+         v.setStatus(Const.Calc.SUCCEED);
+     }else{
+         data[Const.AmountIdx.TRANS_SETTLE_AMT]             = TRANS_SETTLE_AMT;         //2号位置,作为清算金额;
+         data[Const.AmountIdx.MER_DISC_CODE]                = discCd;
+         data[Const.AmountIdx.BRAND_LAST_MONTH_USD_AMT]     = BRAND_LAST_MONTH_USD_AMT;
+         v.setStatus(super.calcOpr(discCd, data));
+         v.setResult((data[1]));
+     }
+
+
+
+
+
+
+
+    logger.debug("calcMerchantChargeByLastMonth() discCd/TRANS_SETTLE_AMT/Status/Result - " +StringTools.toSplit("/", discCd,TRANS_SETTLE_AMT,v.getStatus(),v.getResult()));
+    return v;
+   }
+
+   /***
+    * 代理分润计算
+    * @param discCd
+    * @param TRANS_SETTLE_AMT               交易清算金额
+    * @param ALL_LAST_MONTH_USD_AMT         代理机构上月美元交易金额(所有品牌)
+    * @param MER_DISC_CODE                  该笔交易的商户手续费代码
+    * @return
+    */
+    public CalcResult calcAgentCharge(long discCd,long TRANS_SETTLE_AMT,long ALL_LAST_MONTH_USD_AMT,long MER_DISC_CODE){
+     CalcResult v = new CalcResult();
+     //固定百分比,直接计算,代码范围:1000001~1999999
+     if(discCd > 1000000 && discCd < 2000000){//固定百分比计算
+         long mdr= discCd - 1000000;
+         v.setResult(TRANS_SETTLE_AMT * mdr/1000000);
+         v.setStatus(Const.Calc.SUCCEED);
+     }else{
+         this.initData();
+         data[Const.AmountIdx.TRANS_SETTLE_AMT] = TRANS_SETTLE_AMT;                        //2号位置,作为清算金额;
+         data[Const.AmountIdx.MER_DISC_CODE]    = MER_DISC_CODE;
+         data[Const.AmountIdx.ALL_LAST_MONTH_USD_AMT] = ALL_LAST_MONTH_USD_AMT;
+         v.setStatus(super.calcOpr(discCd, data));
+         v.setResult(data[1]);
+     }
+    return v;
+   }
+
+    /**
+     * ChargeCode规则说明查询
+     * @param discCdList 商户手续费计费代码集合
+     * @return
+     */
+    public CalcResult selectChargeCodeList(List<Long> discCdList) {
+        CalcResult v = new CalcResult();
+        List<SaChargeDiscCd> list = new ArrayList();
+        List<SaChargeDiscCd> listSaChargeDiscCdStatic = StaticData.ListSaChargeDiscCd;
+        List<SaChargeDiscCd> listSaChargeDiscCd = new ArrayList<>();
+        listSaChargeDiscCd.addAll(listSaChargeDiscCdStatic);
+        Iterator<SaChargeDiscCd> it = listSaChargeDiscCd.iterator();
+            while (it.hasNext()) {
+                //it.next()方法即可返回当前元素
+                if (it.next().getStatus() == 1) {
+                    it.remove();
+                }
+            }
+        System.out.println(listSaChargeDiscCd.size());
+        if(discCdList==null || discCdList.size()==0){
+            v.setMessage(JSON.toJSONString(listSaChargeDiscCd));
+            v.setStatus(Const.Calc.SUCCEED);
+            return v;
+        }
+        discCdList.forEach((d)->{
+            listSaChargeDiscCd.forEach((s)->{
+                if(s.getDiscCd()==d.intValue()){
+                    list.add(s);
+                }
+            });
+        });
+        if(list.size()==0){
+            v.setStatus(Const.Calc.ERR_ALGO_NULL);
+            return v;
+        }
+        v.setMessage(JSON.toJSONString(list));
+        v.setStatus(Const.Calc.SUCCEED);
+        return v;
+    }
+
+    /**
+     * 创建特殊计费(单笔固定金额)
+     * @param fix 固定金额(以分为单位)
+     * @return
+     */
+    public ResultVO createDiscSingleFix(long fix) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd saChargeDiscCd = new SaChargeDiscCd();
+        List<SaChargeDiscCd> saChargeDiscCdsList = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+        Integer discCdNew=0;
+        String new_nm="";
+        String new_comment="";
+        for (SaChargeDiscCd saChargeDiscCd1:saChargeDiscCdsList) {
+            Integer discCd = saChargeDiscCd1.getDiscCd();
+            if(2000001<=discCd && discCd<=2000999){
+                if(discCdNew<=discCd){
+                    discCdNew=discCd+1;
+                }
+            }
+            String nm = saChargeDiscCd1.getNm();
+            String comment = saChargeDiscCd1.getComment();
+            BigDecimal bigDecimal = new BigDecimal(fix);
+            BigDecimal multiply = bigDecimal.divide(new BigDecimal(100)).setScale(2);
+            new_nm="固定收费"+multiply+"("+fix+"JPY/KRW)";
+            new_comment="单笔固定收费"+multiply+"("+fix+"JPY/KRW)";
+            if(nm.equals(new_nm) && (comment.equals(new_comment))){
+                ResultVO resultVO = new ResultVO();
+                resultVO.setStatus(ResultVO.FAIL);
+                resultVO.setMessage("特殊计费配置重复(单笔固定金额)");
+                return resultVO;
+            }
+        };
+        //特殊计费名稱信息表信息配置
+        crateSaChargeDiscCd(saChargeDiscCdController, saChargeDiscCd, discCdNew, new_nm, new_comment);
+
+        //特殊计费功能信息表信息配置
+        createSaChargeDiscAlgo(discCdNew,0,new BigInteger("-1"),fix,'=',new BigInteger("0"),' ',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,1,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+
+        //添加完成信息刷新
+        StaticData.initList();
+        //响应信息返回
+        ResultVO resultVO = new ResultVO();
+        resultVO.setMessage("创建特殊计费(单笔固定金额)添加完成");
+        DiscSingleFix discSingleFix = new DiscSingleFix();
+        discSingleFix.setDiscCd(discCdNew);
+        discSingleFix.setNm(new_nm);
+        discSingleFix.setComment(new_comment);
+        resultVO.setData(discSingleFix);
+        return resultVO;
+    }
+
+    private void crateSaChargeDiscCd(SaChargeDiscCdController saChargeDiscCdController, SaChargeDiscCd saChargeDiscCd, Integer discCdNew, String new_nm, String new_comment) throws Exception {
+        //特殊计费名称信息表信息配置
+        saChargeDiscCd.setDiscCd(discCdNew);
+        saChargeDiscCd.setDiscTp(new Short("0"));
+        saChargeDiscCd.setNm(new_nm);
+        saChargeDiscCd.setComment(new_comment);
+        saChargeDiscCd.setStatus(1);
+        saChargeDiscCd.setRecUpdTs(new Date());
+        saChargeDiscCd.setRecCrtTs(new Date());
+        saChargeDiscCdController.create(saChargeDiscCd);
+    }
+
+    private void createSaChargeDiscAlgo( Integer discCdNew,Integer stepNo,BigInteger OperRslt,long fix,Character Operator1,BigInteger Object2,Character Operator2,BigInteger Object3) throws Exception {
+        SaChargeDiscAlgoPK saChargeDiscAlgoPK = new SaChargeDiscAlgoPK();
+        SaChargeDiscAlgoController saChargeDiscAlgoController = new SaChargeDiscAlgoController();
+        SaChargeDiscAlgo saChargeDiscAlgo = new SaChargeDiscAlgo();
+        saChargeDiscAlgoPK.setDiscCd(discCdNew);
+        saChargeDiscAlgoPK.setStepNo(stepNo);
+        saChargeDiscAlgo.setSaChargeDiscAlgoPK(saChargeDiscAlgoPK);
+        saChargeDiscAlgo.setOperRslt(OperRslt);
+        saChargeDiscAlgo.setObject1(BigInteger.valueOf(fix));
+        saChargeDiscAlgo.setOperator1(Operator1);
+        saChargeDiscAlgo.setObject2(Object2);
+        saChargeDiscAlgo.setOperator2(Operator2);
+        saChargeDiscAlgo.setObject3(Object3);
+        saChargeDiscAlgo.setStatus(1);
+        saChargeDiscAlgo.setRecCrtTs(new Date());
+        saChargeDiscAlgo.setRecUpdTs(new Date());
+        saChargeDiscAlgoController.create(saChargeDiscAlgo);
+    }
+    /**
+     * 创建特殊计费(单笔固定金额+百分比)
+     * @param fix 固定金额(以分为单位)
+     * @param percent 百分比手续费	1.2(为1.2%)
+     * @return
+     */
+    public ResultVO createDiscSingleFixAndPercent(long fix, double percent) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd saChargeDiscCd = new SaChargeDiscCd();
+        List<SaChargeDiscCd> saChargeDiscCdsList = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+        Integer discCdNew=0;
+        String new_nm="";
+        String new_comment="";
+        for (SaChargeDiscCd saChargeDiscCd1:saChargeDiscCdsList) {
+            Integer discCd = saChargeDiscCd1.getDiscCd();
+            if(2001001<=discCd && discCd<=2001999){
+                if(discCdNew<=discCd){
+                    discCdNew=discCd+1;
+                }
+            }
+            String nm = saChargeDiscCd1.getNm();
+            String comment = saChargeDiscCd1.getComment();
+            //固定金额
+            BigDecimal bigDecimal = new BigDecimal(fix);
+            BigDecimal multiply = bigDecimal.divide(new BigDecimal(100)).setScale(2);
+            //百分比
+            String format = new DecimalFormat("0.00").format(new BigDecimal(Double.toString(percent)));
+            new_nm="固定收费"+multiply+"("+fix+"JPY/KRW)+百分比"+format+"%";
+            new_comment="单笔固定收费"+multiply+"("+fix+"JPY/KRW)+百分比"+format+"%";
+            if(nm.equals(new_nm) && (new_comment.equals(comment))){
+                ResultVO resultVO = new ResultVO();
+                resultVO.setStatus(ResultVO.FAIL);
+                resultVO.setMessage("特殊计费配置重复(单笔固定金额+百分比)");
+                return resultVO;
+            }
+        }
+        //特殊计费名称信息表信息配置
+        crateSaChargeDiscCd(saChargeDiscCdController, saChargeDiscCd, discCdNew, new_nm, new_comment);
+        //特殊计费功能信息表信息配置
+        BigDecimal bigDecimal = new BigDecimal(Double.toString(percent));
+        BigInteger multiply = bigDecimal.multiply(new BigDecimal("100")).toBigInteger();
+        createSaChargeDiscAlgo(discCdNew,0,new BigInteger("-1"),-2,'*',multiply,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,1,new BigInteger("-1"),-1,'+',new BigInteger(String.valueOf(fix)),' ',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,2,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+
+        //添加完成信息刷新
+        StaticData.initList();
+
+        //响应信息返回
+        ResultVO resultVO = new ResultVO();
+        resultVO.setMessage("创建特殊计费(单笔固定金额)添加完成");
+        DiscSingleFix discSingleFix = new DiscSingleFix();
+        discSingleFix.setDiscCd(discCdNew);
+        discSingleFix.setNm(new_nm);
+        discSingleFix.setComment(new_comment);
+        resultVO.setData(discSingleFix);
+        return resultVO;
+    }
+
+
+    /**
+     * 创建特殊计费(单笔固定金额+百分比)
+     * @param monthAmount1 上月金额(美元)
+     * @param percent1 百分比手续费	1.2(为1.2%)
+     * @param monthAmount2 上月金额(美元)
+     * @param percent2 百分比手续费	1.2(为1.2%)
+     * @return
+     */
+    public ResultVO createDiscMonthLadder2( long monthAmount1,double percent1,long monthAmount2, double percent2) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd saChargeDiscCd = new SaChargeDiscCd();
+        List<SaChargeDiscCd> saChargeDiscCdsList = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+        Integer discCdNew=0;
+        String new_nm="";
+        String new_comment="";
+        for (SaChargeDiscCd saChargeDiscCd1:saChargeDiscCdsList) {
+            Integer discCd = saChargeDiscCd1.getDiscCd();
+            if(2002001<=discCd && discCd<=2002999){
+                if(discCdNew<=discCd){
+                    discCdNew=discCd+1;
+                }
+            }
+            String nm = saChargeDiscCd1.getNm();
+            String comment = saChargeDiscCd1.getComment();
+            BigDecimal bigDecimal = new BigDecimal(monthAmount2);
+            BigDecimal multiply = bigDecimal.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format2 = new DecimalFormat("#.##").format(multiply);
+            BigDecimal bigDecima2 = new BigDecimal(monthAmount1);
+            BigDecimal multiply2 = bigDecima2.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format = new DecimalFormat("#.##").format(multiply2);
+            BigDecimal multiply3 = bigDecimal.divide(new BigDecimal(100)).setScale(2);
+            String format3 = new DecimalFormat("#.00").format(multiply3);
+            //百分比
+            new_nm="2级阶梯计费"+percent1+"%/"+percent2+"%(上月品牌美元交易額"+format+"~"+format2+"万/MAX)";
+            new_comment="品牌上月交易额(美元):>"+format3+",MDR="+percent2+"%;否则MDR="+percent1+"%";
+            if(nm.equals(new_nm) && (new_comment.equals(comment))){
+                ResultVO resultVO = new ResultVO();
+                resultVO.setStatus(ResultVO.FAIL);
+                resultVO.setMessage("特殊计费配置重复(2级阶梯计费)");
+                return resultVO;
+            }
+        }
+        //特殊计费名称信息表信息配置
+        crateSaChargeDiscCd(saChargeDiscCdController, saChargeDiscCd, discCdNew, new_nm, new_comment);
+
+
+        //特殊计费功能信息表信息配置
+        BigDecimal bigDecimal = new BigDecimal(Double.toString(percent1));
+        BigInteger multiply1 = bigDecimal.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima2 = new BigDecimal(Double.toString(percent2));
+        BigInteger multiply2 = bigDecima2.multiply(new BigDecimal("100")).toBigInteger();
+        createSaChargeDiscAlgo(discCdNew,0,new BigInteger("2"),0,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount2)));
+        createSaChargeDiscAlgo(discCdNew,1,new BigInteger("4"),monthAmount2,'L',new BigInteger("-11"),'L',new BigInteger("1000000000000"));
+        createSaChargeDiscAlgo(discCdNew,2,new BigInteger("-1"),-2,'*',multiply1,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,3,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,4,new BigInteger("-1"),-2,'*',multiply2,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,5,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        //添加完成信息刷新
+        StaticData.initList();
+
+        //响应信息返回
+        ResultVO resultVO = new ResultVO();
+        resultVO.setMessage("创建特殊计费(2级阶梯计费)添加完成");
+        DiscSingleFix discSingleFix = new DiscSingleFix();
+        discSingleFix.setDiscCd(discCdNew);
+        discSingleFix.setNm(new_nm);
+        discSingleFix.setComment(new_comment);
+        resultVO.setData(discSingleFix);
+        return resultVO;
+    }
+
+    public ResultVO createDiscMonthLadder3(long monthAmount1, double percent1, long monthAmount2, double percent2,long monthAmount3, double percent3) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd saChargeDiscCd = new SaChargeDiscCd();
+        List<SaChargeDiscCd> saChargeDiscCdsList = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+        Integer discCdNew=0;
+        String new_nm="";
+        String new_comment="";
+        for (SaChargeDiscCd saChargeDiscCd1:saChargeDiscCdsList) {
+            Integer discCd = saChargeDiscCd1.getDiscCd();
+            if(2003001<=discCd && discCd<=2003999){
+                if(discCdNew<=discCd){
+                    discCdNew=discCd+1;
+                }
+            }
+            String nm = saChargeDiscCd1.getNm();
+            String comment = saChargeDiscCd1.getComment();
+            //1级
+            BigDecimal bigDecimal = new BigDecimal(monthAmount1);
+            BigDecimal multiply = bigDecimal.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format = new DecimalFormat("#.##").format(multiply);
+            //2级
+            BigDecimal bigDecima2 = new BigDecimal(monthAmount2);
+            BigDecimal multiply2 = bigDecima2.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format2 = new DecimalFormat("#.##").format(multiply2);
+            //3级
+            BigDecimal bigDecima3 = new BigDecimal(monthAmount3);
+            BigDecimal multiply3 = bigDecima3.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format3 = new DecimalFormat("#.##").format(multiply3);
+
+            BigDecimal multiply4 = bigDecima3.divide(new BigDecimal(100)).setScale(2);
+            String format4 = new DecimalFormat("#.00").format(multiply4);
+            BigDecimal multiply5 = bigDecima2.divide(new BigDecimal(100)).setScale(2);
+            String format6 = new DecimalFormat("#.00").format(multiply5);
+
+            new_nm="3级阶梯计费"+percent1+"%/"+percent2+"%/"+percent3+"%(上月品牌美元交易額"+format+"~"+format2+"万/"+format3+"万/MAX)";
+            new_comment="品牌上月交易额(美元):>"+format4+",MDR="+percent3+"%;>"+format6+",MDR="+percent2+"%;否则MDR="+percent1+"%";
+            if(nm.equals(new_nm) && (new_comment.equals(comment))){
+                ResultVO resultVO = new ResultVO();
+                resultVO.setStatus(ResultVO.FAIL);
+                resultVO.setMessage("特殊计费配置重复(3级阶梯计费)");
+                return resultVO;
+            }
+        }
+        //特殊计费名称信息表信息配置
+        crateSaChargeDiscCd(saChargeDiscCdController, saChargeDiscCd, discCdNew, new_nm, new_comment);
+
+
+        //特殊计费功能信息表信息配置
+        BigDecimal bigDecimal = new BigDecimal(Double.toString(percent1));
+        BigInteger multiply1 = bigDecimal.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima2 = new BigDecimal(Double.toString(percent2));
+        BigInteger multiply2 = bigDecima2.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima3 = new BigDecimal(Double.toString(percent3));
+        BigInteger multiply3 = bigDecima3.multiply(new BigDecimal("100")).toBigInteger();
+        createSaChargeDiscAlgo(discCdNew,0,new BigInteger("3"),0,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount2)));
+        createSaChargeDiscAlgo(discCdNew,1,new BigInteger("5"),monthAmount2,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount3)));
+        createSaChargeDiscAlgo(discCdNew,2,new BigInteger("7"),monthAmount3,'L',new BigInteger("-11"),'L',new BigInteger("1000000000000"));
+        createSaChargeDiscAlgo(discCdNew,3,new BigInteger("-1"),-2,'*',multiply1,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,4,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,5,new BigInteger("-1"),-2,'*',multiply2,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,6,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,7,new BigInteger("-1"),-2,'*',multiply3,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,8,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+
+        //添加完成信息刷新
+        StaticData.initList();
+
+        //响应信息返回
+        ResultVO resultVO = new ResultVO();
+        resultVO.setMessage("创建特殊计费(3级阶梯计费)添加完成");
+        DiscSingleFix discSingleFix = new DiscSingleFix();
+        discSingleFix.setDiscCd(discCdNew);
+        discSingleFix.setNm(new_nm);
+        discSingleFix.setComment(new_comment);
+        resultVO.setData(discSingleFix);
+        return resultVO;
+    }
+
+    public ResultVO createDiscMonthLadder4(long monthAmount1, double percent1, long monthAmount2, double percent2, long monthAmount3, double percent3, long monthAmount4, double percent4) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd saChargeDiscCd = new SaChargeDiscCd();
+        List<SaChargeDiscCd> saChargeDiscCdsList = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+        Integer discCdNew=0;
+        String new_nm="";
+        String new_comment="";
+        for (SaChargeDiscCd saChargeDiscCd1:saChargeDiscCdsList) {
+            Integer discCd = saChargeDiscCd1.getDiscCd();
+            if(2004001<=discCd && discCd<=2004999){
+                if(discCdNew<=discCd){
+                    discCdNew=discCd+1;
+                }
+            }
+            String nm = saChargeDiscCd1.getNm();
+            String comment = saChargeDiscCd1.getComment();
+            //1级
+            BigDecimal bigDecimal = new BigDecimal(monthAmount1);
+            BigDecimal multiply = bigDecimal.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format = new DecimalFormat("#.##").format(multiply);
+            //2级
+            BigDecimal bigDecima2 = new BigDecimal(monthAmount2);
+            BigDecimal multiply2 = bigDecima2.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format2 = new DecimalFormat("#.##").format(multiply2);
+            //3级
+            BigDecimal bigDecima3 = new BigDecimal(monthAmount3);
+            BigDecimal multiply3 = bigDecima3.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format3 = new DecimalFormat("#.##").format(multiply3);
+            //4级
+            BigDecimal bigDecima4 = new BigDecimal(monthAmount4);
+            BigDecimal multiply4 = bigDecima4.divide(new BigDecimal(1000000)).setScale(2,BigDecimal.ROUND_HALF_UP);
+            String format4 = new DecimalFormat("#.##").format(multiply4);
+
+            BigDecimal multiply5 = bigDecima4.divide(new BigDecimal(100)).setScale(2);
+            String format5 = new DecimalFormat("#.00").format(multiply5);
+            BigDecimal multiply6 = bigDecima3.divide(new BigDecimal(100)).setScale(2);
+            String format6 = new DecimalFormat("#.00").format(multiply6);
+            BigDecimal multiply7 = bigDecima2.divide(new BigDecimal(100)).setScale(2);
+            String format7= new DecimalFormat("#.00").format(multiply7);
+
+            new_nm="4级阶梯计费"+percent1+"%/"+percent2+"%/"+percent3+"%/"+percent4+"%(上月品牌美元交易額"+format+"~"+format2+"万/"+format3+"万/"+format4+"万/MAX)";
+            new_comment="品牌上月交易额(美元):>"+format5+",MDR="+percent4+"%;>"+format6+",MDR="+percent3+"%;>"+format7+",MDR="+percent2+"%;否则MDR="+percent1+"%";
+            if(nm.equals(new_nm) && (new_comment.equals(comment))){
+                ResultVO resultVO = new ResultVO();
+                resultVO.setStatus(ResultVO.FAIL);
+                resultVO.setMessage("特殊计费配置重复(4级阶梯计费)");
+                return resultVO;
+            }
+        }
+
+        //特殊计费名称信息表信息配置
+        crateSaChargeDiscCd(saChargeDiscCdController, saChargeDiscCd, discCdNew, new_nm, new_comment);
+
+        //特殊计费功能信息表信息配置
+        BigDecimal bigDecimal = new BigDecimal(Double.toString(percent1));
+        BigInteger multiply1 = bigDecimal.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima2 = new BigDecimal(Double.toString(percent2));
+        BigInteger multiply2 = bigDecima2.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima3 = new BigDecimal(Double.toString(percent3));
+        BigInteger multiply3 = bigDecima3.multiply(new BigDecimal("100")).toBigInteger();
+        BigDecimal bigDecima4 = new BigDecimal(Double.toString(percent4));
+        BigInteger multiply4 = bigDecima4.multiply(new BigDecimal("100")).toBigInteger();
+        createSaChargeDiscAlgo(discCdNew,0,new BigInteger("4"),0,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount2)));
+        createSaChargeDiscAlgo(discCdNew,1,new BigInteger("6"),monthAmount2,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount3)));
+        createSaChargeDiscAlgo(discCdNew,2,new BigInteger("8"),monthAmount3,'L',new BigInteger("-11"),'L',new BigInteger(String.valueOf(monthAmount4)));
+        createSaChargeDiscAlgo(discCdNew,3,new BigInteger("10"),monthAmount4,'L',new BigInteger("-11"),'L',new BigInteger("1000000000000"));
+        createSaChargeDiscAlgo(discCdNew,4,new BigInteger("-1"),-2,'*',multiply1,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,5,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,6,new BigInteger("-1"),-2,'*',multiply2,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,7,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,8,new BigInteger("-1"),-2,'*',multiply3,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,9,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+        createSaChargeDiscAlgo(discCdNew,10,new BigInteger("-1"),-2,'*',multiply4,'/',new BigInteger("10000"));
+        createSaChargeDiscAlgo(discCdNew,11,new BigInteger("0"),0,'$',new BigInteger("0"),'$',new BigInteger("0"));
+
+
+        //添加完成信息刷新
+        StaticData.initList();
+
+        //响应信息返回
+        ResultVO resultVO = new ResultVO();
+        resultVO.setMessage("创建特殊计费(4级阶梯计费)添加完成");
+        DiscSingleFix discSingleFix = new DiscSingleFix();
+        discSingleFix.setDiscCd(discCdNew);
+        discSingleFix.setNm(new_nm);
+        discSingleFix.setComment(new_comment);
+        resultVO.setData(discSingleFix);
+        return resultVO;
+    }
+
+    public ResultVO releaseDisc(long discCd) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd entity = saChargeDiscCdController.findEntity(SaChargeDiscCd.class,Integer.valueOf(String.valueOf(discCd)));
+        if(entity.getStatus()==0){
+            ResultVO resultVO = new ResultVO();
+            resultVO.setStatus(ResultVO.FAIL);
+            resultVO.setMessage("计费代码已生效,请勿重复发送");
+            return  resultVO;
+        }
+        entity.setStatus(0);
+        saChargeDiscCdController.edit(entity);
+        //生效完成信息刷新
+        StaticData.initList();
+        return  new ResultVO();
+    }
+
+    public ResultVO deleteDisc(long discCd) throws Exception {
+        SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+        SaChargeDiscCd entity = saChargeDiscCdController.findEntity(SaChargeDiscCd.class,Integer.valueOf(String.valueOf(discCd)));
+        if(entity==null){
+            ResultVO resultVO = new ResultVO();
+            resultVO.setStatus(ResultVO.FAIL);
+            resultVO.setMessage("计费代码不存在");
+            return  resultVO;
+        }
+        if(entity.getStatus()==0){
+            ResultVO resultVO = new ResultVO();
+            resultVO.setStatus(ResultVO.FAIL);
+            resultVO.setMessage("计费代码已生效,不能删除");
+            return  resultVO;
+        }
+        //信息表信息删除
+        saChargeDiscCdController.delete(entity);
+        //功能表信息删除
+        SaChargeDiscAlgoController saChargeDiscAlgoController = new SaChargeDiscAlgoController();
+        //List<SaChargeDiscAlgo> entitiesSQL = saChargeDiscAlgoController.findEntitiesSQL("select * from sa_charge_disc_algo where disc_cd=" + entity.getDiscCd(), true, 10, 0);
+        List<SaChargeDiscAlgo> entities = saChargeDiscAlgoController.findEntities(SaChargeDiscAlgo.class);
+        for (SaChargeDiscAlgo sa:entities){
+            if(sa.getSaChargeDiscAlgoPK().getDiscCd()==entity.getDiscCd()){
+                saChargeDiscAlgoController.delete(sa);
+            }
+        }
+        //删除完成信息刷新
+        StaticData.initList();
+        return new ResultVO();
+    }
+
+
+    public ResultVO selectFindCode(Long discCd, String nm, Integer status,Integer pageNum,Integer pageSize) {
+        ResultVO v = new ResultVO();
+        List<SaChargeDiscCd> list = new ArrayList();
+        List<SaChargeDiscCd> listSaChargeDiscCdStatic = StaticData.ListSaChargeDiscCd;
+        List<SaChargeDiscCd> listSaChargeDiscCdNew = new ArrayList<>();
+        listSaChargeDiscCdNew.addAll(listSaChargeDiscCdStatic);
+        if(status!=null) {
+            if(status==0){
+                status=1;
+            }else {
+                status=0;
+            }
+            Iterator<SaChargeDiscCd> it = listSaChargeDiscCdNew.iterator();
+            while (it.hasNext()) {
+                if (it.next().getStatus() ==status) {   //it.next()方法即可返回当前元素
+                    it.remove();
+                }
+            }
+        }
+        List<SaChargeDiscCd> listSaChargeDiscCd = new ArrayList<>();
+        if(nm!=null) {
+            Iterator<SaChargeDiscCd> it = listSaChargeDiscCdNew.iterator();
+            SaChargeDiscCd next =null;
+            while (it.hasNext()) {
+                SaChargeDiscCd sa = it.next();
+                if (sa.getNm().contains(nm)) {   //it.next()方法即可返回当前元素
+                   next = sa;
+                   listSaChargeDiscCd.add(next);
+                }
+            }
+        }else {
+            listSaChargeDiscCd.addAll(listSaChargeDiscCdNew);
+        }
+        if(discCd==null){
+            v.setData(pageUtil.getPage(pageNum,pageSize,listSaChargeDiscCd));
+            v.setMessage("查询成功");
+            v.setStatus(ResultVO.SUCCESS);
+            return v;
+        }
+        listSaChargeDiscCd.forEach((s)->{
+                if(s.getDiscCd()==discCd.intValue()){
+                    list.add(s);
+                }
+            });
+        if(list.size()==0){
+            v.setMessage("未查询到");
+            v.setStatus(ResultVO.FAIL);
+            return v;
+        }
+        v.setData(pageUtil.getPage(pageNum,pageSize,list));
+        v.setMessage("查询成功");
+        v.setStatus(ResultVO.SUCCESS);
+        return v;
+    }
+}

+ 94 - 0
Charge/src/main/java/com/allpay/charge/calc/define/AlgoCfg.java

@@ -0,0 +1,94 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.define;
+
+import com.allpay.charge.tools.StringTools;
+
+
+
+/**
+ *
+ * @author Brian
+ */
+public class AlgoCfg {
+    long discCd;
+   
+    int  stepNo;
+    long operRslt;
+
+    long object1;
+    char operator1;
+    long object2;
+    char operator2;
+    long object3;
+    
+    public AlgoCfg(long discCd,int stepNo,long operRslt,long object1,char operator1,long object2,char operator2,long object3){
+        this.discCd = discCd;
+        this.stepNo = stepNo;
+        this.operRslt = operRslt;
+        this.object1 = object1;
+        this.operator1 = operator1;
+        this.object2 = object2;
+        this.operator2 = operator2;
+        this.object3 = object3;
+    }
+
+    public String getValues(){
+        return StringTools.toSplit(",",this.discCd, this.stepNo,this.operRslt,this.object1,this.operator1,this.object2,this.operator2,this.object3);
+    }
+
+    /*
+     public AlgoCfg(SaChargeDiscAlgo obj){
+        this.discCd = obj.getSaChargeDiscAlgoPK().getDiscCd();
+        this.stepNo = obj.getSaChargeDiscAlgoPK().getStepNo();
+        this.operRslt = obj.getOperRslt().longValue();
+        this.object1 = obj.getObject1().longValue();
+        this.operator1 = obj.getOperator1();
+        this.object2 = obj.getObject2().longValue();
+        this.operator2 = obj.getOperator2();
+        this.object3 = obj.getObject3().longValue();
+     }
+*/
+    
+    public void printValue(){
+        System.out.printf("%10d%3d%5d%13d%3s%13d%3s%13d\n",this.discCd, this.stepNo,this.operRslt,this.object1,this.operator1,this.object2,this.operator2,this.object3);
+    }
+    
+
+    public long getDiscCd(){
+        return this.discCd;
+    }   
+    
+    public int getStepNo(){
+        return this.stepNo;
+    }
+ 
+    public long getOperRslt(){
+        return this.operRslt;
+    }
+
+    public long getObject1(){
+        return this.object1;
+    }    
+
+    public long getObject2(){
+        return this.object2;
+    }      
+
+    public long getObject3(){
+        return this.object3;
+    }   
+    
+    public char getOperator1(){
+        return this.operator1;
+    }  
+
+    public char getOperator2(){
+        return this.operator2;
+    }  
+    
+    
+}

+ 55 - 0
Charge/src/main/java/com/allpay/charge/calc/define/CalcResult.java

@@ -0,0 +1,55 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.define;
+
+import org.json.JSONObject;
+
+
+/**
+ *
+ * @author Brian
+ */
+public class CalcResult {
+    int  status;
+    long result;
+    String message;
+
+    public String getMessage() { return message; }
+
+    public void setMessage(String message) { this.message = message; }
+
+    public void setStatus(int status){
+        this.status = status;
+    }
+
+    public void setResult(long result){
+        this.result = result;
+    }
+
+    public int getStatus() {
+        return this.status;
+    }
+
+    public long getResult(){
+        return this.result;
+    }
+
+    public  String getForJson(){
+       JSONObject jsonObj = new JSONObject();
+       jsonObj.put("status", this.status);
+       if(this.status == 0) jsonObj.put("result", this.result);
+       return jsonObj.toString(1);
+    }
+
+    public  String getForMessageJson(){
+        JSONObject jsonObj = new JSONObject();
+        jsonObj.put("status", this.status);
+        if(this.status == 0) jsonObj.put("message", this.message);
+        return jsonObj.toString(1);
+    }
+
+
+}

+ 37 - 0
Charge/src/main/java/com/allpay/charge/calc/define/Const.java

@@ -0,0 +1,37 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.define;
+
+
+/**
+ *
+ * @author Brian
+ */
+public  class Const {
+
+
+  public static class AmountIdx{
+     public static  int RETURN_AMT      = 1; //-1 :默认返回计算结果
+     public static  int TRANS_SETTLE_AMT= 2; //-2 :单笔交易金额(清算币种,默认)
+     public static  int MER_DISC_CODE   = 10; //-10:该笔交易的商户手续费代码
+     public static  int BRAND_LAST_MONTH_USD_AMT   = 11; //-11:商户(实体)上月USD交易额(当前支付品牌)
+     public static  int ALL_LAST_MONTH_USD_AMT   = 12; //-12:商户(实体)上月USD交易额(所有交易)
+
+  }
+
+  public static class Calc{
+        public static int SUCCEED			=0;     //计算成功
+        public static int ERR_ALGO_NULL                 =10;    //无效的计算代码(ALGO为空)
+        public static int ERR_OPERRSLT_OVERLIMIT_1	=20;    //配置错误,计算跳转超限
+        public static int ERR_OPERRSLT_OVERLIMIT_2	=21;    //配置错误,计算参数超限
+        public static int ERR_CALC_STEP                 =30;    //计算步骤错误
+        public static int ERR_OTHER			=40;
+        public static int ERR_AMOUNT_OVERLIMIT          =50;   //金额超限(小于0或大于999999999999)
+        public static long ERR_CALC_STEP_L              =9999999999999999L; //计算步骤错误
+    }
+
+
+}

+ 68 - 0
Charge/src/main/java/com/allpay/charge/calc/define/ResultVO.java

@@ -0,0 +1,68 @@
+package com.allpay.charge.calc.define;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 统一响应信息
+ *
+ * @author kang.wang
+ * @create 2018-12-10 15:23
+ **/
+@Data
+public class ResultVO<T> implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public T getData() {
+		return data;
+	}
+
+	public void setData(T data) {
+		this.data = data;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public static final String SUCCESS = "success";
+
+	public static final String FAIL = "fail";
+
+	private String status = SUCCESS;
+
+	private String message = "OK";
+
+	private T data;
+
+
+	public ResultVO() {
+		super();
+	}
+
+	public ResultVO(T data) {
+		super();
+		this.data = data;
+	}
+
+	public ResultVO(Throwable e) {
+		super();
+		this.message = e.toString();
+		this.status = FAIL;
+	}
+
+}

+ 76 - 0
Charge/src/main/java/com/allpay/charge/calc/define/StaticData.java

@@ -0,0 +1,76 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.calc.define;
+
+import com.allpay.charge.calc.core.Charge;
+import com.allpay.charge.db.controller.SaChargeDiscAlgoController;
+import com.allpay.charge.db.controller.SaChargeDiscCdController;
+import com.allpay.charge.db.entity.SaChargeDiscAlgo;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.allpay.charge.db.entity.SaChargeDiscCd;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author Brian
+ */
+
+public class StaticData {
+  public  static List<AlgoCfg> listAlgoCfg = new ArrayList<>();
+  public  static List<SaChargeDiscCd> ListSaChargeDiscCd = new ArrayList<>();
+  public  static Charge charge=new Charge();
+
+  private static final Logger logger = Logger.getLogger(StaticData.class);
+
+
+//  static {
+//    initList() ;
+//  }
+//
+  /*
+public static final void initList(List<AlgoCfg> list)  {
+  listAlgoCfg.clear();
+  listAlgoCfg.addAll(list);
+  logger.info("initList() size:" + list.size());
+}
+*/
+
+   public static  void initList(){
+       List<AlgoCfg> list = new ArrayList<>();
+       list.clear();
+        SaChargeDiscAlgoController saChargeDiscAlgoController =new SaChargeDiscAlgoController();
+        List<SaChargeDiscAlgo> findEntities = saChargeDiscAlgoController.findEntities(SaChargeDiscAlgo.class);
+        findEntities.forEach((t) -> {
+            list.add(new AlgoCfg(
+                    t.getSaChargeDiscAlgoPK().getDiscCd(),
+                    t.getSaChargeDiscAlgoPK().getStepNo(),
+                    t.getOperRslt().longValue(),
+                    t.getObject1().longValue(),
+                    t.getOperator1(),
+                    t.getObject2().longValue(),
+                    t.getOperator2(),
+                    t.getObject3().longValue()
+            ));
+        });
+    listAlgoCfg.clear();
+    listAlgoCfg.addAll(list);
+    logger.info("initList() size:" + list.size());
+
+      // ListSaChargeDiscCd
+       SaChargeDiscCdController saChargeDiscCdController = new SaChargeDiscCdController();
+       List<SaChargeDiscCd> Entities = saChargeDiscCdController.findEntities(SaChargeDiscCd.class);
+       ListSaChargeDiscCd.clear();
+       ListSaChargeDiscCd=Entities;
+       logger.info("initListSaChargeDiscCd() size:" + Entities.size());
+
+   }
+
+
+
+
+}

+ 34 - 0
Charge/src/main/java/com/allpay/charge/config/InterceptorConfig.java

@@ -0,0 +1,34 @@
+package com.allpay.charge.config;
+
+import com.allpay.charge.interceptor.PermissionsInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+/**
+ * Created by zhang on 2018/12/20.
+ */
+@Configuration
+public class InterceptorConfig extends WebMvcConfigurationSupport {
+	@Autowired
+	private PermissionsInterceptor authInterceptor;
+
+	@Override
+	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(authInterceptor).addPathPatterns("/mp/**");
+		//管理平台登录之后,再开始运行
+		// registry.addInterceptor(managerInterceptor).addPathPatterns("/mp/ats/**");
+		super.addInterceptors(registry);
+	}
+
+
+	@Override
+	public void configurePathMatch(PathMatchConfigurer configurer) {
+		//setUseSuffixPatternMatch 后缀模式匹配
+		configurer.setUseSuffixPatternMatch(false);
+		//setUseTrailingSlashMatch 自动后缀路径模式匹配
+		configurer.setUseTrailingSlashMatch(true);
+	}
+}

+ 111 - 0
Charge/src/main/java/com/allpay/charge/config/ResourceServerConfig.java

@@ -0,0 +1,111 @@
+package com.allpay.charge.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.security.SecurityProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.AccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
+import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.CorsConfigurationSource;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * @author kang.wang
+ * @date 2019/06/04
+ **/
+@Configuration
+@EnableResourceServer
+@Slf4j
+public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
+
+	@Value("${commonMessage.ossUrl}")
+	private String OssUrl;
+
+	@Bean
+	public FilterRegistrationBean corsFilter() {
+		FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(corsConfigurationSource()));
+		bean.setOrder(SecurityProperties.DEFAULT_FILTER_ORDER);
+		return bean;
+	}
+
+	@Bean
+	public CorsConfigurationSource corsConfigurationSource() {
+		UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+		CorsConfiguration config = new CorsConfiguration();
+		config.setAllowCredentials(true);
+		config.addAllowedOrigin("*");
+		config.addAllowedHeader("*");
+		config.addAllowedMethod("*");
+		source.registerCorsConfiguration("/**", config);
+		return source;
+	}
+
+	@Override
+	public void configure(HttpSecurity http) throws Exception {
+		http
+				.csrf().disable()
+				.exceptionHandling()
+				.authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
+				.and()
+				.authorizeRequests()
+				.antMatchers("/charge/**").permitAll()
+				.anyRequest().authenticated()
+				.and()
+				.httpBasic();
+	}
+
+	@Override
+	public void configure(ResourceServerSecurityConfigurer resources) {
+		resources.tokenServices(tokenServices());//.resourceId(SPARKLR_RESOURCE_ID);
+	}
+
+	@Bean
+	public ResourceServerTokenServices tokenServices() {
+		RemoteTokenServices remoteTokenServices = new RemoteTokenServices();
+//这里配置远程校验token的地址,(也可以使用其他方式,例如本地校验)
+		remoteTokenServices.setCheckTokenEndpointUrl(OssUrl+"/server/oauth/check_token");
+//为方便测试使用硬编码,要和security-server配置的相同(security服务会校验客户端信息)
+		remoteTokenServices.setClientId("demo1");
+		remoteTokenServices.setClientSecret("demosecret1");
+//		remoteTokenServices.setRestTemplate(restTemplate());
+//使用默认令牌数据的存储
+		remoteTokenServices.setAccessTokenConverter(accessTokenConverter());
+		return remoteTokenServices;
+	}
+
+	@Bean
+	public RestTemplate restTemplate() {
+		//httpRequestFactory()
+		RestTemplate restTemplate = new RestTemplate();
+		List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
+		for (HttpMessageConverter<?> converter : converters) {
+			if (converter instanceof MappingJackson2HttpMessageConverter) {
+				MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter;
+				jsonConverter.setObjectMapper(new ObjectMapper());
+//				jsonConverter.setSupportedMediaTypes(ImmutableList.of(new MediaType("application", "json", MappingJackson2HttpMessageConverter.DEFAULT_CHARSET), new MediaType("text", "javascript", MappingJackson2HttpMessageConverter.DEFAULT_CHARSET)));
+			}
+		}
+		return restTemplate;
+	}
+	@Bean
+	public AccessTokenConverter accessTokenConverter() {
+		return new DefaultAccessTokenConverter();
+	}
+}

+ 151 - 0
Charge/src/main/java/com/allpay/charge/db/controller/AbstractController.java

@@ -0,0 +1,151 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.controller;
+
+import com.allpay.charge.db.exceptions.NonexistentEntityException;
+import com.allpay.charge.db.exceptions.PreexistingEntityException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+import javax.persistence.criteria.CriteriaQuery;
+
+
+/**
+ *
+ * @author Brian
+ * @param <T>
+ */
+
+public abstract class AbstractController<T> implements Serializable{
+
+
+    private final String EMF_NAME ="com.allpay_charge_jar_0.0.1-local";
+
+    private final  EntityManagerFactory emf = Persistence.createEntityManagerFactory(EMF_NAME);
+
+    public EntityManager getEntityManager() {
+        return emf.createEntityManager();
+     }
+
+    public void create(T entity) throws PreexistingEntityException, Exception {
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            em.persist(entity);
+            em.getTransaction().commit();
+        } catch (Exception ex) {
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void edit(T entity) throws NonexistentEntityException, Exception {
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            em.merge(entity);
+            em.getTransaction().commit();
+        } catch (Exception ex) {
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+      public void delete(T entity) throws NonexistentEntityException, Exception {
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            T merge = em.merge(entity);
+            em.remove(merge);
+            em.getTransaction().commit();
+        } catch (Exception ex) {
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public List<T> findEntitiesSQL(String SQL,boolean all, int maxResults, int firstResult) throws ClassNotFoundException {
+        EntityManager em = getEntityManager();
+        try {
+            Query q =  em.createNativeQuery(SQL);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+         } finally {
+            em.close();
+        }
+    }
+
+    public T findEntity(Class c,Object id){
+        EntityManager em = getEntityManager();
+        try {
+            return (T) em.find(c, id);
+        } finally {
+            em.close();
+        }
+    }
+
+    private List<T> findEntities(Class c,boolean all, int maxResults, int firstResult) {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            cq.select(cq.from(c));
+            Query q = em.createQuery(cq);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+        } finally {
+            em.close();
+        }
+    }
+
+
+    public List<T> findEntities(Class c) {
+        return findEntities( c,true, -1, -1);
+    }
+
+    public List<T> findEntities(Class c,int maxResults, int firstResult) {
+        return findEntities(c,false, maxResults, firstResult);
+    }
+
+
+    public List<T> findEntitiesQuery(Query query,boolean all, int maxResults, int firstResult) throws ClassNotFoundException {
+        EntityManager em = getEntityManager();
+        try {
+            if (!all) {
+                query.setMaxResults(maxResults);
+                query.setFirstResult(firstResult);
+            }
+            return query.getResultList();
+         } finally {
+            em.close();
+        }
+    }
+
+
+}

+ 19 - 0
Charge/src/main/java/com/allpay/charge/db/controller/SaChargeDiscAlgoController.java

@@ -0,0 +1,19 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.controller;
+
+import com.allpay.charge.db.entity.SaChargeDiscAlgo;
+
+
+
+/**
+ *
+ * @author Brian
+ */
+public class SaChargeDiscAlgoController extends AbstractController<SaChargeDiscAlgo>{
+    
+}
+  

+ 19 - 0
Charge/src/main/java/com/allpay/charge/db/controller/SaChargeDiscCdController.java

@@ -0,0 +1,19 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.controller;
+
+import com.allpay.charge.db.entity.SaChargeDiscCd;
+
+
+
+/**
+ *
+ * @author Brian
+ */
+public class SaChargeDiscCdController extends AbstractController<SaChargeDiscCd>{
+    
+}
+  

+ 13 - 0
Charge/src/main/java/com/allpay/charge/db/entity/DiscSingleFix.java

@@ -0,0 +1,13 @@
+package com.allpay.charge.db.entity;
+
+import lombok.Data;
+
+@Data
+public class DiscSingleFix {
+
+    private Integer discCd;
+
+    private String nm;
+
+    private String comment;
+}

+ 22 - 0
Charge/src/main/java/com/allpay/charge/db/entity/Page.java

@@ -0,0 +1,22 @@
+package com.allpay.charge.db.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class Page {
+
+    private Integer currentPage;//当前页
+
+    private int pageSize;//每页显示记录条数
+
+    private int totalPage;//总页数
+
+    private List<?> dataList;//每页显示的数据
+
+    private int star;//开始数据
+
+    private int listSize;
+
+}

+ 200 - 0
Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscAlgo.java

@@ -0,0 +1,200 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Brian
+ */
+@Entity
+@Data
+@Table(name = "sa_charge_disc_algo")
+@XmlRootElement
+@NamedQueries({
+    @NamedQuery(name = "SaChargeDiscAlgo.findAll", query = "SELECT s FROM SaChargeDiscAlgo s"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByDiscCd", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.saChargeDiscAlgoPK.discCd = :discCd"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByStepNo", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.saChargeDiscAlgoPK.stepNo = :stepNo"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByOperRslt", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.operRslt = :operRslt"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByObject1", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.object1 = :object1"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByOperator1", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.operator1 = :operator1"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByObject2", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.object2 = :object2"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByOperator2", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.operator2 = :operator2"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByObject3", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.object3 = :object3"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByOperIn", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.operIn = :operIn"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByRecUpdUsrId", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.recUpdUsrId = :recUpdUsrId"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByRecUpdTs", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.recUpdTs = :recUpdTs"),
+    @NamedQuery(name = "SaChargeDiscAlgo.findByRecCrtTs", query = "SELECT s FROM SaChargeDiscAlgo s WHERE s.recCrtTs = :recCrtTs")})
+public class SaChargeDiscAlgo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    @EmbeddedId
+    protected SaChargeDiscAlgoPK saChargeDiscAlgoPK;
+    @Column(name = "oper_rslt")
+    private BigInteger operRslt;
+    @Column(name = "object1")
+    private BigInteger object1;
+    @Column(name = "operator1")
+    private Character operator1;
+    @Column(name = "object2")
+    private BigInteger object2;
+    @Column(name = "operator2")
+    private Character operator2;
+    @Column(name = "object3")
+    private BigInteger object3;
+    @Column(name = "oper_in")
+    private Character operIn;
+    @Size(max = 20)
+    @Column(name = "rec_upd_usr_id")
+    private String recUpdUsrId;
+    @Column(name = "rec_upd_ts")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date recUpdTs;
+    @Column(name = "rec_crt_ts")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date recCrtTs;
+    @Column(name = "status")
+    private Integer status;
+    public SaChargeDiscAlgo() {
+    }
+
+    public SaChargeDiscAlgo(SaChargeDiscAlgoPK saChargeDiscAlgoPK) {
+        this.saChargeDiscAlgoPK = saChargeDiscAlgoPK;
+    }
+
+    public SaChargeDiscAlgo(int discCd, int stepNo) {
+        this.saChargeDiscAlgoPK = new SaChargeDiscAlgoPK(discCd, stepNo);
+    }
+
+    public SaChargeDiscAlgoPK getSaChargeDiscAlgoPK() {
+        return saChargeDiscAlgoPK;
+    }
+
+    public void setSaChargeDiscAlgoPK(SaChargeDiscAlgoPK saChargeDiscAlgoPK) {
+        this.saChargeDiscAlgoPK = saChargeDiscAlgoPK;
+    }
+
+    public BigInteger getOperRslt() {
+        return operRslt;
+    }
+
+    public void setOperRslt(BigInteger operRslt) {
+        this.operRslt = operRslt;
+    }
+
+    public BigInteger getObject1() {
+        return object1;
+    }
+
+    public void setObject1(BigInteger object1) {
+        this.object1 = object1;
+    }
+
+    public Character getOperator1() {
+        return operator1;
+    }
+
+    public void setOperator1(Character operator1) {
+        this.operator1 = operator1;
+    }
+
+    public BigInteger getObject2() {
+        return object2;
+    }
+
+    public void setObject2(BigInteger object2) {
+        this.object2 = object2;
+    }
+
+    public Character getOperator2() {
+        return operator2;
+    }
+
+    public void setOperator2(Character operator2) {
+        this.operator2 = operator2;
+    }
+
+    public BigInteger getObject3() {
+        return object3;
+    }
+
+    public void setObject3(BigInteger object3) {
+        this.object3 = object3;
+    }
+
+    public Character getOperIn() {
+        return operIn;
+    }
+
+    public void setOperIn(Character operIn) {
+        this.operIn = operIn;
+    }
+
+    public String getRecUpdUsrId() {
+        return recUpdUsrId;
+    }
+
+    public void setRecUpdUsrId(String recUpdUsrId) {
+        this.recUpdUsrId = recUpdUsrId;
+    }
+
+    public Date getRecUpdTs() {
+        return recUpdTs;
+    }
+
+    public void setRecUpdTs(Date recUpdTs) {
+        this.recUpdTs = recUpdTs;
+    }
+
+    public Date getRecCrtTs() {
+        return recCrtTs;
+    }
+
+    public void setRecCrtTs(Date recCrtTs) {
+        this.recCrtTs = recCrtTs;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 0;
+        hash += (saChargeDiscAlgoPK != null ? saChargeDiscAlgoPK.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        // TODO: Warning - this method won't work in the case the id fields are not set
+        if (!(object instanceof SaChargeDiscAlgo)) {
+            return false;
+        }
+        SaChargeDiscAlgo other = (SaChargeDiscAlgo) object;
+        if ((this.saChargeDiscAlgoPK == null && other.saChargeDiscAlgoPK != null) || (this.saChargeDiscAlgoPK != null && !this.saChargeDiscAlgoPK.equals(other.saChargeDiscAlgoPK))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "com.allpay.charge.db.entity.SaChargeDiscAlgo[ saChargeDiscAlgoPK=" + saChargeDiscAlgoPK + " ]";
+    }
+
+}

+ 89 - 0
Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscAlgoPK.java

@@ -0,0 +1,89 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.entity;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.validation.constraints.NotNull;
+
+/**
+ *
+ * @author Brian
+ */
+@Embeddable
+public class
+
+
+
+
+
+SaChargeDiscAlgoPK implements Serializable {
+
+    @Basic(optional = false)
+    @NotNull
+    @Column(name = "disc_cd")
+    private int discCd;
+    @Basic(optional = false)
+    @NotNull
+    @Column(name = "step_no")
+    private int stepNo;
+
+    public SaChargeDiscAlgoPK() {
+    }
+
+    public SaChargeDiscAlgoPK(int discCd, int stepNo) {
+        this.discCd = discCd;
+        this.stepNo = stepNo;
+    }
+
+    public int getDiscCd() {
+        return discCd;
+    }
+
+    public void setDiscCd(int discCd) {
+        this.discCd = discCd;
+    }
+
+    public int getStepNo() {
+        return stepNo;
+    }
+
+    public void setStepNo(int stepNo) {
+        this.stepNo = stepNo;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 0;
+        hash += (int) discCd;
+        hash += (int) stepNo;
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        // TODO: Warning - this method won't work in the case the id fields are not set
+        if (!(object instanceof SaChargeDiscAlgoPK)) {
+            return false;
+        }
+        SaChargeDiscAlgoPK other = (SaChargeDiscAlgoPK) object;
+        if (this.discCd != other.discCd) {
+            return false;
+        }
+        if (this.stepNo != other.stepNo) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "com.allpay.charge.db.entity.SaChargeDiscAlgoPK[ discCd=" + discCd + ", stepNo=" + stepNo + " ]";
+    }
+
+}

+ 170 - 0
Charge/src/main/java/com/allpay/charge/db/entity/SaChargeDiscCd.java

@@ -0,0 +1,170 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.db.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Brian
+ */
+@Entity
+@Data
+@Table(name = "sa_charge_disc_cd")
+@XmlRootElement
+@NamedQueries({
+    @NamedQuery(name = "SaChargeDiscCd.findAll", query = "SELECT s FROM SaChargeDiscCd s"),
+    @NamedQuery(name = "SaChargeDiscCd.findByDiscCd", query = "SELECT s FROM SaChargeDiscCd s WHERE s.discCd = :discCd"),
+    @NamedQuery(name = "SaChargeDiscCd.findByDiscTp", query = "SELECT s FROM SaChargeDiscCd s WHERE s.discTp = :discTp"),
+    @NamedQuery(name = "SaChargeDiscCd.findByNm", query = "SELECT s FROM SaChargeDiscCd s WHERE s.nm = :nm"),
+    @NamedQuery(name = "SaChargeDiscCd.findByComment", query = "SELECT s FROM SaChargeDiscCd s WHERE s.comment = :comment"),
+    @NamedQuery(name = "SaChargeDiscCd.findByOperIn", query = "SELECT s FROM SaChargeDiscCd s WHERE s.operIn = :operIn"),
+    @NamedQuery(name = "SaChargeDiscCd.findByRecUpdUsrId", query = "SELECT s FROM SaChargeDiscCd s WHERE s.recUpdUsrId = :recUpdUsrId"),
+    @NamedQuery(name = "SaChargeDiscCd.findByRecUpdTs", query = "SELECT s FROM SaChargeDiscCd s WHERE s.recUpdTs = :recUpdTs"),
+    @NamedQuery(name = "SaChargeDiscCd.findByRecCrtTs", query = "SELECT s FROM SaChargeDiscCd s WHERE s.recCrtTs = :recCrtTs")})
+public class SaChargeDiscCd implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    @Id
+    @Basic(optional = false)
+    @NotNull
+    @Column(name = "disc_cd")
+    private Integer discCd;
+    @Column(name = "disc_tp")
+    private Short discTp;
+    @NotNull
+    @Column(name = "status")
+    private Integer status;
+    @Size(max = 200)
+    @Column(name = "nm")
+    private String nm;
+    @Size(max = 200)
+    @Column(name = "comment")
+    private String comment;
+    @Column(name = "oper_in")
+    private Character operIn;
+    @Size(max = 20)
+    @Column(name = "rec_upd_usr_id")
+    private String recUpdUsrId;
+    @Column(name = "rec_upd_ts")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date recUpdTs;
+    @Column(name = "rec_crt_ts")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date recCrtTs;
+
+    public SaChargeDiscCd() {
+    }
+
+    public SaChargeDiscCd(Integer discCd) {
+        this.discCd = discCd;
+    }
+
+    public Integer getDiscCd() {
+        return discCd;
+    }
+
+    public void setDiscCd(Integer discCd) {
+        this.discCd = discCd;
+    }
+
+    public Short getDiscTp() {
+        return discTp;
+    }
+
+    public void setDiscTp(Short discTp) {
+        this.discTp = discTp;
+    }
+
+    public String getNm() {
+        return nm;
+    }
+
+    public void setNm(String nm) {
+        this.nm = nm;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public Character getOperIn() {
+        return operIn;
+    }
+
+    public void setOperIn(Character operIn) {
+        this.operIn = operIn;
+    }
+
+    public String getRecUpdUsrId() {
+        return recUpdUsrId;
+    }
+
+    public void setRecUpdUsrId(String recUpdUsrId) {
+        this.recUpdUsrId = recUpdUsrId;
+    }
+
+    public Date getRecUpdTs() {
+        return recUpdTs;
+    }
+
+    public void setRecUpdTs(Date recUpdTs) {
+        this.recUpdTs = recUpdTs;
+    }
+
+    public Date getRecCrtTs() {
+        return recCrtTs;
+    }
+
+    public void setRecCrtTs(Date recCrtTs) {
+        this.recCrtTs = recCrtTs;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 0;
+        hash += (discCd != null ? discCd.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        // TODO: Warning - this method won't work in the case the id fields are not set
+        if (!(object instanceof SaChargeDiscCd)) {
+            return false;
+        }
+        SaChargeDiscCd other = (SaChargeDiscCd) object;
+        if ((this.discCd == null && other.discCd != null) || (this.discCd != null && !this.discCd.equals(other.discCd))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "com.allpay.charge.db.entity.SaChargeDiscCd[ discCd=" + discCd + " ]";
+    }
+
+}

+ 20 - 0
Charge/src/main/java/com/allpay/charge/db/exceptions/IllegalOrphanException.java

@@ -0,0 +1,20 @@
+package com.allpay.charge.db.exceptions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class IllegalOrphanException extends Exception {
+    private List<String> messages;
+    public IllegalOrphanException(List<String> messages) {
+        super((messages != null && messages.size() > 0 ? messages.get(0) : null));
+        if (messages == null) {
+            this.messages = new ArrayList<String>();
+        }
+        else {
+            this.messages = messages;
+        }
+    }
+    public List<String> getMessages() {
+        return messages;
+    }
+}

+ 10 - 0
Charge/src/main/java/com/allpay/charge/db/exceptions/NonexistentEntityException.java

@@ -0,0 +1,10 @@
+package com.allpay.charge.db.exceptions;
+
+public class NonexistentEntityException extends Exception {
+    public NonexistentEntityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    public NonexistentEntityException(String message) {
+        super(message);
+    }
+}

+ 10 - 0
Charge/src/main/java/com/allpay/charge/db/exceptions/PreexistingEntityException.java

@@ -0,0 +1,10 @@
+package com.allpay.charge.db.exceptions;
+
+public class PreexistingEntityException extends Exception {
+    public PreexistingEntityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    public PreexistingEntityException(String message) {
+        super(message);
+    }
+}

+ 27 - 0
Charge/src/main/java/com/allpay/charge/exception/BadRequestException.java

@@ -0,0 +1,27 @@
+package com.allpay.charge.exception;
+
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:26
+ * @Version : V0.0.1
+ */
+@Getter
+public class BadRequestException extends RuntimeException{
+
+    private Integer status = BAD_REQUEST.value();
+
+    public BadRequestException(String msg){
+        super(msg);
+    }
+
+    public BadRequestException(HttpStatus status, String msg){
+        super(msg);
+        this.status = status.value();
+    }
+}

+ 27 - 0
Charge/src/main/java/com/allpay/charge/exception/IllegalOperationException.java

@@ -0,0 +1,27 @@
+package com.allpay.charge.exception;
+
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:35
+ * @Version : V0.0.1
+ */
+@Getter
+public class IllegalOperationException extends  RuntimeException {
+
+    private Integer status = METHOD_NOT_ALLOWED.value();
+
+    public IllegalOperationException(String msg){
+        super(msg);
+    }
+
+    public IllegalOperationException(HttpStatus status, String msg){
+        super(msg);
+        this.status = status.value();
+    }
+}

+ 27 - 0
Charge/src/main/java/com/allpay/charge/exception/ProcessingFailureException.java

@@ -0,0 +1,27 @@
+package com.allpay.charge.exception;
+
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+import static org.springframework.http.HttpStatus.OK;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:26
+ * @Version : V0.0.1
+ */
+@Getter
+public class ProcessingFailureException extends RuntimeException{
+
+    private Integer status = OK.value();
+
+    public ProcessingFailureException(String msg){
+        super(msg);
+    }
+
+    public ProcessingFailureException(HttpStatus status, String msg){
+        super(msg);
+        this.status = status.value();
+    }
+}

+ 27 - 0
Charge/src/main/java/com/allpay/charge/exception/UnauthenticatedException.java

@@ -0,0 +1,27 @@
+package com.allpay.charge.exception;
+
+import lombok.Getter;
+import org.springframework.http.HttpStatus;
+
+import static org.springframework.http.HttpStatus.FORBIDDEN;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/19 09:41
+ * @Version : V0.0.1
+ */
+@Getter
+public class UnauthenticatedException extends RuntimeException {
+
+    private Integer status = FORBIDDEN.value();
+
+    public UnauthenticatedException(String msg){
+        super(msg);
+    }
+
+    public UnauthenticatedException(HttpStatus status, String msg){
+        super(msg);
+        this.status = status.value();
+    }
+}

+ 33 - 0
Charge/src/main/java/com/allpay/charge/exception/handler/ApiError.java

@@ -0,0 +1,33 @@
+package com.allpay.charge.exception.handler;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:35
+ * @Version : V0.0.1
+ */
+@Data
+public class ApiError {
+
+    private Integer status;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime timestamp;
+    private String message;
+
+    private ApiError() {
+        timestamp = LocalDateTime.now();
+    }
+
+    public ApiError(Integer status, String message) {
+        this();
+        this.status = status;
+        this.message = message;
+    }
+}
+
+

+ 46 - 0
Charge/src/main/java/com/allpay/charge/exception/handler/ApiSuccess.java

@@ -0,0 +1,46 @@
+package com.allpay.charge.exception.handler;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/22 16:41
+ * @Version : V0.0.1
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ApiSuccess<T> {
+
+    public static final String SUCCESS_CODE = "success";
+    public static final String FAIL_CODE = "fail";
+
+    public static final ApiSuccess<String> SUCCESS = new ApiSuccess<String>(SUCCESS_CODE, "ok");
+    public static final ApiSuccess<String> Fail = new ApiSuccess<String>(FAIL_CODE, "fail");
+
+    private String status;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime timestamp;
+    private T content;
+
+    private ApiSuccess(){timestamp = LocalDateTime.now();};
+
+    public ApiSuccess(String status,T content) {
+        this.status = status;
+        this.content = content;
+    }
+
+    public ApiSuccess(T content) {
+        this.status = SUCCESS_CODE;
+        this.content = content;
+    }
+
+    public static <T> ApiSuccess<T> ok(T content) {
+        return new ApiSuccess<>(content);
+    }
+
+}

+ 108 - 0
Charge/src/main/java/com/allpay/charge/exception/handler/GlobalExceptionHandler.java

@@ -0,0 +1,108 @@
+package com.allpay.charge.exception.handler;
+
+import cn.hutool.core.util.StrUtil;
+import com.allpay.charge.exception.IllegalOperationException;
+import com.allpay.charge.exception.ProcessingFailureException;
+import com.allpay.charge.exception.UnauthenticatedException;
+import com.allpay.charge.tools.ThrowableUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import java.util.stream.Collectors;
+
+import static org.springframework.http.HttpStatus.*;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/13 14:25
+ * @Version : V0.0.1
+ */
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+
+    /**
+     * 处理所有不可知的异常
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(Throwable.class)
+    public ResponseEntity<ApiError> handleException(Throwable e){
+        // 打印堆栈信息
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiError apiError = new ApiError(BAD_REQUEST.value(), StrUtil.isBlank(e.getMessage()) ?"系统异常":e.getMessage());
+        return buildResponseT(apiError);
+    }
+
+    /**
+     * 处理非法的操作异常
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(UnauthenticatedException.class)
+    public ResponseEntity<ApiError> handleException(UnauthenticatedException e){
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiError apiError = new ApiError(FORBIDDEN.value(),e.getMessage());
+        return buildResponseT(apiError);
+    }
+
+    /**
+     * 处理非法的操作异常
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(IllegalOperationException.class)
+    public ResponseEntity<ApiError> handleException(IllegalOperationException e){
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiError apiError = new ApiError(METHOD_NOT_ALLOWED.value(),e.getMessage());
+        return buildResponseT(apiError);
+    }
+
+    //处理Get请求中 使用@Valid 验证路径中请求实体校验失败后抛出的异常,详情继续往下看代码
+    @ExceptionHandler(BindException.class)
+    public ResponseEntity<ApiError> BindExceptionHandler(BindException e) {
+        log.error(ThrowableUtil.getStackTrace(e));
+        String message = e.getBindingResult().getAllErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining());
+        ApiError apiError = new ApiError(BAD_REQUEST.value(),message);
+        return buildResponseT(apiError);
+    }
+
+    //处理请求参数格式错误 @RequestParam上validate失败后抛出的异常是javax.validation.ConstraintViolationException
+    @ExceptionHandler(ConstraintViolationException.class)
+    public ResponseEntity<ApiError> ConstraintViolationExceptionHandler(ConstraintViolationException e) {
+        String message = e.getConstraintViolations().stream().map(ConstraintViolation::getMessage).collect(Collectors.joining());
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiError apiError = new ApiError(BAD_REQUEST.value(),message);
+        return buildResponseT(apiError);
+    }
+
+    //处理请求参数格式错误 @RequestBody上validate失败后抛出的异常是MethodArgumentNotValidException异常。
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public ResponseEntity<ApiError> MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
+        String message = e.getBindingResult().getAllErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining());
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiError apiError = new ApiError(BAD_REQUEST.value(),message);
+        return buildResponseT(apiError);
+    }
+
+    //处理失败异常
+    @ExceptionHandler(ProcessingFailureException.class)
+    public ResponseEntity<ApiSuccess> ProcessingFailureExceptionHandler(ProcessingFailureException e) {
+        log.error(ThrowableUtil.getStackTrace(e));
+        ApiSuccess apiSuccess = new ApiSuccess<>(ApiSuccess.FAIL_CODE,e.getMessage());
+        return ResponseEntity.ok(apiSuccess);
+    }
+
+    private ResponseEntity<ApiError> buildResponseT(ApiError apiError) {
+        return new ResponseEntity<ApiError>(apiError, HttpStatus.valueOf(apiError.getStatus()));
+    }
+}

+ 35 - 0
Charge/src/main/java/com/allpay/charge/helper/RefreshData.java

@@ -0,0 +1,35 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.helper;
+
+import com.allpay.charge.calc.define.StaticData;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Brian
+ */
+public class RefreshData extends Thread{
+       @Override
+    public void run(){
+        while(true){
+            //刷新操作
+            //...
+            StaticData.initList();
+            try {
+                Thread.sleep(60*1000*60*2);
+            } catch (InterruptedException ex) {
+                Logger.getLogger(RefreshData.class.getName()).log(Level.SEVERE, null, ex);
+            }
+
+        }
+
+    }
+
+
+
+}

+ 107 - 0
Charge/src/main/java/com/allpay/charge/interceptor/PermissionsInterceptor.java

@@ -0,0 +1,107 @@
+package com.allpay.charge.interceptor;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.http.HttpException;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.allpay.charge.annoation.GetUserInfo;
+import com.allpay.charge.annoation.PermissionRequire;
+import com.allpay.charge.calc.define.ResultVO;
+import com.allpay.charge.exception.BadRequestException;
+import com.allpay.charge.exception.UnauthenticatedException;
+import com.allpay.charge.tools.SignatureUtil;
+import com.allpay.charge.tools.ThreadLocalUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/19 09:37
+ * @Version : V0.0.1
+ */
+@Slf4j
+@Component
+public class PermissionsInterceptor extends HandlerInterceptorAdapter {
+
+    @Value("${commonMessage.verifyFunctionUrl}")
+    private String verifyFunctionUrl;
+    @Value("${commonMessage.userInfo}")
+    private String userInfoUrl;
+
+    private boolean returnResult(HttpServletResponse response, String message) {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        try (PrintWriter out = response.getWriter()) {
+            ResultVO result = new ResultVO();
+            result.setStatus(ResultVO.FAIL);
+            result.setMessage(message);
+            String jsonString = JSON.toJSONString(result);
+            out.append(jsonString);
+            return false;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        if (handler instanceof HandlerMethod) {
+            //签名验证
+            boolean vertify = SignatureUtil.vertify(request, "3d98df38bd49ab8ac7e64f21197");
+            if(!vertify){
+                return false;
+            }
+            String authorization = request.getHeader("Authorization");
+            PermissionRequire annotation = ((HandlerMethod) handler).getMethodAnnotation(PermissionRequire.class);
+            GetUserInfo userInfoAnnotation = ((HandlerMethod) handler).getMethodAnnotation(GetUserInfo.class);
+            if (ObjectUtil.isEmpty(userInfoAnnotation)) {
+                String userInfo = HttpUtil.createGet(userInfoUrl).header("Authorization", authorization).execute().body();
+                JSONObject jsonObject = JSON.parseObject(userInfo);
+                if (ObjectUtil.isNotNull(jsonObject) && "success".equals(jsonObject.getString("status"))) {
+                    String operator = jsonObject.getJSONObject("data").getString("operatorCode");
+                    ThreadLocalUtil.operatorId.set(operator);
+                } else {
+                   // return returnResult(response, "获取用户信息失败");
+                     throw new BadRequestException("获取用户信息失败");
+                }
+            }
+            if (annotation != null) {
+                String res = null;
+                log.info("权限验证接口:{}", annotation.value());
+                try {
+                    res = HttpUtil.createGet(verifyFunctionUrl + "?function_id=" + annotation.value()).header("Authorization", authorization).execute().body();
+                } catch (HttpException e) {
+                    log.warn("请求权限异常:{}", e.getMessage());
+                   // return returnResult(response, "权限接口异常");
+                    throw new UnauthenticatedException("权限接口异常");
+                }
+                JSONObject jsonObject = JSON.parseObject(res);
+                if (ObjectUtil.isNotNull(jsonObject) && "success".equals(jsonObject.getString("status"))) {
+                    return true;
+                } else {
+                    //return returnResult(response, "没有权限");
+                    throw new UnauthenticatedException("没有权限");
+                }
+            } else {
+                return true;
+            }
+        }
+        return true;
+    }
+
+
+}
+

+ 57 - 0
Charge/src/main/java/com/allpay/charge/tools/SHA256Util.java

@@ -0,0 +1,57 @@
+package com.allpay.charge.tools;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Created by lei on 2018/12/15.
+ */
+@Slf4j
+public class SHA256Util {
+
+	/**
+	 * 利用java原生的摘要实现SHA256加密
+	 *
+	 * @param str 加密后的报文
+	 * @return
+	 */
+	public static String getSHA256(String str) {
+		MessageDigest messageDigest;
+		String encodeStr = "";
+		try {
+			messageDigest = MessageDigest.getInstance("SHA-256");
+			messageDigest.update(str.getBytes("UTF-8"));
+			encodeStr = byte2Hex(messageDigest.digest());
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		return encodeStr;
+	}
+
+
+	/**
+	 * 将byte转为16进制
+	 *
+	 * @param bytes
+	 * @return
+	 */
+	private static String byte2Hex(byte[] bytes) {
+		StringBuffer stringBuffer = new StringBuffer();
+		String temp = null;
+		for (int i = 0; i < bytes.length; i++) {
+			temp = Integer.toHexString(bytes[i] & 0xFF);
+			if (temp.length() == 1) {
+				//1得到一位的进行补0操作
+				stringBuffer.append("0");
+			}
+			stringBuffer.append(temp);
+		}
+		return stringBuffer.toString();
+	}
+}
+

+ 164 - 0
Charge/src/main/java/com/allpay/charge/tools/SignatureUtil.java

@@ -0,0 +1,164 @@
+package com.allpay.charge.tools;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.alibaba.fastjson.parser.Feature;
+import com.allpay.charge.calc.define.ResultVO;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
+/**
+ * @author : lei.chen
+ * @Company : AllPay
+ * @CreateDate : 2019/5/16 9:32
+ */
+public class SignatureUtil {
+
+	/**
+	 * 日志层
+	 */
+	private static final Logger logger = LoggerFactory.getLogger(SignatureUtil.class);
+
+	public static String getSignature(HashMap map, String SecretKey) {
+
+		List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(map.entrySet());
+		// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
+		// sort all incoming parameters by ASCII code of field name from small to large (dictionary order)
+		Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
+			@Override
+			public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
+				return (o1.getKey()).toString().compareTo(o2.getKey());
+			}
+		});
+		// 构造签名键值对的格式
+		//Construct a format for signing key-value pairs
+		StringBuilder String1 = new StringBuilder();
+		for (Map.Entry<String, String> item : infoIds) {
+			if (item.getKey() != null && !"".equals(item.getKey())) {
+				String val = item.getValue();
+				String key = item.getKey();
+				if (val != null) {
+					String1.append(key + "=" + val + "&");
+				}
+			}
+
+		}
+
+		String1.deleteCharAt(String1.length() - 1);
+		//添加双方都同意的签名密钥
+		//the signed key agreed by both
+		StringBuilder stringSignTemp = String1.append(SecretKey);
+		// Add the signature key agreed by both parties
+		String result = stringSignTemp.toString();
+		//SHA256 encryption to get the signature
+		String signature = SHA256Util.getSHA256(result);
+		return signature;
+	}
+
+	public static boolean vertify(HttpServletRequest request, String SecretKey) {
+
+		//将需要验签的参数转化成map集合形式开始验签
+		//String json = JSON.toJSONString(object);
+		//漏洞检查完之后再改回来
+		//Map map=JSON.parseObject(json,new TypeReference<TreeMap<String, String>>(){} , Feature.OrderedField);
+		Map map = converRequest(request);
+		logger.info("request param:" + map);
+		Object sign = map.get("signature");
+		if (sign == null) {
+			returnResult("signature is not exist");
+			return false;
+		}
+		map.remove("signature");
+		List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(map.entrySet());
+		// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
+		// sort all incoming parameters by ASCII code of field name from small to large (dictionary order)
+		Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
+			@Override
+			public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
+				return (o1.getKey()).toString().compareTo(o2.getKey());
+			}
+		});
+		// 构造签名键值对的格式
+		//Construct a format for signing key-value pairs
+		StringBuilder String1 = new StringBuilder();
+		for (Map.Entry<String, String> item : infoIds) {
+			if (item.getKey() != null && !"".equals(item.getKey()) && item.getValue() != null) {
+				String key = item.getKey();
+				Object val = item.getValue();
+				if (val != null) {
+					String1.append(key + "=" + val + "&");
+				}
+			}
+
+		}
+		if (StringUtils.isNotBlank(String1.toString())) {
+			String1.deleteCharAt(String1.length() - 1);
+		}
+		//添加双方都同意的签名密钥
+		//the signed key agreed by both
+		StringBuilder stringSignTemp = String1.append(SecretKey);
+		// Add the signature key agreed by both parties
+		String result = stringSignTemp.toString();
+		logger.info("signature parameter: " + result);
+		//SHA256 encryption to get the signature
+		String signature = SHA256Util.getSHA256(result);
+		logger.info("right signature:" + signature);
+		if (!sign.equals(signature)) {
+			returnResult("signature is error");
+			return false;
+		}
+			return true;
+	}
+
+	private static void returnResult(String message) {
+		HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
+		response.setCharacterEncoding("UTF-8");
+		response.setContentType("application/json; charset=utf-8");
+		try (PrintWriter out = response.getWriter()) {
+			ResultVO result = new ResultVO();
+			result.setStatus(ResultVO.FAIL);
+			result.setMessage(message);
+			String jsonString = JSON.toJSONString(result);
+			out.append(jsonString);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	public static Map converRequest(HttpServletRequest request){
+		Map properties = request.getParameterMap();
+		Map returnMap = new HashMap();
+		Iterator entries = properties.entrySet().iterator();
+		Map.Entry entry;
+		String name = "";
+		String value = "";
+		while (entries.hasNext()) {
+			entry = (Map.Entry) entries.next();
+			name = (String) entry.getKey();
+			Object valueObj = entry.getValue();
+			if(null == valueObj){
+				value = "";
+			}else if(valueObj instanceof String[]){
+				String[] values = (String[])valueObj;
+				for(int i=0;i<values.length;i++){
+					value = values[i] + ",";
+				}
+				value = value.substring(0, value.length()-1);
+			}else{
+				value = valueObj.toString();
+			}
+			returnMap.put(name, value);
+		}
+		return returnMap;
+	}
+}

+ 20 - 0
Charge/src/main/java/com/allpay/charge/tools/StringTools.java

@@ -0,0 +1,20 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.tools;
+
+/**
+ *
+ * @author Brian
+ */
+public class StringTools {
+    public static String toSplit(String split,Object ... args){
+        String v="";
+        for(Object s:args){
+            v += s + split;
+        }
+        return v;
+    }
+}

+ 18 - 0
Charge/src/main/java/com/allpay/charge/tools/ThreadLocalUtil.java

@@ -0,0 +1,18 @@
+package com.allpay.charge.tools;
+
+/**
+ * @Description :
+ * @Author : Simon.shi
+ * @Date : 2019/8/30 15:22
+ * @Version : V0.0.1
+ */
+public class ThreadLocalUtil {
+
+    public static ThreadLocal<String> operatorId = new ThreadLocal<>();
+
+    public static String getOperatorId() {
+        String operatorCode = operatorId.get();
+        operatorId.remove();
+        return operatorCode;
+    }
+}

+ 28 - 0
Charge/src/main/java/com/allpay/charge/tools/ThrowableUtil.java

@@ -0,0 +1,28 @@
+package com.allpay.charge.tools;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * 异常工具
+ * @author Zheng Jie
+ * @date 2019-01-06
+ */
+public class ThrowableUtil {
+
+    /**
+     * 获取堆栈信息
+     * @param throwable
+     * @return
+     */
+    public static String getStackTrace(Throwable throwable){
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        try {
+            throwable.printStackTrace(pw);
+            return sw.toString();
+        } finally {
+            pw.close();
+        }
+    }
+}

+ 36 - 0
Charge/src/main/java/com/allpay/charge/tools/TimeConsuming.java

@@ -0,0 +1,36 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.allpay.charge.tools;
+
+/**
+ *
+ * @author Brian
+ */
+public class TimeConsuming {
+    long tm = System.currentTimeMillis();
+    public void print(){
+        long l= System.currentTimeMillis() ;
+        System.out.printf("time-consuming:%d ms\n",l - tm );
+        tm = l ;        
+    }
+
+    public String getPrint(){
+        String v;
+        long l= System.currentTimeMillis() ;
+        v = "time-consuming: " + (l - tm) + " ms" ;
+        tm = l ; 
+        return v;
+    }
+    
+    public void print(String s){
+        System.out.printf("%s - ",s);
+        print();
+    }
+    
+    public String getPrint(String s){
+        return s + ":" + getPrint();
+    }
+}

+ 37 - 0
Charge/src/main/java/com/allpay/charge/tools/pageUtil.java

@@ -0,0 +1,37 @@
+package com.allpay.charge.tools;
+
+import com.allpay.charge.db.entity.Page;
+
+import java.util.List;
+
+public class pageUtil {
+
+    public static Page getPage(Integer pagNum, Integer pageSize, List<?> showdata){
+
+        //刚开始的页面为第一页
+        Page page = new Page();
+        page.setCurrentPage(pagNum);
+
+        //设置每页数据为十条
+        page.setPageSize(pageSize);
+
+        //每页的开始数
+
+        page.setStar((page.getCurrentPage() - 1) * page.getPageSize());
+
+        //list的大小
+
+        int count = showdata.size();
+        page.setListSize(count);
+
+        //设置总页数
+
+        page.setTotalPage(count % 10 == 0 ? count / 10 : count / 10 + 1);
+
+        //对list进行截取
+
+        page.setDataList(showdata.subList(page.getStar(),count-page.getStar()>page.getPageSize()?page.getStar()+page.getPageSize():count));
+        return page;
+    }
+
+}

+ 44 - 0
Charge/src/main/resources/META-INF/persistence.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+  <!--本地-->
+  <persistence-unit name="com.allpay_charge_jar_0.0.1-local" transaction-type="RESOURCE_LOCAL">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <class>com.allpay.charge.db.entity.SaChargeDiscCd</class>
+    <class>com.allpay.charge.db.entity.SaChargeDiscAlgo</class>
+    <properties>
+      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://192.168.50.54:3306/ddb?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false&amp;autoReconnect=true&amp;serverTimezone=UTC"/>
+      <property name="javax.persistence.jdbc.user" value="root"/>
+      <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
+      <property name="javax.persistence.jdbc.password" value="123456"/>
+      <property name="eclipselink.cache.shared.default" value="false"/>
+    </properties>
+  </persistence-unit>
+  <!--测试-->
+  <persistence-unit name="com.allpay_charge_jar_0.0.1-test" transaction-type="RESOURCE_LOCAL">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <class>com.allpay.charge.db.entity.SaChargeDiscCd</class>
+    <class>com.allpay.charge.db.entity.SaChargeDiscAlgo</class>
+    <properties>
+      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://172.16.2.14:3306/ddb?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false&amp;autoReconnect=true&amp;serverTimezone=UTC"/>
+      <property name="javax.persistence.jdbc.user" value="root"/>
+      <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
+      <property name="javax.persistence.jdbc.password" value="Allpay123!"/>
+      <property name="eclipselink.cache.shared.default" value="false"/>
+    </properties>
+  </persistence-unit>
+  <!--生产-->
+  <persistence-unit name="com.allpay_charge_jar_0.0.1-pro" transaction-type="RESOURCE_LOCAL">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <class>com.allpay.charge.db.entity.SaChargeDiscCd</class>
+    <class>com.allpay.charge.db.entity.SaChargeDiscAlgo</class>
+    <properties>
+      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://172.16.80.11:3305/ddb?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false&amp;autoReconnect=true&amp;serverTimezone=UTC"/>
+      <property name="javax.persistence.jdbc.user" value="root"/>
+      <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
+      <property name="javax.persistence.jdbc.password" value="Allpay123$%^"/>
+      <property name="eclipselink.cache.shared.default" value="false"/>
+    </properties>
+  </persistence-unit>
+</persistence>
+
+

+ 7 - 0
Charge/src/main/resources/application-local.yml

@@ -0,0 +1,7 @@
+server:
+  port: 9000
+commonMessage:
+  ossUrl: http://192.168.50.62:9004
+  verifyFunctionUrl: http://192.168.50.62:9004/server/verify_function
+  userInfo: http://192.168.50.62:9004/server/user/get_user_info
+  emfName: com.allpay_charge_jar_0.0.1-local

+ 7 - 0
Charge/src/main/resources/application-test.yml

@@ -0,0 +1,7 @@
+server:
+  port: 9000
+commonMessage:
+  ossUrl: http://172.16.2.14:9004
+  verifyFunctionUrl: http://172.16.2.14:9004/server/verify_function
+  userInfo: http://172.16.2.14:9004/server/user/get_user_info
+  EMF_NAME: com.allpay_charge_jar_0.0.1-test

+ 6 - 0
Charge/src/main/resources/application.yml

@@ -0,0 +1,6 @@
+spring:
+  profiles:
+    active: local
+  http:
+    encoding:
+      force-response: true

+ 19 - 0
Charge/src/main/resources/log4j.properties

@@ -0,0 +1,19 @@
+log4j.rootLogger=DEBUG, CA ,RFA
+#DEBUG\u8868\u793a\u65e5\u5fd7\u8f93\u51fa\u7ea7\u522b\uff0cDEBUG\uff0cINFO\uff0cWARN\uff0cERROR\uff0cFATAL\uff0cCA,RFA\u81ea\u5b9a\u4e49\u7684\u6587\u4ef6\u8f93\u51fa\u4f4d\u7f6e\u4ee5\u53ca\u8bbe\u7f6e
+
+#\u5b9a\u4e49CA\u7684\u8f93\u51fa\u76ee\u7684\u5730\u4e3a\u63a7\u5236\u53f0
+log4j.appender.CA=org.apache.log4j.ConsoleAppender
+#\u5e03\u5c40\u4e3a PatternLayout \u53ef\u4ee5\u7075\u6d3b\u5730\u6307\u5b9a\u5e03\u5c40\u6a21\u5f0f\u3002
+log4j.appender.CA.layout=org.apache.log4j.PatternLayout
+#\u8bbe\u7f6e\u8f93\u51fa\u683c\u5f0f
+log4j.appender.CA.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] %m%n
+#\u5b9a\u4e49R\u7684\u8f93\u51fa\u76ee\u7684\u5730\u4e3a\u6587\u4ef6\uff0c\u5e76\u4e14\u6587\u4ef6\u5927\u5c0f\u5230\u8fbe\u6307\u5b9a\u5c3a\u5bf8\u7684\u65f6\u5019\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6
+log4j.appender.RFA=org.apache.log4j.RollingFileAppender
+#\u8bbe\u7f6e\u8f93\u51fa\u7684\u6587\u4ef6\u5730\u5740
+log4j.appender.RFA.File=D:\\Test_Log4j.log
+#\u8bbe\u7f6e\u6587\u4ef6\u5927\u5c0f\u4f1f100 kb \u6587\u4ef6\u5230\u8fbe100\u65f6\uff0c\u4ea7\u751f\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0c
+#MaxBackupIndex \u6700\u5927\u8bb0\u5f55\u7684\u6587\u4ef6\u6570\u4e3a1 \u67e5\u8fc7\u4e00\u4e2a\u6587\u4ef6\u5220\u9664\u6587\u4ef6\u8f83\u65e9\u7684\u3002
+log4j.appender.RFA.MaxFileSize=100KB log4j.appender.RFA.MaxBackupIndex=1
+#\u4ee5\u4e0b\u548c\u4e0a\u9762\u4e00\u6837
+log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
+log4j.appender.RFA.layout.ConversionPattern=%p %t %c - %m%n

+ 13 - 0
Charge/src/test/java/com/allpay/charge/ChargeApplicationTests.java

@@ -0,0 +1,13 @@
+package com.allpay.charge;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ChargeApplicationTests {
+
+	@Test
+	void contextLoads() {
+	}
+
+}

+ 0 - 0
README.md