DESKTOP-71BH0QO\L、ming
2021-04-25 717deb35e2654e41a9679fccc2e7409927a58912
Merge remote-tracking branch 'origin/master'
20个文件已修改
3个文件已添加
648 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxMessagePushApi.java 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/resources/bootstrap.yml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/SecurityConstants.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/shop/ComShopOrderVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HttpClientUtil.java 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxUtil.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxXCXTempSend.java 238 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopOrderDAO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopStoreDAO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopUserAddressDAO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComShopUserAddressDO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopOrderServiceImpl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopUserAddressServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/LoginApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/OrderApi.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/SercuritFilter.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxMessagePushApi.java
New file
@@ -0,0 +1,153 @@
package com.panzhihua.applets.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.common.utlis.WxUtil;
import com.panzhihua.common.utlis.WxXCXTempSend;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
@Slf4j
@RestController
@RequestMapping("/wx/push/")
public class WxMessagePushApi {
    private String token = "01A9CB2234D7CBD0AC61B75EB1263805";
    private String url = "www.taobao.com";//图文跳转地址
    private String thumbUrl = "https://www.psciio.com//idcard/f986ba3ae7a241d9bce5cb568adec7da.jpg";//图片地址
    @Resource
    private WxXCXTempSend wxXCXTempSend;
    /**
     * 微信接口配置信息认证接口<br>
     * 需要正确响应微信发送的Token验证。 加密/校验流程如下:<br>
     * 1. 将token、timestamp、nonce三个参数进行字典序排序<br>
     * 2. 将三个参数字符串拼接成一个字符串进行sha1加密<br>
     * 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
     */
    @RequestMapping("/cgi")
    public void cgi(HttpServletRequest request, HttpServletResponse response) {
        boolean isGet = request.getMethod().toLowerCase().equals("get");
        // 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
        try {
            if (isGet) {
                String signature = request.getParameter("signature");
                // 时间戳
                String timestamp = request.getParameter("timestamp");
                // 随机数
                String nonce = request.getParameter("nonce");
                // 随机字符串
                String echostr = request.getParameter("echostr");
                log.info("signature = "+signature+" , timestamp = "+timestamp+ " , nonce = "+nonce+ " , echostr = "+echostr);
                String[] strArray = new String[] { token, timestamp, nonce };
                Arrays.sort(strArray);
                StringBuilder sb = new StringBuilder();
                for (String str : strArray) {
                    sb.append(str);
                }
                // SHA1签名生成
                MessageDigest md = MessageDigest.getInstance("SHA-1");
                md.update(sb.toString().getBytes());
                byte[] digest = md.digest();
                StringBuffer hexstr = new StringBuffer();
                String shaHex = "";
                for (int i = 0; i < digest.length; i++) {
                    shaHex = Integer.toHexString(digest[i] & 0xFF);
                    if (shaHex.length() < 2) {
                        hexstr.append(0);
                    }
                    hexstr.append(shaHex);
                }
                if (hexstr.toString().equals(signature)) {
                    response.getOutputStream().write(echostr.getBytes());
                }
            }else{
                // 进入POST聊天处理
                // 将请求、响应的编码均设置为UTF-8(防止中文乱码)
                request.setCharacterEncoding("UTF-8");
                response.setCharacterEncoding("UTF-8");
                // 接收消息并返回消息
                String result = acceptMessage(request, response);
                // 响应消息
                PrintWriter out = response.getWriter();
                out.print(result);
                out.close();
            }
        } catch (Exception ex) {
            log.error("微信帐号接口配置失败!", ex);
            ex.printStackTrace();
        }
    }
    /**
     * 接受到微信接口数据
     * @param request
     * @param response
     * @return
     */
    private String acceptMessage(HttpServletRequest request, HttpServletResponse response) {
        String respMessage = "";
        String inputLine = "";
        String notityXml = "";
        try {
            //接收数据
            while((inputLine = request.getReader().readLine()) != null){
                notityXml += inputLine;
            }
            // xml请求解析
            JSONObject requestJson = JSON.parseObject(notityXml);
            log.info(">>>>>>>>>>>>>"+requestJson.toString());
            // 发送方帐号(open_id)
            String fromUserName = requestJson.get("FromUserName").toString();
            // 公众帐号
            String toUserName = requestJson.get("ToUserName").toString();
            // 消息类型
            String msgType = requestJson.get("MsgType").toString();
//            String Event = requestJson.get("Event").toString();  //SCAN 为扫描信息  VIEW 公众号底部点击事件
            log.info("fromUserName = "+fromUserName+" , ToUserName = "+toUserName+ " , msgType = "+msgType);
            String access_token = wxXCXTempSend.getAccessToken();//获取access_token
            //公众号关注事件消息
            if(msgType.equals("event")){
//                log.info("公众号被关注事件..........");
            }else if(msgType.equals("text")){
//                if(StringUtils.isNotEmpty(access_token)){
//                    String mediaId = wxXCXTempSend.getMediaId(access_token);//获取mediaId
//                    WxUtil.sendKfImagesMessage(fromUserName,access_token,mediaId);
//                }
//                log.info("公众号接受文字..........");
            }else if(msgType.equals("image")){
//                log.info("公众号接受图片..........");
            }else if(msgType.equals("miniprogrampage")){
                if(StringUtils.isNotEmpty(access_token)){
                    String mediaId = wxXCXTempSend.getMediaId(access_token);//获取mediaId
                    WxUtil.sendKfImagesMessage(fromUserName,access_token,mediaId);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return respMessage;
    }
}
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/resources/bootstrap.yml
@@ -15,6 +15,9 @@
      max-file-size: 10MB
      max-request-size: 10MB
server:
  max-http-header-size: 10MB
eureka:
  client:
    service-url:
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml
@@ -124,6 +124,13 @@
            <artifactId>json</artifactId>
            <version>20160810</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.9</version>
        </dependency>
    </dependencies>
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/SecurityConstants.java
@@ -11,6 +11,10 @@
    public static final String ROLE_ALL="springsecurity:role:all";//平台所有权限存储在redis
    public static final String ROLE_USER="springsecurity:role:";//某个用户的具体权限
    public static final String ROLE_APPLETS="applets";//小程序用户通用角色
    public static final String APPLETS_ACCESS_TOKEN ="APPLETS_ACCESS_TOKEN";//小程序获取的access_token
    public static final String APPLETS_ACCESS_TOKEN_TIME ="APPLETS_ACCESS_TOKEN_TIME";//小程序获取的access_token
    public static final String APPLETS_ACCESS_MEDIA_ID ="APPLETS_ACCESS_MEDIA_ID";//小程序获取的access_token
    public static final String APPLETS_ACCESS_MEDIA_ID_TIME ="APPLETS_ACCESS_MEDIA_ID_TIME";//小程序获取的access_token
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java
@@ -45,7 +45,7 @@
    /**
     * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
     */
    private static final int BATCH_COUNT = 100;
    private static final int BATCH_COUNT = 5000;
    List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>();
    @Override
@@ -91,6 +91,10 @@
                if(oneData.get(1) == null){
                    throw new ServiceException("500", "身份证号不可为空:第" + index + "行,第2列");
                }
                //判断身份证号码位数
                if(oneData.get(1).length() != 18){
                    throw new ServiceException("500", "身份证号位数不正确:第" + index + "行,第2列");
                }
                vo.setCardNo(oneData.get(1));
                //根据身份证号码解析年龄以及性别
                //获取用户生日
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/shop/ComShopOrderVO.java
@@ -13,6 +13,9 @@
    @ApiModelProperty(value = "订单号")
    private String orderNo;
    @ApiModelProperty(value = "订单ID")
    private Long orderId;
    @ApiModelProperty(value = "订单金额")
    private BigDecimal orderTotal;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/HttpClientUtil.java
@@ -7,8 +7,10 @@
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.springframework.util.ObjectUtils;
@@ -20,6 +22,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -131,4 +136,118 @@
    }
    /**
     * http请求工具类,get请求
     *
     * @param url
     * @param params
     * @param resonseCharSet
     * @return
     * @throws Exception
     */
    public static String httpGet(String url, Map<String, Object> params, String... resonseCharSet) throws Exception {
        DefaultHttpClient defaultHttpClient = null;
        BufferedReader bufferedReader = null;
        try {
            defaultHttpClient = new DefaultHttpClient();
            if (params != null) {
                StringBuilder stringBuilder = new StringBuilder();
                Iterator<String> iterator = params.keySet().iterator();
                String key;
                while (iterator.hasNext()) {
                    key = iterator.next();
                    Object val = params.get(key);
                    if (val instanceof List) {
                        List v = (List) val;
                        for (Object o : v) {
                            stringBuilder.append(key).append("=").append(o.toString()).append("&");
                        }
                    } else {
                        stringBuilder.append(key).append("=").append(val.toString()).append("&");
                    }
                }
                stringBuilder.deleteCharAt(stringBuilder.length() - 1);
                url = url + "?" + stringBuilder.toString();
                log.info("url:{}", url);
            }
            HttpGet httpGet = new HttpGet(url);
            httpGet.setHeader("Content-Type", "application/json;charset=ut-8");
            HttpResponse httpResponse = defaultHttpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() != 200) {
                String errorLog = "请求失败,errorCode:" + httpResponse.getStatusLine().getStatusCode();
                log.info(errorLog);
                throw new Exception(url + errorLog);
            }
            //读取返回信息
            String charSet = "utf-8";
            if (resonseCharSet != null && resonseCharSet.length > 0)
                charSet = resonseCharSet[0];
            String output;
            bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), charSet));
            StringBuilder dataBuilder = new StringBuilder();
            while ((output = bufferedReader.readLine()) != null) {
                dataBuilder.append(output);
            }
            return dataBuilder.toString();
        } catch (IOException e) {
            e.printStackTrace();
            throw e;
        } finally {
            if (defaultHttpClient != null)
                defaultHttpClient.getConnectionManager().shutdown();
            if (bufferedReader != null)
                bufferedReader.close();
        }
    }
    /**
     * http请求工具类,post请求
     *
     * @param url    url
     * @param param 参数值 仅支持String
     * @return
     * @throws Exception
     */
    public static String httpPost(String url, String param) throws Exception {
        DefaultHttpClient defaultHttpClient = null;
        BufferedReader bufferedReader = null;
        try {
            defaultHttpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            httpPost.setHeader("Content-Type", "application/json;charset=ut-8");
            if (StringUtils.isNotBlank(param)) {
                log.info("参数值:{}", param);
                HttpEntity httpEntity = new StringEntity(param, "utf-8");
                httpPost.setEntity(httpEntity);
            }
            HttpResponse httpResponse = defaultHttpClient.execute(httpPost);
            if (httpResponse.getStatusLine().getStatusCode() != 200) {
                String errorLog = "请求失败,errorCode:" + httpResponse.getStatusLine().getStatusCode();
                log.info(errorLog);
                throw new Exception(url + errorLog);
            }
            //读取返回信息
            String output;
            bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "utf-8"));
            StringBuilder stringBuilder = new StringBuilder();
            while ((output = bufferedReader.readLine()) != null) {
                stringBuilder.append(output);
            }
            log.info("调用微信接口返回的参数:" + stringBuilder.toString());
            return stringBuilder.toString();
        } catch (IOException e) {
            e.printStackTrace();
            throw e;
        } finally {
            if (defaultHttpClient != null)
                defaultHttpClient.getConnectionManager().shutdown();
            if (bufferedReader != null)
                bufferedReader.close();
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java
@@ -1,6 +1,7 @@
package com.panzhihua.common.utlis;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import java.util.Base64;
@@ -10,6 +11,7 @@
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2021-01-08 09:45
 **/
@Slf4j
public class RealNameUtil {
    private static final String CLIENT_ID="2092261934651932672";
    private static final String SECRET="de1c0dbb-9197-4724-9cc2-aa94e30a072f";
@@ -32,7 +34,10 @@
        jsonObject.put("idNumber",idcard);
        jsonObject.put("realName",name);
        String param=jsonObject.toJSONString();
        log.info("请求公安实名认证接口,请求地址:" + URL);
        log.info("请求公安实名认证接口,请求参数:" + param);
        String postByJson = HttpClientUtil.sendPostByJson(URL, param, 0, headerkey, headervalue + encodeToString);
        log.info("请求公安实名认证接口,返回参数:" + postByJson);
        int code = JSONObject.parseObject(postByJson).getIntValue("code");
        if (0==code) {
            result =true;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxUtil.java
New file
@@ -0,0 +1,59 @@
package com.panzhihua.common.utlis;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.http.entity.ContentType;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class WxUtil {
    //客服消息推送地址
    public final static String kf_url = "https://api.weixin.qq.com/cgi-bin/message/custom/send";
    public static String sendKfLinkMessage(String openid,String url,String thumbUrl,String access_token)throws Exception{
        Map<String,Object> map_content = new HashMap<>();
        map_content.put("title","社区福利一分购");
        map_content.put("description","点击参与社区一分钱抢购活动");
        map_content.put("url",url);//跳转地址
        map_content.put("thumb_url",thumbUrl);//图片地址
        Map<String,Object> map = new HashMap<>();
        map.put("touser",openid);
        map.put("msgtype","link");
        map.put("link",map_content);
        String content = JSON.toJSONString(map);
        return HttpClientUtil.httpPost(kf_url+"?access_token="+access_token,content);
    }
    public static String sendKfConetntMessage(String openid,String access_token)throws Exception{
        Map<String,Object> map_content = new HashMap<>();
        map_content.put("content","社区福利一分购");
        Map<String,Object> map = new HashMap<>();
        map.put("touser",openid);
        map.put("msgtype","text");
        map.put("text",map_content);
        String content = JSON.toJSONString(map);
        return HttpClientUtil.httpPost(kf_url+"?access_token="+access_token,content);
    }
    public static String sendKfImagesMessage(String openid,String access_token,String mediaId)throws Exception{
        Map<String,Object> map_content = new HashMap<>();
        map_content.put("media_id",mediaId);
        Map<String,Object> map = new HashMap<>();
        map.put("touser",openid);
        map.put("msgtype","image");
        map.put("image",map_content);
        String content = JSON.toJSONString(map);
        return HttpClientUtil.httpPost(kf_url+"?access_token="+access_token,content);
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/WxXCXTempSend.java
New file
@@ -0,0 +1,238 @@
package com.panzhihua.common.utlis;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.constants.SecurityConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class WxXCXTempSend {
    private static String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential";
    private static String APP_IMAGE_URL = "https://www.psciio.com//idcard/8fa82cfba258498eab2fa818220fb592.jpg";
    private static String APP_IMAGE_NAME = "5.jpg";
    public static final String APP_ID = "wx0cef797390444b75";
    private static final String APP_SECRET = "c7ea9aaa7e391a487e8a5b9ba61045d1";
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 获取小程序token,(ps:0=token获取失败)
     *
     * @return
     */
    public String getAccessToken() throws Exception {
//        String accessToken = ;
//        Boolean aBoolean = redisTemplate.hasKey(SecurityConstants.APPLETS_ACCESS_TOKEN);
//        ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
//        if(aBoolean){
//            Long expireTime = Long.parseLong(valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME));
//            if(expireTime <= System.currentTimeMillis()){
//                redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN);//如果过期则删除
//                redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME);//如果过期则删除
//
//                valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken);
//                valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + "");
//            }else{
//                accessToken = valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN);
//            }
//        }else{
//            accessToken = getAppAccessToken();
//            valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken);
//            valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + "");
//        }
        return getAppAccessToken();
    }
    private String getAppAccessToken() throws Exception{
        String accessToken = "0";
        try {
            //此处APP_ID APP_SECRET  在微信小程序后端可见
//            String accessTokenUrl = String.format(TEMP_URL, APP_ID, APP_SECRET);
            String accessTokenUrl = ACCESS_TOKEN_URL + "&appid=" + APP_ID + "&secret=" + APP_SECRET;
            String result = HttpClientUtil.httpGet(accessTokenUrl, null, null);
            Map<String, Object> resultMap = JSON.parseObject(result, Map.class);
            if(resultMap.containsKey("access_token")) {
                accessToken = resultMap.get("access_token").toString();
            }
        } catch (IOException ioe) {
            log.error("小程序http请求异常");
            ioe.printStackTrace();
        }
        return accessToken;
    }
    public String getMediaId(String accessToken){
        String mediaId = "";
        Boolean aBoolean = redisTemplate.hasKey(SecurityConstants.APPLETS_ACCESS_MEDIA_ID);
        ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
        if(aBoolean){
            Long expireTime = Long.parseLong(valueOperations.get(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME));
            if(expireTime <= System.currentTimeMillis()){
                redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_MEDIA_ID);//如果过期则删除
                redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME);//如果过期则删除
                mediaId = getAppMediaId(accessToken);
                valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID, mediaId);
                valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME, System.currentTimeMillis() + 259000000 + "");
            }else{
                mediaId = valueOperations.get(SecurityConstants.APPLETS_ACCESS_MEDIA_ID);
            }
        }else{
            mediaId = getAppMediaId(accessToken);
            valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID, mediaId);
            valueOperations.set(SecurityConstants.APPLETS_ACCESS_MEDIA_ID_TIME, System.currentTimeMillis() + 259000000 + "");
        }
        return mediaId;
    }
    private String getAppMediaId(String accessToken){
        String appMediaId = "";
        try {
            MultipartFile file = createFileItem(APP_IMAGE_URL,APP_IMAGE_NAME);
            appMediaId = uploadFile(file,accessToken);
        }catch (Exception e){
            log.error("上传临时图片素材失败,错误原因:" + e.getMessage());
        }
        return appMediaId;
    }
    /**
     * url转变为 MultipartFile对象
     * @param url
     * @param fileName
     * @return
     * @throws Exception
     */
    private static MultipartFile createFileItem(String url, String fileName) throws Exception{
        FileItem item = null;
        try {
            HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
            conn.setReadTimeout(30000);
            conn.setConnectTimeout(30000);
            //设置应用程序要从网络连接读取数据
            conn.setDoInput(true);
            conn.setRequestMethod("GET");
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                InputStream is = conn.getInputStream();
                FileItemFactory factory = new DiskFileItemFactory(16, null);
                String textFieldName = "uploadfile";
                item = factory.createItem(textFieldName, ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName);
                OutputStream os = item.getOutputStream();
                int bytesRead = 0;
                byte[] buffer = new byte[8192];
                while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
                    os.write(buffer, 0, bytesRead);
                }
                os.close();
                is.close();
            }
        } catch (IOException e) {
            throw new RuntimeException("文件下载失败", e);
        }
        return new CommonsMultipartFile(item);
    }
    /**
     * 微信小程序临时素材上传
     *
     * @param file
     * @return
     * @author yixiu
     * @throws Exception
     */
    public String uploadFile(MultipartFile file,String access_token) throws Exception {
        String url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + access_token + "&type=image";
        String result = null;
        String fileName = file.getOriginalFilename();
        URL urlObj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
        con.setRequestMethod("POST");
        con.setDoInput(true);
        con.setDoOutput(true);
        con.setUseCaches(false);
        // 设置请求头信息
        con.setRequestProperty("Connection", "Keep-Alive");
        con.setRequestProperty("Charset", "UTF-8");
        // 设置边界
        String BOUNDARY = "----------" + System.currentTimeMillis();
        con.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=\"media\";filename=\"" + fileName + "\"\r\n");
        sb.append("Content-Type:application/octet-stream\r\n\r\n");
        byte[] head = sb.toString().getBytes("utf-8");
        // 获得输出流
        OutputStream out = new DataOutputStream(con.getOutputStream());
        // 输出表头
        out.write(head);
        // 文件正文部分
        // 把文件已流文件的方式 推入到url中
        DataInputStream in = new DataInputStream(file.getInputStream());
        int bytes = 0;
        byte[] bufferOut = new byte[1024];
        while ((bytes = in.read(bufferOut)) != -1) {
            out.write(bufferOut, 0, bytes);
        }
        in.close();
        // 结尾部分
        byte[] foot = ("\r\n--" + BOUNDARY + "--\r\n").getBytes("utf-8");// 定义最后数据分隔线
        out.write(foot);
        out.flush();
        out.close();
        StringBuffer buffer = new StringBuffer();
        BufferedReader reader = null;
        try {
            // 定义BufferedReader输入流来读取URL的响应
            reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String line = null;
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
            }
            if (result == null) {
                result = buffer.toString();
            }
        } catch (IOException e) {
            System.out.println("发送POST请求出现异常! {}");
            e.printStackTrace();
            throw new IOException("数据读取异常");
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
        // 获取到返回HTTP结果
        Map<String, Object> map = JSONObject.parseObject(result, Map.class);
        if (map.containsKey("media_id")) {
            return map.get("media_id").toString();
        }
        System.out.println("小程序上传临时素材出错,返回信息为:    " + result);
        return null;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopOrderDAO.java
@@ -87,7 +87,7 @@
    IPage<ComShopOrderSearchVO> pageOrderBy(Page page, @Param("pageComShopOrderSearchDTO")  PageComShopOrderSearchDTO pageComShopOrderSearchDTO);
    @Select("<script> " +
            "SELECT sr.total_amount AS goods_total, GROUP_CONCAT(og.goods_name) AS goods_name , sum(og.amount) AS goods_count, " +
            "SELECT sr.total_amount AS goods_total, GROUP_CONCAT(og.goods_name  separator  '\n') AS goods_name , sum(og.amount) AS goods_count, " +
                " su.phone AS account, uad.name AS receiver, uad.phone AS receiverPhone, \n" +
                " concat(uad.province_name, uad.city_name, uad.district_name, uad.detail_address) AS receiver_address, ss.name AS storeName, sr.remark," +
                    "  CASE\n" +
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopStoreDAO.java
@@ -22,7 +22,7 @@
            "select id,`name`,store_password,contacts,store_account,classify_id,logo,phone,delivery_type,remark,`status`," +
            "sale,sale_volume,store_detail,create_at from com_shop_store c" +
            " <where>" +
            "c.delete_status=1" +
            "c.delete_status=1 and status = 1" +
            "<if test='pageComShopStoreDTO.contacts != null and pageComShopStoreDTO.contacts.trim() != &quot;&quot;'>" +
            "and c.contacts like concat('%',#{pageComShopStoreDTO.contacts},'%') \n" +
            " </if> " +
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopUserAddressDAO.java
@@ -20,7 +20,7 @@
    @Select("select id,`name`,phone,province_code,province_name,city_code,city_name" +
            ",district_code,district_name,detail_address,is_default " +
            " from com_shop_user_address where user_id = #{userId} order by create_at desc")
            " from com_shop_user_address where delete_status = 2 and user_id = #{userId} order by create_at desc")
    List<ComShopUserAddressVO> pageUserAddressList(Page page, @Param("userId") Long userId);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComShopUserAddressDO.java
@@ -81,6 +81,11 @@
    private Integer isDefault;
    /**
     * 是否已删除(1.是  2.否)
     */
    private Integer deleteStatus;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -204,7 +204,7 @@
            //判断DB和exel数据重复判断
            boolean result = comMngPopulationDOS.stream().anyMatch(population -> population.getCardNo().equals(vo.getCardNo()));
            if (result) {
                return R.fail("导入实有人口已存在(" + vo.getCardNo() + ")");
                return R.fail(501,"导入实有人口已存在(" + vo.getCardNo() + ")");
            }
            index++;
        }
