| | |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | |
| | | private void addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException { |
| | | private void addKey(SubmitKeyInfo keyInfo, Long wxUid, String ip, IPUtil.IPInfo ipInfo) throws KeyVerifyException, KeyOrderException, WxOrderCountException { |
| | | |
| | | // 查询没有处理的数量 |
| | | long notProcessCount = keyOrderService.countUserNotDoOrder(wxUid, new Date(System.currentTimeMillis() - 1000*60*30)); |
| | |
| | | throw new KeyVerifyException(KeyVerifyException.CODE_COMMON, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | KeyOrder order = keyOrderService.addKeyOrder(keyInfo, wxUid, TimeUtil.getGernalTime(System.currentTimeMillis(), Constant.DB_DAY_FORMAT),orderType, orderDto); |
| | | Long uid = keyOrderService.getCanDistributeUid(Constant.MAX_PAY_ACCOUNT_QUEUE_SIZE); |
| | | if (uid != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | private Map<String, IPUtil.IPInfo> ipInfoMap=new HashMap<>(); |
| | | @ResponseBody |
| | | @RequestMapping(value = "submitKeyV4") |
| | | public String submitKeyV4(SubmitKeyInfo keyInfo, HttpSession session, HttpServletRequest request) { |
| | |
| | | WxUserInfo user = (WxUserInfo) session.getAttribute(Constant.SESSION_KEY_USER); |
| | | if (StringUtil.isNullOrEmpty(keyInfo.getKey())) { |
| | | return JsonUtil.loadFalseResult("请上传key"); |
| | | } |
| | | String ip = IPUtil.getRemotIP(request); |
| | | keyInfo.setIp(ip); |
| | | if(!ipInfoMap.containsKey(ip)){ |
| | | try { |
| | | IPUtil.IPInfo ipInfo = IPUtil.getLocalIPInfo(ip); |
| | | ipInfoMap.put(ip, ipInfo); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | String citys = systemConfigService.getValueCache(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS); |
| | | if(citys!=null&&ipInfoMap.get(ip)!=null){ |
| | | List<String> cityList = Arrays.asList(citys.split(",")); |
| | | if(cityList.contains(ipInfoMap.get(ip).getCity())){ |
| | | LogUtil.loggerDebug.warn("区域屏蔽:{}-{}", ip, new Gson().toJson(ipInfoMap.get(ip))); |
| | | return JsonUtil.loadFalseResult("暂时无法上传口令"); |
| | | } |
| | | } |
| | | |
| | | try { |
| | |
| | | return JsonUtil.loadTrueResult(Constant.RESULT_CODE_NEED_LOGIN, root); |
| | | } |
| | | wxLogger.info("微信有授权:" + session.getId()); |
| | | LogUtil.loggerDebug.warn("GEO信息:{}-{}-{}", user.getId(),ip, new Gson().toJson(ipInfoMap.get(ip))); |
| | | try { |
| | | addKey(keyInfo, user.getId()); |
| | | addKey(keyInfo, user.getId(),ip, ipInfoMap.get(ip)); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (KeyOrderException e) { |
| | | e.printStackTrace(); |
| | |
| | | |
| | | wxLogger.info("从session读取到key:{}", alipayKeyInfo); |
| | | if (alipayKeyInfo != null) { |
| | | addKey(alipayKeyInfo, user.getId()); |
| | | if(!ipInfoMap.containsKey(alipayKeyInfo.getIp())){ |
| | | try { |
| | | IPUtil.IPInfo ipInfo = IPUtil.getLocalIPInfo(alipayKeyInfo.getIp()); |
| | | ipInfoMap.put(alipayKeyInfo.getIp(), ipInfo); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | addKey(alipayKeyInfo, user.getId(),alipayKeyInfo.getIp(),ipInfoMap.get(alipayKeyInfo.getIp())); |
| | | } |
| | | response.sendRedirect(successLink); |
| | | return; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getForbiddenSubmitCitys") |
| | | public String getForbiddenSubmitCitys() { |
| | | String value = systemConfigService.getValue(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("citys", value); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setForbiddenSubmitCitys") |
| | | public String setForbiddenSubmitCitys(String citys) { |
| | | systemConfigService.setValue(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS, citys); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | AGENT_ORDER_CHANNEL_SHARE_RATIO("agent_order_channel_share_ratio", "代理订单渠道分成比例"), |
| | | RE_EXCUTE_PAY_CLIENTS("re_excute_pay_clients", "重新执行支付的账号"), |
| | | USER_SUBMIT_KEY_COUNT_LIMIT("user_submit_key_count_limit_v2", "用户提交口令次数限制"), |
| | | FORBIDDEN_SUBMIT_CITYS("forbidden_submit_citys","禁止提交口令的城市"), |
| | | ; |
| | | |
| | | |
| | |
| | | package com.taoke.autopay.utils; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.show.api.ShowApiRequest; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.lionsoul.ip2region.xdb.Searcher; |
| | | import org.yeshi.utils.HttpUtil; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedInputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class IPUtil { |
| | | private static Searcher searcher; |
| | | |
| | | static { |
| | | try { |
| | | URL url = IPUtil.class.getClassLoader().getResource("ip2region.xdb"); |
| | | String path = new File(url.toURI()).getAbsolutePath(); |
| | | byte[] vIndex = Searcher.loadVectorIndexFromFile(path); |
| | | searcher = Searcher.newWithVectorIndex(path, vIndex); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // http://verx.daili666.com/ip/?tid=558287898012218&num=1&operator=2 |
| | | public static void changeIp() { |
| | | System.getProperties().setProperty("proxySet", "true"); // 如果不设置,只要代理IP和代理端口正确,此项不设置也可以 |
| | | System.getProperties().setProperty("http.proxyHost", "213.85.92.10"); |
| | | System.getProperties().setProperty("http.proxyPort", "80"); |
| | | LogUtil.i(getHtml("http://www.ip138.com/ip2city.asp")); // 判断代理是否设置成功 |
| | | } |
| | | |
| | | private static String getHtml(String address) { |
| | | StringBuffer html = new StringBuffer(); |
| | | String result = null; |
| | | try { |
| | | URL url = new URL(address); |
| | | URLConnection conn = url.openConnection(); |
| | | conn.setRequestProperty("User-Agent", |
| | | "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 2.0.50727; CIBA)"); |
| | | BufferedInputStream in = new BufferedInputStream(conn.getInputStream()); |
| | | try { |
| | | String inputLine; |
| | | byte[] buf = new byte[4096]; |
| | | int bytesRead = 0; |
| | | while (bytesRead >= 0) { |
| | | inputLine = new String(buf, 0, bytesRead, "ISO-8859-1"); |
| | | html.append(inputLine); |
| | | bytesRead = in.read(buf); |
| | | inputLine = null; |
| | | } |
| | | buf = null; |
| | | } finally { |
| | | in.close(); |
| | | conn = null; |
| | | url = null; |
| | | } |
| | | result = new String(html.toString().trim().getBytes("ISO-8859-1"), "gb2312").toLowerCase(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | html = null; |
| | | return result; |
| | | } |
| | | |
| | | private static void sendNoticeEmail(String get) { |
| | | if (get != null && get.contains("订单剩余数量不足")) { |
| | | /* |
| | | * MailSenderUtil.sendEmail("1101184511@qq.com", "系统提示:IP订单剩余数量不足", |
| | | * "IP订单剩余数量不足,请登录到代理666充值"); |
| | | */ |
| | | } |
| | | } |
| | | |
| | | public static String getRemotIP(HttpServletRequest request) { |
| | | String ip = request.getHeader("x-forwarded-for"); |
| | |
| | | } |
| | | |
| | | public static IPInfo getLocalIPInfo(String ip) throws Exception { |
| | | String appcode = "46789780da4f4d92885c3d39b97e3ba9"; |
| | | String appcode = "0c175db2439b4ef782594b7434187505"; |
| | | // 通过阿里云的接口获取IP信息 |
| | | String url = "https://zjip.market.alicloudapi.com/lifeservice/QueryIpAddr/query?ip=" + URLEncoder.encode(ip, "UTF-8"); |
| | | // 网络请求 |
| | |
| | | private String money; |
| | | private String referer; |
| | | private String a; |
| | | private String ip; |
| | | |
| | | public SubmitKeyInfo() { |
| | | } |
| | |
| | | public void setA(String a) { |
| | | this.a = a; |
| | | } |
| | | |
| | | public String getIp() { |
| | | return ip; |
| | | } |
| | | |
| | | public void setIp(String ip) { |
| | | this.ip = ip; |
| | | } |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <meta name="viewport" |
| | | content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> |
| | | <title>禁止上传口令区域</title> |
| | | <link rel="stylesheet" type="text/css" href="layui/css/layui.css" /> |
| | | <style> |
| | | body { |
| | | padding: 10px; |
| | | } |
| | | |
| | | input { |
| | | width: 200px !important; |
| | | } |
| | | </style> |
| | | </head> |
| | | |
| | | <body> |
| | | |
| | | <form class="layui-form" lay-filter="edit"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">区域</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="citys" required |
| | | placeholder="请输入城市" autocomplete="off" class="layui-input"> |
| | | <div class="layui-form-mid layui-word-aux layui-font-red">精确到市,多个区域用英文逗号分割,如: 广州,南宁</div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-input-block"> |
| | | <button class="layui-btn layui-btn-normal" lay-submit lay-filter="sure" id="sure">确定</button> |
| | | </div> |
| | | </form> |
| | | <script src="layui/layui.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="js/http_api.js"></script> |
| | | <script> |
| | | layui.use(['form', 'layedit', 'laydate'], function() { |
| | | var form = layui.form, |
| | | layer = layui.layer; |
| | | |
| | | |
| | | //自定义验证规则 |
| | | form.verify({ |
| | | num: [/^(\d|,)+$/, "只能包含数字或者英文逗号"] |
| | | }); |
| | | |
| | | let index = layer.load(1); |
| | | |
| | | $.post("/admin/api/settings/getForbiddenSubmitCitys", {}, |
| | | function(response) { |
| | | layer.close(index); |
| | | if (response.code == 0) { |
| | | form.val("edit", response.data); |
| | | } else { |
| | | layer.msg(response.msg); |
| | | } |
| | | }, 'json').fail(function(jqXHR, textStatus, errorThrown) { |
| | | layer.msg("网络请求失败"); |
| | | layer.close(index); |
| | | }); |
| | | |
| | | |
| | | //监听提交 |
| | | form.on('submit(sure)', function(data) { |
| | | var params = data.field; |
| | | |
| | | if(params.alipay_key_verify_state==undefined){ |
| | | params.alipay_key_verify_state = "0"; |
| | | } |
| | | console.log(params); |
| | | $.post("/admin/api/settings/setForbiddenSubmitCitys", params, |
| | | function(response) { |
| | | if (response.code == 0) { |
| | | layer.msg("修改成功"); |
| | | } else { |
| | | layer.msg(response.msg); |
| | | } |
| | | }, 'json').fail(function(jqXHR, textStatus, errorThrown) { |
| | | layer.msg("网络请求失败"); |
| | | }); |
| | | return false; |
| | | }); |
| | | |
| | | }); |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | <dd><a href="javascript:;" data-url="settings_edit.html" data-id='41' data-text="默认参数设置"><span class="l-line"></span>默认参数设置</a></dd> |
| | | <dd><a href="javascript:;" data-url="user-actioncount-limit.html" data-id='42' data-text="限制代付单数"><span class="l-line"></span>限制代付单数</a></dd> |
| | | <dd><a href="javascript:;" data-url="settings_timeout_device.html" data-id='43' data-text="重新支付设备"><span class="l-line"></span>重新支付设备</a></dd> |
| | | <dd><a href="javascript:;" data-url="forbidden_submit_areas.html" data-id='44' data-text="禁止口令提交区域"><span class="l-line"></span>禁止口令提交区域</a></dd> |
| | | </dl> |
| | | </li> |
| | | <li class="layui-nav-item"> |