diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..e3afd6f
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..572c742
--- /dev/null
+++ b/.project
@@ -0,0 +1,46 @@
+
+
+ pay
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator
+
+
+
+
+ com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope
new file mode 100644
index 0000000..2fc9dba
--- /dev/null
+++ b/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/com.genuitec.eclipse.core.prefs b/.settings/com.genuitec.eclipse.core.prefs
new file mode 100644
index 0000000..3057485
--- /dev/null
+++ b/.settings/com.genuitec.eclipse.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+validator.Checked=WebRoot/js,WebRoot/index.html
+validator.Unchecked=
diff --git a/.settings/com.genuitec.eclipse.j2eedt.core.prefs b/.settings/com.genuitec.eclipse.j2eedt.core.prefs
new file mode 100644
index 0000000..7132d6d
--- /dev/null
+++ b/.settings/com.genuitec.eclipse.j2eedt.core.prefs
@@ -0,0 +1,2 @@
+defaultTldInfo=f\=http\://java.sun.com/jsf/core;http\://java.sun.com/jsf/html\=h;http\://struts.apache.org/tags-bean\=bean;http\://java.sun.com/jsp/jstl/fmt\=fmt;bean\=http\://struts.apache.org/tags-bean;nested\=http\://struts.apache.org/tags-nested;http\://java.sun.com/jsp/jstl/sql\=sql;c\=http\://java.sun.com/jsp/jstl/core;fmt\=http\://java.sun.com/jsp/jstl/fmt;http\://struts.apache.org/tags-logic\=logic;http\://java.sun.com/jsp/jstl/xml\=x;http\://java.sun.com/jsp/jstl/core\=c;logic\=http\://struts.apache.org/tags-logic;h\=http\://java.sun.com/jsf/html;http\://struts.apache.org/tags-tiles\=tiles;http\://java.sun.com/jsp/jstl/functions\=fn;tiles\=http\://struts.apache.org/tags-tiles;sql\=http\://java.sun.com/jsp/jstl/sql;http\://struts.apache.org/tags-html\=html;html\=http\://struts.apache.org/tags-html;http\://struts.apache.org/tags-nested\=nested;http\://java.sun.com/jsf/core\=f;fn\=http\://java.sun.com/jsp/jstl/functions;x\=http\://java.sun.com/jsp/jstl/xml
+eclipse.preferences.version=1
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..e97d718
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..8938ee1
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/WebRoot/META-INF/MANIFEST.MF b/WebRoot/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/WebRoot/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/WebRoot/WEB-INF/classes/applicationContext.xml b/WebRoot/WEB-INF/classes/applicationContext.xml
new file mode 100644
index 0000000..b102b73
--- /dev/null
+++ b/WebRoot/WEB-INF/classes/applicationContext.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/WebRoot/WEB-INF/classes/config.properties b/WebRoot/WEB-INF/classes/config.properties
new file mode 100644
index 0000000..20c0243
--- /dev/null
+++ b/WebRoot/WEB-INF/classes/config.properties
@@ -0,0 +1,2 @@
+a=b
+c=d
diff --git a/WebRoot/WEB-INF/classes/springmvc-servlet.xml b/WebRoot/WEB-INF/classes/springmvc-servlet.xml
new file mode 100644
index 0000000..679c0be
--- /dev/null
+++ b/WebRoot/WEB-INF/classes/springmvc-servlet.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WebRoot/WEB-INF/web.xml b/WebRoot/WEB-INF/web.xml
new file mode 100644
index 0000000..3339d15
--- /dev/null
+++ b/WebRoot/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+
+
+ pay
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+ contextConfigLocation
+ classpath:applicationContext.xml
+
+
+ springmvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ contextConfigLocation
+ classpath:springmvc-servlet.xml
+
+
+
+ /index.html
+ /index.jsp
+
+
+ springmvc
+ /
+
+
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+ encodingFilter
+ /*
+
+
\ No newline at end of file
diff --git a/WebRoot/index.html b/WebRoot/index.html
new file mode 100644
index 0000000..9a22d55
--- /dev/null
+++ b/WebRoot/index.html
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+ 顺诚百宝箱
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/applicationContext.xml b/src/applicationContext.xml
new file mode 100644
index 0000000..b102b73
--- /dev/null
+++ b/src/applicationContext.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/src/config.properties b/src/config.properties
new file mode 100644
index 0000000..20c0243
--- /dev/null
+++ b/src/config.properties
@@ -0,0 +1,2 @@
+a=b
+c=d
diff --git a/src/sc545/pay/interceptor/testInterceptor.java b/src/sc545/pay/interceptor/testInterceptor.java
new file mode 100644
index 0000000..4d77c25
--- /dev/null
+++ b/src/sc545/pay/interceptor/testInterceptor.java
@@ -0,0 +1,82 @@
+package sc545.pay.interceptor;
+
+
+
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.*;
+
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import sc545.pay.utils.DBUtil;
+import sc545.pay.utils.ReadTxt;
+import sc545.pay.utils.Utils;
+
+
+
+
+public class testInterceptor implements HandlerInterceptor{
+
+ @Override
+ public boolean preHandle(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Object handler) throws Exception {
+
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ request.setCharacterEncoding("utf-8");
+
+ /*************************************拉黑高频访问ip******************************************/
+ if(!"".equals(ReadTxt.getSetting(null, "拉黑ip.txt", Utils.getIpAddr(request), ""))){
+ PrintWriter out = response.getWriter();
+ out.print("系统检测到高频次访问已被拉黑IP
若误封请前往微信公众号【顺诚百宝箱】反馈
感谢理解!
IP:"+Utils.getIpAddr(request));
+ return false;
+ }
+ String ipdate = ReadTxt.getSetting(null, "访问者IP.txt", Utils.getIpAddr(request), "");//获取此ip上次访问时间和已经访问的次数
+ String[] idt = ipdate.split("_");//分隔
+ long i=0;//已经访问的次数
+ if(!"".equals(ipdate)){
+ if(ipdate.indexOf("_")>0) i=Utils.getNum(idt[1]);
+ //检查此ip第一次访问到现在过了几秒
+ Date ds = Utils.string2Date(idt[0], null);
+ long xc = (new Date().getTime() - ds.getTime())/1000;
+ if(xc<=30){//30秒超过50次
+ if(i>50){//拉黑此ip3天
+ ReadTxt.writeSetting(null,"拉黑ip.txt", Utils.getIpAddr(request), Utils.date2String(new Date(), null));
+ ReadTxt.delSetting(null, "访问者IP.txt", Utils.getIpAddr(request));
+ }else{//正常ip
+ }
+ }else{//正常ip
+ ReadTxt.delSetting(null, "访问者IP.txt", Utils.getIpAddr(request));
+ }
+ ReadTxt.writeSetting(null,"访问者IP.txt", Utils.getIpAddr(request), idt[0]+"_"+(++i));
+ }else
+ ReadTxt.writeSetting(null,"访问者IP.txt", Utils.getIpAddr(request), Utils.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")+"_1");
+ /*******************************************************************************/
+
+
+
+
+
+ DBUtil db = new DBUtil();
+
+ //闭站
+ String cw = ReadTxt.getSetting(null, "setting.ini", "closeweb", "0");
+ if("1".equals(cw)) {
+ String uri = request.getRequestURI();
+ if(uri.indexOf("/admin")<0){
+ Utils.outHtml(response.getWriter(), ReadTxt.getSetting(null, "setting.ini", "closewebtxt", "本站暂停访问"), "/*about:blank*/");
+ return false;
+ }
+ }
+
+
+
+ return true;
+ }
+
+}
diff --git a/src/sc545/pay/main/MainController.java b/src/sc545/pay/main/MainController.java
new file mode 100644
index 0000000..ef5598f
--- /dev/null
+++ b/src/sc545/pay/main/MainController.java
@@ -0,0 +1,140 @@
+package sc545.pay.main;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+
+
+import sc545.pay.utils.DBUtil;
+import sc545.pay.utils.GsonUtils;
+import sc545.pay.utils.Utils;
+
+
+
+
+@CrossOrigin(origins = "*", maxAge = 3600)
+@RestController
+public class MainController {
+
+
+ /**
+ * 获取付款码
+ * @param param
+ * @param request
+ * @param response
+ * @return
+ */
+ @RequestMapping(value = "/createOrder", produces = "text/html;charset=UTF-8")
+ public String createOrder(
+ @RequestParam(required = false, defaultValue = "") String n,
+ @RequestParam(required = false, defaultValue = "") String t,
+ HttpServletRequest request,
+ HttpServletResponse response
+ ) {
+
+ double num = Utils.getNumDouble(n);
+ if(num<0.01||num>2000) return "{\"errcode\":\"-1\",\"msg\":\"0<金额<2000\"}";
+ core core=new core();
+ HashMap order = core.createOrder(num, t);
+
+ return GsonUtils.ObjectToJson(order);
+ }
+
+
+ /**
+ * 查询订单
+ * @param id
+ * @param request
+ * @param response
+ * @return
+ */
+ @RequestMapping(value = "/queryOrder", produces = "text/html;charset=UTF-8")
+ public String queryOrder(
+ @RequestParam(required = false, defaultValue = "") String id,
+ HttpServletRequest request,
+ HttpServletResponse response
+ ) {
+
+
+ core core=new core();
+ Map order = core.queryOrder(id);
+
+ return GsonUtils.ObjectToJson(order);
+ }
+
+ /**
+ * 查询支付是否已完成
+ * @param id
+ * @param request
+ * @param response
+ * @return
+ */
+ @RequestMapping(value = "/queryPay", produces = "text/html;charset=UTF-8")
+ public String queryPay(
+ @RequestParam(required = false, defaultValue = "") String id,
+ HttpServletRequest request,
+ HttpServletResponse response
+ ) {
+
+
+ core core=new core();
+ Map order = core.queryOrder(id);
+
+ if(order!=null){
+ if("3".equals(order.get("ostatus")+"")||"4".equals(order.get("ostatus")+"")) return "{\"msg\":\"已支付\"}";
+ else return "{\"msg\":\"未支付\"}";
+ }else{
+ return "{\"msg\":\"未支付\"}";
+ }
+ }
+
+ /**
+ * 支付宝通知回调
+ * 设置中的“应用网关”
+ * @param param
+ * @param request
+ * @param response
+ */
+ @RequestMapping(value = "/alinotify", produces = "text/html;charset=UTF-8")
+ public void alinotify(
+ @RequestParam(required = false, defaultValue = "") Map param,
+ HttpServletRequest request,
+ HttpServletResponse response
+ ) {
+
+ DBUtil db = new DBUtil();
+ core core=new core();
+
+ //只有支付成功后,支付宝才会回调应用接口,可直接获取支付宝响应的参数
+ String order_id = param.get("out_trade_no");
+ int s =0;
+ String ss = param.get("trade_status");
+ if("WAIT_BUYER_PAY".equals(ss)) s=1;
+ else if("TRADE_CLOSED".equals(ss)) s=2;
+ else if("TRADE_SUCCESS".equals(ss)) s=3;
+ else if("TRADE_FINISHED".equals(ss)) s=4;
+
+ //检查数据库是否有本数据,有就修改,没有新增
+ int i = db.execSql("select * from _orders where out_trade_no = ?", new String[]{order_id});
+ if(i>0) core.updateOrder(order_id);
+ else{
+ db.execUpdate("insert into _orders(out_trade_no,trade_no,otitle,onum,ostatus,zfbuser,paynum,getnum,zfbuserid,getbody) "
+ + "values("+order_id+",?,?,"+param.get("total_amount")+","+s+",?,"+param.get("buyer_pay_amount")+","+param.get("receipt_amount")+",?,?)", new String[]{param.get("trade_no"),param.get("subject"),param.get("buyer_logon_id"),param.get("buyer_id"),param.toString()});
+
+ }
+
+
+
+
+ }
+
+
+}
diff --git a/src/sc545/pay/main/core.java b/src/sc545/pay/main/core.java
new file mode 100644
index 0000000..a66657c
--- /dev/null
+++ b/src/sc545/pay/main/core.java
@@ -0,0 +1,161 @@
+package sc545.pay.main;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import sc545.pay.utils.DBUtil;
+import sc545.pay.utils.ImgUtils;
+import sc545.pay.utils.ReadTxt;
+import sc545.pay.utils.Utils;
+
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.domain.AlipayTradePrecreateModel;
+import com.alipay.api.domain.AlipayTradeQueryModel;
+import com.alipay.api.request.AlipayTradePrecreateRequest;
+import com.alipay.api.request.AlipayTradeQueryRequest;
+import com.alipay.api.response.AlipayTradePrecreateResponse;
+import com.alipay.api.response.AlipayTradeQueryResponse;
+
+public class core {
+ AlipayClient client = null;
+ /**支付宝回调的接口地址*/
+ private static String aliNotifyUrl = ReadTxt.getSetting(null, "setting.ini", "web", "localhost")+"/pay/alinotify";
+
+ public core() {
+ getConfig();
+ }
+
+ public static void main(String[] args) {
+
+ //每天定时清空无订单和超时关闭的数据库数据
+ core c=new core();
+ c.queryOrder("1655263616880");
+ c.updateOrder("1655272489467");
+
+ }
+
+ /**
+ * 创建付款订单
+ */
+ public HashMap createOrder(double num,String title){
+ if(num<=0) return null;
+ HashMap rs = new HashMap<>();
+ AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
+
+ String h=new Date().getTime()+Utils.randomNum(10, 99)+"";
+
+ AlipayTradePrecreateModel model = new AlipayTradePrecreateModel();
+ model.setOutTradeNo(h);//订单号(保证不重复)
+ model.setTotalAmount(num+"");//订单金额
+ model.setSubject(title);//标题(关键字)不可用特殊标点
+ model.setQrCodeTimeoutExpress("10m");
+ request.setBizModel(model);
+ request.setNotifyUrl(aliNotifyUrl);//应用网关(异步通知)
+
+ AlipayTradePrecreateResponse response = null;
+ try {
+ response = client.execute(request);
+ } catch (AlipayApiException e) {e.printStackTrace();}
+
+ if(response.isSuccess()){
+
+ //订单存入数据库
+ DBUtil db = new DBUtil();
+ int i = db.execUpdate("insert into _orders(out_trade_no,otitle,onum,qrcode) values("+ response.getOutTradeNo()+",?,"+num+",?)", new String[]{title,response.getQrCode()});
+ if(i==1){
+ rs.put("code", "1");
+ rs.put("qrcode", response.getQrCode());
+ rs.put("qrimg", ImgUtils.QrImgB64(response.getQrCode(), 300));
+ rs.put("out_trade_no", response.getOutTradeNo());
+ }else rs.put("errcode", "-1");
+ } else {
+ rs.put("errcode", "-1");
+ }
+
+ return rs;
+
+ }
+
+ /**查询订单状态*/
+ public Map queryOrder(String orderId){
+ if(orderId==null||orderId.trim().length()<1) return null;
+ DBUtil db = new DBUtil();
+ //查数据库
+ //先检查数据库是否有这个数据,若查不到或者等待付款,就去更新订单状态,交易成功和交易结束直接返回,订单关闭就把数据库数据删除
+ List