From 363c0f2d5ac2cec13e28bcba4f46f272dff448dc Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 28 Jul 2022 16:55:55 +0800
Subject: [PATCH] 20220727  保存代码

---
 src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java    |   15 
 src/main/resources/mapper/modules/MallTeamLeaderMapper.xml                         |    2 
 src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java                       |    3 
 src/main/java/cc/mrbird/febs/pay/util/HttpsRequest.java                            |  186 ++++++++++++++
 src/main/resources/mapper/modules/MallMemberMapper.xml                             |    2 
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java |   17 +
 src/main/java/cc/mrbird/febs/pay/util/HttpsRequest2.java                           |  213 ++++++++++++++++
 src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java         |    2 
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java   |    8 
 src/main/java/cc/mrbird/febs/pay/util/HttpResponse.java                            |   58 ++++
 src/main/resources/templates/febs/views/modules/leader/leaderList.html             |   18 +
 src/main/java/cc/mrbird/febs/pay/util/HttpRequest.java                             |  196 +++++++++++++++
 src/main/java/cc/mrbird/febs/pay/util/WechatConfigure.java                         |   24 +
 13 files changed, 726 insertions(+), 18 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java
index f1135fc..1eeebc2 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java
@@ -12,12 +12,10 @@
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
 import java.util.List;
 import java.util.Map;
 
@@ -57,4 +55,13 @@
         return iAdminMallTeamLeaderService.selectList(mallTeamLeader);
     }
 
+    /**
+     * 团长信息--取消团长
+     */
+    @GetMapping("leaderCancel/{id}")
+    @ControllerEndpoint(operation = "团长信息--取消团长", exceptionMessage = "取消团长失败")
+    public FebsResponse leaderCancel(@NotNull(message = "{required}") @PathVariable Long id) {
+        return iAdminMallTeamLeaderService.leaderCancel(id);
+    }
+
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java b/src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java
index a91d2aa..0d3f0bf 100644
--- a/src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java
+++ b/src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java
@@ -15,11 +15,12 @@
 
     //用户ID
     private Long memberId;
-    //申请状态 1:审核通过 2:审核不通过 3:申请中
+    //申请状态 1:审核通过 2:审核不通过 3:申请中 4:已取消
     private Integer state;
     public static final Integer STATE_YES = 1;
     public static final Integer STATE_NO = 2;
     public static final Integer STATE_ING = 3;
+    public static final Integer STATE_CANCEL = 4;
     //团长姓名
     private String name;
     //手机号码
diff --git a/src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java b/src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java
index b4ac3bf..fcf3239 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java
@@ -20,4 +20,6 @@
     FebsResponse leaderUpdate(AdminLeaderUpdateDto adminLeaderUpdateDto);
 
     List<AdminSelectListLeaderVo> selectList(MallTeamLeader mallTeamLeader);
+
+    FebsResponse leaderCancel(Long id);
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java
index fbc4bed..31e930d 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java
@@ -12,6 +12,7 @@
 import cc.mrbird.febs.mall.vo.AdminMallTeamLeaderVo;
 import cc.mrbird.febs.mall.vo.AdminSelectListLeaderVo;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -76,4 +77,20 @@
         }
         return list;
     }
+
+    @Override
+    public FebsResponse leaderCancel(Long id) {
+        MallTeamLeader mallTeamLeader = this.baseMapper.selectById(id);
+        if(ObjectUtil.isEmpty(mallTeamLeader)){
+            return new FebsResponse().fail().message("团长信息不存在");
+        }
+        Integer state = mallTeamLeader.getState();
+        if(MallTeamLeader.STATE_YES != state){
+            return new FebsResponse().fail().message("团长的状态不是审核通过");
+        }
+        mallTeamLeader.setState(MallTeamLeader.STATE_CANCEL);
+        this.baseMapper.updateById(mallTeamLeader);
+        return new FebsResponse().success().message("已取消");
+    }
+
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java
index 0b5f278..6043076 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java
@@ -45,6 +45,10 @@
         if(CollUtil.isNotEmpty(mallTeamLeaders)){
             return new FebsResponse().fail().message("正在申请中");
         }