@@ -217,7 +217,7 @@
//            ComMngVillageDO comMngVillageDO = villageDOList.stream().filter(village -> village.getAlley().equals(vo.getRoad()) && village.getHouseNum().equals(Integer.valueOf(vo.getDoorNo()))).findFirst().orElse(null);
            BeanUtils.copyProperties(vo, comMngPopulationDO);
            if (comMngVillageDO == null) {
                throw new ServiceException("街道巷:" + vo.getRoad() + "不存在!");
                throw new ServiceException("查无:" + vo.getRoad() + "小区/房租地址,请先新建地址");
            }
            List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
            comMngPopulationDO.setVillageId(comMngVillageDO.getVillageId());
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopOrderServiceImpl.java
@@ -287,6 +287,7 @@
        comShopOrderOperateDAO.insert(orderOperateDO);
        shopOrderVO.setOrderNo(orderNo);
        shopOrderVO.setOrderTotal(orderTotal);
        shopOrderVO.setOrderId(shopOrderDO.getId());
        try {
            BigDecimal money = orderTotal;
@@ -647,11 +648,10 @@
        if(!(comShopOrderDO.getStatus() == 3)){
            return R.fail("订单还未发货");
        }
        comShopOrderDO.setStatus(4);
        //comShopOrderDO.setStatus(4);
        comShopOrderDO.setDeliveryStatus(5);
        int updated = comShopOrderDAO.updateById(comShopOrderDO);
        if(updated==1){
            //创建订单操作记录
            ComShopOrderOperateDO orderOperateDO = new ComShopOrderOperateDO();
            orderOperateDO.setOrderNo(comShopOrderDO.getOrderNo());
@@ -851,6 +851,9 @@
        }catch (Exception e){
            log.error("调用微信支付异常,异常原因:" + e.getMessage());
        }
        shopOrderVO.setOrderId(orderDO.getId());
        shopOrderVO.setOrderNo(orderDO.getOrderNo());
        shopOrderVO.setOrderTotal(orderDO.getTotalAmount());
        return R.ok(shopOrderVO);
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -54,7 +54,7 @@
    @Override
    public R pageStoreList(PageComShopStoreDTO pageComShopStoreDTO) {
        Page page = new Page<>(pageComShopStoreDTO.getPageNum(), pageComShopStoreDTO.getPageSize());
        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStoreByAdmin(page, pageComShopStoreDTO);
        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStore(page, pageComShopStoreDTO);
        return R.ok(comShopStoreVOIPage);
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopUserAddressServiceImpl.java
@@ -110,7 +110,8 @@
        if(userAddressDO == null){
            return R.fail("未查询到用户收货地址信息");
        }
        if(this.baseMapper.deleteById(addressId) > 0){
        userAddressDO.setDeleteStatus(1);
        if(this.baseMapper.updateById(userAddressDO) > 0){
            return R.ok();
        }else{
            return R.fail("删除收货地址失败");
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -551,6 +551,7 @@
        //接入第三方实名认证
        String idCard = loginUserInfoVO.getIdCard();
        String name = loginUserInfoVO.getName();
        log.info("用户实名认证发送请求,姓名:" + name + "身份证号码:" + idCard);
        boolean b = RealNameUtil.authentication(idCard, name);
        if (!b) {
            return R.fail("身份认证失败:公安系统认证错误");
springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/LoginApi.java
@@ -60,7 +60,7 @@
                    return R.fail("账号被禁用");
                }
            }
            return R.fail("商家不存在");
            return R.fail(storeR.getMsg());
        }catch (Exception e){
            return R.fail("登陆失败了");
        }
springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/OrderApi.java
@@ -3,6 +3,8 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -154,7 +156,18 @@
                    ExcelWriter excelWriter = null;
                    InputStream inputStream=null;
                    try {
                        excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
                        contentWriteCellStyle.setWrapped(true);
                        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
                        HorizontalCellStyleStrategy horizontalCellStyleStrategy =
                                new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
                        excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                                .registerWriteHandler(horizontalCellStyleStrategy).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build();
                        excelWriter.write(excelShopOrderDTO, writeSheet);
                        excelWriter.finish();
springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java
@@ -77,8 +77,9 @@
        boolean refreshToken = requestURI.contains("refreshToken");
        boolean logout = requestURI.contains("logout");
        boolean wxPay = requestURI.contains("wxNotify");
        boolean wxCgi = requestURI.contains("cgi");
        SafeboxRequestWrapper safeboxRequestWrapper = new SafeboxRequestWrapper(request);
        if (login||doc||css||js||ui||swagger||ico||docs||error||refreshToken||useragreement||wxPay) {
        if (login||doc||css||js||ui||swagger||ico||docs||error||refreshToken||useragreement||wxPay||wxCgi) {
            //什么也不做
        } else {
            // 获取请求头中JWT的Token
springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/SercuritFilter.java
@@ -76,9 +76,10 @@
        boolean docs = !requestUrl.contains("docs");
        boolean login = !requestUrl.contains("login");
        boolean wxNotify = !requestUrl.contains("wxNotify");
        boolean wxCgi = !requestUrl.contains("cgi");
        boolean refreshToken = !requestUrl.contains("refreshToken");
        boolean useragreement = !requestUrl.contains("useragreement");
        if (contains&&docs&&login&&refreshToken&&useragreement&&wxNotify) {
        if (contains&&docs&&login&&refreshToken&&useragreement&&wxNotify&&wxCgi) {
            configAttributes.add(new SecurityConfig(SecurityConstants.ROLE_APPLETS));
        }
        return configAttributes;