| | |
| | | <scope>system</scope> |
| | | <systemPath>${project.basedir}/lib/proguard.jar</systemPath> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.httpcomponents</groupId> |
| | | <artifactId>httpmime</artifactId> |
| | | <version>4.5.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-redis</artifactId> |
| | | </dependency> |
| | | <!--引入本地工行支付jar end--> |
| | | </dependencies> |
| | | |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.config; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 项目中需继承此类 |
| | | * |
| | | * @author lihen |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "wx.conf") |
| | | public class WxConfig { |
| | | |
| | | /** |
| | | * 获取 App ID |
| | | * |
| | | * @return App ID |
| | | */ |
| | | @JsonProperty("appId") |
| | | public String appId; |
| | | |
| | | /** |
| | | * 获取 Secret |
| | | * |
| | | * @return Secret |
| | | */ |
| | | @JsonProperty("secret") |
| | | public String secret; |
| | | |
| | | public String getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(String appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getSecret() { |
| | | return secret; |
| | | } |
| | | |
| | | public void setSecret(String secret) { |
| | | this.secret = secret; |
| | | } |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITAgentService; |
| | | import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; |
| | |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITBranchOfficeService tBranchOfficeService; |
| | | @Autowired |
| | | private RedisTemplate<String,String> redisTemplate; |
| | | @Autowired |
| | | private HttpUtils httpUtils; |
| | | @Autowired |
| | | private TokenUtils tokenUtils; |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | @RequestMapping("") |
| | | public String index() { |
| | | return PREFIX + "tDriver.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到佣金首页 |
| | | */ |
| | | @RequestMapping("/commission") |
| | | public String commissionIndex() { |
| | | return PREFIX + "tDriverCommission.html"; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping("/driverDetail") |
| | | public String driverDetail(Integer tDriverId, Model model) { |
| | | tDriverService.detail(tDriverId,model); |
| | | tDriverService.auditPage(tDriverId,model); |
| | | return PREFIX + "tDriverDetail.html"; |
| | | } |
| | | |
| | |
| | | * 跳转区域页面 |
| | | */ |
| | | @RequestMapping("/areaPage") |
| | | public String areaDetail(Model model) { |
| | | public String areaDetail(String area,String areaId,Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("province",tRegions); |
| | | model.addAttribute("provinceList",tRegions); |
| | | List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | // 查询市 |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds)); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | | List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | model.addAttribute("districtList",tRegions2); |
| | | |
| | | if(StringUtils.hasLength(area) && StringUtils.hasLength(areaId)){ |
| | | String[] split = area.split("/"); |
| | | model.addAttribute("provinceName",split[0]); |
| | | model.addAttribute("cityName",split[1]); |
| | | model.addAttribute("districtName",split[2]); |
| | | |
| | | String[] split1 = areaId.split("/"); |
| | | model.addAttribute("provinceId",split1[0]); |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | } |
| | | return PREFIX + "tDriverArea.html"; |
| | | } |
| | | |
| | |
| | | @ResponseBody |
| | | public Object list(String createTime,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.ne("isException",2); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | } |
| | | /** |
| | | * 获取佣金列表 |
| | | */ |
| | | @RequestMapping(value = "/commission/list") |
| | | @ResponseBody |
| | | public Object commissionList(String name,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status); |
| | | wrapper.ne("isException",2); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | |
| | | @ResponseBody |
| | | public Object listBack(String condition) { |
| | | return tDriverService.selectList(null); |
| | | } |
| | | /** |
| | | * ocr |
| | | */ |
| | | @RequestMapping(value = "/ocr") |
| | | @ResponseBody |
| | | public Object ocr(String imgUrl) { |
| | | /*String accessToken = redisTemplate.opsForValue().get(TokenUtils.ACCESS_TOKEN_CACHE_KEY); |
| | | if (!StringUtils.hasLength(accessToken)) { |
| | | accessToken = tokenUtils.getSimpleAccessToken(); |
| | | } |
| | | File file = new File(imgUrl); |
| | | String url = Constant.OCR_URL.replace("MODE", "scan").replace("ACCESS_TOKEN", accessToken); |
| | | String result = httpUtils.registRequest(url, file); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | System.err.println(jsonObject); |
| | | return jsonObject;*/ |
| | | return tDriverService.ocr(imgUrl); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(count>0){ |
| | | return "该司机已存在!"; |
| | | } |
| | | |
| | | // 对省市区做处理 |
| | | String[] split = tDriver.getAreaId().split("/"); |
| | | // 查询省市 |
| | | // 黑龙江省/大兴安岭地区 |
| | | // 702/852 |
| | | TRegion province = tRegionService.selectById(split[0]); |
| | | tDriver.setProvinceName(province.getName()); |
| | | tDriver.setProvinceCode(province.getCode()); |
| | | |
| | | TRegion city = tRegionService.selectById(split[1]); |
| | | tDriver.setCityName(city.getName()); |
| | | tDriver.setCityCode(city.getCode()); |
| | | |
| | | TRegion area = tRegionService.selectById(split[2]); |
| | | tDriver.setAreaName(area.getName()); |
| | | tDriver.setAreaCode(area.getCode()); |
| | | |
| | | tDriver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tDriver.setBalance(BigDecimal.ZERO); |
| | | tDriver.setBackgroundBalance(BigDecimal.ZERO); |
| | | |
| | | // 通过省市查询代理商 |
| | | TAgent tAgent = tAgentService.selectOne(new EntityWrapper<TAgent>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tAgent)){ |
| | | tDriver.setAgentId(tAgent.getId()); |
| | | } |
| | | // 查询邀约人(司机端) |
| | | TDriver emergencyDriver = tDriverService.selectOne(new EntityWrapper<TDriver>().eq("phone", tDriver.getEmergencyPhone()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(emergencyDriver)){ |
| | | tDriver.setInviterId(emergencyDriver.getId()); |
| | | tDriver.setInviterType(2); |
| | | } |
| | | // 通过省市区查询分公司 |
| | | TBranchOffice tBranchOffice = tBranchOfficeService.selectOne(new EntityWrapper<TBranchOffice>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .eq("districtCode", area.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tBranchOffice)){ |
| | | tDriver.setBranchOfficeId(tBranchOffice.getId()); |
| | | } |
| | | |
| | | tDriverService.addOrUpdate(tDriver); |
| | | tDriverService.insert(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TDriver tDriver) { |
| | | // Object ocr = ocr("E:\\071bf986db0b00355c0ed190bbd3b16.png"); |
| | | // System.err.println(ocr); |
| | | tDriverService.addOrUpdate(tDriver); |
| | | tDriverService.updateById(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | @ApiOperation(value = "市区查询",notes="市区查询") |
| | | @RequestMapping(value = "/areaCity") |
| | | @ResponseBody |
| | | public Object areaCity(Integer parentId) { |
| | | return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id",parentId)); |
| | | public Object areaCity(Integer parentId,Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId)); |
| | | model.addAttribute("list",tRegions); |
| | | return tRegions; |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.resp; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 接收accessToken实体 |
| | | */ |
| | | public class AccessTokenRespBody extends RespBody implements Serializable { |
| | | |
| | | /** |
| | | * 获取到的凭证 |
| | | */ |
| | | @JsonProperty("access_token") |
| | | private String accessToken; |
| | | /** |
| | | * 凭证有效时间,单位:秒 |
| | | */ |
| | | @JsonProperty("expires_in") |
| | | private int expiresIn; |
| | | |
| | | public String getAccessToken() { |
| | | return accessToken; |
| | | } |
| | | |
| | | public void setAccessToken(String accessToken) { |
| | | this.accessToken = accessToken; |
| | | } |
| | | |
| | | public int getExpiresIn() { |
| | | return expiresIn; |
| | | } |
| | | |
| | | public void setExpiresIn(int expiresIn) { |
| | | this.expiresIn = expiresIn; |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.resp; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | |
| | | /** |
| | | * @author ck |
| | | * @ClassName RespBody |
| | | * @Description |
| | | * @date 2023-02-23 11:44 |
| | | */ |
| | | public class RespBody { |
| | | @JsonProperty("errcode") |
| | | private Integer errorCode; |
| | | |
| | | @JsonProperty("errmsg") |
| | | private String errorMsg; |
| | | |
| | | public Integer getErrorCode() { |
| | | return errorCode; |
| | | } |
| | | |
| | | public void setErrorCode(Integer errorCode) { |
| | | this.errorCode = errorCode; |
| | | } |
| | | |
| | | public String getErrorMsg() { |
| | | return errorMsg; |
| | | } |
| | | |
| | | public void setErrorMsg(String errorMsg) { |
| | | this.errorMsg = errorMsg; |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.util; |
| | | |
| | | public class Constant { |
| | | |
| | | /** |
| | | * OCR识别地址 |
| | | */ |
| | | public static final String OCR_URL = "https://api.weixin.qq.com/cv/ocr/driving?type=MODE&access_token=ACCESS_TOKEN"; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | * 属性 类型 默认值 必填 说明 |
| | | * grant_type string 是 填写 client_credential |
| | | * appid string 是 小程序唯一凭证,即 AppID,可在「微信公众平台 - 设置 - 开发设置」页中获得。(需要已经成为开发者,且帐号没有异常状态) |
| | | * secret string 是 小程序唯一凭证密钥,即 AppSecret,获取方式同 appid |
| | | * 返回值 |
| | | * Object |
| | | * 返回的 JSON 数据包 |
| | | * <p> |
| | | * 属性 类型 说明 |
| | | * access_token string 获取到的凭证 |
| | | * expires_in number 凭证有效时间,单位:秒。目前是7200秒之内的值。 |
| | | * errcode number 错误码 |
| | | * errmsg string 错误信息 |
| | | */ |
| | | public static String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}"; |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.util; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import org.apache.http.Consts; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.HttpStatus; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.methods.HttpUriRequest; |
| | | import org.apache.http.client.protocol.HttpClientContext; |
| | | import org.apache.http.conn.ConnectTimeoutException; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.entity.mime.MultipartEntityBuilder; |
| | | import org.apache.http.entity.mime.content.FileBody; |
| | | import org.apache.http.entity.mime.content.StringBody; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.*; |
| | | import java.net.SocketTimeoutException; |
| | | import java.net.URI; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class HttpUtils { |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | private final static String KEY = "5cc9622f299335639dbc046f3812c52a"; |
| | | |
| | | //请求超时时间 |
| | | private final static Integer TIME_OUT = 1000; |
| | | //http连接池 |
| | | private static volatile PoolingHttpClientConnectionManager poolingHttpClientConnectionManager; |
| | | //请求配置 |
| | | private static RequestConfig requestConfig; |
| | | |
| | | public static PoolingHttpClientConnectionManager getPoolingHttpClientConnectionManager() { |
| | | if (poolingHttpClientConnectionManager == null) { |
| | | synchronized (HttpUtils.class) { |
| | | if (poolingHttpClientConnectionManager == null) { |
| | | poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(); |
| | | //连接池最大连接数 |
| | | poolingHttpClientConnectionManager.setMaxTotal(1024); |
| | | //每个路由最大连接数 |
| | | poolingHttpClientConnectionManager.setDefaultMaxPerRoute(32); |
| | | |
| | | //配置请求的超时设置 |
| | | requestConfig = |
| | | RequestConfig.custom().setConnectionRequestTimeout(TIME_OUT).setConnectTimeout(TIME_OUT).setSocketTimeout(TIME_OUT).build(); |
| | | } |
| | | } |
| | | } |
| | | return poolingHttpClientConnectionManager; |
| | | } |
| | | |
| | | public static CloseableHttpClient getHttpClient() { |
| | | return HttpClients.custom().setConnectionManager(getPoolingHttpClientConnectionManager()).setDefaultRequestConfig(requestConfig).build(); |
| | | } |
| | | |
| | | /** |
| | | * 请求发送执行 |
| | | * |
| | | * @param httpMethd |
| | | * @return |
| | | */ |
| | | public String registRequest(HttpUriRequest httpMethd) { |
| | | CloseableHttpClient httpClient = getHttpClient(); |
| | | CloseableHttpResponse httpResponse = null; |
| | | try { |
| | | httpResponse = httpClient.execute(httpMethd, HttpClientContext.create()); |
| | | int statusCode = httpResponse.getStatusLine().getStatusCode(); |
| | | if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { |
| | | log.error("响应失败 statusCode {}", statusCode); |
| | | httpMethd.abort(); |
| | | } |
| | | log.debug("响应成功 statusCode {}", statusCode); |
| | | String response = EntityUtils.toString(httpResponse.getEntity(), Consts.UTF_8); |
| | | log.debug("响应成功 response {}", response); |
| | | return response; |
| | | } catch (ConnectTimeoutException e) { |
| | | throw new RuntimeException("接口超时"); |
| | | } catch (SocketTimeoutException e) { |
| | | throw new RuntimeException("读取接口数据超时"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("接口请求失败,请尝试检查网络环境或请求接口是否能正常访问"); |
| | | } finally { |
| | | // 关闭响应 |
| | | try { |
| | | if (httpResponse != null) { |
| | | httpResponse.close(); |
| | | } |
| | | // 关闭连接 |
| | | //httpClient.close(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("关闭流异常:IOException"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 请求发送执行 |
| | | * |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public String registRequest(String url, File file) { |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | CloseableHttpResponse httpResponse = null; |
| | | try { |
| | | HttpPost httpPost = new HttpPost(url); |
| | | RequestConfig requestConfig = RequestConfig.custom() |
| | | .setSocketTimeout(10000) |
| | | .setConnectTimeout(5000) |
| | | .build(); |
| | | httpPost.setConfig(requestConfig); |
| | | HttpEntity entity = MultipartEntityBuilder.create().addPart("img", new FileBody(file)).build(); |
| | | httpPost.setEntity(entity); |
| | | httpResponse = httpClient.execute(httpPost); |
| | | int statusCode = httpResponse.getStatusLine().getStatusCode(); |
| | | if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { |
| | | log.error("响应失败 statusCode {}", statusCode); |
| | | httpPost.abort(); |
| | | } |
| | | log.debug("响应成功 statusCode {}", statusCode); |
| | | String response = EntityUtils.toString(httpResponse.getEntity(), Consts.UTF_8); |
| | | log.debug("响应成功 response {}", response); |
| | | return response; |
| | | } catch (ConnectTimeoutException e) { |
| | | throw new RuntimeException("接口超时"); |
| | | } catch (SocketTimeoutException e) { |
| | | throw new RuntimeException("读取接口数据超时"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("接口请求失败,请尝试检查网络环境或请求接口是否能正常访问"); |
| | | } finally { |
| | | // 关闭响应 |
| | | try { |
| | | if (httpResponse != null) { |
| | | httpResponse.close(); |
| | | } |
| | | // 关闭连接 |
| | | httpClient.close(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("关闭流异常:IOException"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param type |
| | | * @param file |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public String ocr(String type, File file){ |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | CloseableHttpResponse response = null; |
| | | String result = null; |
| | | // HttpClient请求的相关设置,可以不用配置,用默认的参数,这里设置连接和超时时长(毫秒) |
| | | RequestConfig config = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).build(); |
| | | try { |
| | | HttpPost httppost = new HttpPost("http://v.juhe.cn/certificates/query"); |
| | | // FileBody封装File类型的参数 |
| | | FileBody bin = new FileBody(file); |
| | | // StringBody封装String类型的参数 |
| | | StringBody keyBody = new StringBody(KEY, ContentType.TEXT_PLAIN); |
| | | StringBody typeBody = new StringBody(type, ContentType.TEXT_PLAIN); |
| | | // addPart将参数传入,并指定参数名称 |
| | | HttpEntity reqEntity = MultipartEntityBuilder.create() |
| | | .addPart("pic", bin).addPart("key", keyBody) |
| | | .addPart("cardType", typeBody).build(); |
| | | httppost.setEntity(reqEntity); |
| | | httppost.setConfig(config); |
| | | // 执行网络请求并返回结果 |
| | | response = httpClient.execute(httppost); |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = ConvertStreamToString(resEntity.getContent(), "UTF-8"); |
| | | } |
| | | EntityUtils.consume(resEntity); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("接口请求失败,请尝试检查网络环境或请求接口是否能正常访问"+":"+e); |
| | | } finally { |
| | | try { |
| | | response.close(); |
| | | httpClient.close(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("流关闭失败!"+":"+e); |
| | | } |
| | | } |
| | | // 得到的是JSON类型的数据需要第三方解析JSON的jar包来解析 |
| | | return result; |
| | | } |
| | | |
| | | // 此方法是把传进的字节流转化为相应的字符串并返回,此方法一般在网络请求中用到 |
| | | public static String ConvertStreamToString(InputStream is, String charset) |
| | | throws Exception { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try (InputStreamReader inputStreamReader = new InputStreamReader(is,charset)) { |
| | | try (BufferedReader reader = new BufferedReader(inputStreamReader)) { |
| | | String line = null; |
| | | while ((line = reader.readLine()) != null) { |
| | | sb.append(line).append("\r\n"); |
| | | } |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public List<BasicNameValuePair> toPairs(Map<String, Object> params) { |
| | | List<BasicNameValuePair> pairs = Lists.newArrayList(); |
| | | if (params != null && !params.isEmpty()) { |
| | | pairs = params.entrySet().stream().map(entry -> new BasicNameValuePair(entry.getKey(), |
| | | entry.getValue().toString())).collect(Collectors.toList()); |
| | | } |
| | | return pairs; |
| | | } |
| | | |
| | | /** |
| | | * get url请求 |
| | | * |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public String get(String url) { |
| | | HttpGet request = new HttpGet(); |
| | | try { |
| | | request.setURI(new URI(url)); |
| | | return registRequest(request); |
| | | } catch (Exception e) { |
| | | log.error("请求失败", e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * PSOT URL方式提交 |
| | | * |
| | | * @param url 请求url |
| | | * @param params 请求参数 |
| | | * @return |
| | | */ |
| | | public String postFromUrl(String url, Map<String, Object> params) { |
| | | HttpPost request = new HttpPost(url); |
| | | RequestConfig requestConfig = RequestConfig.custom() |
| | | .setSocketTimeout(10000) |
| | | .setConnectTimeout(5000) |
| | | .build(); |
| | | request.setConfig(requestConfig); |
| | | request.setEntity(new UrlEncodedFormEntity(toPairs(params), Consts.UTF_8)); |
| | | return registRequest(request); |
| | | } |
| | | |
| | | /** |
| | | * PSOT JSON方式提交 |
| | | * |
| | | * @param url 请求url |
| | | * @param params json串 |
| | | * @return |
| | | */ |
| | | public String postFromJson(String url, String params) { |
| | | HttpPost request = new HttpPost(url); |
| | | request.setHeader("Content-type", "application/json"); |
| | | request.setHeader("Accept", "application/json"); |
| | | RequestConfig requestConfig = RequestConfig.custom() |
| | | .setSocketTimeout(8000) |
| | | .setConnectTimeout(6000) |
| | | .build(); |
| | | request.setConfig(requestConfig); |
| | | StringEntity entity = new StringEntity(params, StandardCharsets.UTF_8); |
| | | entity.setContentType("application/json"); |
| | | request.setEntity(entity); |
| | | try { |
| | | return registRequest(request); |
| | | } catch (Exception e) { |
| | | log.error("请求失败", e); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.util; |
| | | |
| | | import com.stylefeng.guns.modular.system.config.WxConfig; |
| | | import com.stylefeng.guns.modular.system.controller.resp.AccessTokenRespBody; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author xiaochen |
| | | * @Date 2021/11/5/00519:26 |
| | | */ |
| | | @Component |
| | | public class TokenUtils { |
| | | public final static String ACCESS_TOKEN_CACHE_KEY = "accessToken"; |
| | | @Autowired |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | @Autowired |
| | | private WxConfig wxConfig; |
| | | @Autowired |
| | | private RestTemplate wxRestTemplate; |
| | | @Autowired |
| | | private WxJsonUtils wxJsonUtils; |
| | | // @Autowired |
| | | // private RedisUtils redisUtils; |
| | | |
| | | /** |
| | | * @return |
| | | */ |
| | | public String getSimpleAccessToken() { |
| | | String accessToken = redisTemplate.opsForValue().get(ACCESS_TOKEN_CACHE_KEY); |
| | | if (StringUtils.hasLength(accessToken)) { |
| | | return accessToken; |
| | | } |
| | | String requestUrl = MessageFormat.format(Constant.ACCESS_TOKEN_URL, wxConfig.getAppId(), wxConfig.getSecret()); |
| | | String respBody = wxRestTemplate.getForEntity(requestUrl, String.class).getBody(); |
| | | AccessTokenRespBody accessTokenRespBody = wxJsonUtils.parseObject(respBody, AccessTokenRespBody.class); |
| | | // 判断有误异常 |
| | | if (StringUtils.hasLength(accessTokenRespBody.getErrorMsg())) { |
| | | // 抛出错误 |
| | | throw new RuntimeException(accessTokenRespBody.getErrorCode() + ":" + accessTokenRespBody.getErrorMsg()); |
| | | } |
| | | redisTemplate.opsForValue().set(ACCESS_TOKEN_CACHE_KEY, accessTokenRespBody.getAccessToken(), 2, TimeUnit.HOURS); |
| | | return accessTokenRespBody.getAccessToken(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.util; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.JsonSerializer; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
| | | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | @Component |
| | | public final class WxJsonUtils { |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | public static final String dateFormat = "yyyy-MM-dd"; |
| | | public static final String dateTimeFormat = "yyyy-MM-dd HH:mm:ss"; |
| | | private static final ObjectMapper OM = new ObjectMapper(); |
| | | private static final JavaTimeModule timeModule = new JavaTimeModule(); |
| | | |
| | | /** |
| | | * 转换LocalDateTime |
| | | */ |
| | | static class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> { |
| | | @Override |
| | | public void serialize(LocalDateTime localDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { |
| | | jsonGenerator.writeString(localDateTime.format(DateTimeFormatter.ofPattern(dateTimeFormat))); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换LocalDate |
| | | */ |
| | | static class LocalDateSerializer extends JsonSerializer<LocalDate> { |
| | | @Override |
| | | public void serialize(LocalDate localDate, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { |
| | | jsonGenerator.writeString(localDate.format(DateTimeFormatter.ofPattern(dateFormat))); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置 ObjectMapper |
| | | * |
| | | * @return |
| | | */ |
| | | private ObjectMapper getObjectMapper() { |
| | | // 序列化 |
| | | timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer()); |
| | | timeModule.addSerializer(LocalDate.class, new LocalDateSerializer()); |
| | | // 反序列化 |
| | | timeModule.addDeserializer(LocalDateTime.class, |
| | | new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat))); |
| | | timeModule.addDeserializer(LocalDate.class, |
| | | new LocalDateDeserializer(DateTimeFormatter.ofPattern(dateFormat))); |
| | | // 允许对象忽略json中不存在的属性 |
| | | OM.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | OM.registerModule(timeModule); |
| | | return OM; |
| | | } |
| | | |
| | | /** |
| | | * 将对象序列化 |
| | | */ |
| | | public <T> String toJsonString(T obj) { |
| | | try { |
| | | ObjectMapper om = getObjectMapper(); |
| | | return om.writeValueAsString(obj); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("转json字符串失败:{}", obj); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 反序列化对象字符串 |
| | | */ |
| | | public <T> T parseObject(String json, Class<T> clazz) { |
| | | try { |
| | | ObjectMapper om = getObjectMapper(); |
| | | return om.readValue(json, clazz); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("反序列化对象字符串失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 反序列化字符串成为对象 |
| | | */ |
| | | public <T> T parseObject(String json, TypeReference<T> valueTypeRef) { |
| | | try { |
| | | ObjectMapper om = getObjectMapper(); |
| | | return om.readValue(json, valueTypeRef); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("反序列化字符串成为对象失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | private Integer integral; |
| | | /** |
| | | * 剩余积分 |
| | | */ |
| | | private Double score; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | private Integer status; |
| | |
| | | |
| | | @ApiModelProperty(value = "驾驶证初次领证时间") |
| | | private Date firstCertificateTime; |
| | | @ApiModelProperty(value = "佣金") |
| | | private BigDecimal commission; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "区域") |
| | |
| | | @ApiModelProperty(value = "区域id") |
| | | private String areaId; |
| | | |
| | | public BigDecimal getCommission() { |
| | | return commission; |
| | | } |
| | | |
| | | public void setCommission(BigDecimal commission) { |
| | | this.commission = commission; |
| | | } |
| | | |
| | | public Double getScore() { |
| | | return score; |
| | | } |
| | | |
| | | public void setScore(Double score) { |
| | | this.score = score; |
| | | } |
| | | |
| | | public String getArea() { |
| | | return area; |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | |
| | | void auditPage(Integer id, Model model); |
| | | |
| | | /** |
| | | * 跳转详情页面 |
| | | * @param tDriverId |
| | | * @param model |
| | | * 聚合ocr识别 |
| | | * @param imgUrl |
| | | * @return |
| | | */ |
| | | void detail(Integer tDriverId, Model model); |
| | | JSONObject ocr(String imgUrl); |
| | | |
| | | /** |
| | | * 新增修改处理数据 |
| | | * @param tDriver |
| | | */ |
| | | void addOrUpdate(TDriver tDriver); |
| | | |
| | | /** |
| | | * 查询佣金列表 |
| | | * @param name |
| | | * @param phone |
| | | * @param status |
| | | * @return |
| | | */ |
| | | EntityWrapper<TDriver> getCommissionPageList(String name, String phone, Integer status); |
| | | |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.HttpUtils; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.enums.OrderStateEnum; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Autowired |
| | | private TOrderRefusalMapper tOrderRefusalMapper; |
| | | @Autowired |
| | | private TRegionMapper tRegionMapper; |
| | | @Autowired |
| | | private ITRegionService itRegionService; |
| | | @Autowired |
| | | private HttpUtils httpUtils; |
| | | |
| | | @Override |
| | | public EntityWrapper<TDriver> getPageList(String createTime, String phone, Integer status) { |
| | |
| | | model.addAttribute("id",tDriver.getId()); |
| | | model.addAttribute("code",tDriver.getCode()); |
| | | model.addAttribute("name",tDriver.getName()); |
| | | model.addAttribute("avatar",tDriver.getAvatar()); |
| | | model.addAttribute("phone",tDriver.getPhone()); |
| | | model.addAttribute("sex",tDriver.getSex()); |
| | | model.addAttribute("driverLicenseNumber",tDriver.getDriverLicenseNumber()); |
| | |
| | | model.addAttribute("provinceName",tDriver.getProvinceName()); |
| | | model.addAttribute("cityName",tDriver.getCityName()); |
| | | model.addAttribute("areaName",tDriver.getAreaName()); |
| | | model.addAttribute("integral",tDriver.getIntegral()); |
| | | model.addAttribute("score",tDriver.getScore()); |
| | | model.addAttribute("createTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tDriver.getCreateTime())); |
| | | |
| | | // 计算驾龄 |
| | |
| | | |
| | | String monthDate = new SimpleDateFormat("yyyyMM").format(new Date()); |
| | | |
| | | // 设置余额 |
| | | tDriver.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance())); |
| | | if(Objects.nonNull(tDriver.getBackgroundBalance()) && Objects.nonNull(tDriver.getBalance())){ |
| | | // 设置余额 |
| | | tDriver.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance())); |
| | | model.addAttribute("balance",tDriver.getBalance()); |
| | | }else { |
| | | model.addAttribute("balance",BigDecimal.ZERO); |
| | | } |
| | | |
| | | // 所属代理商 |
| | | TAgent tAgent = tAgentMapper.selectById(tDriver.getAgentId()); |
| | |
| | | model.addAttribute("inviterPhone",""); |
| | | } |
| | | |
| | | // 查询当前用户邀请了哪些人 |
| | | List<TDriver> list = tDriverMapper.selectList(new EntityWrapper<TDriver>().eq("inviterId", tDriver.getId())); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | model.addAttribute("inviterCount",list.size()); |
| | | model.addAttribute("inviterCommission",0); |
| | | }else { |
| | | model.addAttribute("inviterCommission",0); |
| | | model.addAttribute("inviterCount",0); |
| | | } |
| | | |
| | | if(!CollectionUtils.isEmpty(tOrders)){ |
| | | //累计订单量 |
| | | List<TOrder> cumulativeOrderCount = tOrders.stream().filter(order -> order.getDriverId().equals(tDriver.getId()) |
| | |
| | | // 拒单次数 |
| | | List<TOrderRefusal> driverRefusalList = tOrderRefusalMapper.selectList(new EntityWrapper<TOrderRefusal>().eq("driver_id", tDriver.getId())); |
| | | model.addAttribute("refusalCount",driverRefusalList.size()); |
| | | // todo 累计收入 |
| | | model.addAttribute("cumulativeIncome",0); |
| | | }else { |
| | | model.addAttribute("cumulativeOrderCount",""); |
| | | model.addAttribute("monthOrderCount",""); |
| | | model.addAttribute("refusalCount",""); |
| | | model.addAttribute("cumulativeOrderCount",0); |
| | | model.addAttribute("monthOrderCount",0); |
| | | model.addAttribute("refusalCount",0); |
| | | // 累计收入 |
| | | model.addAttribute("cumulativeIncome",0); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void detail(Integer tDriverId, Model model) { |
| | | auditPage(tDriverId,model); |
| | | // TODO 查询司机 |
| | | TDriver tDriver = tDriverMapper.selectById(tDriverId); |
| | | public JSONObject ocr(String imgUrl) { |
| | | File file = new File(imgUrl); |
| | | String result = httpUtils.ocr("2", file); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | return jsonObject; |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdate(TDriver tDriver) { |
| | | // 对省市区做处理 |
| | | String[] split = tDriver.getAreaId().split("/"); |
| | | // 查询省市 |
| | | // 黑龙江省/大兴安岭地区 |
| | | // 702/852 |
| | | TRegion province = tRegionMapper.selectById(split[0]); |
| | | tDriver.setProvinceName(province.getName()); |
| | | tDriver.setProvinceCode(province.getCode()); |
| | | |
| | | TRegion city = tRegionMapper.selectById(split[1]); |
| | | if(Objects.isNull(city)){ |
| | | city = itRegionService.selectOne(new EntityWrapper<TRegion>().eq("name",split[1])); |
| | | } |
| | | tDriver.setCityName(city.getName()); |
| | | tDriver.setCityCode(city.getCode()); |
| | | |
| | | TRegion area = tRegionMapper.selectById(split[2]); |
| | | if(Objects.isNull(area)){ |
| | | area = itRegionService.selectOne(new EntityWrapper<TRegion>().eq("name",split[2])); |
| | | } |
| | | tDriver.setAreaName(area.getName()); |
| | | tDriver.setAreaCode(area.getCode()); |
| | | |
| | | tDriver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tDriver.setBalance(BigDecimal.ZERO); |
| | | tDriver.setBackgroundBalance(BigDecimal.ZERO); |
| | | |
| | | // 通过省市查询代理商 |
| | | List<TAgent> tAgent = tAgentMapper.selectList(new EntityWrapper<TAgent>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(!CollectionUtils.isEmpty(tAgent)){ |
| | | tDriver.setAgentId(tAgent.get(0).getId()); |
| | | } |
| | | // 查询邀约人(司机端) |
| | | List<TDriver> emergencyDriver = tDriverMapper.selectList(new EntityWrapper<TDriver>().eq("phone", tDriver.getEmergencyPhone()) |
| | | .last("LIMIT 1")); |
| | | if(!CollectionUtils.isEmpty(emergencyDriver)){ |
| | | tDriver.setInviterId(emergencyDriver.get(0).getId()); |
| | | tDriver.setInviterType(2); |
| | | } |
| | | // 通过省市区查询分公司 |
| | | List<TBranchOffice> tBranchOffice = tBranchOfficeMapper.selectList(new EntityWrapper<TBranchOffice>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .eq("districtCode", area.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(!CollectionUtils.isEmpty(tBranchOffice)){ |
| | | tDriver.setBranchOfficeId(tBranchOffice.get(0).getId()); |
| | | } |
| | | |
| | | // ocr识别 |
| | | // JSONObject ocr = this.ocr("E:\\071bf986db0b00355c0ed190bbd3b16.png"); |
| | | // System.err.println(ocr); |
| | | } |
| | | |
| | | @Override |
| | | public EntityWrapper<TDriver> getCommissionPageList(String name, String phone, Integer status) { |
| | | EntityWrapper<TDriver> wrapper = new EntityWrapper<>(); |
| | | // 手机号 |
| | | if(StringUtils.hasLength(phone)){ |
| | | wrapper.like("phone",phone); |
| | | } |
| | | // 状态 |
| | | if(Objects.nonNull(status)){ |
| | | wrapper.eq("status",status); |
| | | } |
| | | // 姓名 |
| | | if(StringUtils.hasLength(name)){ |
| | | wrapper.like("name",name); |
| | | } |
| | | wrapper.orderBy(true,"approvalStatus"); |
| | | return wrapper; |
| | | } |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: local |
| | | datasource: |
| | | url: jdbc:mysql://192.168.0.80:3306/super_save_driving?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |
| | | db-name: super_save_driving #用来搜集数据库的所有表 |
| | | filters: wall,mergeStat |
| | | # datasource: |
| | | # url: jdbc:mysql://192.168.0.80:3306/super_save_driving?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8 |
| | | # username: root |
| | | # password: 123456 |
| | | # db-name: super_save_driving #用来搜集数据库的所有表 |
| | | # filters: wall,mergeStat |
| | | mvc: |
| | | static-path-pattern: /static/** |
| | | view: |
| | |
| | | multipart: |
| | | max-request-size: 100MB |
| | | max-file-size: 100MB |
| | | redis: |
| | | #测试环境 |
| | | host: 127.0.0.1 |
| | | port: 6379 |
| | | timeout: 5000 |
| | | database: 10 |
| | | |
| | | mybatis-plus: |
| | | type-aliases-package: com.stylefeng.guns.modular.system.model |
| | |
| | | configuration: |
| | | configuration.map-underscore-to-camel-case: true #是否开启自动驼峰命名规则(camel case)映射 |
| | | log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #输出Sql,如需打印Sql注释该配置 |
| | | |
| | | |
| | | wx: |
| | | conf: |
| | | appId: wx3613e8d4c8624ea1 |
| | | secret: 25782eabe39e796a92d2fcb38947e7dc |
| | | |
| | | #eureka: |
| | | # client: |
| | |
| | | <div class="ibox-content"> |
| | | <div class="row row-lg"> |
| | | <div class="col-sm-12" style="height: 100px;"> |
| | | <input hidden id="provinceName" value="${provinceName}"> |
| | | <input hidden id="cityName" value="${cityName}"> |
| | | <input hidden id="districtName" value="${districtName}"> |
| | | <input hidden id="provinceId" value="${provinceId}"> |
| | | <input hidden id="cityId" value="${cityId}"> |
| | | <input hidden id="districtId" value="${districtId}"> |
| | | |
| | | <div class="col-sm-4 control-label"> |
| | | <label class="col-sm-1" style="width: 20px;">省:</label> |
| | | <select class="input-group col-sm-2 " onclick="TDriver.areaCity()" id="province" style="width: 200px;height: 33px" name="province"> |
| | | <option value="">请选择省</option> |
| | | @for(i in province){ |
| | | <option id="${i.id}" value="${i.name}">${i.name}</option> |
| | | @for(i in provinceList){ |
| | | <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option> |
| | | @} |
| | | </select> |
| | | </div> |
| | | <div class="col-sm-4 control-label"> |
| | | <label class="col-sm-1" style="width: 20px;">市:</label> |
| | | <select class="input-group col-sm-2" onclick="TDriver.areaDistrict()" id="city" style="width: 200px;height: 33px" name="city"> |
| | | <option value="">请选择市</option> |
| | | <option>请选择市</option> |
| | | @for(city in cityList){ |
| | | <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option> |
| | | @} |
| | | </select> |
| | | </div> |
| | | <div class="col-sm-4 control-label"> |
| | | <label class="col-sm-1" style="width: 20px;">区:</label> |
| | | <select class="input-group col-sm-2" id="district" style="width: 200px;height: 33px" name="district"> |
| | | <option value="">请选择区</option> |
| | | <option>请选择区</option> |
| | | @for(district in districtList){ |
| | | <option id="${district.id}" value="${district.name}"${district.name == districtName ? 'selected=selected' : ''}>${district.name}</option> |
| | | @} |
| | | </select> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | <script src="${ctxPath}/static/modular/system/tDriver/tDriver.js"></script> |
| | | <script src="${ctxPath}/static/modular/system/tDriver/tDriver_info.js"></script> |
| | | <script type="text/javascript"> |
| | | </script> |
| | | @} |
| | |
| | | </div> |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label">头像:</label> |
| | | <img src="https://lmg.jj20.com/up/allimg/1114/040221103339/210402103339-7-1200.jpg" /> |
| | | <img src="${avatar}" style="height: 100px;width: 100px"/> |
| | | </div> |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label">紧急联系人:</label> |
| | |
| | | <div class="initialLevel col-sm-12 control-label form-group" > |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >驾驶证照片:</label> |
| | | <img src="https://lmg.jj20.com/up/allimg/1114/040221103339/210402103339-7-1200.jpg" /> |
| | | <img src="${driverLicense}" style="height: 100px;width: 100px"/> |
| | | </div> |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label">身份证照片:</label> |
| | | <img src="https://lmg.jj20.com/up/allimg/1114/040221103339/210402103339-7-1200.jpg" /> |
| | | <img src="${idcardFront}" style="height: 100px;width: 100px"/> |
| | | </div> |
| | | </div> |
| | | |
New file |
| | |
| | | @layout("/common/_container.html"){ |
| | | <div class="row"> |
| | | <div class="col-sm-12"> |
| | | <div class="ibox float-e-margins"> |
| | | <div class="ibox-title"> |
| | | <h5>管理</h5> |
| | | </div> |
| | | <div class="ibox-content"> |
| | | <div class="row row-lg"> |
| | | <div class="col-sm-12"> |
| | | <div class="row"> |
| | | <div class="col-sm-3"> |
| | | <#NameCon id="phone" name="手机号" /> |
| | | </div> |
| | | <div class="col-sm-3"> |
| | | <#NameCon id="name" name="司机姓名" /> |
| | | </div> |
| | | <div class="col-sm-1"> |
| | | <select class="input-group" id="status" style="width: 80px;height: 33px" name="status"> |
| | | <option value="">状态</option> |
| | | <option value="1">正常</option> |
| | | <option value="2">冻结</option> |
| | | </select> |
| | | </div> |
| | | <div class="col-sm-3"> |
| | | <#button name="搜索" icon="fa-search" clickFun="TDriverCommission.search()"/> |
| | | <#button name="重置" icon="fa-trash" clickFun="TDriverCommission.resetSearch()" space="true"/> |
| | | </div> |
| | | <div class="col-sm-3"> |
| | | <button type="button" class="btn btn-primary " onclick="TDriverCommission.export()" id="export"> |
| | | <i class="fa "></i> 导出 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | <!--<div class="hidden-xs" id="TDriverTableToolbar" role="group"> |
| | | @if(shiro.hasPermission("/tDriver/add")){ |
| | | <#button name="添加" icon="fa-plus" clickFun="TDriver.openAddTDriver()"/> |
| | | @} |
| | | @if(shiro.hasPermission("/tDriver/update")){ |
| | | <#button name="修改" icon="fa-edit" clickFun="TDriver.openTDriverDetail()" space="true"/> |
| | | @} |
| | | @if(shiro.hasPermission("/tDriver/delete")){ |
| | | <#button name="删除" icon="fa-remove" clickFun="TDriver.delete()" space="true"/> |
| | | @} |
| | | </div>--> |
| | | <#table id="TDriverCommissionTable"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <script src="${ctxPath}/static/modular/system/tDriver/tDriverCommission.js"></script> |
| | | <script type="text/javascript"> |
| | | laydate.render({ |
| | | elem: '#createTime', |
| | | type: 'date', |
| | | range: true |
| | | }); |
| | | </script> |
| | | @} |
| | |
| | | <div class="initialLevel col-sm-12 control-label form-group" > |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >身份证正面照:</label> |
| | | <img id="" src="${idcardFront}" style="height: 100px;width: 100px"/> |
| | | <img src="${idcardFront}" style="height: 100px;width: 100px"/> |
| | | </div> |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label">身份证背面照:</label> |
| | |
| | | <div class="initialLevel col-sm-12 control-label form-group" > |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label" >累计订单:</label> |
| | | <label>${name}</label> |
| | | <label>${cumulativeOrderCount}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >邀约用户人数:</label> |
| | | <label>${idcard}</label> |
| | | <label>${inviterCount}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >累计获得佣金:</label> |
| | | <label>${idcard}</label> |
| | | <label>${inviterCommission}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label" >当前积分:</label> |
| | | <label>${idcard}</label> |
| | | <label>${integral}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label" >代驾次数:</label> |
| | | <label>${idcard}</label> |
| | | <label>${cumulativeOrderCount}</label> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="initialLevel col-sm-12 control-label form-group" > |
| | | <div class="initialLevel col-sm-2 control-label form-group" > |
| | | <label class="control-label" >累计获得收入:</label> |
| | | <label>${name}</label> |
| | | <label>${cumulativeIncome}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >钱包余额:</label> |
| | | <label>${idcard}</label> |
| | | <label>${balance}</label> |
| | | </div> |
| | | <div class="initialLevel col-sm-3 control-label form-group" > |
| | | <label class="control-label" >评论分数:</label> |
| | | <label>${idcard}</label> |
| | | <label>${score}</label> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | * 打开区域选择页面 |
| | | */ |
| | | TDriver.area = function () { |
| | | |
| | | var area = $("#area").val(); |
| | | var areaId = $("#areaId").val(); |
| | | |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '区域选择', |
| | | area: ['1000px', '270px'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/areaPage' |
| | | content: Feng.ctxPath + '/tDriver/areaPage?area='+area+'&areaId='+areaId |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
New file |
| | |
| | | /** |
| | | * 管理初始化 |
| | | */ |
| | | var TDriverCommission = { |
| | | id: "TDriverCommissionTable", //表格id |
| | | seItem: null, //选中的条目 |
| | | table: null, |
| | | layerIndex: -1 |
| | | }; |
| | | |
| | | /** |
| | | * 初始化表格的列 |
| | | */ |
| | | TDriverCommission.initColumn = function () { |
| | | return [ |
| | | {field: 'selectItem', radio: true}, |
| | | {title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'}, |
| | | {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '手机号', field: 'phone', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '所属代理商', field: 'agentName', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '性别', field: 'sex', visible: false, align: 'center', valign: 'middle', |
| | | formatter: function (value, row) { |
| | | if (row.sex === 1){ |
| | | return '<span>男</span>' |
| | | }else if (row.sex === 2){ |
| | | return '<span>女</span>' |
| | | }else { |
| | | return '<span>未知</span>' |
| | | } |
| | | }}, |
| | | {title: '推广人数', field: 'cumulativeOrderCount', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '关联人数', field: 'cumulativeOrderCount', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '累计获得佣金', field: 'cumulativeOrderCount', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '可提现佣金', field: 'monthOrderCount', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '已提现金额', field: 'integral', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', |
| | | formatter: function (value, row) { |
| | | if (row.status === 1){ |
| | | return '<span>正常</span>' |
| | | }else if (row.status === 2){ |
| | | return '<span>冻结</span>' |
| | | }else if (row.status === 3){ |
| | | return '<span>已删除</span>' |
| | | } |
| | | }}, |
| | | {title: '操作', visible: true, align: 'center', valign: 'middle',width:150, |
| | | formatter: function (value, row) { |
| | | if (row.status === 1){ |
| | | return '<a href="#" onclick="TDriverCommission.searchTDriverDetail('+row.id+')" style="color:green">详情</a>' |
| | | }else if (row.status === 2){ |
| | | return '<a href="#" onclick="TDriverCommission.searchTDriverDetail('+row.id+')" style="color:green">详情</a>' |
| | | } |
| | | } |
| | | } |
| | | ]; |
| | | }; |
| | | |
| | | /** |
| | | * 检查是否选中 |
| | | */ |
| | | TDriverCommission.check = function () { |
| | | var selected = $('#' + this.id).bootstrapTable('getSelections'); |
| | | if(selected.length == 0){ |
| | | Feng.info("请先选中表格中的某一记录!"); |
| | | return false; |
| | | }else{ |
| | | TDriverCommission.seItem = selected[0]; |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 点击添加 |
| | | */ |
| | | TDriverCommission.openAddTDriver = function () { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '添加', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/tDriver_add' |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 打开查看详情 |
| | | */ |
| | | TDriverCommission.openTDriverDetail = function () { |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/tDriver_update/' + TDriver.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 打开查看详情(使用中) |
| | | */ |
| | | TDriverCommission.searchTDriverDetail = function (id) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/driverDetail?tDriverId=' + id |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | TDriverCommission.delete = function () { |
| | | if (this.check()) { |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/delete", function (data) { |
| | | Feng.success("删除成功!"); |
| | | TDriverCommission.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("删除失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("tDriverId",this.seItem.id); |
| | | ajax.start(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 停用页面 |
| | | */ |
| | | TDriverCommission.stop = function (id) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '停用', |
| | | area: ['45%', '50%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/tDriver_start_and_stop?id='+id |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 启动页面 |
| | | */ |
| | | TDriverCommission.start = function (id) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '启用', |
| | | area: ['45%', '50%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/tDriver_start_and_stop?id='+id |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 提交启用冻结 |
| | | */ |
| | | TDriverCommission.updateStatus = function () { |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/update-status", function (data) { |
| | | Feng.success("修改成功!"); |
| | | TDriverInfoDlg.close(); |
| | | parent.TDriverCommission.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("修改失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("id",$("#id").val()); |
| | | ajax.set("status",$("#status").val()); |
| | | if($("#status").val() == 1){ |
| | | ajax.set("remark",$("#stopRemark").val()); |
| | | } |
| | | if($("#status").val() == 2){ |
| | | ajax.set("remark",$("#startRemark").val()); |
| | | } |
| | | ajax.start(); |
| | | }; |
| | | |
| | | /** |
| | | * 司机信息导出 |
| | | */ |
| | | TDriverCommission.export=function(){ |
| | | var createTime=$("#name").val() |
| | | var phone=$("#phone").val() |
| | | var status=$("#status").val() |
| | | window.location.href=Feng.ctxPath + "/tDriver/export?name="+name |
| | | +"&status="+status |
| | | +"&phone="+phone |
| | | ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询列表 |
| | | */ |
| | | TDriverCommission.search = function () { |
| | | var queryData = {}; |
| | | queryData['name'] = $("#name").val(); |
| | | queryData['phone'] = $("#phone").val(); |
| | | queryData['status'] = $("#status").val(); |
| | | TDriverCommission.table.refresh({query: queryData}); |
| | | }; |
| | | |
| | | /** |
| | | * 重置 |
| | | */ |
| | | TDriverCommission.resetSearch = function (){ |
| | | $("#name").val(''); |
| | | $("#phone").val(''); |
| | | $("#status").val(''); |
| | | TDriverCommission.search(); |
| | | } |
| | | |
| | | $(function () { |
| | | var defaultColunms = TDriverCommission.initColumn(); |
| | | var table = new BSTable(TDriverCommission.id, "/tDriver/commission/list", defaultColunms); |
| | | table.setPaginationType("client"); |
| | | TDriverCommission.table = table.init(); |
| | | }); |