+        List<MallTeamLeader> mallTeamLeaderCancel = this.baseMapper.selectListByMemberIdAndState(memberId, MallTeamLeader.STATE_CANCEL);
+        if(CollUtil.isNotEmpty(mallTeamLeaderCancel)){
+            return new FebsResponse().fail().message("当前用户无法申请");
+        }
         MallTeamLeader mallTeamLeader = MallTeamLeaderConversion.INSTANCE.dtoToEntity(apiApplayLeaderDto);
         mallTeamLeader.setMemberId(memberId);
         mallTeamLeader.setState(MallTeamLeader.STATE_ING);
@@ -68,10 +72,13 @@
         List<MallTeamLeader> mallTeamLeadersIng = this.baseMapper.selectListByMemberIdAndState(memberId, MallTeamLeader.STATE_ING);
         List<MallTeamLeader> mallTeamLeadersNo = this.baseMapper.selectListByMemberIdAndState(memberId, MallTeamLeader.STATE_NO);
         List<MallTeamLeader> mallTeamLeadersYes = this.baseMapper.selectListByMemberIdAndState(memberId, MallTeamLeader.STATE_YES);
+        List<MallTeamLeader> mallTeamLeadersCancel = this.baseMapper.selectListByMemberIdAndState(memberId, MallTeamLeader.STATE_CANCEL);
         if(CollUtil.isNotEmpty(mallTeamLeadersIng) ||CollUtil.isNotEmpty(mallTeamLeadersYes)){
             apiMallleaderStateVo.setState(2);
         }else if(CollUtil.isNotEmpty(mallTeamLeadersNo)){
             apiMallleaderStateVo.setState(1);
+        }else if(CollUtil.isNotEmpty(mallTeamLeadersCancel)){
+            apiMallleaderStateVo.setState(2);
         }else{
             apiMallleaderStateVo.setState(1);
         }
@@ -82,6 +89,7 @@
     public FebsResponse getApiLeaderInfoVoById(Long id) {
         MallTeamLeader mallTeamLeader = this.baseMapper.selectById(id);
         ApiLeaderInfoVo apiLeaderInfoVo = new ApiLeaderInfoVo();
+        apiLeaderInfoVo.setId(mallTeamLeader.getId());
         apiLeaderInfoVo.setName(mallTeamLeader.getName());
         apiLeaderInfoVo.setPhone(mallTeamLeader.getPhone());
         apiLeaderInfoVo.setAddressPic(mallTeamLeader.getAddressPic());
diff --git a/src/main/java/cc/mrbird/febs/pay/util/HttpRequest.java b/src/main/java/cc/mrbird/febs/pay/util/HttpRequest.java
new file mode 100644
index 0000000..0446ba2
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/pay/util/HttpRequest.java
@@ -0,0 +1,196 @@
+package cc.mrbird.febs.pay.util;
+
+import javax.net.ssl.HttpsURLConnection;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Map;
+
+public class HttpRequest {
+	public static final String SEND_POST = "POST";
+	public static final String SEND_GET = "GET";
+	private HttpRequest() {
+	}
+
+	public static HttpRequest createHttpRequest() {
+		return new HttpRequest();
+	}
+
+	public HttpResponse sendHttpGet(String urlString, Map<String, String> params) throws IOException {
+
+		if (params != null) {
+			StringBuffer param = new StringBuffer();
+			int i = 0;
+			for (String key : params.keySet()) {
+				if (i == 0)
+					param.append("?");
+				else
+					param.append("&");
+				param.append(key).append("=").append((String) params.get(key));
+				i++;
+			}
+			urlString = urlString + param;
+		}
+		URL url = new URL(urlString);
+		HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
+		urlConnection.setRequestMethod("GET");
+		urlConnection.setDoOutput(true);
+		urlConnection.setDoInput(true);
+		urlConnection.setUseCaches(false);
+
+		HttpResponse response = new HttpResponse();
+		response.setInputStream(urlConnection.getInputStream());
+		response.setContentType(urlConnection.getContentType());
+		response.setContentLength(urlConnection.getContentLength());
+
+		response.setFileName(urlConnection.getRequestProperty("filename"));
+		return response;
+	}
+
+	public HttpResponse sendHttpPost(String urlString, Map<String, String> params, String filePath, String contentType)
+			throws IOException {
+		if (params != null) {
+			StringBuffer param = new StringBuffer();
+			int i = 0;
+			for (String key : params.keySet()) {
+				if (i == 0)
+					param.append("?");
+				else
+					param.append("&");
+				param.append(key).append("=").append((String) params.get(key));
+				i++;
+			}
+			urlString = urlString + param;
+		}
+
+		URL url = new URL(urlString);
+		HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
+
+		urlConnection.setRequestMethod("POST");
+		urlConnection.setDoOutput(true);
+		urlConnection.setDoInput(true);
+		urlConnection.setUseCaches(false);
+
+		File file = new File(filePath);
+
+		urlConnection.setRequestProperty("Connection", "Keep-Alive");
+		urlConnection.setRequestProperty("Charset", "UTF-8");
+
+		String BOUNDARY = "----------" + System.currentTimeMillis();
+		urlConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
+
+		StringBuilder sb = new StringBuilder();
+		sb.append("--");
+		sb.append(BOUNDARY);
+		sb.append("\r\n");
+		sb.append("Content-Disposition: form-data;name=\"file\";filename=\"" + file.getName() + "\"\r\n");
+		sb.append("Content-Type:application/octet-stream\r\n\r\n");
+
+		byte[] head = sb.toString().getBytes("utf-8");
+
+		OutputStream out1 = new DataOutputStream(urlConnection.getOutputStream());
+
+		out1.write(head);
+
+		DataInputStream in1 = new DataInputStream(new FileInputStream(file));
+		int bytes = 0;
+		byte[] bufferOut = new byte[1024];
+		while ((bytes = in1.read(bufferOut)) != -1) {
+			out1.write(bufferOut, 0, bytes);
+		}
+		in1.close();
+
+		byte[] foot = ("\r\n--" + BOUNDARY + "--\r\n").getBytes("utf-8");
+
+		out1.write(foot);
+
+		out1.flush();
+		out1.close();
+
+		FileInputStream in = new FileInputStream(file);
+
+		OutputStream out = urlConnection.getOutputStream();
+		byte[] buf = new byte[1024];
+		int hasRead = 0;
+		while ((hasRead = in.read(buf)) > 0) {
+			out.write(buf, 0, hasRead);
+		}
+		in.close();
+		out.flush();
+		out.close();
+
+		HttpResponse response = new HttpResponse();
+		response.setInputStream(urlConnection.getInputStream());
+
+		return response;
+	}
+
+	public HttpResponse sendHttpsGet(String urlString, Map<String, String> params) throws IOException {
+		if (params != null) {
+			StringBuffer param = new StringBuffer();
+			int i = 0;
+			for (String key : params.keySet()) {
+				if (i == 0)
+					param.append("?");
+				else
+					param.append("&");
+				param.append(key).append("=").append((String) params.get(key));
+				i++;
+			}
+			urlString = urlString + param;
+		}
+
+		URL url = new URL(urlString);
+		HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
+
+		urlConnection.setRequestMethod("GET");
+		urlConnection.setDoOutput(true);
+		urlConnection.setDoInput(true);
+		urlConnection.setUseCaches(false);
+
+		HttpResponse response = new HttpResponse();
+		response.setInputStream(urlConnection.getInputStream());
+		response.setContentType(urlConnection.getContentType());
+		response.setContentLength(urlConnection.getContentLength());
+
+		return response;
+	}
+
+	public HttpResponse sendHttpsPost(String urlString, Map<String, String> params, String sendData)
+			throws IOException {
+		if (params != null) {
+			StringBuffer param = new StringBuffer();
+			int i = 0;
+			for (String key : params.keySet()) {
+				if (i == 0)
+					param.append("?");
+				else
+					param.append("&");
+				param.append(key).append("=").append((String) params.get(key));
+				i++;
+			}
+			urlString = urlString + param;
+		}
+
+		URL url = new URL(urlString);
+		HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
+
+		urlConnection.setRequestMethod("POST");
+		urlConnection.setDoOutput(true);
+		urlConnection.setDoInput(true);
+		urlConnection.setUseCaches(false);
+
+		if (sendData != null) {
+			urlConnection.getOutputStream().write(sendData.getBytes("utf-8"));
+			urlConnection.getOutputStream().flush();
+			urlConnection.getOutputStream().close();
+		}
+
+		HttpResponse response = new HttpResponse();
+		response.setInputStream(urlConnection.getInputStream());
+		response.setContentType(urlConnection.getContentType());
+		response.setContentLength(urlConnection.getContentLength());
+
+		return response;
+	}
+}
diff --git a/src/main/java/cc/mrbird/febs/pay/util/HttpResponse.java b/src/main/java/cc/mrbird/febs/pay/util/HttpResponse.java
new file mode 100644
index 0000000..314f7b1
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/pay/util/HttpResponse.java
@@ -0,0 +1,58 @@
+package cc.mrbird.febs.pay.util;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class HttpResponse {
+	private InputStream inputStream;
+	private String fileName;
+	private String contentType;
+	private int contentLength;
+	public String getFileName() {
+		return this.fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
+	public InputStream getInputStream() {
+		return this.inputStream;
+	}
+
+	public void setInputStream(InputStream inputStream) {
+		this.inputStream = inputStream;
+	}
+
+	public String getContentType() {
+		return this.contentType;
+	}
+
+	public void setContentType(String contentType) {
+		this.contentType = contentType;
+	}
+
+	public int getContentLength() {
+		return this.contentLength;
+	}
+
+	public void setContentLength(int contentLength) {
+		this.contentLength = contentLength;
+	}
+
+	public String getDataString() {
+		StringBuilder sb = new StringBuilder();
+		try {
+			InputStreamReader isr = new InputStreamReader(getInputStream(), "utf-8");
+			char[] cbuf = new char[1024];
+			int hasRead = 0;
+			while ((hasRead = isr.read(cbuf)) > 0) {
+				sb.append(cbuf, 0, hasRead);
+			}
+			isr.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sb.toString();
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest.java b/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest.java
new file mode 100644
index 0000000..a9b3a2d
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest.java
@@ -0,0 +1,186 @@
+package cc.mrbird.febs.pay.util;
+
+import cc.mrbird.febs.pay.service.IServiceRequest;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+
+/**
+ * User: rizenguo
+ * Date: 2014/10/29
+ * Time: 14:36
+ */
+public class HttpsRequest implements IServiceRequest {
+
+    public interface ResultListener {
+
+
+        public void onConnectionPoolTimeoutError();
+
+    }
+
+    //表示请求器是否已经做了初始化工作
+    private boolean hasInit = false;
+
+    //连接超时时间,默认10秒
+    private int socketTimeout = 10000;
+
+    //传输超时时间,默认30秒
+    private int connectTimeout = 30000;
+
+    //请求器的配置
+    private RequestConfig requestConfig;
+
+    //HTTP请求器
+    private CloseableHttpClient httpClient;
+
+    public HttpsRequest() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException {
+        init();
+    }
+
+    private void init() throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {
+
+   /*    KeyStore keyStore = KeyStore.getInstance("PKCS12");
+        FileInputStream instream = new FileInputStream(new File(Configure.getCertLocalPath()));//加载本地的证书进行https加密传输
+        try {
+            keyStore.load(instream, Configure.getCertPassword().toCharArray());//设置证书密码
+        } catch (CertificateException e) {
+            e.printStackTrace();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } finally {
+            instream.close();
+        }
+
+        // Trust own CA and all self-signed certs
+        SSLContext sslcontext = SSLContexts.custom()
+                .loadKeyMaterial(keyStore, Configure.getCertPassword().toCharArray())
+                .build();
+        // Allow TLSv1 protocol only
+        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+                sslcontext,
+                new String[]{"TLSv1"},
+                null,
+                SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+*/
+    	 httpClient = HttpClients.custom().build();
+        //根据默认超时限制初始化requestConfig
+        requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
+        hasInit = true;
+    }
+
+    /**
+     * 通过Https往API post xml数据
+     *
+     * @param url    API地址
+     * @param xmlObj 要提交的XML数据对象
+     * @return API回包的实际数据
+     * @throws IOException
+     * @throws KeyStoreException
+     * @throws UnrecoverableKeyException
+     * @throws NoSuchAlgorithmException
+     * @throws KeyManagementException
+     */
+
+    public String sendPost(String url, Object xmlObj) throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {
+
+        if (!hasInit) {
+            init();
+        }
+
+        String result = null;
+
+        HttpPost httpPost = new HttpPost(url);
+
+        //解决XStream对出现双下划线的bug
+        XStream xStreamForRequestPostData = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("-_", "_")));
+
+        //将要提交给API的数据对象转换成XML格式数据Post给API
+        String postDataXML = xStreamForRequestPostData.toXML(xmlObj);
+
+        //得指明使用UTF-8编码,否则到API服务器XML的中文不能被成功识别
+        StringEntity postEntity = new StringEntity(postDataXML, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.setEntity(postEntity);
+
+        //设置请求器的配置
+        httpPost.setConfig(requestConfig);
+
+
+        try {
+            HttpResponse response = httpClient.execute(httpPost);
+
+            HttpEntity entity = response.getEntity();
+
+            result = EntityUtils.toString(entity, "UTF-8");
+            
+        } catch (ConnectionPoolTimeoutException e) {
+//            log.e("http get throw ConnectionPoolTimeoutException(wait time out)");
+
+        } catch (ConnectTimeoutException e) {
+//            log.e("http get throw ConnectTimeoutException");
+
+        } catch (SocketTimeoutException e) {
+//            log.e("http get throw SocketTimeoutException");
+
+        } catch (Exception e) {
+        	e.printStackTrace();
+//            log.e("http get throw Exception");
+
+        } finally {
+            httpPost.abort();
+        }
+
+        return result;
+    }
+
+    /**
+     * 设置连接超时时间
+     *
+     * @param socketTimeout 连接时长,默认10秒
+     */
+    public void setSocketTimeout(int socketTimeout) {
+    	this.socketTimeout = socketTimeout;
+        resetRequestConfig();
+    }
+
+    /**
+     * 设置传输超时时间
+     *
+     * @param connectTimeout 传输时长,默认30秒
+     */
+    public void setConnectTimeout(int connectTimeout) {
+    	this.connectTimeout = connectTimeout;
+        resetRequestConfig();
+    }
+
+    private void resetRequestConfig(){
+        requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
+    }
+
+    /**
+     * 允许商户自己做更高级更复杂的请求器配置
+     *
+     * @param requestConfig 设置HttpsRequest的请求器配置
+     */
+    public void setRequestConfig(RequestConfig requestConfig) {
+    	this.requestConfig = requestConfig;
+    }
+}
diff --git a/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest2.java b/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest2.java
new file mode 100644
index 0000000..ace9851
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/pay/util/HttpsRequest2.java
@@ -0,0 +1,213 @@
+package cc.mrbird.febs.pay.util;
+
+import cc.mrbird.febs.pay.service.IServiceRequest;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.security.*;
+import java.security.cert.CertificateException;
+
+/**
+ * User: rizenguo
+ * Date: 2014/10/29
+ * Time: 14:36
+ */
+public class HttpsRequest2 implements IServiceRequest {
+
+    public interface ResultListener {
+
+
+        public void onConnectionPoolTimeoutError();
+
+    }
+
+    //表示请求器是否已经做了初始化工作
+    private boolean hasInit = false;
+
+    //连接超时时间,默认10秒
+    private int socketTimeout = 10000;
+
+    //传输超时时间,默认30秒
+    private int connectTimeout = 30000;
+
+    //请求器的配置
+    private RequestConfig requestConfig;
+
+    //HTTP请求器
+    private CloseableHttpClient httpClient;
+    //证书地址
+    private String  certLocalPath;
+    //商户号
+    private String mchId;
+
+    public HttpsRequest2() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException {
+
+    }
+
+    private void init() throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {
+
+        KeyStore keyStore = KeyStore.getInstance("PKCS12");
+        FileInputStream instream = new FileInputStream(new File(certLocalPath));//加载本地的证书进行https加密传输
+        try {
+            keyStore.load(instream, mchId.toCharArray());//设置证书密码
+        } catch (CertificateException e) {
+            e.printStackTrace();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } finally {
+            instream.close();
+        }
+        // Trust own CA and all self-signed certs
+        SSLContext sslcontext = SSLContexts.custom()
+                .loadKeyMaterial(keyStore, mchId.toCharArray())
+                .build();
+        // Allow TLSv1 protocol only
+        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+                sslcontext,
+                new String[]{"TLSv1"},
+                null,
+                SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+
+        httpClient = HttpClients.custom()
+                .setSSLSocketFactory(sslsf)
+                .build();
+        // httpClient = HttpClients.custom().build();
+        //根据默认超时限制初始化requestConfig
+        requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
+        hasInit = true;
+    }
+
+    /**
+     * 通过Https往API post xml数据
+     *
+     * @param url    API地址
+     * @param xmlObj 要提交的XML数据对象
+     * @return API回包的实际数据
+     * @throws IOException
+     * @throws KeyStoreException
+     * @throws UnrecoverableKeyException
+     * @throws NoSuchAlgorithmException
+     * @throws KeyManagementException
+     */
+
+    public String sendPost(String url, Object xmlObj) throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {
+
+        if (!hasInit) {
+            init();
+        }
+
+        String result = null;
+
+        HttpPost httpPost = new HttpPost(url);
+
+        //解决XStream对出现双下划线的bug
+        XStream xStreamForRequestPostData = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("-_", "_")));
+
+        //将要提交给API的数据对象转换成XML格式数据Post给API
+        String postDataXML = xStreamForRequestPostData.toXML(xmlObj);
+
+        //得指明使用UTF-8编码,否则到API服务器XML的中文不能被成功识别
+        StringEntity postEntity = new StringEntity(postDataXML, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.setEntity(postEntity);
+
+        //设置请求器的配置
+        httpPost.setConfig(requestConfig);
+
+
+        try {
+            HttpResponse response = httpClient.execute(httpPost);
+
+            HttpEntity entity = response.getEntity();
+
+            result = EntityUtils.toString(entity, "UTF-8");
+
+        } catch (ConnectionPoolTimeoutException e) {
+//            log.e("http get throw ConnectionPoolTimeoutException(wait time out)");
+
+        } catch (ConnectTimeoutException e) {
+//            log.e("http get throw ConnectTimeoutException");
+
+        } catch (SocketTimeoutException e) {
+//            log.e("http get throw SocketTimeoutException");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+//            log.e("http get throw Exception");
+
+        } finally {
+            httpPost.abort();
+        }
+
+        return result;
+    }
+
+    /**
+     * 设置连接超时时间
+     *
+     * @param socketTimeout 连接时长,默认10秒
+     */
+    public void setSocketTimeout(int socketTimeout) {
+        this.socketTimeout = socketTimeout;
+        resetRequestConfig();
+    }
+
+    /**
+     * 设置传输超时时间
+     *
+     * @param connectTimeout 传输时长,默认30秒
+     */
+    public void setConnectTimeout(int connectTimeout) {
+        this.connectTimeout = connectTimeout;
+        resetRequestConfig();
+    }
+
+    private void resetRequestConfig(){
+        requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
+    }
+
+    /**
+     * 允许商户自己做更高级更复杂的请求器配置
+     *
+     * @param requestConfig 设置HttpsRequest的请求器配置
+     */
+    public void setRequestConfig(RequestConfig requestConfig) {
+        this.requestConfig = requestConfig;
+    }
+
+
+    public String getMchId() {
+        return mchId;
+    }
+
+    public void setMchId(String mchId) {
+        this.mchId = mchId;
+    }
+
+    public String getCertLocalPath() {
+        return certLocalPath;
+    }
+
+    public void setCertLocalPath(String certLocalPath) {
+        this.certLocalPath = certLocalPath;
+    }
+}
diff --git a/src/main/java/cc/mrbird/febs/pay/util/WechatConfigure.java b/src/main/java/cc/mrbird/febs/pay/util/WechatConfigure.java
index f69cd9f..ab2a6ef 100644
--- a/src/main/java/cc/mrbird/febs/pay/util/WechatConfigure.java
+++ b/src/main/java/cc/mrbird/febs/pay/util/WechatConfigure.java
@@ -7,18 +7,23 @@
     /**
      * 发送http请求类
      */
-    public static String HttpsRequestClassName = "com.matrix.component.wechat.externalInterface.common.HttpsRequest";
+    public static String HttpsRequestClassName = "cc.mrbird.febs.pay.util.HttpsRequest";
+
     public static final String TRADE_TYPE_JSAPI = "JSAPI";
 
-    // 2)被扫支付查询API
+    /**
+     * 发送  SSL请求,企业付款,退款用
+     */
+    public static String HttpsRequestClassName2 = "cc.mrbird.febs.pay.util.HttpsRequest2";
+
+    // 被扫支付查询API
     public static String PAY_QUERY_API = "https://api.mch.weixin.qq.com/pay/orderquery";
-
-
 
     /**
      * 微信商户号
      */
     public static final String WECHARPAY_MCHID = "1605533690";
+
     /**
      * 支付秘钥
      */
@@ -28,21 +33,18 @@
      * 小程序APPID
      */
     public static final String MINIPROGRAM_APPID = "wx5cc58f796224af61";
-    // 8) 企业付款API
+
+    // 企业付款API
     public static String COM_PAY_API="https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";
 
-    /**
-     * 发送  SSL请求,企业付款,退款用
-     */
-    public static String HttpsRequestClassName2 = "com.matrix.component.wechat.externalInterface.common.HttpsRequest2";
-
-    // 3)退款API
+    // 退款API
     public static String REFUND_API = "https://api.mch.weixin.qq.com/secapi/pay/refund";
 
     /**
      * 成功
      */
     public static final String CODE_SUCCESS = "SUCCESS";
+
     /**
      * SUCCESS报文
      */
diff --git a/src/main/resources/mapper/modules/MallMemberMapper.xml b/src/main/resources/mapper/modules/MallMemberMapper.xml
index 94ea777..dd74bb6 100644
--- a/src/main/resources/mapper/modules/MallMemberMapper.xml
+++ b/src/main/resources/mapper/modules/MallMemberMapper.xml
@@ -33,7 +33,7 @@
                 </if>
             </if>
         </where>
-        order by m.CREATED_TIME desc
+        GROUP BY m.id order by m.CREATED_TIME desc
     </select>
 
     <select id="getMallMemberInfoById" resultType="cc.mrbird.febs.mall.vo.MallMemberVo">
diff --git a/src/main/resources/mapper/modules/MallTeamLeaderMapper.xml b/src/main/resources/mapper/modules/MallTeamLeaderMapper.xml
index b80a2d7..d15f0f8 100644
--- a/src/main/resources/mapper/modules/MallTeamLeaderMapper.xml
+++ b/src/main/resources/mapper/modules/MallTeamLeaderMapper.xml
@@ -146,7 +146,7 @@
         select
             a.*
         from mall_team_leader a
-        where a.unique_code = #{uniqueCode} limit 1
+        where a.unique_code = #{uniqueCode} and a.state = 1 limit 1
     </select>
 
     <select id="selectLeaderByLonAndLat" resultType="cc.mrbird.febs.mall.entity.MallTeamLeader">
diff --git a/src/main/resources/templates/febs/views/modules/leader/leaderList.html b/src/main/resources/templates/febs/views/modules/leader/leaderList.html
index 74430e9..841d023 100644
--- a/src/main/resources/templates/febs/views/modules/leader/leaderList.html
+++ b/src/main/resources/templates/febs/views/modules/leader/leaderList.html
@@ -20,6 +20,7 @@
                                                 <option value="1">通过</option>
                                                 <option value="2">不通过</option>
                                                 <option value="3">申请中</option>
+                                                <option value="4">取消</option>
                                             </select>
                                         </div>
                                     </div>
@@ -97,6 +98,11 @@
                     }
                 });
             }
+            if (layEvent === 'leaderCancel') {
+                febs.modal.confirm('取消', '确认取消该团长?', function () {
+                    leaderCancel(data.id);
+                });
+            }
             if (layEvent === 'seeImgThumb') {
                 var t = $view.find('#seeImgThumb'+data.id+'');
                 //页面层
@@ -113,6 +119,13 @@
                 });
             }
         });
+
+        function leaderCancel(id) {
+            febs.get(ctx + 'admin/leader/leaderCancel/' + id, null, function () {
+                febs.alert.success('操作成功');
+                $query.click();
+            });
+        }
 
         // 查询按钮
         $query.on('click', function () {
@@ -148,6 +161,8 @@
                                 return '<span style="color:red;">拒绝</span>'
                             }else if (d.state === 3) {
                                 return '<span style="color:blue;">待审核</span>'
+                            }else if (d.state === 4) {
+                                return '<span style="color:blue;">已取消</span>'
                             }else{
                                 return ''
                             }
@@ -157,6 +172,9 @@
                             if (d.state === 3) {
                                 return ''
                                     + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="leaderUpdate" shiro:hasPermission="user:update">审核</button>'
+                            }else if(d.state === 1) {
+                                return ''
+                                    + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="leaderCancel" shiro:hasPermission="user:update">取消</button>'
                             }else{
                                 return '';
                             }

--
Gitblit v1.9.1