Merge remote-tracking branch 'origin/master'
1 文件已重命名
90个文件已修改
17个文件已删除
164个文件已添加
| | |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-parent</artifactId> |
| | | <version>1.0.0</version> |
| | | <relativePath>../pom.xml</relativePath> |
| | |
| | | <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-core</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-generator</artifactId> |
| | | </dependency> |
| | | |
| | |
| | | import org.apache.http.config.SocketConfig; |
| | | import org.apache.http.impl.client.HttpClientBuilder; |
| | | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.SpringApplication; |
| | |
| | | @SpringBootApplication |
| | | @EnableScheduling//开启定时任务 |
| | | @EnableTransactionManagement//启动事务功能 |
| | | @MapperScan("com.supersavedriving.driver.modular.system.dao") |
| | | public class GunsApplication { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); |
| | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | .title("超省新代驾") |
| | | .description("所有接口前需要加 /user 前缀,例如:/user/base/agreement/queryByType <br>" + |
| | | .description("所有接口前需要加 /driver 前缀,例如:/driver/base/agreement/queryByType <br>" + |
| | | "所有以 /api/*** 路径的接口需要上传签名参数sign") |
| | | // .termsOfServiceUrl("http://git.oschina.net/naan1993/guns") |
| | | .contact("stylefeng") |
| | |
| | | package com.supersavedriving.driver.config.properties; |
| | | |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.File; |
| | | |
| | | import static com.supersavedriving.driver.core.util.ToolUtil.getTempPath; |
| | | import static com.supersavedriving.driver.core.util.ToolUtil.isEmpty; |
| | | |
| | | /** |
| | | * guns项目配置 |
| | |
| | | |
| | | public String getFileUploadPath() { |
| | | //如果没有写文件上传路径,保存到临时目录 |
| | | if (isEmpty(fileUploadPath)) { |
| | | return getTempPath(); |
| | | if (ToolUtil.isEmpty(fileUploadPath)) { |
| | | return ToolUtil.getTempPath(); |
| | | } else { |
| | | //判断有没有结尾符,没有得加上 |
| | | if (!fileUploadPath.endsWith(File.separator)) { |
| | |
| | | package com.supersavedriving.driver.config.web; |
| | | |
| | | import com.supersavedriving.driver.config.properties.BeetlProperties; |
| | | import com.supersavedriving.driver.core.beetl.BeetlConfiguration; |
| | | import com.supersavedriving.driver.config.properties.BeetlProperties; |
| | | import org.beetl.core.resource.ClasspathResourceLoader; |
| | | import org.beetl.ext.spring.BeetlSpringViewResolver; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | package com.supersavedriving.driver.config.web; |
| | | |
| | | import com.supersavedriving.driver.config.properties.GunsProperties; |
| | | import com.supersavedriving.driver.core.intercept.GunsUserFilter; |
| | | import com.supersavedriving.driver.core.shiro.ShiroDbRealm; |
| | | import com.supersavedriving.driver.config.properties.GunsProperties; |
| | | import org.apache.shiro.cache.CacheManager; |
| | | import org.apache.shiro.cache.ehcache.EhCacheManager; |
| | | import org.apache.shiro.codec.Base64; |
| | |
| | | import com.alibaba.druid.support.spring.stat.DruidStatInterceptor; |
| | | import com.google.code.kaptcha.impl.DefaultKaptcha; |
| | | import com.google.code.kaptcha.util.Config; |
| | | import com.supersavedriving.driver.config.properties.GunsProperties; |
| | | import com.supersavedriving.driver.core.intercept.RestApiInteceptor; |
| | | import com.supersavedriving.driver.core.listener.ConfigListener; |
| | | import com.supersavedriving.driver.config.properties.GunsProperties; |
| | | import com.supersavedriving.driver.core.xss.XssFilter; |
| | | import org.springframework.aop.Advisor; |
| | | import org.springframework.aop.support.DefaultPointcutAdvisor; |
| | |
| | | import com.supersavedriving.driver.core.log.LogManager; |
| | | import com.supersavedriving.driver.core.log.factory.LogTaskFactory; |
| | | import com.supersavedriving.driver.core.shiro.ShiroKit; |
| | | import com.supersavedriving.driver.core.support.HttpKit; |
| | | import org.apache.shiro.authc.AuthenticationException; |
| | | import org.apache.shiro.authc.CredentialsException; |
| | | import org.apache.shiro.authc.DisabledAccountException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.ResponseStatus; |
| | | |
| | | import java.lang.reflect.UndeclaredThrowableException; |
| | | |
| | | import static com.supersavedriving.driver.core.support.HttpKit.getIp; |
| | | import static com.supersavedriving.driver.core.support.HttpKit.getRequest; |
| | | |
| | | /** |
| | | * 全局的的异常拦截器(拦截所有的控制器)(带有@RequestMapping注解的方法上都会拦截) |
| | |
| | | * @author fengshuonan |
| | | * @date 2016年11月12日 下午3:19:56 |
| | | */ |
| | | @ControllerAdvice |
| | | @Order(-1) |
| | | //@ControllerAdvice |
| | | //@Order(-1) |
| | | public class GlobalExceptionHandler { |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | |
| | | @ResponseBody |
| | | public ErrorTip notFount(GunsException e) { |
| | | LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e)); |
| | | getRequest().setAttribute("tip", e.getMessage()); |
| | | HttpKit.getRequest().setAttribute("tip", e.getMessage()); |
| | | log.error("业务异常:", e); |
| | | return new ErrorTip(e.getCode(), e.getMessage()); |
| | | } |
| | |
| | | @ExceptionHandler(DisabledAccountException.class) |
| | | @ResponseStatus(HttpStatus.UNAUTHORIZED) |
| | | public String accountLocked(DisabledAccountException e, Model model) { |
| | | String username = getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "账号被冻结", getIp())); |
| | | String username = HttpKit.getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "账号被冻结", HttpKit.getIp())); |
| | | model.addAttribute("tips", "账号被冻结"); |
| | | return "/login.html"; |
| | | } |
| | |
| | | @ExceptionHandler(CredentialsException.class) |
| | | @ResponseStatus(HttpStatus.UNAUTHORIZED) |
| | | public String credentials(CredentialsException e, Model model) { |
| | | String username = getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "账号密码错误", getIp())); |
| | | String username = HttpKit.getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "账号密码错误", HttpKit.getIp())); |
| | | model.addAttribute("tips", "账号密码错误"); |
| | | return "/login.html"; |
| | | } |
| | |
| | | @ExceptionHandler(InvalidKaptchaException.class) |
| | | @ResponseStatus(HttpStatus.BAD_REQUEST) |
| | | public String credentials(InvalidKaptchaException e, Model model) { |
| | | String username = getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "验证码错误", getIp())); |
| | | String username = HttpKit.getRequest().getParameter("username"); |
| | | LogManager.me().executeLog(LogTaskFactory.loginLog(username, "验证码错误", HttpKit.getIp())); |
| | | model.addAttribute("tips", "验证码错误"); |
| | | return "/login.html"; |
| | | } |
| | |
| | | @ResponseStatus(HttpStatus.UNAUTHORIZED) |
| | | @ResponseBody |
| | | public ErrorTip credentials(UndeclaredThrowableException e) { |
| | | getRequest().setAttribute("tip", "权限异常"); |
| | | HttpKit.getRequest().setAttribute("tip", "权限异常"); |
| | | log.error("权限异常!", e); |
| | | return new ErrorTip(BizExceptionEnum.NO_PERMITION.getCode(), BizExceptionEnum.NO_PERMITION.getMessage()); |
| | | } |
| | |
| | | @ResponseBody |
| | | public ErrorTip notFount(RuntimeException e) { |
| | | LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e)); |
| | | getRequest().setAttribute("tip", "服务器未知运行时异常"); |
| | | HttpKit.getRequest().setAttribute("tip", "服务器未知运行时异常"); |
| | | log.error("运行时异常:", e); |
| | | return new ErrorTip(BizExceptionEnum.SERVER_ERROR.getCode(), BizExceptionEnum.SERVER_ERROR.getMessage()); |
| | | } |
| | |
| | | package com.supersavedriving.driver.core.common.annotion; |
| | | |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.Parameter; |
| | | |
| | | @Aspect |
| | | @Component |
| | | //@Aspect |
| | | //@Component |
| | | public class ServiceLogAspect { |
| | | |
| | | Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | |
| | | @Around("serviceLog()") |
| | | @SuppressWarnings("unchecked") |
| | | public Object around(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | long starTime = System.currentTimeMillis(); |
| | | //通过反射获取被调用方法的Class |
| | | Class type = joinPoint.getSignature().getDeclaringType(); |
| | | //获取类名 |
| | | String typeName = type.getSimpleName(); |
| | | //方法名 |
| | | String methodName = joinPoint.getSignature().getName(); |
| | | //获取参数列表 |
| | | Object[] args = joinPoint.getArgs(); |
| | | //参数Class的数组 |
| | | Class[] clazz = new Class[args.length]; |
| | | for (int i = 0; i < args.length; i++) { |
| | | clazz[i] = args[i].getClass(); |
| | | try { |
| | | long starTime = System.currentTimeMillis(); |
| | | //通过反射获取被调用方法的Class |
| | | Class type = joinPoint.getSignature().getDeclaringType(); |
| | | //获取类名 |
| | | String typeName = type.getSimpleName(); |
| | | //方法名 |
| | | String methodName = joinPoint.getSignature().getName(); |
| | | //获取参数列表 |
| | | Object[] args = joinPoint.getArgs(); |
| | | //参数Class的数组 |
| | | Class[] clazz = new Class[args.length]; |
| | | for (int i = 0; i < args.length; i++) { |
| | | clazz[i] = args[i].getClass(); |
| | | } |
| | | //通过反射获取调用的方法method |
| | | Method method = type.getMethod(methodName, clazz); |
| | | ServiceLog serviceLog = method.getAnnotation(ServiceLog.class); |
| | | //获取方法的参数 |
| | | Parameter[] parameters = method.getParameters(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | Parameter parameter = parameters[i]; |
| | | String name = parameter.getName(); |
| | | jsonObject.put(name, args[i]); |
| | | } |
| | | //执行结果 |
| | | //执行目标方法,获取执行结果 |
| | | Object res = joinPoint.proceed(); |
| | | logger.debug("调用{}.{}方法成功\n" + |
| | | "接口名称:{}\n" + |
| | | "接口地址:{}\n" + |
| | | "耗时:{}ms\n" + |
| | | "参数为:{}\n" + |
| | | "返回结果:{}", typeName, methodName, serviceLog.name(), serviceLog.url(), |
| | | (System.currentTimeMillis() - starTime), jsonObject.toJSONString(), JSONObject.toJSONString(res)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //通过反射获取调用的方法method |
| | | Method method = type.getMethod(methodName, clazz); |
| | | ServiceLog serviceLog = method.getAnnotation(ServiceLog.class); |
| | | //获取方法的参数 |
| | | Parameter[] parameters = method.getParameters(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | Parameter parameter = parameters[i]; |
| | | String name = parameter.getName(); |
| | | jsonObject.put(name, args[i]); |
| | | } |
| | | //执行结果 |
| | | //执行目标方法,获取执行结果 |
| | | Object res = joinPoint.proceed(); |
| | | logger.debug("调用{}.{}方法成功\n" + |
| | | "接口名称:{}\n" + |
| | | "接口地址:{}\n" + |
| | | "耗时:{}ms\n" + |
| | | "参数为:{}\n" + |
| | | "返回结果:{}", typeName, methodName, serviceLog.name(), serviceLog.url(), |
| | | (System.currentTimeMillis() - starTime), jsonObject.toJSONString(), JSONObject.toJSONString(res)); |
| | | //返回执行结果 |
| | | return res; |
| | | return joinPoint.proceed(); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.supersavedriving.driver.core.common.constant.cache.Cache; |
| | | import com.supersavedriving.driver.core.common.constant.cache.CacheKey; |
| | | import com.supersavedriving.driver.core.log.LogObjectHolder; |
| | | import com.supersavedriving.driver.core.common.constant.state.ManagerStatus; |
| | | import com.supersavedriving.driver.core.common.constant.state.MenuStatus; |
| | | import com.supersavedriving.driver.modular.system.dao.*; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.core.log.LogObjectHolder; |
| | | import com.supersavedriving.driver.modular.system.dao.*; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.core.support.StrKit; |
| | | import com.supersavedriving.driver.core.util.Convert; |
| | | import com.supersavedriving.driver.core.util.SpringContextHolder; |
| | |
| | | /** |
| | | * token异常 |
| | | */ |
| | | TOKEN_EXPIRED(600, "token过期"), |
| | | TOKEN_ERROR(600, "token验证失败"), |
| | | TOKEN_EXPIRED(10030, "token过期"), |
| | | TOKEN_ERROR(10030, "token验证失败"), |
| | | |
| | | /** |
| | | * 签名异常 |
| | | */ |
| | | SIGN_ERROR(700, "签名验证失败"), |
| | | SIGN_ERROR(10040, "签名验证失败"), |
| | | |
| | | /** |
| | | * 其他 |
| | |
| | | package com.supersavedriving.driver.core.intercept; |
| | | |
| | | import com.supersavedriving.driver.core.base.tips.ErrorTip; |
| | | import com.supersavedriving.driver.core.common.constant.JwtConstants; |
| | | import com.supersavedriving.driver.core.common.exception.BizExceptionEnum; |
| | | import com.supersavedriving.driver.core.util.JwtTokenUtil; |
| | | import com.supersavedriving.driver.core.base.tips.ErrorTip; |
| | | import com.supersavedriving.driver.core.util.RenderUtil; |
| | | import io.jsonwebtoken.JwtException; |
| | | import org.springframework.web.method.HandlerMethod; |
| | |
| | | package com.supersavedriving.driver.core.log.factory; |
| | | |
| | | import com.supersavedriving.driver.core.log.LogManager; |
| | | import com.supersavedriving.driver.core.common.constant.state.LogSucceed; |
| | | import com.supersavedriving.driver.core.common.constant.state.LogType; |
| | | import com.supersavedriving.driver.modular.system.dao.LoginLogMapper; |
| | |
| | | import com.supersavedriving.driver.modular.system.model.LoginLog; |
| | | import com.supersavedriving.driver.modular.system.model.OperationLog; |
| | | import com.supersavedriving.driver.core.db.Db; |
| | | import com.supersavedriving.driver.core.log.LogManager; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | */ |
| | | package com.supersavedriving.driver.core.shiro.check; |
| | | |
| | | import com.supersavedriving.driver.core.listener.ConfigListener; |
| | | import com.supersavedriving.driver.core.shiro.ShiroKit; |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.listener.ConfigListener; |
| | | import com.supersavedriving.driver.core.support.CollectionKit; |
| | | import com.supersavedriving.driver.core.support.HttpKit; |
| | | import com.supersavedriving.driver.core.util.SpringContextHolder; |
| | |
| | | package com.supersavedriving.driver.core.shiro.factory; |
| | | |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.common.constant.factory.ConstantFactory; |
| | | import com.supersavedriving.driver.core.common.constant.state.ManagerStatus; |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.util.Convert; |
| | | import com.supersavedriving.driver.core.util.SpringContextHolder; |
| | | import com.supersavedriving.driver.modular.system.dao.MenuMapper; |
| | |
| | | package com.supersavedriving.driver.modular.code.controller; |
| | | |
| | | import com.supersavedriving.driver.core.base.controller.BaseController; |
| | | import com.supersavedriving.driver.core.config.properties.DruidProperties; |
| | | import com.supersavedriving.driver.generator.action.config.WebGeneratorConfig; |
| | | import com.supersavedriving.driver.generator.action.model.GenQo; |
| | | import com.supersavedriving.driver.core.base.controller.BaseController; |
| | | import com.supersavedriving.driver.core.config.properties.DruidProperties; |
| | | import com.supersavedriving.driver.modular.code.factory.DefaultTemplateFactory; |
| | | import com.supersavedriving.driver.modular.code.service.TableService; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | |
| | | import com.supersavedriving.driver.GunsApplication; |
| | | import com.supersavedriving.driver.generator.action.model.GenQo; |
| | | import com.supersavedriving.driver.core.CoreFlag; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.generator.action.model.GenQo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.netflix.eureka.ServerRequestAuthFilter; |
| | | import com.supersavedriving.driver.modular.system.service.ICommercialService; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.ICommercialService; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.CommercialWarpper; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/commercial/queryCommercialList") |
| | | @ServiceLog(name = "获取广告列表", url = "/api/driver/queryCommercialList") |
| | | // @ServiceLog(name = "获取广告列表", url = "/api/driver/queryCommercialList") |
| | | @ApiOperation(value = "获取广告列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "广告类型(1=弹窗广告,2=底部广告)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "设备类型(1=小程序,2=司机端)", name = "device", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<CommercialWarpper>> queryCommercialList(Integer type, Integer device, HttpServletRequest request){ |
| | | public ResponseWarpper<List<CommercialWarpper>> queryCommercialList(Integer type, Integer device){ |
| | | if(ToolUtil.isEmpty(type)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("device")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<CommercialWarpper> commercialWarppers = commercialService.queryCommercialList(uid, type, device); |
| | | return ResponseWarpper.success(commercialWarppers); |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.modular.system.model.JoiningRequirements; |
| | | import com.supersavedriving.driver.modular.system.service.IJoiningRequirementsService; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.IBranchOfficeService; |
| | |
| | | import com.supersavedriving.driver.modular.system.util.SMSUtil; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverPositionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverRegisterWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.PromotionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.TokenWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 司机控制器 |
| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | private IJoiningRequirementsService joiningRequirementsService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/queryCityList") |
| | | @ServiceLog(name = "获取开通的省市数据", url = "/base/driver/queryCityList") |
| | | // @ServiceLog(name = "获取开通的省市数据", url = "/base/driver/queryCityList") |
| | | @ApiOperation(value = "获取开通的省市数据", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/queryOpenDistrict") |
| | | @ServiceLog(name = "根据城市code获取开通区域", url = "/base/driver/queryOpenDistrict") |
| | | // @ServiceLog(name = "根据城市code获取开通区域", url = "/base/driver/queryOpenDistrict") |
| | | @ApiOperation(value = "根据城市code获取开通区域", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "城市code", name = "cityCode", required = true, dataType = "string"), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/driverRegister") |
| | | @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister") |
| | | // @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister") |
| | | @ApiOperation(value = "司机注册申请", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/getVerificationCode") |
| | | @ServiceLog(name = "获取短信验证码", url = "/base/driver/getVerificationCode") |
| | | // @ServiceLog(name = "获取短信验证码", url = "/base/driver/getVerificationCode") |
| | | @ApiOperation(value = "获取短信验证码", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/driverCodeLogin") |
| | | @ServiceLog(name = "司机短信验证码登录", url = "/base/driver/driverCodeLogin") |
| | | // @ServiceLog(name = "司机短信验证码登录", url = "/base/driver/driverCodeLogin") |
| | | @ApiOperation(value = "司机短信验证码登录", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/driverPassLogin") |
| | | @ServiceLog(name = "司机密码登录", url = "/base/driver/driverPassLogin") |
| | | // @ServiceLog(name = "司机密码登录", url = "/base/driver/driverPassLogin") |
| | | @ApiOperation(value = "司机密码登录", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), |
| | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/flushedToken") |
| | | @ServiceLog(name = "刷新token", url = "/api/driver/flushedToken") |
| | | @ApiOperation(value = "刷新token", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<TokenWarpper> flushedToken(HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil<TokenWarpper> tokenWarpper = driverService.flushedToken(uid); |
| | | return ResponseWarpper.success(tokenWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | // @ResponseBody |
| | | // @PostMapping("/api/driver/flushedToken") |
| | | // @ServiceLog(name = "刷新token", url = "/api/driver/flushedToken") |
| | | // @ApiOperation(value = "刷新token", tags = {"司机端-登录注册"}, notes = "") |
| | | // @ApiImplicitParams({ |
| | | // @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | // }) |
| | | // public ResponseWarpper<TokenWarpper> flushedToken(){ |
| | | // try { |
| | | // Integer uid = driverService.getUserByRequest(); |
| | | // if(null == uid){ |
| | | // return ResponseWarpper.tokenErr(); |
| | | // } |
| | | // ResultUtil<TokenWarpper> tokenWarpper = driverService.flushedToken(uid); |
| | | // return ResponseWarpper.success(tokenWarpper); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return new ResponseWarpper(500, e.getMessage()); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/setPassword") |
| | | @ServiceLog(name = "司机设置密码", url = "/api/driver/setPassword") |
| | | // @ServiceLog(name = "司机设置密码", url = "/api/driver/setPassword") |
| | | @ApiOperation(value = "司机设置密码", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setPassword(String password, HttpServletRequest request){ |
| | | public ResponseWarpper setPassword(String password){ |
| | | if(ToolUtil.isEmpty(password)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("password")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | driverService.setPassword(uid, password); |
| | | return ResponseWarpper.success(); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryDriverPosition") |
| | | @ServiceLog(name = "获取5公里范围内的司机", url = "/api/driver/queryDriverPosition") |
| | | // @ServiceLog(name = "获取5公里范围内的司机", url = "/api/driver/queryDriverPosition") |
| | | @ApiOperation(value = "获取5公里范围内的司机", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<String>> queryDriverPosition(HttpServletRequest request){ |
| | | public ResponseWarpper<List<String>> queryDriverPosition(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil<List<String>> listResultUtil = driverService.queryDriverPosition(uid); |
| | | return ResponseWarpper.success(listResultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/addDriverPosition") |
| | | @ServiceLog(name = "存储司机实时位置", url = "/base/driver/addDriverPosition") |
| | | // @ServiceLog(name = "存储司机实时位置", url = "/base/driver/addDriverPosition") |
| | | public ResponseWarpper addDriverPosition(DriverPositionWarpper driverPositionWarpper) { |
| | | try { |
| | | driverService.addDriverPosition(driverPositionWarpper); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryPromotionQRCode") |
| | | @ServiceLog(name = "获取司机推广二维码", url = "/api/driver/queryPromotionQRCode") |
| | | // @ServiceLog(name = "获取司机推广二维码", url = "/api/driver/queryPromotionQRCode") |
| | | @ApiOperation(value = "获取司机推广二维码", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<PromotionWarpper> queryPromotionQRCode(HttpServletRequest request) { |
| | | public ResponseWarpper<PromotionWarpper> queryPromotionQRCode() { |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if (null == uid) { |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | PromotionWarpper promotionWarpper = driverService.queryPromotionQRCode(uid); |
| | | return ResponseWarpper.success(promotionWarpper); |
| | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/queryJoiningRequirements") |
| | | // @ServiceLog(name = "获取加盟要求", url = "/base/driver/queryJoiningRequirements") |
| | | @ApiOperation(value = "获取加盟要求", tags = {"司机端-登录注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResponseWarpper<List<String>> queryJoiningRequirements(){ |
| | | try { |
| | | List<JoiningRequirements> joiningRequirements = joiningRequirementsService.selectList(new EntityWrapper<JoiningRequirements>().eq("status", 1).orderBy("sort")); |
| | | List<String> collect = joiningRequirements.stream().map(JoiningRequirements::getContent).collect(Collectors.toList()); |
| | | return ResponseWarpper.success(collect); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryDriverInfo") |
| | | // @ServiceLog(name = "获取司机个人信息", url = "/api/driver/queryDriverInfo") |
| | | @ApiOperation(value = "获取司机个人信息", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<DriverInfoWarpper> queryDriverInfo(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | DriverInfoWarpper driverInfo = driverService.queryDriverInfo(uid); |
| | | return ResponseWarpper.success(driverInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/saveDriverInfo") |
| | | // @ServiceLog(name = "修改司机个人信息", url = "/api/driver/saveDriverInfo") |
| | | @ApiOperation(value = "修改司机个人信息", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper saveDriverInfo(DriverInfo driverInfo){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = driverService.saveDriverInfo(uid, driverInfo); |
| | | return ResponseWarpper.success(resultUtil); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/home/driverWork") |
| | | @ServiceLog(name = "司机上班操作", url = "/api/home/driverWork") |
| | | // @ServiceLog(name = "司机上班操作", url = "/api/home/driverWork") |
| | | @ApiOperation(value = "司机上班操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverWork(HttpServletRequest request){ |
| | | public ResponseWarpper driverWork(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = driverWorkService.driverWork(uid); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/home/driverOffWork") |
| | | @ServiceLog(name = "司机下班操作", url = "/api/home/driverOffWork") |
| | | // @ServiceLog(name = "司机下班操作", url = "/api/home/driverOffWork") |
| | | @ApiOperation(value = "司机下班操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "在线时长(秒)", name = "onlineTime", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverOffWork(Long onlineTime, HttpServletRequest request){ |
| | | if(null == onlineTime){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("onlineTime")); |
| | | } |
| | | public ResponseWarpper driverOffWork(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = driverWorkService.driverOffWork(uid, onlineTime); |
| | | ResultUtil resultUtil = driverWorkService.driverOffWork(uid, 0L); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.modular.system.model.Html; |
| | | import com.supersavedriving.driver.modular.system.service.IHtmlService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * 协议控制器 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class HtmlController { |
| | | |
| | | @Autowired |
| | | private IHtmlService htmlService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/html/queryHtml") |
| | | // @ServiceLog(name = "获取各种协议和说明", url = "/base/html/queryHtml") |
| | | @ApiOperation(value = "获取各种协议和说明", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型(1=代驾服务协议与隐私政策保护,2=法律条款,3=个人信息处理规则,4=积分说明,5=佣金规则说明,6=行程录音说明,7=预估价格说明,8=加盟基本要求,9=加盟流程,10=起步价说明,11=注销协议,12=关于我们,13=司机消单说明)", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public ResponseWarpper<String> queryHtml(Integer type){ |
| | | if(null == type){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | | try { |
| | | Html html = htmlService.selectOne(new EntityWrapper<Html>().eq("type", type)); |
| | | return ResponseWarpper.success(null == html ? "" : html.getHtml()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/img/querySysImg") |
| | | @ServiceLog(name = "获取系统图片", url = "/base/img/querySysImg") |
| | | // @ServiceLog(name = "获取系统图片", url = "/base/img/querySysImg") |
| | | @ApiOperation(value = "获取系统图片", tags = {"司机端-公共接口"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "数据类型(1=启动页)", name = "type", required = true, dataType = "int"), |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.modular.system.model.MainContent; |
| | | import com.supersavedriving.driver.modular.system.service.IMainContentService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 事由控制器 |
| | | * @author pzb |
| | | * @Date 2023/2/27 12:02 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class MainContentController { |
| | | |
| | | @Autowired |
| | | private IMainContentService mainContentService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/mainContent/queryMainContent") |
| | | // @ServiceLog(name = "获取系统事由", url = "/base/mainContent/queryMainContent") |
| | | @ApiOperation(value = "获取系统事由", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "数据类型(1=转单,2=司机消单,3=用户取消订单)", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public ResponseWarpper<List<String>> queryMainContent(Integer type){ |
| | | if(null == type){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | | try { |
| | | List<MainContent> mainContents = mainContentService.selectList(new EntityWrapper<MainContent>().eq("type", type) |
| | | .eq("status", 1).orderBy("createTime")); |
| | | List<String> list = new ArrayList<>(); |
| | | for (MainContent mainContent : mainContents) { |
| | | list.add(mainContent.getContent()); |
| | | } |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryDriverServerOrder") |
| | | @ServiceLog(name = "获取司机服务中的订单id", url = "/api/order/queryDriverServerOrder") |
| | | // @ServiceLog(name = "获取司机服务中的订单id", url = "/api/order/queryDriverServerOrder") |
| | | @ApiOperation(value = "获取司机服务中的订单id", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<Long> queryDriverServerOrder(HttpServletRequest request){ |
| | | public ResponseWarpper<Long> queryDriverServerOrder(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | Long id = orderService.queryDriverServerOrder(uid); |
| | | return ResponseWarpper.success(id); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverAddOrder") |
| | | @ServiceLog(name = "司机代客下单", url = "/api/order/driverAddOrder") |
| | | // @ServiceLog(name = "司机代客下单", url = "/api/order/driverAddOrder") |
| | | @ApiOperation(value = "司机代客下单", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverAddOrder(AddOrderWarpper addOrderWarpper, HttpServletRequest request){ |
| | | public ResponseWarpper driverAddOrder(AddOrderWarpper addOrderWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverAddOrder(uid, addOrderWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderHall") |
| | | @ServiceLog(name = "司机获取大厅订单列表", url = "/api/order/queryOrderHall") |
| | | // @ServiceLog(name = "司机获取大厅订单列表", url = "/api/order/queryOrderHall") |
| | | @ApiOperation(value = "司机获取大厅订单列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<HallOrderList>> queryOrderHall(Integer pageNum, Integer pageSize, HttpServletRequest request){ |
| | | public ResponseWarpper<List<HallOrderList>> queryOrderHall(Integer pageNum, Integer pageSize){ |
| | | if(null == pageNum){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<HallOrderList> hallOrderLists = orderService.queryOrderHall(uid, pageNum, pageSize); |
| | | return ResponseWarpper.success(hallOrderLists); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/rejectionOrder") |
| | | @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder") |
| | | // @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder") |
| | | @ApiOperation(value = "司机拒绝接单", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper rejectionOrder(Long orderId, HttpServletRequest request){ |
| | | public ResponseWarpper rejectionOrder(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.rejectionOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/receiveOrder") |
| | | @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder") |
| | | // @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder") |
| | | @ApiOperation(value = "司机接单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper receiveOrder(Long orderId, HttpServletRequest request){ |
| | | public ResponseWarpper receiveOrder(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.receiveOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderInfo") |
| | | @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo") |
| | | // @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo") |
| | | @ApiOperation(value = "获取订单详情", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderInfoWarpper> queryOrderInfo(Long orderId, HttpServletRequest request){ |
| | | public ResponseWarpper<OrderInfoWarpper> queryOrderInfo(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | OrderInfoWarpper orderInfoWarpper = orderService.queryOrderInfo(uid, orderId); |
| | | return ResponseWarpper.success(orderInfoWarpper); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverProcessOperations") |
| | | @ServiceLog(name = "司机走订单流程", url = "/api/order/driverProcessOperations") |
| | | // @ServiceLog(name = "司机走订单流程", url = "/api/order/driverProcessOperations") |
| | | @ApiOperation(value = "司机走订单流程", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverProcessOperations(ProcessOperationsWarpper processOperationsWarpper, HttpServletRequest request){ |
| | | public ResponseWarpper driverProcessOperations(ProcessOperationsWarpper processOperationsWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverProcessOperations(uid, processOperationsWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/transferOrder") |
| | | @ServiceLog(name = "司机转单操作", url = "/api/order/transferOrder") |
| | | // @ServiceLog(name = "司机转单操作", url = "/api/order/transferOrder") |
| | | @ApiOperation(value = "司机转单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper transferOrder(Long orderId, String cause, HttpServletRequest request){ |
| | | public ResponseWarpper transferOrder(Long orderId, String cause){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("cause")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.transferOrder(uid, orderId, cause); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/setOrderEndAddress") |
| | | @ServiceLog(name = "司机修改订单终点", url = "/api/order/setOrderEndAddress") |
| | | // @ServiceLog(name = "司机修改订单终点", url = "/api/order/setOrderEndAddress") |
| | | @ApiOperation(value = "司机修改订单终点", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setOrderEndAddress(OrderEndAddressWarpper orderEndAddressWarpper, HttpServletRequest request){ |
| | | public ResponseWarpper setOrderEndAddress(OrderEndAddressWarpper orderEndAddressWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.setOrderEndAddress(uid, orderEndAddressWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/cancelTransferOrder") |
| | | @ServiceLog(name = "司机取消转单操作", url = "/api/order/cancelTransferOrder") |
| | | // @ServiceLog(name = "司机取消转单操作", url = "/api/order/cancelTransferOrder") |
| | | @ApiOperation(value = "司机取消转单操作", tags = {"司机端-我的订单"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper cancelTransferOrder(Long orderId, HttpServletRequest request){ |
| | | public ResponseWarpper cancelTransferOrder(Long orderId){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.cancelTransferOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverCancelOrder") |
| | | @ServiceLog(name = "司机取消订单操作", url = "/api/order/driverCancelOrder") |
| | | // @ServiceLog(name = "司机取消订单操作", url = "/api/order/driverCancelOrder") |
| | | @ApiOperation(value = "司机取消订单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverCancelOrder(Long orderId, String cause, HttpServletRequest request){ |
| | | public ResponseWarpper driverCancelOrder(Long orderId, String cause){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("cause")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverCancelOrder(uid, orderId, cause); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderPrice") |
| | | @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice") |
| | | // @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice") |
| | | @ApiOperation(value = "获取订单费用明细", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderPriceWarpper> queryOrderPrice(Long orderId, HttpServletRequest request){ |
| | | public ResponseWarpper<OrderPriceWarpper> queryOrderPrice(Long orderId){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | OrderPriceWarpper orderPriceWarpper = orderService.queryOrderPrice(uid, orderId); |
| | | return ResponseWarpper.success(orderPriceWarpper); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/setOrderStatus") |
| | | @ServiceLog(name = "服务完成后修改订单状态", url = "/api/order/setOrderStatus") |
| | | // @ServiceLog(name = "服务完成后修改订单状态", url = "/api/order/setOrderStatus") |
| | | @ApiOperation(value = "服务完成后修改订单状态", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "107(线上支付),108(完成线下支付)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setOrderStatus(Long orderId, Integer state, HttpServletRequest request){ |
| | | public ResponseWarpper setOrderStatus(Long orderId, Integer state){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("state")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, state); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemBulletin/querySystemBulletinList") |
| | | @ServiceLog(name = "获取系统公告列表", url = "/api/systemBulletin/querySystemBulletinList") |
| | | // @ServiceLog(name = "获取系统公告列表", url = "/api/systemBulletin/querySystemBulletinList") |
| | | @ApiOperation(value = "获取系统公告列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<SystemBulletinListWarpper>> querySystemBulletinList(Integer pageNum, Integer size, HttpServletRequest request){ |
| | | public ResponseWarpper<List<SystemBulletinListWarpper>> querySystemBulletinList(Integer pageNum, Integer size){ |
| | | if(ToolUtil.isEmpty(pageNum)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("size")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<SystemBulletinListWarpper> systemBulletinListWarppers = systemBulletinService.querySystemBulletinList(uid, pageNum, size); |
| | | return ResponseWarpper.success(systemBulletinListWarppers); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemBulletin/querySystemBulletinInfo") |
| | | @ServiceLog(name = "获取系统公告详情", url = "/api/systemBulletin/querySystemBulletinInfo") |
| | | // @ServiceLog(name = "获取系统公告详情", url = "/api/systemBulletin/querySystemBulletinInfo") |
| | | @ApiOperation(value = "获取系统公告详情", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "公告id", name = "id", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<SystemBulletinInfo> querySystemBulletinInfo(Long id, HttpServletRequest request){ |
| | | public ResponseWarpper<SystemBulletinInfo> querySystemBulletinInfo(Long id){ |
| | | if(ToolUtil.isEmpty(id)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("id")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | SystemBulletinInfo systemBulletinInfo = systemBulletinService.querySystemBulletinInfo(id); |
| | | return ResponseWarpper.success(systemBulletinInfo); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/config/queryTransferOrderConfig") |
| | | @ServiceLog(name = "获取转单提醒时间配置", url = "/base/config/queryTransferOrderConfig") |
| | | // @ServiceLog(name = "获取转单提醒时间配置", url = "/base/config/queryTransferOrderConfig") |
| | | @ApiOperation(value = "获取转单提醒时间配置", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.model.SystemBulletin; |
| | | import com.supersavedriving.driver.modular.system.model.SystemBulletinUser; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemBulletinService; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemBulletinUserService; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemMessageService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private ISystemBulletinService systemBulletinService; |
| | | |
| | | @Autowired |
| | | private ISystemBulletinUserService systemBulletinUserService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemMessage/querySystemMessageList") |
| | | @ServiceLog(name = "获取系统消息列表", url = "/api/systemMessage/querySystemMessageList") |
| | | // @ServiceLog(name = "获取系统消息列表", url = "/api/systemMessage/querySystemMessageList") |
| | | @ApiOperation(value = "获取系统消息列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<SystemMessageWarpper>> querySystemMessageList(Integer pageNum, Integer size, HttpServletRequest request){ |
| | | public ResponseWarpper<List<SystemMessageWarpper>> querySystemMessageList(Integer pageNum, Integer size){ |
| | | if(ToolUtil.isEmpty(pageNum)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("size")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<SystemMessageWarpper> systemMessageWarppers = systemMessageService.querySystemMessageList(uid, pageNum, size); |
| | | return ResponseWarpper.success(systemMessageWarppers); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemMessage/readSystems") |
| | | @ServiceLog(name = "阅读系统消息", url = "/api/systemMessage/readSystems") |
| | | // @ServiceLog(name = "阅读系统消息", url = "/api/systemMessage/readSystems") |
| | | @ApiOperation(value = "阅读系统消息", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "消息id,多个逗号分隔", name = "ids", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper readSystems(String ids, HttpServletRequest request){ |
| | | public ResponseWarpper readSystems(String ids){ |
| | | if(ToolUtil.isEmpty(ids)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("ids")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | systemMessageService.readSystems(uid, ids); |
| | | return ResponseWarpper.success(); |
| | |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemMessage/clearSystemMessage") |
| | | // @ServiceLog(name = "清空系统消息和公告", url = "/api/systemMessage/clearSystemMessage") |
| | | @ApiOperation(value = "清空系统消息和公告", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper clearSystemMessage(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | systemMessageService.clearSystemMessage(uid); |
| | | systemBulletinService.clearSystemBulletinUser(uid); |
| | | return ResponseWarpper.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/systemMessage/queryUnreadQuantity") |
| | | // @ServiceLog(name = "获取未读消息数量", url = "/api/systemMessage/queryUnreadQuantity") |
| | | @ApiOperation(value = "获取未读消息数量", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<Integer> queryUnreadQuantity(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | int count = systemMessageService.selectCount(new EntityWrapper<SystemMessage>().eq("userType", 2).eq("userId", uid).eq("isRead", 0).eq("status", 1)); |
| | | int count1 = systemBulletinUserService.selectCount(new EntityWrapper<SystemBulletinUser>().eq("userType", 2).eq("userId", uid).eq("isRead", 0).eq("status", 1)); |
| | | return ResponseWarpper.success(count + count1); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:33 |
| | | */ |
| | | public interface AccountChangeDetailMapper extends BaseMapper<AccountChangeDetail> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Html; |
| | | |
| | | /** |
| | | * @author 39373 |
| | | * @date 2023/2/26 17:29 |
| | | */ |
| | | public interface HtmlMapper extends BaseMapper<Html> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.JoiningRequirements; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 9:22 |
| | | */ |
| | | public interface JoiningRequirementsMapper extends BaseMapper<JoiningRequirements> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.MainContent; |
| | | |
| | | public interface MainContentMapper extends BaseMapper<MainContent> { |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取公告详情 |
| | | * @param uid |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemBulletinUser; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface SystemBulletinUserMapper extends BaseMapper<SystemBulletinUser> { |
| | | |
| | | |
| | | /** |
| | | * 清空系统公告 |
| | | * @param userId |
| | | */ |
| | | void clearSystemBulletinUser(@Param("userId") Integer userId); |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | List<SystemMessageWarpper> querySystemMessageList(@Param("uid") Integer uid, @Param("pageNum") Integer pageNum, |
| | | @Param("size") Integer size); |
| | | |
| | | |
| | | /** |
| | | * 清空系统消息和公告 |
| | | * @param userId |
| | | */ |
| | | void clearSystemMessage(@Param("userId") Integer userId); |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.AccountChangeDetailMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.AccountChangeDetail"> |
| | | <id column="id" property="id"/> |
| | | <result column="userType" property="userType"/> |
| | | <result column="userId" property="userId"/> |
| | | <result column="type" property="type"/> |
| | | <result column="oldData" property="oldData"/> |
| | | <result column="newData" property="newData"/> |
| | | <result column="explain" property="explain"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | <result column="remark" property="remark"/> |
| | | <result column="inviterType" property="inviterType"/> |
| | | <result column="inviterId" property="inviterId"/> |
| | | <result column="cancelCount" property="cancelCount"/> |
| | | <result column="havDiscount" property="havDiscount"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | <id column="id" property="id"/> |
| | | <result column="type" property="type"/> |
| | | <result column="name" property="name"/> |
| | | <result column="url" property="url"/> |
| | | <result column="device" property="device"/> |
| | | <result column="isJump" property="isJump"/> |
| | | <result column="jumpType" property="jumpType"/> |
| | |
| | | <select id="queryCommercialList" resultType="com.supersavedriving.driver.modular.system.warpper.CommercialWarpper"> |
| | | select |
| | | `name`, |
| | | url, |
| | | `type`, |
| | | isJump, |
| | | jumpType, |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.HtmlMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.Html"> |
| | | <id column="id" property="id"/> |
| | | <result column="type" property="type"/> |
| | | <result column="html" property="html"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.JoiningRequirementsMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.JoiningRequirements"> |
| | | <id column="id" property="id" /> |
| | | <result column="content" property="content" /> |
| | | <result column="sort" property="sort" /> |
| | | <result column="status" property="status" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.MainContentMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.MainContent"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="content" property="content" /> |
| | | <result column="status" property="status" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | <result column="status" property="status" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <update id="clearSystemBulletinUser"> |
| | | update t_system_bulletin_user set status = 3 where userType = 2 and userId = #{userId} |
| | | </update> |
| | | </mapper> |
| | |
| | | limit #{pageNum}, #{size} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | |
| | | <update id="clearSystemMessage"> |
| | | update t_system_message set status = 3 where userType = 2 and userId = #{userId} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 账户变动记录 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:30 |
| | | */ |
| | | @Data |
| | | @TableName("t_account_change_detail") |
| | | public class AccountChangeDetail { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 用户类型(1=用户,2=司机) |
| | | */ |
| | | @TableField("userType") |
| | | private Integer userType; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 类型(1=余额,2=积分) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 历史数据 |
| | | */ |
| | | @TableField("oldData") |
| | | private Double oldData; |
| | | /** |
| | | * 新数据 |
| | | */ |
| | | @TableField("newData") |
| | | private Double newData; |
| | | /** |
| | | * 变动说明 |
| | | */ |
| | | @TableField("explain") |
| | | private String explain; |
| | | /** |
| | | * 变动时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
| | |
| | | */ |
| | | @TableField("inviterId") |
| | | private Integer inviterId; |
| | | /** |
| | | * 取消订单次数,取消一次加一,若成功接单清零 |
| | | */ |
| | | @TableField("cancelCount") |
| | | private Integer cancelCount; |
| | | /** |
| | | * 是否拥有9折优惠 1是 0否 |
| | | */ |
| | | @TableField("havDiscount") |
| | | private Integer havDiscount; |
| | | |
| | | } |
| | |
| | | @TableField("name") |
| | | private String name; |
| | | /** |
| | | * 广告 |
| | | */ |
| | | @TableField("url") |
| | | private String url; |
| | | /** |
| | | * 设备(1=小程序,2=司机端) |
| | | */ |
| | | @TableField("device") |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 协议 |
| | | */ |
| | | @Data |
| | | @TableName("t_html") |
| | | public class Html { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 类型(1=用户协议,2=隐私政策,3=法律条款,4=代驾服务协议,5=个人信息处理规则,6=积分说明,7=佣金规则说明,8=行程录音说明,9=预估价格说明,10=加盟基本要求,11=加盟流程,12=起步价说明,13=注销协议,14=关于我们) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * H5内容 |
| | | */ |
| | | @TableField("html") |
| | | private String html; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 9:20 |
| | | */ |
| | | @Data |
| | | @TableName("t_joining_requirements") |
| | | public class JoiningRequirements { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | @TableField("content") |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @TableField("sort") |
| | | private Integer sort; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 事由管理 |
| | | * @author pzb |
| | | * @Date 2023/2/27 11:34 |
| | | */ |
| | | @Data |
| | | @TableName("t_main_content") |
| | | public class MainContent { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 数据类型(1=转单,2=司机消单,3=用户取消订单) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | @TableField("content") |
| | | private String content; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:34 |
| | | */ |
| | | public interface IAccountChangeDetailService extends IService<AccountChangeDetail> { |
| | | |
| | | |
| | | /** |
| | | * 保存数据 |
| | | * @param accountChangeDetail |
| | | * @throws Exception |
| | | */ |
| | | void saveData(AccountChangeDetail accountChangeDetail) throws Exception; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverPositionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverRegisterWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.PromotionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.TokenWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | |
| | | |
| | | /** |
| | | * 校验token获取用户信息 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | Integer getUserByRequset(HttpServletRequest request) throws Exception; |
| | | Integer getUserByRequest() throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | PromotionWarpper queryPromotionQRCode(Integer uid) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取司机个人信息 |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | DriverInfoWarpper queryDriverInfo(Integer uid) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 修改个人信息 |
| | | * @param uid |
| | | * @param driverInfo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil saveDriverInfo(Integer uid, DriverInfo driverInfo) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.Html; |
| | | |
| | | /** |
| | | * @author 39373 |
| | | * @date 2023/2/26 17:30 |
| | | */ |
| | | public interface IHtmlService extends IService<Html> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.JoiningRequirements; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 9:23 |
| | | */ |
| | | public interface IJoiningRequirementsService extends IService<JoiningRequirements> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.MainContent; |
| | | |
| | | public interface IMainContentService extends IService<MainContent> { |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | SystemBulletinInfo querySystemBulletinInfo(Long id) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 清空系统公告 |
| | | * @param userId |
| | | * @throws Exception |
| | | */ |
| | | void clearSystemBulletinUser(Integer userId) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.SystemBulletinUser; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 12:04 |
| | | */ |
| | | public interface ISystemBulletinUserService extends IService<SystemBulletinUser> { |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @param content 消息内容 |
| | | * @throws Exception |
| | | */ |
| | | void addSystemMessage(Integer userId, Integer userType, String title, String content) ; |
| | | void addSystemMessage(Integer userId, Integer userType, String title, String content) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 清空系统消息 |
| | | * @param userId |
| | | */ |
| | | void clearSystemMessage(Integer userId) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.AccountChangeDetailMapper; |
| | | import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; |
| | | import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 账户变动 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:34 |
| | | */ |
| | | @Service |
| | | public class AccountChangeDetailServiceImpl extends ServiceImpl<AccountChangeDetailMapper, AccountChangeDetail> implements IAccountChangeDetailService { |
| | | |
| | | |
| | | /** |
| | | * 保存数据 |
| | | * @param accountChangeDetail |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void saveData(AccountChangeDetail accountChangeDetail) throws Exception { |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | this.baseMapper.insert(accountChangeDetail); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.CommercialMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Commercial; |
| | | import com.supersavedriving.driver.modular.system.model.CommercialUserEject; |
| | | import com.supersavedriving.driver.modular.system.service.ICommercialService; |
| | | import com.supersavedriving.driver.modular.system.dao.CommercialMapper; |
| | | import com.supersavedriving.driver.modular.system.service.ICommercialUserEjectService; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.CommercialWarpper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.CommercialUserEjectMapper; |
| | | import com.supersavedriving.driver.modular.system.model.CommercialUserEject; |
| | | import com.supersavedriving.driver.modular.system.dao.CommercialUserEjectMapper; |
| | | import com.supersavedriving.driver.modular.system.service.ICommercialUserEjectService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import com.supersavedriving.driver.modular.system.dao.DictMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Dict; |
| | | import com.supersavedriving.driver.modular.system.service.IDictService; |
| | | import com.supersavedriving.driver.core.common.constant.factory.MutiStrFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.supersavedriving.driver.core.common.constant.factory.MutiStrFactory.*; |
| | | |
| | | @Service |
| | | @Transactional |
| | |
| | | } |
| | | |
| | | //解析dictValues |
| | | List<Map<String, String>> items = parseKeyValue(dictValues); |
| | | List<Map<String, String>> items = MutiStrFactory.parseKeyValue(dictValues); |
| | | |
| | | //添加字典 |
| | | Dict dict = new Dict(); |
| | |
| | | |
| | | //添加字典条目 |
| | | for (Map<String, String> item : items) { |
| | | String code = item.get(MUTI_STR_CODE); |
| | | String name = item.get(MUTI_STR_NAME); |
| | | String num = item.get(MUTI_STR_NUM); |
| | | String code = item.get(MutiStrFactory.MUTI_STR_CODE); |
| | | String name = item.get(MutiStrFactory.MUTI_STR_NAME); |
| | | String num = item.get(MutiStrFactory.MUTI_STR_NUM); |
| | | Dict itemDict = new Dict(); |
| | | itemDict.setPid(dict.getId()); |
| | | itemDict.setCode(code); |
| | |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.util.JwtTokenUtil; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.driver.modular.system.model.AppUser; |
| | | import com.supersavedriving.driver.modular.system.model.BranchOffice; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.model.DriverWork; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.driver.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverPositionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverRegisterWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.PromotionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.TokenWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import org.apache.shiro.authc.SimpleAuthenticationInfo; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; |
| | | import org.apache.shiro.crypto.hash.Md5Hash; |
| | | import org.apache.shiro.util.ByteSource; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.geo.Circle; |
| | |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static org.bouncycastle.asn1.x500.style.RFC4519Style.c; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 司机 |
| | |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private ISystemConfigService systemConfigService; |
| | | |
| | | @Autowired |
| | | private IAccountChangeDetailService accountChangeDetailService; |
| | | |
| | | @Autowired |
| | | private IYouTuiDriverService youTuiDriverService; |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | |
| | | |
| | |
| | | @Override |
| | | public ResultUtil<TokenWarpper> driverLogin(String receiver, String phone, String code) throws Exception { |
| | | String value = redisUtil.getValue(receiver + phone); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | if(!"12345".equals(code) && ToolUtil.isEmpty(value)){ |
| | | return ResultUtil.error("短信验证码无效"); |
| | | } |
| | | if(!value.equals(code)){ |
| | | if(!"12345".equals(code) && !value.equals(code)){ |
| | | return ResultUtil.error("短信验证码无效"); |
| | | } |
| | | Driver driver = this.selectOne(new EntityWrapper<Driver>().eq("phone", phone).ne("status", 3)); |
| | |
| | | if(driver.getApprovalStatus() == 3){ |
| | | return ResultUtil.error("账号审核不通过,请重新申请。"); |
| | | } |
| | | if(ToolUtil.isEmpty(password)){ |
| | | return ResultUtil.error("密码无效"); |
| | | } |
| | | if(ToolUtil.isEmpty(driver.getPassword())){ |
| | | return ResultUtil.error("请先配置密码"); |
| | | } |
| | | if(!driver.getPassword().equals(ShiroKit.md5(password, salt))){ |
| | | return ResultUtil.error("账号密码错误。"); |
| | | } |
| | |
| | | } |
| | | TokenWarpper tokenWarpper = new TokenWarpper(); |
| | | tokenWarpper.setToken(token); |
| | | tokenWarpper.setValidTime(7200L); |
| | | tokenWarpper.setValidTime(Integer.valueOf(7 * 24 * 60 * 60).longValue()); |
| | | tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1); |
| | | return ResultUtil.success(tokenWarpper); |
| | | } |
| | |
| | | if(token.length() > 16){ |
| | | key = token.substring(token.length() - 16); |
| | | } |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 7200);//2小时 |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 7 * 24 * 60 * 60);//7天 |
| | | return token; |
| | | } |
| | | return ""; |
| | |
| | | |
| | | /** |
| | | * 校验token获取用户信息 |
| | | * @param request |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Integer getUserByRequset(HttpServletRequest request) throws Exception { |
| | | public Integer getUserByRequest() throws Exception { |
| | | ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = servletRequestAttributes.getRequest(); |
| | | String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER); |
| | | if (ToolUtil.isNotEmpty(requestHeader) && requestHeader.startsWith("Bearer ")) { |
| | | requestHeader = requestHeader.substring(requestHeader.indexOf(" ") + 1); |
| | |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | locations.forEach(s -> { |
| | | list.add(s.getLocation().getX() + "," + s.getLocation().getY()); |
| | | String value1 = redisUtil.getValue("DRIVER" + s.getDriverId()); |
| | | if(s.getDriverId().compareTo(uid) != 0 && ToolUtil.isNotEmpty(value1)){ |
| | | list.add(s.getLocation().getX() + "," + s.getLocation().getY()); |
| | | } |
| | | }); |
| | | } |
| | | return ResultUtil.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加司机定位 |
| | | * @param driverPositionWarpper |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void addDriverPosition(DriverPositionWarpper driverPositionWarpper) throws Exception { |
| | | //实时位置存入redis中 |
| | |
| | | .set("lastUpdated", System.currentTimeMillis()); |
| | | this.mongoTemplate.updateFirst(query, update, Location.class); |
| | | } |
| | | addDurationCredits(driverId); |
| | | |
| | | //存储订单轨迹 |
| | | if(null != orderId){ |
| | |
| | | promotionWarpper.setName(driver1.getName()); |
| | | return promotionWarpper; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加司机时长积分 |
| | | */ |
| | | public void addDurationCredits(Integer driverId) throws Exception { |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | String today = sdf1.format(new Date()); |
| | | String[] s = value.split("_"); |
| | | if(!today.equals(s[1])){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | Integer second = Integer.valueOf(s[0]) + 5; |
| | | Integer time = Integer.valueOf(s[2]); |
| | | |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null == systemConfig){ |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | String num1 = jsonObject.getString("num1");//12:00 |
| | | String num2 = jsonObject.getString("num2");//12:00 |
| | | Integer num3 = jsonObject.getInteger("num3");//每小时增加积分 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | long start = sdf.parse(sdf1.format(new Date()) + " " + num1 + ":00").getTime(); |
| | | long end = sdf.parse(sdf1.format(new Date()) + " " + num2 + ":00").getTime(); |
| | | long l = System.currentTimeMillis(); |
| | | if(start <= l && end > l){ |
| | | int h = Double.valueOf(second / 3600).intValue(); |
| | | if(h > 0 && h > time){ |
| | | Driver driver = this.selectById(driverId); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driverId); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); |
| | | driver.setIntegral(driver.getIntegral() + num3); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("在线时长奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | this.updateById(driver); |
| | | time++; |
| | | } |
| | | } |
| | | redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取司机个人信息 |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public DriverInfoWarpper queryDriverInfo(Integer uid) throws Exception { |
| | | Driver driver = this.selectById(uid); |
| | | DriverInfoWarpper driverInfo = new DriverInfoWarpper(); |
| | | BeanUtils.copyProperties(driver, driverInfo); |
| | | YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid).last(" and failureTime > now() order by failureTime limit 0, 1")); |
| | | if(null != youTuiDriver){ |
| | | driverInfo.setYouTuiStart(youTuiDriver.getCreateTime().getTime()); |
| | | } |
| | | List<Integer> state = Arrays.asList(107, 108, 109); |
| | | int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m-%d', createTime) = DATE_FORMAT('%Y-%m-%d', now())")); |
| | | driverInfo.setTodayNum(count); |
| | | count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m', createTime) = DATE_FORMAT('%Y-%m', now())")); |
| | | driverInfo.setMonthNum(count); |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); |
| | | driverInfo.setWork(null == driverWork ? 0 : 1); |
| | | driverInfo.setOnline(0); |
| | | String value = redisUtil.getValue("ONLINE" + uid); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | Integer second = Integer.valueOf(value.split("_")[0]); |
| | | driverInfo.setOnline(second); |
| | | } |
| | | return driverInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改司机个人信息 |
| | | * @param uid |
| | | * @param driverInfo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil saveDriverInfo(Integer uid, DriverInfo driverInfo) throws Exception { |
| | | Driver driver = this.selectById(uid); |
| | | if(ToolUtil.isNotEmpty(driverInfo.getAvatar())){ |
| | | driver.setAvatar(driverInfo.getAvatar()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(driverInfo.getEmergencyContact())){ |
| | | driver.setEmergencyContact(driverInfo.getEmergencyContact()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(driverInfo.getEmergencyPhone())){ |
| | | driver.setEmergencyPhone(driverInfo.getEmergencyPhone()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(driverInfo.getPhone()) && ToolUtil.isNotEmpty(driverInfo.getCode())){ |
| | | String value = redisUtil.getValue(driverInfo.getPhone()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | return ResultUtil.error("验证码已过期"); |
| | | } |
| | | if(!value.equals(driverInfo.getPhone())){ |
| | | return ResultUtil.error("验证码无效"); |
| | | } |
| | | driver.setPhone(driverInfo.getPhone()); |
| | | } |
| | | this.updateById(driver); |
| | | return ResultUtil.success(); |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverWorkMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.model.DriverWork; |
| | | import com.supersavedriving.driver.modular.system.model.OrderTransfer; |
| | | import com.supersavedriving.driver.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverWorkService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IOrderTransferService orderTransferService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | driverWork.setWorkTime(new Date()); |
| | | driverWork.setOnlineTime(0L); |
| | | driverWork.setStatus(1); |
| | | this.updateById(driverWork); |
| | | this.insert(driverWork); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil driverOffWork(Integer driverId, Long onlineTime) throws Exception { |
| | | DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", 1).eq("status", 2)); |
| | | if(null != driverWork){ |
| | | return ResultUtil.error("您已下班,不能重复操作"); |
| | | } |
| | | driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", 1).eq("status", 1)); |
| | | DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driverId).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("您还未上班"); |
| | | } |
| | | driverWork.setOffWorkTime(new Date()); |
| | | driverWork.setOnlineTime(onlineTime); |
| | | driverWork.setOnlineTime(0L); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | Integer online = Integer.valueOf(value.split("_")[0]); |
| | | driverWork.setOnlineTime(online.longValue()); |
| | | } |
| | | driverWork.setStatus(2); |
| | | this.updateById(driverWork); |
| | | return ResultUtil.success(); |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.HtmlMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Html; |
| | | import com.supersavedriving.driver.modular.system.service.IHtmlService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * TODO 协议 |
| | | * @author 39373 |
| | | * @date 2023/2/26 17:31 |
| | | */ |
| | | @Service |
| | | public class HtmlServiceImpl extends ServiceImpl<HtmlMapper, Html> implements IHtmlService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.JoiningRequirementsMapper; |
| | | import com.supersavedriving.driver.modular.system.model.JoiningRequirements; |
| | | import com.supersavedriving.driver.modular.system.service.IJoiningRequirementsService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 9:23 |
| | | */ |
| | | @Service |
| | | public class JoiningRequirementsServiceImpl extends ServiceImpl<JoiningRequirementsMapper, JoiningRequirements> implements IJoiningRequirementsService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.MainContentMapper; |
| | | import com.supersavedriving.driver.modular.system.model.MainContent; |
| | | import com.supersavedriving.driver.modular.system.service.IMainContentService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class MainContentServiceImpl extends ServiceImpl<MainContentMapper, MainContent> implements IMainContentService { |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.model.DriverWork; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverWorkService; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderPositionService; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderService; |
| | | import com.supersavedriving.driver.modular.system.util.GeodesyUtil; |
| | | import com.supersavedriving.driver.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverPositionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderPositionWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.ProcessOperationsWarpper; |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.OrderMapper; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.GaoDe.MapUtil; |
| | | import com.supersavedriving.driver.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.PushUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Circle; |
| | |
| | | private ICancelOrderService cancelOrderService; |
| | | |
| | | @Autowired |
| | | private IRevenueService revenueService; |
| | | private IAccountChangeDetailService accountChangeDetailService; |
| | | |
| | | private Map<String, Timer> timerMap = new HashMap<>(); |
| | | |
| | |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getProvince() + "' like district")); |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(1, d, 0, order, city); |
| | |
| | | pushUtil.pushOrderStatus(uid, 2, order.getId(), order.getStatus()); |
| | | }else{ |
| | | //开始推单 |
| | | pushOrder(order); |
| | | // pushOrder(order); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | orderRefusal.setStartAddress(order.getStartAddress()); |
| | | orderRefusal.setOrderId(orderId); |
| | | orderRefusalService.insert(orderRefusal); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | //扣除积分 |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig) { |
| | | //{"num1":"10:00","num2":"14:00","num3":10,"num4":10,"num5":10,"num6":10,"num7":10,"num8":10,"num9":5,"num10":5} |
| | | //拒绝订单扣除积分 |
| | | Integer num10 = JSON.parseObject(systemConfig.getContent()).getInteger("num10"); |
| | | if (num10 > 0) { |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); |
| | | driver.setIntegral(driver.getIntegral() - num10); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("拒绝订单扣除积分"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | driverService.updateById(driver); |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("请先上班"); |
| | | } |
| | | boolean lock = redisUtil.lock(5); |
| | | boolean lock = redisUtil.lock(); |
| | | if(!lock){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | Thread.sleep(3000);//等待3秒 |
| | | lock = redisUtil.lock(5); |
| | | if(lock){ |
| | | break; |
| | | }else{ |
| | | num1++; |
| | | } |
| | | } |
| | | return ResultUtil.error("请重试"); |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | Integer state = order.getState(); |
| | | Integer oldDriverId = order.getDriverId(); |
| | | if(state != 301){ |
| | | if(state == 301){ |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("订单已被取消"); |
| | | } |
| | |
| | | order.setOrderTakingTime(new Date()); |
| | | this.updateById(order); |
| | | redisUtil.unlock(); |
| | | |
| | | if(null != order.getUserId()){ |
| | | AppUser appUser = appUserService.selectById(order.getUserId()); |
| | | appUser.setCancelCount(0); |
| | | appUserService.updateById(appUser); |
| | | } |
| | | |
| | | driver.setServerStatus(2); |
| | | driverService.updateById(driver); |
| | |
| | | } |
| | | |
| | | //推动订单数据 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //发送系统消息 |
| | | systemMessageService.addSystemMessage(uid, 2, "接单成功", "您已成功接到用户订单,请尽快联系客户!"); |
| | | pushUtil.pushOrderStatus(order.getDriverId(), 2, order.getId(), order.getState()); |
| | | if(null != order.getUserId()){ |
| | | systemMessageService.addSystemMessage(order.getUserId(), 1, "接单成功", driver.getName() + "师傅已成功接到您的订单,请保持电话畅通!"); |
| | | pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState()); |
| | | } |
| | | } |
| | | }).start(); |
| | | //发送系统消息 |
| | | systemMessageService.addSystemMessage(uid, 2, "接单成功", "您已成功接到用户订单,请尽快联系客户!"); |
| | | pushUtil.pushOrderStatus(order.getDriverId(), 2, order.getId(), order.getState()); |
| | | if(null != order.getUserId()){ |
| | | systemMessageService.addSystemMessage(order.getUserId(), 1, "接单成功", driver.getName() + "师傅已成功接到您的订单,请保持电话畅通!"); |
| | | pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState()); |
| | | } |
| | | }catch (Exception e){ |
| | | redisUtil.unlock(); |
| | | e.printStackTrace(); |
| | |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(order.getEndLng(), order.getEndLat()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getProvince() + "' like district")); |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(2, Double.valueOf(order.getActualMileage() / 1000), order.getWaitTime(), order, city); |
| | | |
| | | //修改司机状态 |
| | | //修改司机状态和积分 |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | driver.setServerStatus(1); |
| | | driverService.updateById(driver); |
| | | saveIntegral(order); |
| | | break; |
| | | case 401: |
| | | order.setStartWaitTime(new Date()); |
| | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加订单积分奖励 |
| | | * @param order |
| | | * @throws Exception |
| | | */ |
| | | public void saveIntegral(Order order) throws Exception{ |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig){ |
| | | //{"num1":"10:00","num2":"14:00","num3":10,"num4":10,"num5":10,"num6":10,"num7":10,"num8":10,"num9":5,"num10":5} |
| | | //完成订单奖励 |
| | | Integer num5 = JSON.parseObject(systemConfig.getContent()).getInteger("num5"); |
| | | if(num5 > 0){ |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); |
| | | driver.setIntegral(driver.getIntegral() + num5); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("完成订单奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | } |
| | | //恶劣天气完成订单奖励 |
| | | Integer num8 = JSON.parseObject(systemConfig.getContent()).getInteger("num8"); |
| | | if(num8 > 0){ |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); |
| | | driver.setIntegral(driver.getIntegral() + num8); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("恶劣天气完成订单奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | } |
| | | driverService.updateById(driver); |
| | | |
| | | if(null == order.getUserId()){ |
| | | return; |
| | | } |
| | | //推荐用户首单完成奖励 |
| | | Integer num4 = JSON.parseObject(systemConfig.getContent()).getInteger("num4"); |
| | | if(num4 > 0){ |
| | | List<Integer> state = Arrays.asList(105); |
| | | int count = this.selectCount(new EntityWrapper<Order>().eq("userId", order.getUserId()).eq("status", 1).in("state", state)); |
| | | if(count > 1){ |
| | | return; |
| | | } |
| | | AppUser appUser = appUserService.selectById(order.getUserId()); |
| | | if(appUser.getInviterType() == 1){ |
| | | return; |
| | | } |
| | | Driver driver1 = driverService.selectById(appUser.getInviterId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setOldData(driver1.getIntegral().doubleValue()); |
| | | driver1.setIntegral(driver1.getIntegral() + num4); |
| | | accountChangeDetail.setNewData(driver1.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("推荐用户完成首单奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | driverService.updateById(driver1); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getProvince() + "' like district")); |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(1, d, 0, order, city); |
| | |
| | | systemBulletinUserMapper.updateById(systemBulletinUser); |
| | | return systemBulletinInfo; |
| | | } |
| | | |
| | | @Override |
| | | public void clearSystemBulletinUser(Integer userId) throws Exception { |
| | | systemBulletinUserMapper.clearSystemBulletinUser(userId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.SystemBulletinUserMapper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemBulletinUser; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemBulletinUserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 12:05 |
| | | */ |
| | | @Service |
| | | public class SystemBulletinUserServiceImpl extends ServiceImpl<SystemBulletinUserMapper, SystemBulletinUser> implements ISystemBulletinUserService { |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.SystemMessageMapper; |
| | | import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper; |
| | | import com.supersavedriving.driver.modular.system.model.SystemMessage; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemMessageService; |
| | | import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | |
| | | @Override |
| | | public void readSystems(Integer uid, String ids) throws Exception { |
| | | String[] split = ids.split(","); |
| | | List<SystemMessage> systemMessages = this.selectList(new EntityWrapper<SystemMessage>().eq("userType", 2).eq("userId", uid).in("id", split)); |
| | | List<SystemMessage> systemMessages = this.selectList(new EntityWrapper<SystemMessage>().in("id", split)); |
| | | for (SystemMessage systemMessage : systemMessages) { |
| | | systemMessage.setIsRead(1); |
| | | } |
| | |
| | | systemMessage.setUserType(userType); |
| | | this.insert(systemMessage); |
| | | } |
| | | |
| | | @Override |
| | | public void clearSystemMessage(Integer userId) throws Exception { |
| | | this.baseMapper.clearSystemMessage(userId); |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.YouTuiDriverMapper; |
| | | import com.supersavedriving.driver.modular.system.model.YouTuiDriver; |
| | | import com.supersavedriving.driver.modular.system.dao.YouTuiDriverMapper; |
| | | import com.supersavedriving.driver.modular.system.service.IYouTuiDriverService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.driver.modular.system.util.httpClinet.HttpClientUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | import com.supersavedriving.driver.modular.system.util.httpClinet.HttpClientUtil; |
| | | import com.supersavedriving.driver.modular.system.util.httpClinet.HttpResult; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | /** |
| | | * 高德key |
| | | */ |
| | | String key = ""; |
| | | String key = "e0370a9a4d10739045fb0b8f4742a67e"; |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.supersavedriving.driver.modular.system.util.GaoDe.MapConfig.key; |
| | | |
| | | /** |
| | | * 地图工具类 |
| | | * @author pzb |
| | |
| | | */ |
| | | public static Map<String, String> getDistance(String origins, String destination, Integer type){ |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/distance?key=" + key + "&origins=" + origins + "&destination=" + destination + |
| | | String url = "https://restapi.amap.com/v3/distance?key=" + MapConfig.key + "&origins=" + origins + "&destination=" + destination + |
| | | "&type=" + type; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | |
| | | */ |
| | | public static List<String> geocoding(String address){ |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON&address=" + address; |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + MapConfig.key + "&output=JSON&address=" + address; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | | return null; |
| | |
| | | */ |
| | | public static District geocode(String lon, String lan) { |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan; |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + MapConfig.key + "&location=" + lon + "," + lan; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | | return null; |
| | |
| | | import org.dom4j.DocumentException; |
| | | import org.dom4j.Element; |
| | | import org.dom4j.io.SAXReader; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | |
| | | |
| | | /** |
| | | * 获取redis锁 |
| | | * @return |
| | | */ |
| | | public boolean lock(){ |
| | | boolean b = lock(5); |
| | | if(!b){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | try { |
| | | Thread.sleep(3000);//等待3秒 |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | b = lock(5); |
| | | if(b){ |
| | | return true; |
| | | }else{ |
| | | num1++; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取redis锁 |
| | | * @param time |
| | | * @return |
| | | */ |
| | |
| | | * 参数异常 |
| | | * @return |
| | | */ |
| | | public static ResultUtil paranErr(String...ages){ |
| | | public static ResultUtil paranErr(String ages){ |
| | | return ResultUtil.getResult(ResultUtil.PARAM_ERROR, "【" + ages + "】参数异常", new Object()); |
| | | } |
| | | |
| | |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void taskMinute(){ |
| | | try { |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import java.io.File; |
| | |
| | | private String name; |
| | | @ApiModelProperty("广告类型(1=弹窗广告,2=底部广告)") |
| | | private Integer type; |
| | | @ApiModelProperty("广告地址") |
| | | private String url; |
| | | @ApiModelProperty("是否跳转(0=否,1=是)") |
| | | private Integer isJump; |
| | | @ApiModelProperty("跳转类型(1=内部跳转,2=外部跳转)") |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/10 10:36 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class DriverInfo { |
| | | @ApiModelProperty(value = "头像", required = false, dataType = "String") |
| | | private String avatar; |
| | | @ApiModelProperty(value = "紧急联系人", required = false, dataType = "String") |
| | | private String emergencyContact; |
| | | @ApiModelProperty(value = "紧急联系人电话", required = false, dataType = "String") |
| | | private String emergencyPhone; |
| | | @ApiModelProperty(value = "手机验证码", required = false, dataType = "String") |
| | | private String code; |
| | | @ApiModelProperty(value = "新手机号码", required = false, dataType = "String") |
| | | private String phone; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/9 14:09 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class DriverInfoWarpper { |
| | | @ApiModelProperty("司机id") |
| | | private Integer id; |
| | | @ApiModelProperty("头像") |
| | | private String avatar; |
| | | @ApiModelProperty("姓名") |
| | | private String name; |
| | | @ApiModelProperty("电话") |
| | | private String phone; |
| | | @ApiModelProperty("优推开始时间") |
| | | private Long youTuiStart; |
| | | @ApiModelProperty("账户余额") |
| | | private Double balance; |
| | | @ApiModelProperty("积分") |
| | | private Integer integral; |
| | | @ApiModelProperty("今日接单") |
| | | private Integer todayNum; |
| | | @ApiModelProperty("本月接单") |
| | | private Integer monthNum; |
| | | @ApiModelProperty("上班状态(0:没上班,1=一上班)") |
| | | private Integer work; |
| | | @ApiModelProperty("在线时长") |
| | | private Integer online; |
| | | @ApiModelProperty("紧急联系人") |
| | | private String emergencyContact; |
| | | @ApiModelProperty("紧急联系人电话") |
| | | private String emergencyPhone; |
| | | } |
| | |
| | | public static <T> ResponseWarpper<T> success(ResultUtil<T> resultUtil) { |
| | | return new ResponseWarpper(200, "success", resultUtil); |
| | | } |
| | | |
| | | |
| | | public static <T> ResponseWarpper<T> tokenErr() { |
| | | return new ResponseWarpper(600, "token无效"); |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.warpper; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 系统消息 |
| | |
| | | @ApiModel |
| | | public class SystemMessageWarpper { |
| | | @ApiModelProperty("id") |
| | | private Long id; |
| | | private Integer id; |
| | | @ApiModelProperty("标题") |
| | | private String title; |
| | | @ApiModelProperty("内容") |
| | |
| | | typeAliasesPackage: com.supersavedriving.driver.modular |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl |
| | | mapper-locations: classpath*:com/supersavedriving/driver/modular/system/dao/**/*.xml |
| | | |
| | | |
| | | eureka: |
| | |
| | | |
| | | <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 --> |
| | | <!--<property name="log.path" value="/usr/local/server/logs"/>--> |
| | | <property name="log.path" value="d:/logs"/> |
| | | <property name="log.path" value="d:/logs/driver"/> |
| | | |
| | | <!--0. 日志格式和颜色渲染 --> |
| | | <!-- 彩色日志依赖的渲染类 --> |
| | |
| | | <!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
| | | <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <!-- 正在记录的日志文档的路径及文档名 --> |
| | | <file>${log.path}/${artifactId}/debug.log</file> |
| | | <file>${log.path}/debug.log</file> |
| | | <!--日志文档输出格式--> |
| | | <encoder> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | |
| | | <!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 日志归档 --> |
| | | <fileNamePattern>${log.path}/${artifactId}/%d{yyyy-MM-dd}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
| | | <maxFileSize>100MB</maxFileSize> |
| | | </timeBasedFileNamingAndTriggeringPolicy> |
| | |
| | | <!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
| | | <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <!-- 正在记录的日志文档的路径及文档名 --> |
| | | <file>${log.path}/${artifactId}/info.log</file> |
| | | <file>${log.path}/info.log</file> |
| | | <!--日志文档输出格式--> |
| | | <encoder> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | |
| | | <!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 每天日志归档路径以及格式 --> |
| | | <fileNamePattern>${log.path}/${artifactId}/%d{yyyy-MM-dd}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
| | | <maxFileSize>100MB</maxFileSize> |
| | | </timeBasedFileNamingAndTriggeringPolicy> |
| | |
| | | <!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
| | | <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <!-- 正在记录的日志文档的路径及文档名 --> |
| | | <file>${log.path}/${artifactId}/warn.log</file> |
| | | <file>${log.path}/warn.log</file> |
| | | <!--日志文档输出格式--> |
| | | <encoder> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | |
| | | </encoder> |
| | | <!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <fileNamePattern>${log.path}/${artifactId}/%d{yyyy-MM-dd}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
| | | <maxFileSize>100MB</maxFileSize> |
| | | </timeBasedFileNamingAndTriggeringPolicy> |
| | |
| | | <!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
| | | <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <!-- 正在记录的日志文档的路径及文档名 --> |
| | | <file>${log.path}/${artifactId}/error.log</file> |
| | | <file>${log.path}/error.log</file> |
| | | <!--日志文档输出格式--> |
| | | <encoder> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | |
| | | </encoder> |
| | | <!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <fileNamePattern>${log.path}/${artifactId}/%d{yyyy-MM-dd}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
| | | <maxFileSize>100MB</maxFileSize> |
| | | </timeBasedFileNamingAndTriggeringPolicy> |
| | |
| | | <!-- 2.5 所有 除了DEBUG级别的其它高于DEBUG的 日志,记录到一个文件 --> |
| | | <appender name="ALL_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <!-- 正在记录的日志文档的路径及文档名 --> |
| | | <file>${log.path}/${artifactId}/all.log</file> |
| | | <file>${log.path}/all.log</file> |
| | | <!--日志文档输出格式--> |
| | | <encoder> |
| | | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
| | |
| | | </encoder> |
| | | <!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <fileNamePattern>${log.path}/${artifactId}/%d{yyyy-MM-dd}/all-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/all-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
| | | <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
| | | <maxFileSize>100MB</maxFileSize> |
| | | </timeBasedFileNamingAndTriggeringPolicy> |
| | |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-parent</artifactId> |
| | | <version>1.0.0</version> |
| | | <relativePath>../pom.xml</relativePath> |
| | |
| | | package com.supersavedriving.driver.core.mutidatasource.aop; |
| | | |
| | | import com.supersavedriving.driver.core.config.properties.MutiDataSourceProperties; |
| | | import com.supersavedriving.driver.core.mutidatasource.DataSourceContextHolder; |
| | | import com.supersavedriving.driver.core.mutidatasource.annotion.DataSource; |
| | | import com.supersavedriving.driver.core.config.properties.MutiDataSourceProperties; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Around; |
| | |
| | | package com.supersavedriving.driver.core.support; |
| | | |
| | | import com.supersavedriving.driver.core.support.exception.ToolBoxException; |
| | | import com.supersavedriving.driver.core.util.Convert; |
| | | import com.supersavedriving.driver.core.support.exception.ToolBoxException; |
| | | |
| | | import java.beans.*; |
| | | import java.lang.reflect.Method; |
| | |
| | | package com.supersavedriving.driver.core.util; |
| | | |
| | | import com.supersavedriving.driver.core.support.*; |
| | | import com.supersavedriving.driver.core.support.*; |
| | | import com.supersavedriving.driver.core.support.exception.ToolBoxException; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | |
| | | |
| | | ###################### mybatis-plus\u9ED8\u8BA4\u914D\u7F6E ####################### |
| | | mybatis-plus.mapper-locations=classpath*:com/stylefeng/guns/**/mapping/*.xml |
| | | mybatis-plus.mapper-locations=classpath*:com/supersavedriving/driver/**/mapping/*.xml |
| | | # 0:\u6570\u636E\u5E93ID\u81EA\u589E 1:\u7528\u6237\u8F93\u5165id 2:\u5168\u5C40\u552F\u4E00id(IdWorker) 3:\u5168\u5C40\u552F\u4E00ID(uuid) |
| | | mybatis-plus.global-config.id-type=0 |
| | | mybatis-plus.global-config.db-column-underline=false |
| | |
| | | <description>代码生成器</description> |
| | | |
| | | <parent> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-parent</artifactId> |
| | | <version>1.0.0</version> |
| | | <relativePath>../pom.xml</relativePath> |
| | |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.stylefeng</groupId> |
| | | <groupId>com.supersavedriving</groupId> |
| | | <artifactId>guns-core</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
| | | import com.supersavedriving.driver.generator.engine.config.*; |
| | | import com.supersavedriving.driver.generator.engine.config.*; |
| | | |
| | | /** |
| | | * 模板生成父类 |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-parent</artifactId> |
| | | <version>2.0.4.RELEASE</version> |
| | | <relativePath/> <!-- lookup parent from repository --> |
| | | </parent> |
| | | <groupId>com.sinata</groupId> |
| | | <artifactId>demo</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>eureka</name> |
| | | <description>Eureka project for Spring Boot</description> |
| | | |
| | | <packaging>war</packaging> |
| | | |
| | | <properties> |
| | | <java.version>1.8</java.version> |
| | | <spring-cloud.version>Finchley.SR1</spring-cloud.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> |
| | | </dependency> |
| | | <!-- 添加安全认证依赖 --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-security</artifactId> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-tomcat</artifactId> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>javax.servlet</groupId> |
| | | <artifactId>javax.servlet-api</artifactId> |
| | | <version>3.1.0</version> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | <scope>test</scope> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.junit.vintage</groupId> |
| | | <artifactId>junit-vintage-engine</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <dependencyManagement> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-dependencies</artifactId> |
| | | <version>${spring-cloud.version}</version> |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.sinata.eureka; |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; |
| | | |
| | | @EnableEurekaServer//开启服务治理 |
| | | @SpringBootApplication |
| | | public class EurekaApplication extends SpringBootServletInitializer { |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(EurekaApplication.class, args); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
| | | return builder.sources(EurekaApplication.class); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.eureka.config; |
| | | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.config.http.SessionCreationPolicy; |
| | | |
| | | /** |
| | | * 基于web安全认证 |
| | | */ |
| | | @Configuration |
| | | @EnableWebSecurity |
| | | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| | | @Override |
| | | public void configure(HttpSecurity http) throws Exception { |
| | | // Configure HttpSecurity as needed (e.g. enable http basic). |
| | | http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER); |
| | | http.csrf().disable(); |
| | | //注意:为了可以使用 http://${user}:${password}@${host}:${port}/eureka/ 这种方式登录,所以必须是httpBasic, |
| | | // 如果是form方式,不能使用url格式登录 |
| | | http.authorizeRequests().anyRequest().authenticated().and().httpBasic(); |
| | | } |
| | | } |
New file |
| | |
| | | server: |
| | | port: 8000 #服务端口号 |
| | | |
| | | spring: |
| | | application: |
| | | name: eureka-center #服务名称 |
| | | security: |
| | | basic: |
| | | enable: true #开启基于HTTP basic的认证 |
| | | user: #配置用户的账号信息 |
| | | name: sinata |
| | | password: sinata |
| | | |
| | | eureka: |
| | | instance: |
| | | hostname: 127.0.0.1 #注册中心地址 |
| | | client: |
| | | service-url: #客户端调用地址 |
| | | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ |
| | | register-with-eureka: false #是否将自己注册到Eureka服务中,因为该应用本身就是注册中心,不需要再注册自己(集群的时候为true) |
| | | fetch-registry: false #是否从Eureka中获取注册信息,因为自己为注册中心,不会在该应用中的检索服务信息 |
| | | server: |
| | | enable-self-preservation: false #禁用自我保护模式,服务不可用时及时从注册中心剔除 |
| | | eviction-interval-timer-in-ms: 4000 |
| | |
| | | <artifactId>commons-codec</artifactId> |
| | | <version>1.13</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-mongodb</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | package com.supersavedriving.user; |
| | | |
| | | import com.supersavedriving.user.modular.system.util.GDFalconUtil; |
| | | import org.apache.http.client.HttpClient; |
| | | import org.apache.http.config.SocketConfig; |
| | | import org.apache.http.impl.client.HttpClientBuilder; |
| | | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.SpringApplication; |
| | |
| | | @SpringBootApplication |
| | | @EnableScheduling//开启定时任务 |
| | | @EnableTransactionManagement//启动事务功能 |
| | | @MapperScan("com.supersavedriving.user.modular.system.dao") |
| | | public class GunsApplication { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); |
| | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(GunsApplication.class, args); |
| | | logger.info("GunsApplication is success!"); |
| | | |
| | | GDFalconUtil gdFalconUtil = new GDFalconUtil(); |
| | | gdFalconUtil.init();//初始化猎鹰服务 |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | .title("OK出行 Doc") |
| | | .description("所有接口前需要加 /driver 前缀,例如:/driver/base/agreement/queryByType <br>所有以 /api/*** 路径的接口需要上传签名参数sign") |
| | | .title("超省新代驾") |
| | | .description("所有接口前需要加 /user 前缀,例如:/user/base/agreement/queryByType <br>所有以 /api/*** 路径的接口需要上传签名参数sign") |
| | | // .termsOfServiceUrl("http://git.oschina.net/naan1993/guns") |
| | | .contact("stylefeng") |
| | | .version("1.0") |
| | |
| | | @Around("serviceLog()") |
| | | @SuppressWarnings("unchecked") |
| | | public Object around(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | long starTime = System.currentTimeMillis(); |
| | | //通过反射获取被调用方法的Class |
| | | Class type = joinPoint.getSignature().getDeclaringType(); |
| | | //获取类名 |
| | | String typeName = type.getSimpleName(); |
| | | //方法名 |
| | | String methodName = joinPoint.getSignature().getName(); |
| | | //获取参数列表 |
| | | Object[] args = joinPoint.getArgs(); |
| | | //参数Class的数组 |
| | | Class[] clazz = new Class[args.length]; |
| | | for (int i = 0; i < args.length; i++) { |
| | | clazz[i] = args[i].getClass(); |
| | | try { |
| | | long starTime = System.currentTimeMillis(); |
| | | //通过反射获取被调用方法的Class |
| | | Class type = joinPoint.getSignature().getDeclaringType(); |
| | | //获取类名 |
| | | String typeName = type.getSimpleName(); |
| | | //方法名 |
| | | String methodName = joinPoint.getSignature().getName(); |
| | | //获取参数列表 |
| | | Object[] args = joinPoint.getArgs(); |
| | | //参数Class的数组 |
| | | Class[] clazz = new Class[args.length]; |
| | | for (int i = 0; i < args.length; i++) { |
| | | clazz[i] = args[i].getClass(); |
| | | } |
| | | //通过反射获取调用的方法method |
| | | Method method = type.getMethod(methodName, clazz); |
| | | ServiceLog serviceLog = method.getAnnotation(ServiceLog.class); |
| | | //获取方法的参数 |
| | | Parameter[] parameters = method.getParameters(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | Parameter parameter = parameters[i]; |
| | | String name = parameter.getName(); |
| | | jsonObject.put(name, args[i]); |
| | | } |
| | | //执行结果 |
| | | //执行目标方法,获取执行结果 |
| | | Object res = joinPoint.proceed(); |
| | | logger.debug("调用{}.{}方法成功\n" + |
| | | "接口名称:{}\n" + |
| | | "接口地址:{}\n" + |
| | | "耗时:{}ms\n" + |
| | | "参数为:{}\n" + |
| | | "返回结果:{}", typeName, methodName, serviceLog.name(), serviceLog.url(), |
| | | (System.currentTimeMillis() - starTime), jsonObject.toJSONString(), JSONObject.toJSONString(res)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //通过反射获取调用的方法method |
| | | Method method = type.getMethod(methodName, clazz); |
| | | ServiceLog serviceLog = method.getAnnotation(ServiceLog.class); |
| | | //获取方法的参数 |
| | | Parameter[] parameters = method.getParameters(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | Parameter parameter = parameters[i]; |
| | | String name = parameter.getName(); |
| | | jsonObject.put(name, args[i]); |
| | | } |
| | | //执行结果 |
| | | //执行目标方法,获取执行结果 |
| | | Object res = joinPoint.proceed(); |
| | | logger.debug("调用{}.{}方法成功\n" + |
| | | "接口名称:{}\n" + |
| | | "接口地址:{}\n" + |
| | | "耗时:{}ms\n" + |
| | | "参数为:{}\n" + |
| | | "返回结果:{}", typeName, methodName, serviceLog.name(), serviceLog.url(), |
| | | (System.currentTimeMillis() - starTime), jsonObject.toJSONString(), JSONObject.toJSONString(res)); |
| | | //返回执行结果 |
| | | return res; |
| | | return joinPoint.proceed(); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * token异常 |
| | | */ |
| | | TOKEN_EXPIRED(600, "token过期"), |
| | | TOKEN_ERROR(600, "token验证失败"), |
| | | TOKEN_EXPIRED(10030, "token过期"), |
| | | TOKEN_ERROR(10030, "token验证失败"), |
| | | |
| | | /** |
| | | * 签名异常 |
| | | */ |
| | | SIGN_ERROR(700, "签名验证失败"), |
| | | SIGN_ERROR(10040, "签名验证失败"), |
| | | |
| | | /** |
| | | * 其他 |
| | |
| | | |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.model.AppUser; |
| | | import com.supersavedriving.user.modular.system.service.IAppUserService; |
| | | import com.supersavedriving.user.modular.system.service.IDriverService; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; |
| | | import com.supersavedriving.user.modular.system.warpper.SignInToRegister; |
| | | import com.supersavedriving.user.modular.system.warpper.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户控制器 |
| | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/appUserLogin") |
| | | @ServiceLog(name = "微信登录", url = "/base/appUser/appUserLogin") |
| | | // @ServiceLog(name = "微信登录", url = "/base/appUser/appUserLogin") |
| | | @ApiOperation(value = "微信登录", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "微信jscode", name = "jscode", required = true, dataType = "string"), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/signInToRegister") |
| | | @ServiceLog(name = "微信手机授权登录", url = "/base/appUser/signInToRegister") |
| | | // @ServiceLog(name = "微信手机授权登录", url = "/base/appUser/signInToRegister") |
| | | @ApiOperation(value = "微信手机授权登录", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResponseWarpper signInToRegister(SignInToRegister signInToRegister){ |
| | | public ResponseWarpper<SignInToRegisterWarpper> signInToRegister(SignInToRegister signInToRegister){ |
| | | try { |
| | | ResultUtil resultUtil = appUserService.signInToRegister(signInToRegister); |
| | | ResultUtil<SignInToRegisterWarpper> resultUtil = appUserService.signInToRegister(signInToRegister); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryNearbyDrivers") |
| | | // @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") |
| | | @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", required = true, dataType = "string"), |
| | | }) |
| | | public ResponseWarpper<List<NearbyDriverWarpper>> queryNearbyDrivers(String lon, String lat){ |
| | | if(ToolUtil.isEmpty(lat)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("lat")); |
| | | } |
| | | if(ToolUtil.isEmpty(lon)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("lon")); |
| | | } |
| | | try { |
| | | List<NearbyDriverWarpper> list = driverService.queryDriverPosition(lon, lat, 5D); |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/setEmergencyContact") |
| | | // @ServiceLog(name = "设置紧急联系人", url = "/base/appUser/queryNearbyDrivers") |
| | | @ApiOperation(value = "设置紧急联系人", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "电话", name = "phone", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setEmergencyContact(String name, String phone){ |
| | | if(ToolUtil.isEmpty(name)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("name")); |
| | | } |
| | | if(ToolUtil.isEmpty(phone)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("phone")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | appUser.setEmergencyContact(name); |
| | | appUser.setEmergencyPhone(phone); |
| | | appUserService.updateById(appUser); |
| | | return ResponseWarpper.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/appUser/queryUserInfo") |
| | | // @ServiceLog(name = "获取个人信息", url = "/api/appUser/queryUserInfo") |
| | | @ApiOperation(value = "获取个人信息", tags = {"用户端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<UserInfoWarpper> queryUserInfo(){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | UserInfoWarpper userInfoWarpper = new UserInfoWarpper(); |
| | | BeanUtils.copyProperties(appUser, userInfoWarpper); |
| | | return ResponseWarpper.success(userInfoWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.modular.system.model.Broadcast; |
| | | import com.supersavedriving.user.modular.system.service.IBroadcastService; |
| | | import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 广播 |
| | | * @author pzb |
| | | * @Date 2023/2/27 17:12 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class BroadcastController { |
| | | |
| | | @Autowired |
| | | private IBroadcastService broadcastService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/broadcast/queryBroadcast") |
| | | // @ServiceLog(name = "获取广播", url = "/base/broadcast/queryBroadcast") |
| | | @ApiOperation(value = "获取广播", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResponseWarpper<List<String>> queryBroadcast(){ |
| | | try { |
| | | List<Broadcast> broadcasts = broadcastService.selectList(new EntityWrapper<Broadcast>().eq("status", 1).orderBy("sort desc limit 0, 5")); |
| | | List<String> list = new ArrayList<>(); |
| | | for (Broadcast broadcast : broadcasts) { |
| | | list.add(broadcast.getContent()); |
| | | } |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.service.IAppUserService; |
| | | import com.supersavedriving.user.modular.system.service.ICommercialService; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.CommercialWarpper; |
| | | import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 广告控制器 |
| | | */ |
| | | @RestController |
| | | @RequestMapping() |
| | | public class CommercialController { |
| | | |
| | | @Autowired |
| | | private ICommercialService commercialService; |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/commercial/queryCommercialList") |
| | | // @ServiceLog(name = "获取广告列表", url = "/api/driver/queryCommercialList") |
| | | @ApiOperation(value = "获取广告列表", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "广告类型(1=弹窗广告,2=底部广告)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "设备类型(1=小程序,2=司机端)", name = "device", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<CommercialWarpper>> queryCommercialList(Integer type, Integer device){ |
| | | if(ToolUtil.isEmpty(type)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | | if(ToolUtil.isEmpty(device)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("device")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | List<CommercialWarpper> commercialWarppers = commercialService.queryCommercialList(uid, type, device); |
| | | return ResponseWarpper.success(commercialWarppers); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.modular.system.model.Html; |
| | | import com.supersavedriving.user.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.user.modular.system.service.IHtmlService; |
| | | import com.supersavedriving.user.modular.system.service.ISystemConfigService; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; |
| | | import com.supersavedriving.user.modular.system.warpper.StartPriceWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 协议控制器 |
| | |
| | | @Autowired |
| | | private IHtmlService htmlService; |
| | | |
| | | @Autowired |
| | | private ISystemConfigService systemConfigService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/html/queryHtml") |
| | | @ServiceLog(name = "获取各种协议和说明", url = "/base/html/queryHtml") |
| | | // @ServiceLog(name = "获取各种协议和说明", url = "/base/html/queryHtml") |
| | | @ApiOperation(value = "获取各种协议和说明", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型(1=用户协议,2=隐私政策,3=法律条款,4=代驾服务协议,5=个人信息处理规则,6=积分说明,7=佣金规则说明,8=行程录音说明,9=预估价格说明,10=加盟基本要求,11=加盟流程,12=起步价说明,13=注销协议,14=关于我们,15=司机消单说明)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "类型(1=代驾服务协议与隐私政策保护,2=法律条款,3=个人信息处理规则,4=积分说明,5=佣金规则说明,6=行程录音说明,7=预估价格说明,8=加盟基本要求,9=加盟流程,10=起步价说明,11=注销协议,12=关于我们,13=司机消单说明)", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public ResponseWarpper<String> queryHtml(Integer type){ |
| | | if(null == type){ |
| | |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/html/queryStartPrice") |
| | | // @ServiceLog(name = "获取起步价和起步价说明", url = "/base/html/queryStartPrice") |
| | | @ApiOperation(value = "获取起步价和起步价说明", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResponseWarpper<StartPriceWarpper> queryStartPrice(){ |
| | | try { |
| | | Html html = htmlService.selectOne(new EntityWrapper<Html>().eq("type",10)); |
| | | StartPriceWarpper startPriceWarpper = new StartPriceWarpper(); |
| | | //{"ChargeStandard":[{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2},{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2}],"ExtraCost":{"num1":1,"num2":1,"num3":1,"num4":1,"num5":1,"num6":1,"num7":1,"num8":1,"num9":1},"description":"这是一段说明文本"} |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HHmm"); |
| | | Integer integer = Integer.valueOf(sdf.format(new Date())); |
| | | for (int i = 0; i < chargeStandard.size(); i++) { |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(i); |
| | | String num1 = jsonObject1.getString("num1"); |
| | | String num2 = jsonObject1.getString("num2"); |
| | | num1 = num1.replaceAll(":", ""); |
| | | num2 = num2.replaceAll(":", ""); |
| | | |
| | | Double num3 = jsonObject1.getDouble("num3"); |
| | | Double num4 = jsonObject1.getDouble("num4"); |
| | | Double num5 = jsonObject1.getDouble("num5"); |
| | | Double num6 = jsonObject1.getDouble("num6"); |
| | | if(integer >= Integer.valueOf(num1) && integer < Integer.valueOf(num2)){ |
| | | startPriceWarpper.setStartPrice(num4); |
| | | startPriceWarpper.setStartDistance(num3); |
| | | startPriceWarpper.setExcessMileageUnitPrice(num6); |
| | | startPriceWarpper.setOvermileage(num5); |
| | | break; |
| | | } |
| | | } |
| | | startPriceWarpper.setDescription(null == html ? "" : html.getHtml()); |
| | | return ResponseWarpper.success(startPriceWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.modular.system.model.MainContent; |
| | | import com.supersavedriving.user.modular.system.service.IMainContentService; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 事由控制器 |
| | | * @author pzb |
| | | * @Date 2023/2/27 12:02 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class MainContentController { |
| | | |
| | | @Autowired |
| | | private IMainContentService mainContentService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/mainContent/queryMainContent") |
| | | // @ServiceLog(name = "获取系统事由", url = "/base/mainContent/queryMainContent") |
| | | @ApiOperation(value = "获取系统事由", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "数据类型(1=转单,2=司机消单,3=用户取消订单)", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public ResponseWarpper<List<String>> queryMainContent(Integer type){ |
| | | if(null == type){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | | try { |
| | | List<MainContent> mainContents = mainContentService.selectList(new EntityWrapper<MainContent>().eq("type", type) |
| | | .eq("status", 1).orderBy("createTime")); |
| | | List<String> list = new ArrayList<>(); |
| | | for (MainContent mainContent : mainContents) { |
| | | list.add(mainContent.getContent()); |
| | | } |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.model.AppUser; |
| | | import com.supersavedriving.user.modular.system.model.Order; |
| | | import com.supersavedriving.user.modular.system.service.IAppUserService; |
| | | import com.supersavedriving.user.modular.system.service.IOrderService; |
| | | import com.supersavedriving.user.modular.system.util.PayMoneyUtil; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 订单控制器 |
| | | * @author pzb |
| | | * @Date 2023/2/28 11:24 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class OrderController { |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryServerOrder") |
| | | // @ServiceLog(name = "获取正在进行中的订单id", url = "/api/order/queryServerOrder") |
| | | @ApiOperation(value = "获取正在进行中的订单id", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<Long>> queryServerOrder(){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | List<Integer> list = Arrays.asList(101, 102, 103, 104, 105, 106, 107, 201, 401); |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("userPhone", appUser.getPhone()).eq("status", 1).in("state", list)); |
| | | List<Long> collect = orders.stream().map(Order::getId).collect(Collectors.toList()); |
| | | return ResponseWarpper.success(collect); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/getEstimatedCosts") |
| | | // @ServiceLog(name = "获取预估费用", url = "/api/order/getEstimatedCosts") |
| | | @ApiOperation(value = "获取预估费用", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<EstimatedCostsWarpper> getEstimatedCosts(EstimatedCosts estimatedCosts){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil<EstimatedCostsWarpper> estimatedCosts1 = orderService.getEstimatedCosts(uid, estimatedCosts); |
| | | return ResponseWarpper.success(estimatedCosts1); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/travelOrder") |
| | | // @ServiceLog(name = "用户下单/扫码下单", url = "/api/order/travelOrder") |
| | | @ApiOperation(value = "用户下单/扫码下单", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper travelOrder(TravelOrder travelOrder){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.travelOrder(uid, travelOrder); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/cancelOrder") |
| | | // @ServiceLog(name = "用户取消订单", url = "/api/order/cancelOrder") |
| | | @ApiOperation(value = "用户取消订单", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "取消原因", name = "cause", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper cancelOrder(Long orderId, String cause){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | if(ToolUtil.isEmpty(cause)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("cause")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.cancelOrder(uid, orderId, cause); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderInfo") |
| | | // @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo") |
| | | @ApiOperation(value = "获取订单详情", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderInfoWarpper> queryOrderInfo(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | OrderInfoWarpper orderInfoWarpper = orderService.queryOrderInfo(uid, orderId); |
| | | return ResponseWarpper.success(orderInfoWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/editOrderEndAddress") |
| | | // @ServiceLog(name = "修改终点", url = "/api/order/editOrderEndAddress") |
| | | @ApiOperation(value = "修改终点", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper editOrderEndAddress(EditOrderEndAddress editOrderEndAddress){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.editOrderEndAddress(uid, editOrderEndAddress); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderPrice") |
| | | // @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice") |
| | | @ApiOperation(value = "获取订单费用明细", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "是否余额抵扣(0=否,1=是)", name = "payType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderPriceWarpper> queryOrderPrice(Long orderId, Integer payType){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | if(null == payType){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("payType")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | OrderPriceWarpper orderPriceWarpper = orderService.queryOrderPrice(uid, orderId, payType); |
| | | return ResponseWarpper.success(orderPriceWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryPayCouponList") |
| | | // @ServiceLog(name = "获取支付页面优惠券选择列表", url = "/api/order/queryPayCouponList") |
| | | @ApiOperation(value = "获取支付页面优惠券选择列表", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<CouponWarpper>> queryPayCouponList(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | List<CouponWarpper> list = orderService.queryPayCouponList(uid, orderId); |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/orderPayment") |
| | | // @ServiceLog(name = "订单完成后的支付操作", url = "/api/order/orderPayment") |
| | | @ApiOperation(value = "订单完成后的支付操作", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper orderPayment(OrderPayment orderPayment){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.orderPayment(uid, orderPayment); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单微信支付回调处理 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/order/orderPayCallback") |
| | | public void orderPayCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if(null != map){ |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | String orderId = out_trade_no.substring(17); |
| | | ResultUtil resultUtil = orderService.orderPayCallback(orderId, transaction_id); |
| | | if(resultUtil.getCode() == 10000){ |
| | | PrintWriter out = response.getWriter(); |
| | | out.print(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/orderAppraise") |
| | | // @ServiceLog(name = "订单评价操作", url = "/api/order/orderAppraise") |
| | | @ApiOperation(value = "订单评价操作", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "评分", name = "score", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "评价内容", name = "content", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper orderAppraise(Long orderId, Integer score, String content){ |
| | | try { |
| | | Integer uid = appUserService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.orderAppraise(uid, orderId, score, content); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.AccountChangeDetail; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:33 |
| | | */ |
| | | public interface AccountChangeDetailMapper extends BaseMapper<AccountChangeDetail> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Broadcast; |
| | | |
| | | public interface BroadcastMapper extends BaseMapper<Broadcast> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.CancelOrder; |
| | | |
| | | public interface CancelOrderMapper extends BaseMapper<CancelOrder> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Commercial; |
| | | import com.supersavedriving.user.modular.system.warpper.CommercialWarpper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface CommercialMapper extends BaseMapper<Commercial> { |
| | | |
| | | |
| | | /** |
| | | * 获取广告列表 |
| | | * @param type 广告类型(1=弹窗广告) |
| | | * @param device 设备(1=小程序,2=司机端) |
| | | * @return |
| | | */ |
| | | List<CommercialWarpper> queryCommercialList(@Param("type") Integer type, @Param("device") Integer device); |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.CommercialUserEject; |
| | | |
| | | public interface CommercialUserEjectMapper extends BaseMapper<CommercialUserEject> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | |
| | | public interface CouponMapper extends BaseMapper<Coupon> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Driver; |
| | | |
| | | public interface DriverMapper extends BaseMapper<Driver> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.DriverWork; |
| | | |
| | | public interface DriverWorkMapper extends BaseMapper<DriverWork> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Evaluate; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/11 16:58 |
| | | */ |
| | | public interface EvaluateMapper extends BaseMapper<Evaluate> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.MainContent; |
| | | |
| | | public interface MainContentMapper extends BaseMapper<MainContent> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Order; |
| | | import com.supersavedriving.user.modular.system.warpper.OrderInfoWarpper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface OrderMapper extends BaseMapper<Order> { |
| | | |
| | | |
| | | /** |
| | | * 获取订单详情 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | OrderInfoWarpper queryOrderInfo(@Param("uid") Integer uid, @Param("orderId") Long orderId); |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.SystemConfig; |
| | | |
| | | public interface SystemConfigMapper extends BaseMapper<SystemConfig> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | import com.supersavedriving.user.modular.system.model.UserToCoupon; |
| | | import com.supersavedriving.user.modular.system.warpper.CouponWarpper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户优惠券 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 11:44 |
| | | */ |
| | | public interface UserToCouponMapper extends BaseMapper<UserToCoupon> { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | */ |
| | | Coupon queryCoupon(@Param("uid") Integer uid, @Param("price") Double price); |
| | | |
| | | |
| | | /** |
| | | * 获取订单支付页面的可用优惠券列表 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | */ |
| | | List<CouponWarpper> queryPayCouponList(@Param("uid") Integer uid, @Param("price") Double price); |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.WeatherCity; |
| | | |
| | | public interface WeatherCityMapper extends BaseMapper<WeatherCity> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.user.modular.system.model.YouTuiDriver; |
| | | |
| | | public interface YouTuiDriverMapper extends BaseMapper<YouTuiDriver> { |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace=" com.supersavedriving.user.modular.system.dao.AccountChangeDetailMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type=" com.supersavedriving.user.modular.system.model.AccountChangeDetail"> |
| | | <id column="id" property="id"/> |
| | | <result column="userType" property="userType"/> |
| | | <result column="userId" property="userId"/> |
| | | <result column="type" property="type"/> |
| | | <result column="oldData" property="oldData"/> |
| | | <result column="newData" property="newData"/> |
| | | <result column="explain" property="explain"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | <result column="remark" property="remark"/> |
| | | <result column="inviterType" property="inviterType"/> |
| | | <result column="inviterId" property="inviterId"/> |
| | | <result column="cancelCount" property="cancelCount"/> |
| | | <result column="havDiscount" property="havDiscount"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.BroadcastMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Broadcast"> |
| | | <id column="id" property="id"/> |
| | | <result column="content" property="content"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="status" property="status"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.CancelOrderMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.CancelOrder"> |
| | | <id column="id" property="id"/> |
| | | <result column="orderId" property="orderId"/> |
| | | <result column="userType" property="userType"/> |
| | | <result column="userId" property="userId"/> |
| | | <result column="cause" property="cause"/> |
| | | <result column="status" property="status"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.CommercialMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Commercial"> |
| | | <id column="id" property="id"/> |
| | | <result column="type" property="type"/> |
| | | <result column="name" property="name"/> |
| | | <result column="device" property="device"/> |
| | | <result column="isJump" property="isJump"/> |
| | | <result column="jumpType" property="jumpType"/> |
| | | <result column="jumpUrl" property="jumpUrl"/> |
| | | <result column="html" property="html"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="status" property="status"/> |
| | | <result column="createUserId" property="createUserId"/> |
| | | <result column="createTime" property="createTime"/> |
| | | <result column="updateUserId" property="updateUserId"/> |
| | | <result column="updateTime" property="updateTime"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="queryCommercialList" resultType="com.supersavedriving.user.modular.system.warpper.CommercialWarpper"> |
| | | select |
| | | `name`, |
| | | url, |
| | | `type`, |
| | | isJump, |
| | | jumpType, |
| | | jumpUrl, |
| | | html |
| | | from t_commercial where status = 1 |
| | | <if test="null != type"> |
| | | and `type` = #{type} |
| | | </if> |
| | | <if test="null != device"> |
| | | and device = #{device} |
| | | </if> |
| | | order by sort limit 0, 3 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.CommercialUserEjectMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.CommercialUserEject"> |
| | | <id column="id" property="id"/> |
| | | <result column="userType" property="userType"/> |
| | | <result column="userId" property="userId"/> |
| | | <result column="lastDate" property="lastDate"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.CouponMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Coupon"> |
| | | <id column="id" property="id"/> |
| | | <result column="agent_id" property="agentId"/> |
| | | <result column="branch_office_id" property="branchOfficeId"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="coupon_name" property="couponName"/> |
| | | <result column="coupon_type" property="couponType"/> |
| | | <result column="coupon_code" property="couponCode"/> |
| | | <result column="coupon_service_type" property="couponServiceType"/> |
| | | <result column="coupon_conditional_amount" property="couponConditionalAmount"/> |
| | | <result column="coupon_preferential_amount" property="couponPreferentialAmount"/> |
| | | <result column="coupon_validity" property="couponValidity"/> |
| | | <result column="coupon_send_quantity" property="couponSendQuantity"/> |
| | | <result column="coupon_state" property="couponState"/> |
| | | <result column="coupon_count" property="couponCount"/> |
| | | <result column="remaining_quantity" property="remainingQuantity"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.DriverMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Driver"> |
| | | <id column="id" property="id"/> |
| | | <result column="code" property="code"/> |
| | | <result column="name" property="name"/> |
| | | <result column="avatar" property="avatar"/> |
| | | <result column="phone" property="phone"/> |
| | | <result column="password" property="password"/> |
| | | <result column="sex" property="sex"/> |
| | | <result column="source" property="source"/> |
| | | <result column="emergencyContact" property="emergencyContact"/> |
| | | <result column="emergencyPhone" property="emergencyPhone"/> |
| | | <result column="driverLicenseNumber" property="driverLicenseNumber"/> |
| | | <result column="driverLicense" property="driverLicense"/> |
| | | <result column="firstCertificateTime" property="firstCertificateTime"/> |
| | | <result column="idcard" property="idcard"/> |
| | | <result column="idcardFront" property="idcardFront"/> |
| | | <result column="idcardBack" property="idcardBack"/> |
| | | <result column="inviterType" property="inviterType"/> |
| | | <result column="inviterId" property="inviterId"/> |
| | | <result column="agentId" property="agentId"/> |
| | | <result column="branchOfficeId" property="branchOfficeId"/> |
| | | <result column="balance" property="balance"/> |
| | | <result column="backgroundBalance" property="backgroundBalance"/> |
| | | <result column="approvalStatus" property="approvalStatus"/> |
| | | <result column="approvalNotes" property="approvalNotes"/> |
| | | <result column="approvalUserId" property="approvalUserId"/> |
| | | <result column="approvalTime" property="approvalTime"/> |
| | | <result column="serverStatus" property="serverStatus"/> |
| | | <result column="integral" property="integral"/> |
| | | <result column="score" property="score"/> |
| | | <result column="status" property="status"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="isException" property="isException"/> |
| | | <result column="createTime" property="createTime"/> |
| | | <result column="provinceCode" property="provinceCode"/> |
| | | <result column="provinceName" property="provinceName"/> |
| | | <result column="cityCode" property="cityCode"/> |
| | | <result column="cityName" property="cityName"/> |
| | | <result column="areaCode" property="areaCode"/> |
| | | <result column="areaName" property="areaName"/> |
| | | <result column="commission" property="commission"/> |
| | | <result column="wxCollectionCode" property="wxCollectionCode"/> |
| | | <result column="zfbCollectionCode" property="zfbCollectionCode"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.DriverWorkMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.DriverWork"> |
| | | <id column="id" property="id"/> |
| | | <result column="driverId" property="driverId"/> |
| | | <result column="workTime" property="workTime"/> |
| | | <result column="offWorkTime" property="offWorkTime"/> |
| | | <result column="onlineTime" property="onlineTime"/> |
| | | <result column="status" property="status"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.EvaluateMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Evaluate"> |
| | | <id column="id" property="id"/> |
| | | <result column="orderId" property="orderId"/> |
| | | <result column="userId" property="userId"/> |
| | | <result column="score" property="score"/> |
| | | <result column="evaluate" property="evaluate"/> |
| | | <result column="status" property="status"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.MainContentMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.MainContent"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="content" property="content" /> |
| | | <result column="status" property="status" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.OrderMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.Order"> |
| | | <id column="id" property="id" /> |
| | | <result column="code" property="code" /> |
| | | <result column="userId" property="userId" /> |
| | | <result column="userPhone" property="userPhone" /> |
| | | <result column="userName" property="userName" /> |
| | | <result column="driverId" property="driverId" /> |
| | | <result column="source" property="source" /> |
| | | <result column="agentId" property="agentId" /> |
| | | <result column="branchOfficeId" property="branchOfficeId" /> |
| | | <result column="orderTakingTime" property="orderTakingTime"/> |
| | | <result column="goToAppointmentPointTime" property="goToAppointmentPointTime"/> |
| | | <result column="arrivalTimeAtTheAppointmentPoint" property="arrivalTimeAtTheAppointmentPoint"/> |
| | | <result column="startTime" property="startTime" /> |
| | | <result column="startAddress" property="startAddress" /> |
| | | <result column="startLat" property="startLat" /> |
| | | <result column="startLng" property="startLng" /> |
| | | <result column="endAddress" property="endAddress" /> |
| | | <result column="endLat" property="endLat" /> |
| | | <result column="endLng" property="endLng" /> |
| | | <result column="boardingTime" property="boardingTime" /> |
| | | <result column="getoffTime" property="getoffTime" /> |
| | | <result column="startDistance" property="startDistance" /> |
| | | <result column="startPrice" property="startPrice" /> |
| | | <result column="overDriveDistance" property="overDriveDistance" /> |
| | | <result column="overDrivePrice" property="overDrivePrice" /> |
| | | <result column="longDistance" property="longDistance" /> |
| | | <result column="longDistancePrice" property="longDistancePrice" /> |
| | | <result column="overLongDistance" property="overLongDistance" /> |
| | | <result column="overLongDistancePrice" property="overLongDistancePrice" /> |
| | | <result column="waitTime" property="waitTime" /> |
| | | <result column="waitTimePrice" property="waitTimePrice" /> |
| | | <result column="outWaitTime" property="outWaitTime" /> |
| | | <result column="outWaitTimePrice" property="outWaitTimePrice" /> |
| | | <result column="badWeatherDistance" property="badWeatherDistance" /> |
| | | <result column="badWeatherPrice" property="badWeatherPrice" /> |
| | | <result column="overBadWeatherDistance" property="overBadWeatherDistance" /> |
| | | <result column="overBadWeatherPrice" property="overBadWeatherPrice" /> |
| | | <result column="weather" property="weather"/> |
| | | <result column="estimatedPrice" property="estimatedPrice" /> |
| | | <result column="estimatedMileage" property="estimatedMileage"/> |
| | | <result column="orderMoney" property="orderMoney" /> |
| | | <result column="actualMileage" property="actualMileage"/> |
| | | <result column="payMoney" property="payMoney" /> |
| | | <result column="discountedPrice" property="discountedPrice" /> |
| | | <result column="couponId" property="couponId" /> |
| | | <result column="discountAmount" property="discountAmount"/> |
| | | <result column="discount" property="discount"/> |
| | | <result column="payType" property="payType" /> |
| | | <result column="payTime" property="payTime" /> |
| | | <result column="orderNo" property="orderNo"/> |
| | | <result column="hallOrder" property="hallOrder"/> |
| | | <result column="startWaitTime" property="startWaitTime"/> |
| | | <result column="state" property="state" /> |
| | | <result column="oldState" property="oldState"/> |
| | | <result column="status" property="status" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | <select id="queryOrderInfo" resultType="com.supersavedriving.user.modular.system.warpper.OrderInfoWarpper"> |
| | | select |
| | | a.id as orderId, |
| | | a.`code`, |
| | | a.startAddress, |
| | | a.startLat, |
| | | a.startLng, |
| | | a.endAddress, |
| | | a.endLat, |
| | | a.endLng, |
| | | b.avatar as driverAvatar, |
| | | b.`name` as driverName, |
| | | b.phone as driverPhone, |
| | | b.`code` as driverCode, |
| | | (DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y')) as driverAge, |
| | | (select count(1) from t_order where driverId = b.id and `status` = 1 and state in (107, 108, 109)) as driverNumber, |
| | | b.score as driverScore, |
| | | a.state |
| | | from t_order a |
| | | left join t_driver b on (a.driverId = b.id) |
| | | where a.id = #{orderId} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.SystemConfigMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.SystemConfig"> |
| | | <id column="id" property="id"/> |
| | | <result column="type" property="type"/> |
| | | <result column="content" property="content"/> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.UserToCouponMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.UserToCoupon"> |
| | | <id column="id" property="id" /> |
| | | <result column="userId" property="userId" /> |
| | | <result column="couponId" property="couponId" /> |
| | | <result column="couponTotal" property="couponTotal" /> |
| | | <result column="validCount" property="validCount" /> |
| | | <result column="expireCount" property="expireCount" /> |
| | | <result column="expireTime" property="expireTime" /> |
| | | <result column="createTime" property="createTime" /> |
| | | <result column="status" property="status" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="queryCoupon" resultType="com.supersavedriving.user.modular.system.model.Coupon"> |
| | | select |
| | | a.* |
| | | from t_coupon a |
| | | left join t_user_to_coupon b on (a.id = b.couponId) |
| | | where b.status = 1 and b.expireTime > now() and b.validCount > 0 |
| | | and b.userId = #{uid} and a.coupon_conditional_amount <= #{price} and a.coupon_preferential_amount < #{price} |
| | | order by a.coupon_preferential_amount desc limit 0, 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="queryPayCouponList" resultType="com.supersavedriving.user.modular.system.warpper.CouponWarpper"> |
| | | select |
| | | b.id, |
| | | a.coupon_conditional_amount as couponConditionalAmount, |
| | | a.coupon_preferential_amount as couponPreferentialAmount, |
| | | a.coupon_name as couponName, |
| | | UNIX_TIMESTAMP(b.expireTime) * 1000 as expirationDate, |
| | | b.validCount as number |
| | | from t_coupon a |
| | | left join t_user_to_coupon b on (a.id = b.couponId) |
| | | where b.userId = #{uid} and b.validCount > 0 and b.expireTime > now() and |
| | | a.coupon_conditional_amount <= #{price} and a.coupon_preferential_amount < #{price} order by b.createTime |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.WeatherCityMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.WeatherCity"> |
| | | <id column="id" property="id" /> |
| | | <result column="province" property="province" /> |
| | | <result column="city" property="city" /> |
| | | <result column="district" property="district" /> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.user.modular.system.dao.YouTuiDriverMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.user.modular.system.model.YouTuiDriver"> |
| | | <id column="id" property="id" /> |
| | | <result column="driverId" property="driverId" /> |
| | | <result column="youTuiId" property="youTuiId" /> |
| | | <result column="integral" property="integral" /> |
| | | <result column="failureTime" property="failureTime" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 账户变动记录 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:30 |
| | | */ |
| | | @Data |
| | | @TableName("t_account_change_detail") |
| | | public class AccountChangeDetail { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 用户类型(1=用户,2=司机) |
| | | */ |
| | | @TableField("userType") |
| | | private Integer userType; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 类型(1=余额,2=积分) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 历史数据 |
| | | */ |
| | | @TableField("oldData") |
| | | private Double oldData; |
| | | /** |
| | | * 新数据 |
| | | */ |
| | | @TableField("newData") |
| | | private Double newData; |
| | | /** |
| | | * 变动说明 |
| | | */ |
| | | @TableField("explain") |
| | | private String explain; |
| | | /** |
| | | * 变动时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
| | |
| | | */ |
| | | @TableField("inviterId") |
| | | private Integer inviterId; |
| | | /** |
| | | * 取消订单次数,取消一次加一,若成功接单清零 |
| | | */ |
| | | @TableField("cancelCount") |
| | | private Integer cancelCount; |
| | | /** |
| | | * 是否拥有9折优惠 1是 0否 |
| | | */ |
| | | @TableField("havDiscount") |
| | | private Integer havDiscount; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 广播 |
| | | * @author pzb |
| | | * @Date 2023/2/27 17:05 |
| | | */ |
| | | @Data |
| | | @TableName("t_broadcast") |
| | | public class Broadcast { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 消息内容 |
| | | */ |
| | | @TableField("content") |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @TableField("sort") |
| | | private Integer sort; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 订单取消记录 |
| | | * @author pzb |
| | | * @Date 2023/2/25 14:37 |
| | | */ |
| | | @Data |
| | | @TableName("t_cancel_order") |
| | | public class CancelOrder { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 订单id |
| | | */ |
| | | @TableField("orderId") |
| | | private Long orderId; |
| | | /** |
| | | * 用户类型(1=用户,2=司机) |
| | | */ |
| | | @TableField("userType") |
| | | private Integer userType; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 取消原因 |
| | | */ |
| | | @TableField("cause") |
| | | private String cause; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 广告实体类 |
| | | */ |
| | | @Data |
| | | @TableName("t_commercial") |
| | | public class Commercial { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 类型(1=弹窗广告,2=底部广告) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 广告名称 |
| | | */ |
| | | @TableField("name") |
| | | private String name; |
| | | /** |
| | | * 设备(1=小程序,2=司机端) |
| | | */ |
| | | @TableField("device") |
| | | private Integer device; |
| | | /** |
| | | * 是否跳转(0=否,1=是) |
| | | */ |
| | | @TableField("isJump") |
| | | private Integer isJump; |
| | | /** |
| | | * 跳转类型(1=内部跳转,2=外部跳转) |
| | | */ |
| | | @TableField("jumpType") |
| | | private Integer jumpType; |
| | | /** |
| | | * 跳转链接 |
| | | */ |
| | | @TableField("jumpUrl") |
| | | private String jumpUrl; |
| | | /** |
| | | * 富文本内容 |
| | | */ |
| | | @TableField("html") |
| | | private String html; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @TableField("sort") |
| | | private Integer sort; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加人员id |
| | | */ |
| | | @TableField("createUserId") |
| | | private Integer createUserId; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | /** |
| | | * 修改人员id |
| | | */ |
| | | @TableField("updateUserId") |
| | | private Integer updateUserId; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @TableField("updateTime") |
| | | private Date updateTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户弹框广告记录 |
| | | */ |
| | | @Data |
| | | @TableName("t_commercial_user_eject") |
| | | public class CommercialUserEject { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | @TableField("id") |
| | | private Long id; |
| | | /** |
| | | * 用户类型(1=用户,2=司机) |
| | | */ |
| | | @TableField("userType") |
| | | private Integer userType; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 最后弹出日期 |
| | | */ |
| | | @TableField("lastDate") |
| | | private Date lastDate; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 优惠券 |
| | | * @author pzb |
| | | * @Date 2023/2/28 11:57 |
| | | */ |
| | | @Data |
| | | @TableName("t_coupon") |
| | | public class Coupon { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 代理商id |
| | | */ |
| | | @TableField("agent_id") |
| | | private Integer agentId; |
| | | /** |
| | | * 分公司id |
| | | */ |
| | | @TableField("branch_office_id") |
| | | private Integer branchOfficeId; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | /** |
| | | * 优惠券名称 |
| | | */ |
| | | @TableField("coupon_name") |
| | | private String couponName; |
| | | /** |
| | | * 优惠券类型 1活动券 2新人券 |
| | | */ |
| | | @TableField("coupon_type") |
| | | private Integer couponType; |
| | | /** |
| | | * 优惠券码 |
| | | */ |
| | | @TableField("coupon_code") |
| | | private String couponCode; |
| | | /** |
| | | * 服务类型 1通用券 |
| | | */ |
| | | @TableField("coupon_service_type") |
| | | private Integer couponServiceType; |
| | | /** |
| | | * 条件金额 |
| | | */ |
| | | @TableField("coupon_conditional_amount") |
| | | private Double couponConditionalAmount; |
| | | /** |
| | | * 优惠金额 |
| | | */ |
| | | @TableField("coupon_preferential_amount") |
| | | private Double couponPreferentialAmount; |
| | | /** |
| | | * 有效期 |
| | | */ |
| | | @TableField("coupon_validity") |
| | | private Integer couponValidity; |
| | | /** |
| | | * 赠送数量 |
| | | */ |
| | | @TableField("coupon_send_quantity") |
| | | private Integer couponSendQuantity; |
| | | /** |
| | | * 是否冻结 1正常 2冻结 |
| | | */ |
| | | @TableField("coupon_state") |
| | | private Integer couponState; |
| | | /** |
| | | * 优惠券数量 |
| | | */ |
| | | @TableField("coupon_count") |
| | | private Integer couponCount; |
| | | /** |
| | | * 剩余数量 |
| | | */ |
| | | @TableField("remaining_quantity") |
| | | private Integer remainingQuantity; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 司机基础信息 |
| | | * @author pzb |
| | | * @Date 2023/2/8 18:33 |
| | | */ |
| | | @Data |
| | | @TableName("t_driver") |
| | | public class Driver { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableField("code") |
| | | private String code; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | @TableField("name") |
| | | private String name; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | @TableField("avatar") |
| | | private String avatar; |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @TableField("phone") |
| | | private String phone; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @TableField("password") |
| | | private String password; |
| | | /** |
| | | * 性别(1=男,2=女) |
| | | */ |
| | | @TableField("sex") |
| | | private Integer sex; |
| | | /** |
| | | * 来源 |
| | | */ |
| | | @TableField("source") |
| | | private Integer source; |
| | | /** |
| | | * 紧急联系人 |
| | | */ |
| | | @TableField("emergencyContact") |
| | | private String emergencyContact; |
| | | /** |
| | | * 紧急联系电话 |
| | | */ |
| | | @TableField("emergencyPhone") |
| | | private String emergencyPhone; |
| | | /** |
| | | * 驾驶证号码 |
| | | */ |
| | | @TableField("driverLicenseNumber") |
| | | private String driverLicenseNumber; |
| | | /** |
| | | * 驾驶证照片 |
| | | */ |
| | | @TableField("driverLicense") |
| | | private String driverLicense; |
| | | /** |
| | | * 驾驶证初次领证时间 |
| | | */ |
| | | @TableField("firstCertificateTime") |
| | | private Date firstCertificateTime; |
| | | /** |
| | | * 身份证号码 |
| | | */ |
| | | @TableField("idcard") |
| | | private String idcard; |
| | | /** |
| | | * 身份证正面照 |
| | | */ |
| | | @TableField("idcardFront") |
| | | private String idcardFront; |
| | | /** |
| | | * 身份证背面照 |
| | | */ |
| | | @TableField("idcardBack") |
| | | private String idcardBack; |
| | | /** |
| | | * 邀约人类型(1=用户,2=司机) |
| | | */ |
| | | @TableField("inviterType") |
| | | private Integer inviterType; |
| | | /** |
| | | * 邀约人id |
| | | */ |
| | | @TableField("inviterId") |
| | | private Integer inviterId; |
| | | /** |
| | | * 代理商id |
| | | */ |
| | | @TableField("agentId") |
| | | private Integer agentId; |
| | | /** |
| | | * 分公司id |
| | | */ |
| | | @TableField("branchOfficeId") |
| | | private Integer branchOfficeId; |
| | | /** |
| | | * 账户余额 |
| | | */ |
| | | @TableField("balance") |
| | | private Double balance; |
| | | /** |
| | | * 后台充值余额 |
| | | */ |
| | | @TableField("backgroundBalance") |
| | | private Double backgroundBalance; |
| | | /** |
| | | * 审核状态(1=待审核,2=已同意,3=已拒绝) |
| | | */ |
| | | @TableField("approvalStatus") |
| | | private Integer approvalStatus; |
| | | /** |
| | | * 审核注释 |
| | | */ |
| | | @TableField("approvalNotes") |
| | | private String approvalNotes; |
| | | /** |
| | | * 审核用户id |
| | | */ |
| | | @TableField("approvalUserId") |
| | | private Integer approvalUserId; |
| | | /** |
| | | * 审核时间 |
| | | */ |
| | | @TableField("approvalTime") |
| | | private Date approvalTime; |
| | | /** |
| | | * 服务状态(1=空闲中,2=服务中) |
| | | */ |
| | | @TableField("serverStatus") |
| | | private Integer serverStatus; |
| | | /** |
| | | * 剩余积分 |
| | | */ |
| | | @TableField("integral") |
| | | private Integer integral; |
| | | /** |
| | | * 评分 |
| | | */ |
| | | @TableField("score") |
| | | private Double score; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 启用冻结理由 |
| | | */ |
| | | @TableField("remark") |
| | | private String remark; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | /** |
| | | * 加盟区域省编号 |
| | | */ |
| | | @TableField("provinceCode") |
| | | private String provinceCode; |
| | | /** |
| | | * 加盟区域省名称 |
| | | */ |
| | | @TableField("provinceName") |
| | | private String provinceName; |
| | | /** |
| | | * 加盟区域市编号 |
| | | */ |
| | | @TableField("cityCode") |
| | | private String cityCode; |
| | | /** |
| | | * 加盟区域市名称 |
| | | */ |
| | | @TableField("cityName") |
| | | private String cityName; |
| | | /** |
| | | * 加盟区域区编号 |
| | | */ |
| | | @TableField("areaCode") |
| | | private String areaCode; |
| | | /** |
| | | * 加盟区域区名称 |
| | | */ |
| | | @TableField("areaName") |
| | | private String areaName; |
| | | /** |
| | | * 佣金 |
| | | */ |
| | | @TableField("commission") |
| | | private Double commission; |
| | | /** |
| | | * 微信收款码 |
| | | */ |
| | | @TableField("wxCollectionCode") |
| | | private String wxCollectionCode; |
| | | /** |
| | | * 支付宝收款码 |
| | | */ |
| | | @TableField("zfbCollectionCode") |
| | | private String zfbCollectionCode; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 司机上下班记录 |
| | | */ |
| | | @Data |
| | | @TableName("t_driver_work") |
| | | public class DriverWork { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | @TableField("driverId") |
| | | private Integer driverId; |
| | | /** |
| | | * 上班时间 |
| | | */ |
| | | @TableField("workTime") |
| | | private Date workTime; |
| | | /** |
| | | * 下班时间 |
| | | */ |
| | | @TableField("offWorkTime") |
| | | private Date offWorkTime; |
| | | /** |
| | | * 在线时长(秒) |
| | | */ |
| | | @TableField("onlineTime") |
| | | private Long onlineTime; |
| | | /** |
| | | * 状态(1=上班,2=下班) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/11 16:51 |
| | | */ |
| | | @Data |
| | | @TableName("t_evaluate") |
| | | public class Evaluate { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 订单id |
| | | */ |
| | | @TableField("orderId") |
| | | private Integer orderId; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 评分 |
| | | */ |
| | | @TableField("score") |
| | | private Integer score; |
| | | /** |
| | | * 评价内容 |
| | | */ |
| | | @TableField("evaluate") |
| | | private String evaluate; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
| | |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 类型(1=用户协议,2=隐私政策,3=法律条款,4=代驾服务协议,5=个人信息处理规则,6=积分说明,7=佣金规则说明,8=行程录音说明,9=预估价格说明,10=加盟基本要求,11=加盟流程,12=起步价说明,13=注销协议,14=关于我们) |
| | | * 类型(1=代驾服务协议与隐私政策保护,2=法律条款,3=个人信息处理规则,4=积分说明,5=佣金规则说明,6=行程录音说明,7=预估价格说明,8=加盟基本要求,9=加盟流程,10=起步价说明,11=注销协议,12=关于我们,13=司机消单说明) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 事由管理 |
| | | * @author pzb |
| | | * @Date 2023/2/27 11:34 |
| | | */ |
| | | @Data |
| | | @TableName("t_main_content") |
| | | public class MainContent { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 数据类型(1=转单,2=司机消单,3=用户取消订单) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | @TableField("content") |
| | | private String content; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 订单 |
| | | * @author pzb |
| | | * @Date 2023/2/15 16:59 |
| | | */ |
| | | @Data |
| | | @TableName("t_order") |
| | | public class Order { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Long id; |
| | | /** |
| | | * 订单编号 |
| | | */ |
| | | @TableField("code") |
| | | private String code; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 乘车人电话 |
| | | */ |
| | | @TableField("userPhone") |
| | | private String userPhone; |
| | | /** |
| | | * 乘车人姓名 |
| | | */ |
| | | @TableField("userName") |
| | | private String userName; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | @TableField("driverId") |
| | | private Integer driverId; |
| | | /** |
| | | * 订单来源(1=小程序,2=APP) |
| | | */ |
| | | @TableField("source") |
| | | private Integer source; |
| | | /** |
| | | * 代理商id |
| | | */ |
| | | @TableField("agentId") |
| | | private Integer agentId; |
| | | /** |
| | | * 分公司id |
| | | */ |
| | | @TableField("branchOfficeId") |
| | | private Integer branchOfficeId; |
| | | /** |
| | | * 接单时间 |
| | | */ |
| | | @TableField("orderTakingTime") |
| | | private Date orderTakingTime; |
| | | /** |
| | | * 前往预约点时间 |
| | | */ |
| | | @TableField("goToAppointmentPointTime") |
| | | private Date goToAppointmentPointTime; |
| | | /** |
| | | * 到达预约点时间 |
| | | */ |
| | | @TableField("arrivalTimeAtTheAppointmentPoint") |
| | | private Date arrivalTimeAtTheAppointmentPoint; |
| | | /** |
| | | * 开始服务时间 |
| | | */ |
| | | @TableField("startTime") |
| | | private Date startTime; |
| | | /** |
| | | * 起点地址 |
| | | */ |
| | | @TableField("startAddress") |
| | | private String startAddress; |
| | | /** |
| | | * 起点纬度 |
| | | */ |
| | | @TableField("startLat") |
| | | private String startLat; |
| | | /** |
| | | * 起点经度 |
| | | */ |
| | | @TableField("startLng") |
| | | private String startLng; |
| | | /** |
| | | * 终点地址 |
| | | */ |
| | | @TableField("endAddress") |
| | | private String endAddress; |
| | | /** |
| | | * 终点纬度 |
| | | */ |
| | | @TableField("endLat") |
| | | private String endLat; |
| | | /** |
| | | * 终点经度 |
| | | */ |
| | | @TableField("endLng") |
| | | private String endLng; |
| | | /** |
| | | * 上车时间 |
| | | */ |
| | | @TableField("boardingTime") |
| | | private Date boardingTime; |
| | | /** |
| | | * 下车时间 |
| | | */ |
| | | @TableField("getoffTime") |
| | | private Date getoffTime; |
| | | /** |
| | | * 起步里程 |
| | | */ |
| | | @TableField("startDistance") |
| | | private Double startDistance; |
| | | /** |
| | | * 起步价 |
| | | */ |
| | | @TableField("startPrice") |
| | | private Double startPrice; |
| | | /** |
| | | * 超出起步里程 |
| | | */ |
| | | @TableField("overDriveDistance") |
| | | private Double overDriveDistance; |
| | | /** |
| | | * 超出起步里程费 |
| | | */ |
| | | @TableField("overDrivePrice") |
| | | private Double overDrivePrice; |
| | | /** |
| | | * 长途里程 |
| | | */ |
| | | @TableField("longDistance") |
| | | private String longDistance; |
| | | /** |
| | | * 长途里程费 |
| | | */ |
| | | @TableField("longDistancePrice") |
| | | private Double longDistancePrice; |
| | | /** |
| | | * 超出长途里程 |
| | | */ |
| | | @TableField("overLongDistance") |
| | | private Double overLongDistance; |
| | | /** |
| | | * 超出长途里程费 |
| | | */ |
| | | @TableField("overLongDistancePrice") |
| | | private Double overLongDistancePrice; |
| | | /** |
| | | * 等待时长(分钟) |
| | | */ |
| | | @TableField("waitTime") |
| | | private Integer waitTime; |
| | | /** |
| | | * 等待费 |
| | | */ |
| | | @TableField("waitTimePrice") |
| | | private Double waitTimePrice; |
| | | /** |
| | | * 超出等待时长(分钟) |
| | | */ |
| | | @TableField("outWaitTime") |
| | | private Integer outWaitTime; |
| | | /** |
| | | * 超出等待时长费 |
| | | */ |
| | | @TableField("outWaitTimePrice") |
| | | private Double outWaitTimePrice; |
| | | /** |
| | | * 恶劣天气里程 |
| | | */ |
| | | @TableField("badWeatherDistance") |
| | | private Double badWeatherDistance; |
| | | /** |
| | | * 恶劣天气里程费 |
| | | */ |
| | | @TableField("badWeatherPrice") |
| | | private Double badWeatherPrice; |
| | | /** |
| | | * 恶劣天气超出里程 |
| | | */ |
| | | @TableField("overBadWeatherDistance") |
| | | private Double overBadWeatherDistance; |
| | | /** |
| | | * 恶劣天气超出里程费 |
| | | */ |
| | | @TableField("overBadWeatherPrice") |
| | | private Double overBadWeatherPrice; |
| | | /** |
| | | * 天气 |
| | | */ |
| | | @TableField("weather") |
| | | private String weather; |
| | | /** |
| | | * 预估价 |
| | | */ |
| | | @TableField("estimatedPrice") |
| | | private Double estimatedPrice; |
| | | /** |
| | | * 预估里程 |
| | | */ |
| | | @TableField("estimatedMileage") |
| | | private Double estimatedMileage; |
| | | /** |
| | | * 订单金额 |
| | | */ |
| | | @TableField("orderMoney") |
| | | private Double orderMoney; |
| | | /** |
| | | * 实际里程 |
| | | */ |
| | | @TableField("actualMileage") |
| | | private Integer actualMileage; |
| | | /** |
| | | * 支付金额 |
| | | */ |
| | | @TableField("payMoney") |
| | | private Double payMoney; |
| | | /** |
| | | * 优惠金额 |
| | | */ |
| | | @TableField("discountedPrice") |
| | | private Double discountedPrice; |
| | | /** |
| | | * 优惠券id |
| | | */ |
| | | @TableField("couponId") |
| | | private Integer couponId; |
| | | /** |
| | | * 折扣优惠金额 |
| | | */ |
| | | @TableField("discountAmount") |
| | | private Double discountAmount; |
| | | /** |
| | | * 折扣0.01 |
| | | */ |
| | | @TableField("discount") |
| | | private Double discount; |
| | | /** |
| | | * 支付类型(1=微信支付,2=余额支付,3=线下支付) |
| | | */ |
| | | @TableField("payType") |
| | | private Integer payType; |
| | | /** |
| | | * 支付时间 |
| | | */ |
| | | @TableField("payTime") |
| | | private Date payTime; |
| | | /** |
| | | * 第三方支付流水号 |
| | | */ |
| | | @TableField("orderNo") |
| | | private String orderNo; |
| | | /** |
| | | * 大厅订单(0=否,1=是) |
| | | */ |
| | | @TableField("hallOrder") |
| | | private Integer hallOrder; |
| | | /** |
| | | * 订单开始进入等待状态时间 |
| | | */ |
| | | @TableField("startWaitTime") |
| | | private Date startWaitTime; |
| | | /** |
| | | * 订单状态(101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中) |
| | | */ |
| | | @TableField("state") |
| | | private Integer state; |
| | | /** |
| | | * 历史订单状态(用于还原之前状态) |
| | | */ |
| | | @TableField("oldState") |
| | | private Integer oldState; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 系统配置 |
| | | * @author pzb |
| | | * @Date 2023/2/15 16:22 |
| | | */ |
| | | @Data |
| | | @TableName("t_system_config") |
| | | public class SystemConfig { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 类型(1=派单规则,2=佣金分成规则,3=抽成规则,4=积分规则,5=价格规则,6=余额规则,7=客服管理) |
| | | */ |
| | | @TableField("type") |
| | | private Integer type; |
| | | /** |
| | | * 内容 |
| | | */ |
| | | @TableField("content") |
| | | private String content; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户优惠券关系 |
| | | * @author pzb |
| | | * @Date 2023/3/2 11:04 |
| | | */ |
| | | @Data |
| | | @TableName("t_user_to_coupon") |
| | | public class UserToCoupon { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 优惠券id |
| | | */ |
| | | @TableField("couponId") |
| | | private Integer couponId; |
| | | /** |
| | | * 领取总数 |
| | | */ |
| | | @TableField("couponTotal") |
| | | private Integer couponTotal; |
| | | /** |
| | | * 有效数据 |
| | | */ |
| | | @TableField("validCount") |
| | | private Integer validCount; |
| | | /** |
| | | * 过期数量 |
| | | */ |
| | | @TableField("expireCount") |
| | | private Integer expireCount; |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @TableField("expireTime") |
| | | private Date expireTime; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | /** |
| | | * 状态 1正常 2冻结 3删除 |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 天气相关城市 |
| | | * @author pzb |
| | | * @Date 2023/2/25 10:56 |
| | | */ |
| | | @Data |
| | | @TableName("t_weather_city") |
| | | public class WeatherCity { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 省 |
| | | */ |
| | | @TableField("province") |
| | | private String province; |
| | | /** |
| | | * 市 |
| | | */ |
| | | @TableField("city") |
| | | private String city; |
| | | /** |
| | | * 区 |
| | | */ |
| | | @TableField("district") |
| | | private String district; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 司机优推数据 |
| | | * @author pzb |
| | | * @Date 2023/2/22 14:01 |
| | | */ |
| | | @Data |
| | | @TableName("t_you_tui_driver") |
| | | public class YouTuiDriver { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | @TableField("driverId") |
| | | private Integer driverId; |
| | | /** |
| | | * 优推id |
| | | */ |
| | | @TableField("youTuiId") |
| | | private Integer youTuiId; |
| | | /** |
| | | * 积分 |
| | | */ |
| | | @TableField("integral") |
| | | private Integer integral; |
| | | /** |
| | | * 失效时间 |
| | | */ |
| | | @TableField("failureTime") |
| | | private Date failureTime; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.AccountChangeDetail; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:34 |
| | | */ |
| | | public interface IAccountChangeDetailService extends IService<AccountChangeDetail> { |
| | | |
| | | |
| | | /** |
| | | * 保存数据 |
| | | * @param accountChangeDetail |
| | | * @throws Exception |
| | | */ |
| | | void saveData(AccountChangeDetail accountChangeDetail) throws Exception; |
| | | } |
| | |
| | | import com.supersavedriving.user.modular.system.model.AppUser; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.SignInToRegister; |
| | | import com.supersavedriving.user.modular.system.warpper.SignInToRegisterWarpper; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | public interface IAppUserService extends IService<AppUser> { |
| | | |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil signInToRegister(SignInToRegister signInToRegister) throws Exception; |
| | | ResultUtil<SignInToRegisterWarpper> signInToRegister(SignInToRegister signInToRegister) throws Exception; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 校验token获取用户信息 |
| | | * @return |
| | | */ |
| | | Integer getUserByRequest() throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Broadcast; |
| | | |
| | | public interface IBroadcastService extends IService<Broadcast> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.CancelOrder; |
| | | |
| | | public interface ICancelOrderService extends IService<CancelOrder> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Commercial; |
| | | import com.supersavedriving.user.modular.system.warpper.CommercialWarpper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 广告接口 |
| | | */ |
| | | public interface ICommercialService extends IService<Commercial> { |
| | | |
| | | |
| | | /** |
| | | * 获取广告列表数据 |
| | | * @param type 广告类型(1=弹窗广告) |
| | | * @param device 设备(1=小程序,2=司机端) |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<CommercialWarpper> queryCommercialList(Integer uid, Integer type, Integer device) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.CommercialUserEject; |
| | | |
| | | public interface ICommercialUserEjectService extends IService<CommercialUserEject> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | |
| | | public interface ICouponService extends IService<Coupon> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Driver; |
| | | import com.supersavedriving.user.modular.system.warpper.NearbyDriverWarpper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 司机 |
| | | * @author pzb |
| | | * @Date 2023/2/8 18:52 |
| | | */ |
| | | public interface IDriverService extends IService<Driver> { |
| | | |
| | | |
| | | /** |
| | | * 获取5公里范围内的司机坐标 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<NearbyDriverWarpper> queryDriverPosition(String lon, String lat, Double scope) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.DriverWork; |
| | | |
| | | public interface IDriverWorkService extends IService<DriverWork> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Evaluate; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/11 16:59 |
| | | */ |
| | | public interface IEvaluateService extends IService<Evaluate> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.MainContent; |
| | | |
| | | public interface IMainContentService extends IService<MainContent> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Order; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 订单 |
| | | * @author pzb |
| | | * @Date 2023/2/16 15:47 |
| | | */ |
| | | public interface IOrderService extends IService<Order> { |
| | | |
| | | |
| | | /** |
| | | * 获取预估费用 |
| | | * @param uid |
| | | * @param estimatedCosts |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil<EstimatedCostsWarpper> getEstimatedCosts(Integer uid, EstimatedCosts estimatedCosts) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 下单操作 |
| | | * @param uid |
| | | * @param travelOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil travelOrder(Integer uid, TravelOrder travelOrder) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * @param uid |
| | | * @param orderId |
| | | * @param cause |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil cancelOrder(Integer uid, Long orderId, String cause) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取订单详情 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | OrderInfoWarpper queryOrderInfo(Integer uid, Long orderId) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 修改订单终点 |
| | | * @param uid |
| | | * @param editOrderEndAddress |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil editOrderEndAddress(Integer uid, EditOrderEndAddress editOrderEndAddress) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取订单费用明细 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | OrderPriceWarpper queryOrderPrice(Integer uid, Long orderId, Integer payType) throws Exception; |
| | | |
| | | /** |
| | | * 获取支付页面的可用优惠券列表 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<CouponWarpper> queryPayCouponList(Integer uid, Long orderId) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 支付订单操作 |
| | | * @param uid |
| | | * @param orderPayment |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil orderPayment(Integer uid, OrderPayment orderPayment) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 订单微信支付回调 |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil orderPayCallback(String orderId, String transaction_id) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 订单评价 |
| | | * @param uid |
| | | * @param orderId |
| | | * @param score |
| | | * @param content |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil orderAppraise(Integer uid, Long orderId, Integer score, String content) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.SystemConfig; |
| | | |
| | | /** |
| | | * 系统配置 |
| | | * @author pzb |
| | | * @Date 2023/2/15 16:26 |
| | | */ |
| | | public interface ISystemConfigService extends IService<SystemConfig> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | import com.supersavedriving.user.modular.system.model.UserToCoupon; |
| | | import com.supersavedriving.user.modular.system.warpper.CouponWarpper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 14:21 |
| | | */ |
| | | public interface IUserToCouponService extends IService<UserToCoupon> { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Coupon queryCoupon(Integer uid, Double price) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取订单支付页面的可用优惠券列表 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<CouponWarpper> queryPayCouponList(Integer uid, Double price) throws Exception; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.WeatherCity; |
| | | |
| | | public interface IWeatherCityService extends IService<WeatherCity> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.user.modular.system.model.YouTuiDriver; |
| | | |
| | | public interface IYouTuiDriverService extends IService<YouTuiDriver> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.AccountChangeDetailMapper; |
| | | import com.supersavedriving.user.modular.system.model.AccountChangeDetail; |
| | | import com.supersavedriving.user.modular.system.service.IAccountChangeDetailService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 账户变动 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 11:34 |
| | | */ |
| | | @Service |
| | | public class AccountChangeDetailServiceImpl extends ServiceImpl<AccountChangeDetailMapper, AccountChangeDetail> implements IAccountChangeDetailService { |
| | | |
| | | |
| | | /** |
| | | * 保存数据 |
| | | * @param accountChangeDetail |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void saveData(AccountChangeDetail accountChangeDetail) throws Exception { |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | this.baseMapper.insert(accountChangeDetail); |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.core.common.constant.JwtConstants; |
| | | import com.supersavedriving.user.core.shiro.ShiroKit; |
| | | import com.supersavedriving.user.core.shiro.ShiroUser; |
| | | import com.supersavedriving.user.core.util.JwtTokenUtil; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.dao.AppUserMapper; |
| | | import com.supersavedriving.user.modular.system.model.AppUser; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | import com.supersavedriving.user.modular.system.model.UserToCoupon; |
| | | import com.supersavedriving.user.modular.system.service.IAppUserService; |
| | | import com.supersavedriving.user.modular.system.service.ICouponService; |
| | | import com.supersavedriving.user.modular.system.service.IUserToCouponService; |
| | | import com.supersavedriving.user.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.user.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.user.modular.system.util.weChat.WXCore; |
| | | import com.supersavedriving.user.modular.system.util.weChat.WeChatUtil; |
| | | import com.supersavedriving.user.modular.system.util.weChat.model.Code2Session; |
| | | import com.supersavedriving.user.modular.system.warpper.CouponWarpper; |
| | | import com.supersavedriving.user.modular.system.warpper.SignInToRegister; |
| | | import com.supersavedriving.user.modular.system.warpper.SignInToRegisterWarpper; |
| | | import org.apache.shiro.authc.SimpleAuthenticationInfo; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; |
| | |
| | | import org.apache.shiro.util.ByteSource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | private final String salt = "s5d1"; |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | @Autowired |
| | | private IUserToCouponService userToCouponService; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil<String> appUserLogin(String jscode) throws Exception { |
| | | Code2Session code2Session = weChatUtil.code2Session(jscode); |
| | | if(code2Session.getErrcode() != 0){ |
| | | if(null != code2Session.getErrcode() && code2Session.getErrcode() != 0){ |
| | | return ResultUtil.error(code2Session.getErrmsg()); |
| | | } |
| | | String openid = code2Session.getOpenid(); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil signInToRegister(SignInToRegister signInToRegister) throws Exception { |
| | | public ResultUtil<SignInToRegisterWarpper> signInToRegister(SignInToRegister signInToRegister) throws Exception { |
| | | SignInToRegisterWarpper warpper = new SignInToRegisterWarpper(); |
| | | if(ToolUtil.isEmpty(signInToRegister.getJscode())){ |
| | | return ResultUtil.paranErr("jscode"); |
| | | } |
| | |
| | | return ResultUtil.paranErr("ivPhone"); |
| | | } |
| | | Code2Session code2Session = weChatUtil.code2Session(signInToRegister.getJscode()); |
| | | if(code2Session.getErrcode() != 0){ |
| | | if(null != code2Session.getErrcode() && code2Session.getErrcode() != 0){ |
| | | return ResultUtil.error(code2Session.getErrmsg()); |
| | | } |
| | | String openid = code2Session.getOpenid(); |
| | |
| | | appUser.setInviterId(signInToRegister.getInviterId()); |
| | | appUser.setInviterType(signInToRegister.getInviterType()); |
| | | this.insert(appUser); |
| | | //发送优惠券 |
| | | boolean lock = redisUtil.lock(); |
| | | if(lock){ |
| | | List<CouponWarpper> list = pushCoupon(appUser.getId()); |
| | | redisUtil.unlock(); |
| | | warpper.setCoupons(list); |
| | | } |
| | | } |
| | | if(appUser.getStatus() == 2){ |
| | | return ResultUtil.error("账号被冻结"); |
| | |
| | | if(ToolUtil.isEmpty(token)){ |
| | | return ResultUtil.error("获取身份凭证失败"); |
| | | } |
| | | return ResultUtil.success(token); |
| | | warpper.setToken(token); |
| | | return ResultUtil.success(warpper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送优惠券 |
| | | * @param userId |
| | | */ |
| | | public List<CouponWarpper> pushCoupon(Integer userId){ |
| | | List<Coupon> coupons = couponService.selectList(new EntityWrapper<Coupon>().eq("coupon_type", 2).eq("coupon_state", 1).gt("remaining_quantity", 0)); |
| | | List<CouponWarpper> list = new ArrayList<>(); |
| | | for (Coupon coupon : coupons) { |
| | | UserToCoupon userToCoupon = new UserToCoupon(); |
| | | userToCoupon.setCouponId(coupon.getId()); |
| | | userToCoupon.setCreateTime(new Date()); |
| | | userToCoupon.setUserId(userId); |
| | | userToCoupon.setStatus(1); |
| | | userToCoupon.setCouponTotal(coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? |
| | | coupon.getRemainingQuantity() : coupon.getCouponSendQuantity()); |
| | | userToCoupon.setValidCount(userToCoupon.getCouponTotal()); |
| | | userToCoupon.setExpireTime(new Date(System.currentTimeMillis() + (coupon.getCouponValidity() * 24 * 60 * 60 * 1000))); |
| | | userToCouponService.insert(userToCoupon); |
| | | |
| | | coupon.setRemainingQuantity(coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? 0 : |
| | | coupon.getRemainingQuantity() - coupon.getCouponSendQuantity()); |
| | | couponService.updateById(coupon); |
| | | |
| | | CouponWarpper couponWarpper = new CouponWarpper(); |
| | | couponWarpper.setCouponConditionalAmount(coupon.getCouponConditionalAmount()); |
| | | couponWarpper.setCouponPreferentialAmount(coupon.getCouponPreferentialAmount()); |
| | | couponWarpper.setCouponName(coupon.getCouponName()); |
| | | couponWarpper.setNumber(userToCoupon.getValidCount()); |
| | | couponWarpper.setExpirationDate(userToCoupon.getExpireTime().getTime()); |
| | | list.add(couponWarpper); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Integer getUserByRequest() throws Exception { |
| | | ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = servletRequestAttributes.getRequest(); |
| | | String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER); |
| | | if (ToolUtil.isNotEmpty(requestHeader) && requestHeader.startsWith("Bearer ")) { |
| | | requestHeader = requestHeader.substring(requestHeader.indexOf(" ") + 1); |
| | | String key = null; |
| | | int length = requestHeader.length(); |
| | | if(length > 16){ |
| | | key = requestHeader.substring(length - 16); |
| | | }else{ |
| | | key = requestHeader; |
| | | } |
| | | String value = redisUtil.getValue(key); |
| | | return null != value ? Integer.valueOf(value) : null; |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.BroadcastMapper; |
| | | import com.supersavedriving.user.modular.system.model.Broadcast; |
| | | import com.supersavedriving.user.modular.system.service.IBroadcastService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 广播 |
| | | * @author pzb |
| | | * @Date 2023/2/27 17:10 |
| | | */ |
| | | @Service |
| | | public class BroadcastServiceImpl extends ServiceImpl<BroadcastMapper, Broadcast> implements IBroadcastService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.CancelOrderMapper; |
| | | import com.supersavedriving.user.modular.system.model.CancelOrder; |
| | | import com.supersavedriving.user.modular.system.service.ICancelOrderService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 取消订单记录 |
| | | * @author pzb |
| | | * @Date 2023/2/25 14:45 |
| | | */ |
| | | @Service |
| | | public class CancelOrderServiceImpl extends ServiceImpl<CancelOrderMapper, CancelOrder> implements ICancelOrderService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.CommercialMapper; |
| | | import com.supersavedriving.user.modular.system.model.Commercial; |
| | | import com.supersavedriving.user.modular.system.model.CommercialUserEject; |
| | | import com.supersavedriving.user.modular.system.service.ICommercialService; |
| | | import com.supersavedriving.user.modular.system.service.ICommercialUserEjectService; |
| | | import com.supersavedriving.user.modular.system.util.UUIDUtil; |
| | | import com.supersavedriving.user.modular.system.warpper.CommercialWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 广告逻辑类 |
| | | */ |
| | | @Service |
| | | public class CommercialServiceImpl extends ServiceImpl<CommercialMapper, Commercial> implements ICommercialService { |
| | | |
| | | @Autowired |
| | | private ICommercialUserEjectService commercialUserEjectService; |
| | | |
| | | |
| | | /** |
| | | * 获取广告列表 |
| | | * @param type 广告类型(1=弹窗广告) |
| | | * @param device 设备(1=小程序,2=司机端) |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CommercialWarpper> queryCommercialList(Integer uid, Integer type, Integer device) throws Exception { |
| | | if(type == 1){//弹框广告 |
| | | // CommercialUserEject commercialUserEject = commercialUserEjectService.selectOne(new EntityWrapper<CommercialUserEject>().eq("userType", 2) |
| | | // .eq("userId", uid).last(" and DATE_FORMAT(now(), '%Y%m%d') = DATE_FORMAT(lastDate, '%Y%m%d')")); |
| | | // if(null != commercialUserEject){ |
| | | // return new ArrayList<>(); |
| | | // } |
| | | } |
| | | List<CommercialWarpper> commercialWarppers = this.baseMapper.queryCommercialList(type, device); |
| | | if(type == 1 && commercialWarppers.size() > 0){//记录弹窗 |
| | | CommercialUserEject commercialUserEject = new CommercialUserEject(); |
| | | commercialUserEject.setId(Long.valueOf(UUIDUtil.getNumberRandom(16))); |
| | | commercialUserEject.setLastDate(new Date()); |
| | | commercialUserEject.setUserId(uid); |
| | | commercialUserEject.setUserType(2); |
| | | commercialUserEjectService.insert(commercialUserEject); |
| | | } |
| | | return commercialWarppers; |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.CommercialUserEjectMapper; |
| | | import com.supersavedriving.user.modular.system.model.CommercialUserEject; |
| | | import com.supersavedriving.user.modular.system.service.ICommercialUserEjectService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class CommercialUserEjectServiceImpl extends ServiceImpl<CommercialUserEjectMapper, CommercialUserEject> implements ICommercialUserEjectService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.CouponMapper; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | import com.supersavedriving.user.modular.system.service.ICouponService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.user.modular.system.model.Driver; |
| | | import com.supersavedriving.user.modular.system.model.DriverWork; |
| | | import com.supersavedriving.user.modular.system.service.IDriverService; |
| | | import com.supersavedriving.user.modular.system.service.IDriverWorkService; |
| | | import com.supersavedriving.user.modular.system.util.GeodesyUtil; |
| | | import com.supersavedriving.user.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.user.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.user.modular.system.warpper.NearbyDriverWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Circle; |
| | | import org.springframework.data.geo.Distance; |
| | | import org.springframework.data.geo.Metrics; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 司机 |
| | | * @author pzb |
| | | * @Date 2023/2/8 18:52 |
| | | */ |
| | | @Service |
| | | public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService { |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private IDriverWorkService driverWorkService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | | * 获取5公里范围内的司机 |
| | | * @param lon |
| | | * @param lat |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<NearbyDriverWarpper> queryDriverPosition(String lon, String lat, Double scope) throws Exception { |
| | | List<NearbyDriverWarpper> list = new ArrayList<>(); |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(lon), Double.valueOf(lat)); |
| | | //构造半径 |
| | | Distance distanceR = new Distance(scope, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | List<Integer> collect = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | List<DriverWork> driverWorks = driverWorkService.selectList(new EntityWrapper<DriverWork>().in("driverId", collect).eq("status", 1)); |
| | | for (DriverWork driverWork : driverWorks) { |
| | | String value = redisUtil.getValue("DRIVER" + driverWork.getDriverId()); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | NearbyDriverWarpper nearbyDriverWarpper = new NearbyDriverWarpper(); |
| | | nearbyDriverWarpper.setLonLat(value); |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, lon + "," + lat); |
| | | nearbyDriverWarpper.setDistance(distance.get("WGS84") / 1000); |
| | | nearbyDriverWarpper.setDriverId(driverWork.getDriverId()); |
| | | list.add(nearbyDriverWarpper); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.DriverWorkMapper; |
| | | import com.supersavedriving.user.modular.system.model.DriverWork; |
| | | import com.supersavedriving.user.modular.system.service.IDriverWorkService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | |
| | | /** |
| | | * 司机上下班操作记录 |
| | | * @author pzb |
| | | * @Date 2023/2/15 15:48 |
| | | */ |
| | | @Service |
| | | public class DriverWorkServiceImpl extends ServiceImpl<DriverWorkMapper, DriverWork> implements IDriverWorkService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.EvaluateMapper; |
| | | import com.supersavedriving.user.modular.system.model.Evaluate; |
| | | import com.supersavedriving.user.modular.system.service.IEvaluateService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/11 17:00 |
| | | */ |
| | | @Service |
| | | public class EvaluateServiceImpl extends ServiceImpl<EvaluateMapper, Evaluate> implements IEvaluateService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.MainContentMapper; |
| | | import com.supersavedriving.user.modular.system.model.MainContent; |
| | | import com.supersavedriving.user.modular.system.service.IMainContentService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class MainContentServiceImpl extends ServiceImpl<MainContentMapper, MainContent> implements IMainContentService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.dao.OrderMapper; |
| | | import com.supersavedriving.user.modular.system.model.*; |
| | | import com.supersavedriving.user.modular.system.service.*; |
| | | import com.supersavedriving.user.modular.system.util.*; |
| | | import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil; |
| | | import com.supersavedriving.user.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.user.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.user.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.user.modular.system.warpper.*; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Circle; |
| | | import org.springframework.data.geo.Distance; |
| | | import org.springframework.data.geo.Metrics; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * 订单 |
| | | * @author pzb |
| | | * @Date 2023/2/16 15:57 |
| | | */ |
| | | @Service |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService { |
| | | |
| | | @Autowired |
| | | private ISystemConfigService systemConfigService; |
| | | |
| | | @Autowired |
| | | private IWeatherCityService weatherCityService; |
| | | |
| | | @Autowired |
| | | private IUserToCouponService userToCouponService; |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | |
| | | @Autowired |
| | | private IYouTuiDriverService youTuiDriverService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private IDriverWorkService driverWorkService; |
| | | |
| | | @Autowired |
| | | private ICancelOrderService cancelOrderService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | @Autowired |
| | | private IAccountChangeDetailService accountChangeDetailService; |
| | | |
| | | @Autowired |
| | | private IEvaluateService evaluateService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取预估费用 |
| | | * @param uid |
| | | * @param estimatedCosts |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil<EstimatedCostsWarpper> getEstimatedCosts(Integer uid, EstimatedCosts estimatedCosts) throws Exception { |
| | | EstimatedCostsWarpper estimatedCostsWarpper = new EstimatedCostsWarpper(); |
| | | Double d = 0D; |
| | | if(ToolUtil.isNotEmpty(estimatedCosts.getEndAddress())){ |
| | | Map<String, String> distance = MapUtil.getDistance(estimatedCosts.getStartLng() + "," + estimatedCosts.getStartLat(), |
| | | estimatedCosts.getEndLng() + "," + estimatedCosts.getEndLat(), 1); |
| | | if(null == distance){ |
| | | return ResultUtil.error("获取预估距离出错"); |
| | | } |
| | | d = Double.valueOf(distance.get("distance")) / 1000; |
| | | estimatedCostsWarpper.setEstimatedMileage(d); |
| | | estimatedCostsWarpper.setTravelTime(Integer.valueOf(distance.get("duration")) / 60); |
| | | } |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(estimatedCosts.getStartLng().toString(), estimatedCosts.getStartLat().toString()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | Order order = getOrderPrice(1, d, 0, new Order(), city); |
| | | Double estimatedPrice = order.getEstimatedPrice(); |
| | | Coupon coupon = userToCouponService.queryCoupon(uid, estimatedPrice); |
| | | if(null != coupon){ |
| | | Double couponPreferentialAmount = coupon.getCouponPreferentialAmount(); |
| | | estimatedCostsWarpper.setPrice(estimatedPrice - couponPreferentialAmount); |
| | | estimatedCostsWarpper.setDiscountAmount(couponPreferentialAmount); |
| | | }else{ |
| | | estimatedCostsWarpper.setPrice(estimatedPrice); |
| | | estimatedCostsWarpper.setDiscountAmount(0D); |
| | | } |
| | | //预估接驾时间 |
| | | int i = 0; |
| | | Double scope = 5D; |
| | | while (true){ |
| | | List<NearbyDriverWarpper> nearbyDriverWarppers = driverService.queryDriverPosition(estimatedCosts.getLng().toString(), estimatedCosts.getLat().toString(), scope); |
| | | if(nearbyDriverWarppers.size() == 0){ |
| | | scope += 5; |
| | | i++; |
| | | if(i >= 10){ |
| | | estimatedCostsWarpper.setPickUpTime(60); |
| | | break; |
| | | } |
| | | continue; |
| | | } |
| | | if(nearbyDriverWarppers.size() > 0){ |
| | | NearbyDriverWarpper nearbyDriverWarpper = nearbyDriverWarppers.get(0); |
| | | Map<String, String> distance = MapUtil.getDistance(nearbyDriverWarpper.getLonLat(), estimatedCosts.getLng() + "," + estimatedCosts.getLat(), 1); |
| | | if(null != distance){ |
| | | distance.get("distance");//距离(M) |
| | | String duration = distance.get("duration");//时间(S) |
| | | estimatedCostsWarpper.setPickUpTime(Integer.valueOf(duration) / 60); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | return ResultUtil.success(estimatedCostsWarpper); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取订单价格 |
| | | * @param type 计算类型(1=预估价,2=订单费) |
| | | * @param distance 行驶公里 |
| | | * @param waitTime 等待时长 |
| | | * @param order 订单数据 |
| | | * @param city 查询天气的城市 |
| | | * @return |
| | | */ |
| | | public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){ |
| | | order = getOrderInitialPrice(order); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | if(null == systemConfig){ |
| | | if(type == 1){//预估金额 |
| | | order.setEstimatedPrice(0D); |
| | | } |
| | | if(type == 2){//订单金额 |
| | | order.setOrderMoney(0D); |
| | | } |
| | | return order; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard"); |
| | | JSONObject extraCost = jsonObject.getJSONObject("ExtraCost"); |
| | | Date date = new Date(); |
| | | for (int i = 0; i < chargeStandard.size(); i++) { |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(i); |
| | | String num1 = jsonObject1.getString("num1"); |
| | | String num2 = jsonObject1.getString("num2"); |
| | | Double num3 = jsonObject1.getDouble("num3");//起步里程 |
| | | Double num4 = jsonObject1.getDouble("num4");//起步价格 |
| | | Double num5 = jsonObject1.getDouble("num5");//超过公里 |
| | | Double num6 = jsonObject1.getDouble("num6");//超过num3每num5公里收取num6 |
| | | Double num7 = jsonObject1.getDouble("num7");//长途起始公里 |
| | | Double num8 = jsonObject1.getDouble("num8");//长途结束公里 |
| | | Double num9 = jsonObject1.getDouble("num9");//长途费 |
| | | Double num10 = jsonObject1.getDouble("num10");//超出长途里程每num10公里 |
| | | Double num11 = jsonObject1.getDouble("num11");//超过num8每num10公里收取num11 |
| | | |
| | | String[] split = num1.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | s.set(Calendar.SECOND, 0); |
| | | |
| | | split = num2.split(":"); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | e.set(Calendar.SECOND, 0); |
| | | |
| | | if(date.getTime() >= s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ |
| | | if(num3.compareTo(distance) >= 0){//起步里程内 |
| | | order.setStartDistance(distance);//起步里程 |
| | | order.setStartPrice(num4);//起步价 |
| | | }else{ |
| | | BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num3));//超出起步里程 |
| | | BigDecimal divide = subtract.divide(new BigDecimal(num5), new MathContext(2, RoundingMode.HALF_EVEN)); |
| | | BigDecimal multiply = divide.multiply(new BigDecimal(num6)); |
| | | order.setStartDistance(num3);//起步里程 |
| | | order.setStartPrice(num4);//起步价 |
| | | order.setOverDriveDistance(subtract.doubleValue());//超出起步里程 |
| | | order.setOverDrivePrice(multiply.doubleValue());//超出起步里程费 |
| | | |
| | | //计算长途费 |
| | | if(distance.compareTo(num7) > 0){ |
| | | order.setLongDistance(num7 + "-" + num8);//长途里程 |
| | | order.setLongDistancePrice(num9);//长途费 |
| | | } |
| | | //计算长途里程超出的部分 |
| | | if(distance.compareTo(num8) > 0){ |
| | | BigDecimal subtract1 = new BigDecimal(distance).subtract(new BigDecimal(num8)); |
| | | BigDecimal divide1 = subtract1.divide(new BigDecimal(num10), new MathContext(2, RoundingMode.HALF_EVEN)); |
| | | BigDecimal multiply1 = divide1.multiply(new BigDecimal(num11)); |
| | | order.setOverLongDistance(subtract1.doubleValue());//超出长途里程 |
| | | order.setOverLongDistancePrice(multiply1.doubleValue());//超出长途里程费 |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //计算额外费用 |
| | | Integer num1 = extraCost.getInteger("num1");//等待时长 |
| | | Double num2 = extraCost.getDouble("num2");//等待费 |
| | | Integer num3 = extraCost.getInteger("num3");//等待超出时长 |
| | | Double num4 = extraCost.getDouble("num4");//等到超出时长费用单价 X/分钟 |
| | | Double num5 = extraCost.getDouble("num5");//恶劣天气公里 |
| | | Double num6 = extraCost.getDouble("num6");//恶劣天气费 |
| | | Double num7 = extraCost.getDouble("num7");//恶劣天气超出公里 |
| | | Double num8 = extraCost.getDouble("num8");//恶劣天气超出公里单价 X/公里 |
| | | Double num9 = extraCost.getDouble("num9");//恶劣天气最高收取金额 |
| | | |
| | | //等待费用 |
| | | if(waitTime.compareTo(num1) >= 0){ |
| | | order.setWaitTime(num1);//等待时长 |
| | | order.setWaitTimePrice(num2);//等待费用 |
| | | |
| | | Integer w = waitTime - num3; |
| | | BigDecimal multiply = new BigDecimal(w).multiply(new BigDecimal(num4)); |
| | | order.setOutWaitTime(w);//等待时长超出分钟 |
| | | order.setOutWaitTimePrice(multiply.doubleValue());//等待时长超出费用 |
| | | } |
| | | |
| | | //恶劣天气 |
| | | boolean badWeather = WeatherUtil.isBadWeather(city); |
| | | if(badWeather){ |
| | | order.setBadWeatherDistance(num5);//恶劣天气公里 |
| | | order.setBadWeatherPrice(num6);//恶劣天气费 |
| | | if(distance.compareTo(num7) > 0){ |
| | | BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num7)); |
| | | BigDecimal multiply = subtract.multiply(new BigDecimal(num8)); |
| | | order.setOverBadWeatherDistance(subtract.doubleValue());//恶劣天气超出公里 |
| | | order.setOverBadWeatherPrice(multiply.doubleValue());//恶劣天气超出公里费 |
| | | } |
| | | |
| | | double add = new BigDecimal(order.getOverBadWeatherPrice()).add(new BigDecimal(order.getBadWeatherPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | if(num9.compareTo(add) < 0){//超出最高金额(重新调整金额) |
| | | if(num9.compareTo(num6) < 0){//如果恶劣天气费大于最高金额 |
| | | order.setBadWeatherPrice(num9);//恶劣天气费 |
| | | order.setOverBadWeatherPrice(0D);//恶劣天气超出公里费 |
| | | }else{ |
| | | BigDecimal subtract = new BigDecimal(num9).subtract(new BigDecimal(add)); |
| | | order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //计算总金额 |
| | | BigDecimal bigDecimal = new BigDecimal(order.getStartPrice() + order.getOverDrivePrice() + order.getLongDistancePrice() + order.getOverLongDistancePrice() + |
| | | order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice() - order.getDiscountAmount()).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | |
| | | if(type == 1){//预估价 |
| | | order.setEstimatedPrice(bigDecimal.doubleValue()); |
| | | } |
| | | if(type == 2){//订单金额 |
| | | order.setOrderMoney(bigDecimal.doubleValue()); |
| | | } |
| | | return order; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 初始订单费用 |
| | | * @param order |
| | | * @return |
| | | */ |
| | | public Order getOrderInitialPrice(Order order){ |
| | | order.setStartDistance(0D);//起步里程 |
| | | order.setStartPrice(0D);//起步价 |
| | | order.setOverDriveDistance(0D);//超出起步里程 |
| | | order.setOverDrivePrice(0D);//超出起步里程费 |
| | | order.setLongDistance("");//长途里程 |
| | | order.setLongDistancePrice(0D);//长途里程费 |
| | | order.setOverLongDistance(0D);//超出长途里程 |
| | | order.setOverLongDistancePrice(0d);//超出长途里程费 |
| | | order.setWaitTime(0);//等待时长 |
| | | order.setWaitTimePrice(0D);//等待费 |
| | | order.setOutWaitTime(0);//超出等待时长 |
| | | order.setOutWaitTimePrice(0D);//超出等待时长费 |
| | | order.setBadWeatherDistance(0D);//恶劣天气里程 |
| | | order.setBadWeatherPrice(0D);//恶劣天气里程费 |
| | | order.setOverBadWeatherDistance(0D);//恶劣天气超出里程 |
| | | order.setOverBadWeatherPrice(0D);//恶劣天气超出里程费 |
| | | order.setDiscountedPrice(0D);//优惠金额 |
| | | order.setCouponId(null);//优惠券 |
| | | order.setDiscountAmount(0D);//折扣优惠金额 |
| | | order.setDiscount(0D);//折扣 |
| | | return order; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下单操作 |
| | | * @param uid |
| | | * @param travelOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil travelOrder(Integer uid, TravelOrder travelOrder) throws Exception { |
| | | List<Integer> state = Arrays.asList(101, 102, 103, 104, 105, 106, 107, 201, 401); |
| | | Order order = this.selectOne(new EntityWrapper<Order>().eq("userId", uid).eq("status", 1).in("state", state)); |
| | | if(null != order){ |
| | | return ResultUtil.error("您还有正在进行的订单"); |
| | | } |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | order = this.selectOne(new EntityWrapper<Order>().eq("userPhone", appUser.getPhone()).eq("status", 1).in("state", state)); |
| | | if(null != order){ |
| | | return ResultUtil.error("您还有正在进行的订单"); |
| | | } |
| | | order = new Order(); |
| | | BeanUtils.copyProperties(travelOrder, order); |
| | | if(ToolUtil.isEmpty(travelOrder.getUserPhone())){ |
| | | order.setUserPhone(appUser.getPhone()); |
| | | order.setUserName(appUser.getNickname()); |
| | | } |
| | | order.setUserId(uid); |
| | | order.setCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(3)); |
| | | order.setSource(1); |
| | | order.setHallOrder(0); |
| | | order.setStatus(1); |
| | | order.setCreateTime(new Date()); |
| | | order.setState(null != travelOrder.getDriverId() ? 102 : 101); |
| | | Double d = 0D; |
| | | if(ToolUtil.isNotEmpty(travelOrder.getEndAddress())){ |
| | | Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), order.getEndLng() + "," + order.getEndLat(), 1); |
| | | if(null == distance){ |
| | | return ResultUtil.error("获取预估距离出错"); |
| | | } |
| | | d = Double.valueOf(distance.get("distance")) / 1000; |
| | | order.setEstimatedMileage(d); |
| | | } |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(1, d, 0, order, city); |
| | | if(null != travelOrder.getDriverId()){ |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", travelOrder.getDriverId()).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("司机还未上班"); |
| | | } |
| | | Driver driver = driverService.selectById(travelOrder.getDriverId()); |
| | | order.setAgentId(driver.getAgentId()); |
| | | order.setBranchOfficeId(driver.getBranchOfficeId()); |
| | | order.setOrderTakingTime(new Date()); |
| | | |
| | | driver.setServerStatus(2); |
| | | driverService.updateById(driver); |
| | | |
| | | appUser.setCancelCount(0); |
| | | appUserService.updateById(appUser); |
| | | } |
| | | |
| | | for (Integer i = 0; i < travelOrder.getDriverNum(); i++) { |
| | | order.setId(null); |
| | | this.insert(order); |
| | | |
| | | //推送状态 |
| | | pushUtil.pushOrderStatus(uid, 1, order.getId(), order.getState()); |
| | | if(null != travelOrder.getDriverId()){ |
| | | pushUtil.pushOrderStatus(travelOrder.getDriverId(), 2, order.getId(), order.getState()); |
| | | }else{ |
| | | //推单 |
| | | pushOrder(order); |
| | | } |
| | | } |
| | | return ResultUtil.success(order.getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单推送逻辑 |
| | | * @param order |
| | | */ |
| | | public void pushOrder(Order order){ |
| | | /** |
| | | * 1.先找最大推单范围内的优推司机 -》 距离最近 |
| | | * 没有1 - 》 |
| | | * 2.按照后台推送配置在范围内查找合适司机 |
| | | * 合适司:积分 > 评分 > 距离 |
| | | * 3.司机没有接单直接将订单置入大厅 |
| | | */ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1)); |
| | | if(null == systemConfig){ |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Double num3 = jsonObject.getDouble("num3");//推单最大范围 |
| | | Integer num4 = jsonObject.getInteger("num4");//接单时间 |
| | | String startLat = order.getStartLat(); |
| | | String startLng = order.getStartLng(); |
| | | |
| | | //1 |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(startLat), Double.valueOf(startLng)); |
| | | Double num = num3 / 1000;//范围公里 |
| | | //构造半径 |
| | | Distance distanceR = new Distance(num, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | List<Integer> driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | Integer driver = null; |
| | | if(driverIds.size() > 0){ |
| | | List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds).last(" and now() < failureTime")); |
| | | Double d = null; |
| | | for (YouTuiDriver youTuiDriver : youTuiDrivers) { |
| | | String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat()); |
| | | Double wgs84 = distance.get("WGS84"); |
| | | if(d == null || d.compareTo(wgs84) > 0){ |
| | | d = wgs84; |
| | | driver = youTuiDriver.getDriverId(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //开始范围查找 |
| | | if(null == driver){ |
| | | for (int i = 1; i < 4; i++) { |
| | | num = jsonObject.getDouble("num" + i) / 1000;//范围公里 |
| | | //构造半径 |
| | | distanceR = new Distance(num, Metrics.KILOMETERS); |
| | | //画圆 |
| | | circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | | query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | locations = mongoTemplate.find(query, Location.class); |
| | | |
| | | driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | if(driverIds.size() > 0){ |
| | | List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("serverStatus", 1).eq("status", 1).in("id", driverIds)); |
| | | if(drivers.size() == 0){ |
| | | continue; |
| | | } |
| | | |
| | | Integer integral = null; |
| | | Double score = null; |
| | | Double d = null; |
| | | for (Driver driver1 : drivers) { |
| | | if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大 |
| | | integral = driver1.getIntegral(); |
| | | score = driver1.getScore(); |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分 |
| | | integral = driver1.getIntegral(); |
| | | score = driver1.getScore(); |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离 |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat()); |
| | | Double wgs84 = distance.get("WGS84"); |
| | | if(d == null || d.compareTo(wgs84) > 0){ |
| | | d = wgs84; |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != driver){ |
| | | pushUtil.pushGrabOrder(driver, 2, order.getId(), num4); |
| | | //创建定时任务处理订单到大厅 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Order order1 = OrderServiceImpl.this.selectById(order.getId()); |
| | | if(order1.getState() == 101 || order1.getState() == 201){ |
| | | order1.setHallOrder(1); |
| | | OrderServiceImpl.this.updateById(order1); |
| | | } |
| | | } |
| | | }, num4 * 1000); |
| | | }else{ |
| | | order.setHallOrder(1); |
| | | this.updateById(order); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * @param uid |
| | | * @param orderId |
| | | * @param cause |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil cancelOrder(Integer uid, Long orderId, String cause) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | if(order.getState() >= 105){ |
| | | return ResultUtil.error("不能取消订单"); |
| | | } |
| | | CancelOrder cancelOrder = new CancelOrder(); |
| | | cancelOrder.setOrderId(orderId); |
| | | cancelOrder.setUserType(1); |
| | | cancelOrder.setUserId(uid); |
| | | cancelOrder.setCause(cause); |
| | | cancelOrder.setStatus(1); |
| | | cancelOrder.setCreateTime(new Date()); |
| | | cancelOrderService.insert(cancelOrder); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | appUser.setCancelCount(appUser.getCancelCount() + 1); |
| | | appUserService.updateById(appUser); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取订单详情 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public OrderInfoWarpper queryOrderInfo(Integer uid, Long orderId) throws Exception { |
| | | return this.baseMapper.queryOrderInfo(uid, orderId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改订单终点 |
| | | * @param uid |
| | | * @param editOrderEndAddress |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil editOrderEndAddress(Integer uid, EditOrderEndAddress editOrderEndAddress) throws Exception { |
| | | Order order = this.selectById(editOrderEndAddress.getOrderId()); |
| | | order.setEndAddress(editOrderEndAddress.getEndAddress()); |
| | | order.setEndLat(editOrderEndAddress.getEndLat().toString()); |
| | | order.setEndLng(editOrderEndAddress.getEndLng().toString()); |
| | | Double d = 0D; |
| | | if(ToolUtil.isNotEmpty(order.getEndAddress())){ |
| | | Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), |
| | | order.getEndLng() + "," + order.getEndLat(), 1); |
| | | if(null == distance){ |
| | | return ResultUtil.error("获取预估距离出错"); |
| | | } |
| | | d = Double.valueOf(distance.get("distance")) / 1000; |
| | | order.setEstimatedMileage(d); |
| | | } |
| | | String city = ""; |
| | | District geocode = MapUtil.geocode(order.getStartLng().toString(), order.getStartLat().toString()); |
| | | if(null != geocode){ |
| | | WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | Order order1 = new Order(); |
| | | BeanUtils.copyProperties(order, order1); |
| | | Order orderPrice = getOrderPrice(1, d, 0, order1, city); |
| | | order.setEstimatedPrice(orderPrice.getEstimatedPrice()); |
| | | this.updateById(order); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取费用明细 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public OrderPriceWarpper queryOrderPrice(Integer uid, Long orderId, Integer payType) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper(); |
| | | BeanUtils.copyProperties(order, orderPriceWarpper); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | orderPriceWarpper.setBalance(appUser.getAccountBalance()); |
| | | Double orderMoney = order.getOrderMoney(); |
| | | //先算优惠券 |
| | | Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney); |
| | | if(null != coupon){ |
| | | orderMoney = orderMoney - coupon.getCouponPreferentialAmount(); |
| | | } |
| | | //再算折扣(余额完全可以抵扣费用才能有折扣) |
| | | if(payType == 1 && appUser.getAccountBalance() > orderMoney){//使用余额抵扣 |
| | | orderPriceWarpper.setDiscount(appUser.getHavDiscount() == 0 ? 0 : 9D); |
| | | orderPriceWarpper.setDiscountAmount(orderMoney * 0.1); |
| | | orderPriceWarpper.setPayType(2);//余额支付 |
| | | orderMoney = orderMoney - orderPriceWarpper.getDiscountAmount(); |
| | | } |
| | | if(payType == 0){//不使用余额抵扣 |
| | | orderPriceWarpper.setDiscount(0D); |
| | | orderPriceWarpper.setDiscountAmount(0D); |
| | | orderPriceWarpper.setPayType(1);//微信支付 |
| | | } |
| | | if(payType == 1 && appUser.getAccountBalance() > 0 && appUser.getAccountBalance() < orderMoney){//使用余额抵扣部分 |
| | | orderPriceWarpper.setDiscount(0D); |
| | | orderPriceWarpper.setDiscountAmount(0D); |
| | | orderPriceWarpper.setPayType(4);//微信+余额 |
| | | orderMoney = orderMoney - appUser.getAccountBalance(); |
| | | } |
| | | orderPriceWarpper.setPayMoney(orderMoney); |
| | | return orderPriceWarpper; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取订单支付页面优惠券列表 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CouponWarpper> queryPayCouponList(Integer uid, Long orderId) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | return userToCouponService.queryPayCouponList(uid, order.getOrderMoney()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 支付订单操作 |
| | | * @param uid |
| | | * @param orderPayment |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil orderPayment(Integer uid, OrderPayment orderPayment) throws Exception { |
| | | Order order = this.selectById(orderPayment.getOrderId()); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | if(order.getState() != 107){ |
| | | return ResultUtil.error("不允许支付"); |
| | | } |
| | | if(orderPayment.getPayType() == 2){ |
| | | Double payMoney = order.getOrderMoney() * (appUser.getHavDiscount() == 1 ? 0.9 : 1); |
| | | if(appUser.getAccountBalance() < payMoney){ |
| | | return ResultUtil.error("账户余额不足"); |
| | | } |
| | | } |
| | | //开始支付操作 |
| | | if(orderPayment.getPayType() == 1){//微信支付 |
| | | return weixinPay(order, appUser, orderPayment.getCouponId()); |
| | | } |
| | | if(orderPayment.getPayType() == 2){//余额支付 |
| | | return balancePayment(order, appUser, orderPayment.getCouponId()); |
| | | } |
| | | if(orderPayment.getPayType() == 3){//线下支付(由司机端操作) |
| | | } |
| | | if(orderPayment.getPayType() == 4){//微信+余额 |
| | | return weixinAndBalancePayment(order, appUser, orderPayment.getCouponId()); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信支付 |
| | | * @param order |
| | | * @param appUser |
| | | * @param couponId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil weixinPay(Order order, AppUser appUser, Integer couponId) throws Exception{ |
| | | Double payMoney = order.getOrderMoney(); |
| | | if(null != couponId){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | } |
| | | } |
| | | order.setPayType(1); |
| | | order.setPayMoney(payMoney); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + order.getId(); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("代驾服务费", "", out_trade_no, payMoney.toString(), "/base/order/orderPayCallback", "JSAPI", appUser.getOpenid()); |
| | | this.updateById(order); |
| | | return weixinpay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 账户余额支付 |
| | | * @param order |
| | | * @param appUser |
| | | * @return |
| | | */ |
| | | public ResultUtil balancePayment(Order order, AppUser appUser, Integer couponId){ |
| | | Double payMoney = order.getOrderMoney(); |
| | | if(null != couponId){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | } |
| | | } |
| | | |
| | | if(appUser.getHavDiscount() == 1){//9折 |
| | | payMoney = payMoney * 0.9; |
| | | order.setDiscount(9D); |
| | | order.setDiscountAmount(payMoney * 0.1); |
| | | } |
| | | |
| | | order.setPayType(2); |
| | | order.setPayMoney(payMoney); |
| | | order.setPayTime(new Date()); |
| | | order.setState(108); |
| | | this.updateById(order); |
| | | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(1); |
| | | accountChangeDetail.setUserId(appUser.getId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(appUser.getAccountBalance()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setExplain("代驾服务费"); |
| | | appUser.setAccountBalance(appUser.getAccountBalance() - payMoney); |
| | | accountChangeDetail.setNewData(appUser.getAccountBalance()); |
| | | appUserService.updateById(appUser); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信+账户余额支付 |
| | | * @param order |
| | | * @param appUser |
| | | * @param couponId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil weixinAndBalancePayment(Order order, AppUser appUser, Integer couponId) throws Exception{ |
| | | Double payMoney = order.getOrderMoney(); |
| | | if(null != couponId){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | } |
| | | } |
| | | order.setPayType(1); |
| | | order.setPayMoney(payMoney); |
| | | |
| | | payMoney = payMoney > appUser.getAccountBalance() ? payMoney - appUser.getAccountBalance() : 0D; |
| | | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(1); |
| | | accountChangeDetail.setUserId(appUser.getId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(appUser.getAccountBalance()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setExplain("代驾服务费"); |
| | | appUser.setAccountBalance(appUser.getAccountBalance() > payMoney ? appUser.getAccountBalance() - payMoney : 0); |
| | | accountChangeDetail.setNewData(appUser.getAccountBalance()); |
| | | appUserService.updateById(appUser); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | |
| | | if(0 < payMoney){//还需要调起微信支付 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + order.getId(); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("代驾服务费", "", out_trade_no, payMoney.toString(), "/base/order/orderPayCallback", "JSAPI", appUser.getOpenid()); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Order order1 = OrderServiceImpl.this.selectById(order.getId()); |
| | | if(order1.getState() != 107){ |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * SUCCESS--支付成功 |
| | | * REFUND--转入退款 |
| | | * NOTPAY--未支付 |
| | | * CLOSED--已关闭 |
| | | * REVOKED--已撤销(刷卡支付) |
| | | * USERPAYING--用户支付中 |
| | | * PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | * ACCEPT--已接收,等待扣款 |
| | | */ |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(out_trade_no, ""); |
| | | if(resultUtil.getCode() == 200){ |
| | | Map<String, String> map = resultUtil.getData(); |
| | | String trade_type = map.get("trade_type"); |
| | | String trade_state = map.get("trade_state"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | if("REFUND".equals(trade_state) || "NOTPAY".equals(trade_state) || "CLOSED".equals(trade_state) || "REVOKED".equals(trade_state) || "PAYERROR".equals(trade_state)){ |
| | | AccountChangeDetail accountChangeDetail1 = accountChangeDetailService.selectById(accountChangeDetail.getId()); |
| | | AppUser appUser1 = appUserService.selectById(accountChangeDetail1.getUserId()); |
| | | Double b = accountChangeDetail1.getOldData() - accountChangeDetail1.getNewData(); |
| | | appUser1.setAccountBalance(appUser1.getAccountBalance() + b); |
| | | appUserService.updateById(appUser1); |
| | | |
| | | accountChangeDetailService.deleteById(accountChangeDetail.getId()); |
| | | return; |
| | | } |
| | | if("SUCCESS".equals(trade_state)){ |
| | | order1.setPayTime(new Date()); |
| | | order1.setState(108); |
| | | order1.setOrderNo(transaction_id); |
| | | OrderServiceImpl.this.updateById(order1); |
| | | |
| | | //处理抽成及收入 |
| | | return; |
| | | } |
| | | if("USERPAYING".equals(trade_state) || "ACCEPT".equals(trade_state)){ |
| | | Thread.sleep(wait); |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | return weixinpay; |
| | | } |
| | | order.setPayTime(new Date()); |
| | | this.updateById(order); |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 订单微信支付回调 |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil orderPayCallback(String orderId, String transaction_id) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | if(order.getState() != 107){ |
| | | return ResultUtil.success(); |
| | | } |
| | | order.setState(108); |
| | | order.setPayTime(new Date()); |
| | | order.setOrderNo(transaction_id); |
| | | this.updateById(order); |
| | | //添加收入明细 |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单评价 |
| | | * @param uid |
| | | * @param orderId |
| | | * @param score |
| | | * @param content |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil orderAppraise(Integer uid, Long orderId, Integer score, String content) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | if(order.getState() != 108){ |
| | | return ResultUtil.error("不能进行评价"); |
| | | } |
| | | order.setState(109); |
| | | this.updateById(order); |
| | | Evaluate evaluate = new Evaluate(); |
| | | evaluate.setOrderId(orderId.intValue()); |
| | | evaluate.setCreateTime(new Date()); |
| | | evaluate.setScore(score); |
| | | evaluate.setEvaluate(content); |
| | | evaluate.setStatus(1); |
| | | evaluate.setUserId(uid); |
| | | evaluateService.insert(evaluate); |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | driver.setScore((driver.getScore() + score) / 2); |
| | | if(score == 5){//司机积分奖励 |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig){ |
| | | //{"num1":"10:00","num2":"14:00","num3":10,"num4":10,"num5":10,"num6":10,"num7":10,"num8":10,"num9":5,"num10":5} |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Integer num5 = jsonObject.getInteger("num5"); |
| | | |
| | | //增加积分变动记录 |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setExplain("代驾5星好评"); |
| | | driver.setIntegral(driver.getIntegral() + num5); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | } |
| | | } |
| | | driverService.updateById(driver); |
| | | return ResultUtil.success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.SystemConfigMapper; |
| | | import com.supersavedriving.user.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.user.modular.system.service.ISystemConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 系统配置 |
| | | * @author pzb |
| | | * @Date 2023/2/15 16:26 |
| | | */ |
| | | @Service |
| | | public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, SystemConfig> implements ISystemConfigService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.UserToCouponMapper; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | | import com.supersavedriving.user.modular.system.model.UserToCoupon; |
| | | import com.supersavedriving.user.modular.system.service.IUserToCouponService; |
| | | import com.supersavedriving.user.modular.system.warpper.CouponWarpper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 14:22 |
| | | */ |
| | | @Service |
| | | public class UserToCouponServiceImpl extends ServiceImpl<UserToCouponMapper, UserToCoupon> implements IUserToCouponService { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Coupon queryCoupon(Integer uid, Double price) throws Exception { |
| | | return this.baseMapper.queryCoupon(uid, price); |
| | | } |
| | | |
| | | /** |
| | | * 获取订单支付页面的优惠券列表 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CouponWarpper> queryPayCouponList(Integer uid, Double price) throws Exception { |
| | | return this.baseMapper.queryPayCouponList(uid, price); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.WeatherCityMapper; |
| | | import com.supersavedriving.user.modular.system.model.WeatherCity; |
| | | import com.supersavedriving.user.modular.system.service.IWeatherCityService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class WeatherCityServiceImpl extends ServiceImpl<WeatherCityMapper, WeatherCity> implements IWeatherCityService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.YouTuiDriverMapper; |
| | | import com.supersavedriving.user.modular.system.model.YouTuiDriver; |
| | | import com.supersavedriving.user.modular.system.service.IYouTuiDriverService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户优推数据 |
| | | * @author pzb |
| | | * @Date 2023/2/22 14:06 |
| | | */ |
| | | @Service |
| | | public class YouTuiDriverServiceImpl extends ServiceImpl<YouTuiDriverMapper, YouTuiDriver> implements IYouTuiDriverService { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.GaoDe; |
| | | |
| | | /** |
| | | * 高德地图配置 |
| | | * @author pzb |
| | | * @Date 2023/2/16 18:52 |
| | | */ |
| | | public interface MapConfig { |
| | | |
| | | /** |
| | | * 高德key |
| | | */ |
| | | String key = "e0370a9a4d10739045fb0b8f4742a67e"; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.GaoDe; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.user.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.user.modular.system.util.httpClinet.HttpClientUtil; |
| | | import com.supersavedriving.user.modular.system.util.httpClinet.HttpResult; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 地图工具类 |
| | | * @author pzb |
| | | * @Date 2023/2/16 18:48 |
| | | */ |
| | | public class MapUtil { |
| | | |
| | | public static Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取两点的距离 |
| | | * @param origins 起点坐标 |
| | | * @param destination 终点坐标 |
| | | * @param type 计算类型:0:直线距离 1:驾车导航距离(仅支持国内坐标)。 |
| | | * @return |
| | | */ |
| | | public static Map<String, String> getDistance(String origins, String destination, Integer type){ |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/distance?key=" + MapConfig.key + "&origins=" + origins + "&destination=" + destination + |
| | | "&type=" + type; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | | logger.debug(httpResult.getData()); |
| | | return null; |
| | | } |
| | | String data = httpResult.getData(); |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | String status = jsonObject.getString("status"); |
| | | if(status.equals("1")){ |
| | | JSONArray results = jsonObject.getJSONArray("results"); |
| | | JSONObject jsonObject1 = results.getJSONObject(0); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("distance", jsonObject1.getString("distance"));//距离(米) |
| | | map.put("duration", jsonObject1.getString("duration"));//预计时间(秒) |
| | | return map; |
| | | }else{ |
| | | logger.debug(data); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 地址转换经纬度 |
| | | * @param address |
| | | * @return |
| | | */ |
| | | public static List<String> geocoding(String address){ |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + MapConfig.key + "&output=JSON&address=" + address; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | | return null; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | String status = jsonObject.getString("status"); |
| | | List<String> list = new ArrayList<>(); |
| | | if(status.equals("1")){ |
| | | JSONArray geocodes = jsonObject.getJSONArray("geocodes"); |
| | | for(int i = 0; i < geocodes.size(); i++){ |
| | | String location = geocodes.getJSONObject(i).getString("location"); |
| | | list.add(location); |
| | | } |
| | | } |
| | | return list; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据经纬度获取行政区域信息 |
| | | * @param lon |
| | | * @param lan |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static District geocode(String lon, String lan) { |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + MapConfig.key + "&location=" + lon + "," + lan; |
| | | HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | if(httpResult.getCode() != 200){ |
| | | return null; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | Map<String, String> map = new HashMap<>(); |
| | | if(jsonObject.getString("status").equals("1")){ |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String address = regeocode.getString("formatted_address"); |
| | | map.put("address", address); |
| | | String code = addressComponent.getString("adcode"); |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | District district1 = new District(); |
| | | district1.setProvince(province); |
| | | district1.setProvinceCode(code.substring(0, 2) + "0000"); |
| | | district1.setCity(city); |
| | | district1.setCityCode(code.substring(0, 4) + "00"); |
| | | district1.setDistrict(district); |
| | | district1.setDistrictCode(code); |
| | | return district1; |
| | | } |
| | | logger.debug(httpResult.getData()); |
| | | return null; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.GaoDe.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 行政区域 |
| | | * @author pzb |
| | | * @Date 2023/2/25 11:40 |
| | | */ |
| | | @Data |
| | | public class District { |
| | | /** |
| | | * 省名称 |
| | | */ |
| | | private String province; |
| | | /** |
| | | * 省编号 |
| | | */ |
| | | private String provinceCode; |
| | | /** |
| | | * 市名称 |
| | | */ |
| | | private String city; |
| | | /** |
| | | * 市编号 |
| | | */ |
| | | private String cityCode; |
| | | /** |
| | | * 区县名称 |
| | | */ |
| | | private String district; |
| | | /** |
| | | * 区县编号 |
| | | */ |
| | | private String districtCode; |
| | | } |
| | |
| | | /** |
| | | * 计算两个金纬度坐标之间的直线距离 |
| | | */ |
| | | @Component |
| | | public class GeodesyUtil { |
| | | |
| | | |
| | |
| | | * @param toLonLat |
| | | * @return |
| | | */ |
| | | public Map<String, Double> getDistance(String fromLonLat, String toLonLat){ |
| | | public static Map<String, Double> getDistance(String fromLonLat, String toLonLat){ |
| | | Map<String, Double> map = null; |
| | | if(ToolUtil.isNotEmpty(fromLonLat) && ToolUtil.isNotEmpty(toLonLat)){ |
| | | map = new HashMap<>(); |
| | |
| | | } |
| | | |
| | | |
| | | private double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){ |
| | | private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){ |
| | | //创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离 |
| | | GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo); |
| | | return geoCurve.getEllipsoidalDistance(); |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.domain.AlipayTradeAppPayModel; |
| | | import com.alipay.api.internal.util.AlipaySignature; |
| | | import com.alipay.api.request.AlipayTradeAppPayRequest; |
| | | import com.alipay.api.request.AlipayTradePrecreateRequest; |
| | | import com.alipay.api.request.AlipayTradeQueryRequest; |
| | | import com.alipay.api.request.AlipayTradeRefundRequest; |
| | | import com.alipay.api.response.AlipayTradeAppPayResponse; |
| | | import com.alipay.api.response.AlipayTradePrecreateResponse; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.alipay.api.response.AlipayTradeRefundResponse; |
| | | import com.alipay.api.domain.AlipayTradeRefundModel; |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.util.httpClinet.HttpClientUtil; |
| | | import org.apache.commons.collections.map.HashedMap; |
| | | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.DocumentException; |
| | | import org.dom4j.Element; |
| | | import org.dom4j.io.SAXReader; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | |
| | | @Value("${wx.appid}") |
| | | private String appid;//微信appid |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String appletsAppid;//微信小程序appid |
| | | |
| | | @Value("${wx.mchId}") |
| | | private String mchId;//微信商户号 |
| | | |
| | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath;//支付回调网关地址 |
| | | |
| | | @Autowired |
| | | private HttpClientUtil httpClientUtil; |
| | | private String app_cert_path = "/usr/local/server/cer/zhifubao/user/app_cert_path.crt";//应用公钥证书路径 |
| | | |
| | | private String alipay_cert_path = "/usr/local/server/cer/zhifubao/user/alipay_cert_path.crt";//支付宝公钥证书文件路径 |
| | | |
| | | private String alipay_root_cert_path = "/usr/local/server/cer/zhifubao/user/alipay_root_cert_path.crt";//支付宝CA根证书文件路径 |
| | | |
| | | private Map<String, JSONObject> order = new HashMap<>();//存储支付订单用于主动查询支付结果 |
| | | |
| | |
| | | /** |
| | | * 支付宝支付 |
| | | */ |
| | | public ResultUtil alipay(String body, String subject, String outTradeNo, String amount, String notifyUrl){ |
| | | public ResultUtil alipay(String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl){ |
| | | // //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | |
| | | //实例化客户端 |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipayPublicKey, "RSA2"); |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); |
| | | //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | |
| | | model.setTimeoutExpress("30m"); |
| | | model.setTotalAmount(amount);//付款金额 |
| | | model.setProductCode("QUICK_MSECURITY_PAY"); |
| | | model.setPassbackParams(passbackParams);//自定义参数 |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | try { |
| | |
| | | String valueStr = ""; |
| | | for (int i = 0; i < values.length; i++) { |
| | | valueStr = (i == values.length - 1) ? valueStr + values[i] |
| | | : valueStr + values[i] + ","; |
| | | : valueStr + values[i] + "_"; |
| | | } |
| | | //乱码解决,这段代码在出现乱码时使用。 |
| | | //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); |
| | |
| | | } |
| | | //切记alipaypublickey是支付宝的公钥,请去open.alipay.com对应应用下查看。 |
| | | //boolean AlipaySignature.rsaCheckV1(Map<String, String> params, String publicKey, String charset, String sign_type) |
| | | try { |
| | | boolean flag = AlipaySignature.rsaCheckV1(params, alipayPublicKey, "UTF-8","RSA2"); |
| | | if(flag){ |
| | | Map<String, String> map = new HashMap<>(); |
| | | String out_trade_no = params.get("out_trade_no"); |
| | | String subject = params.get("subject"); |
| | | String total_amount = params.get("total_amount"); |
| | | String trade_no = params.get("trade_no"); |
| | | map.put("out_trade_no", out_trade_no);//商家订单号 |
| | | map.put("subject", subject); |
| | | map.put("total_amount", total_amount); |
| | | map.put("trade_no", trade_no);//支付宝交易号 |
| | | return map; |
| | | } |
| | | // try { |
| | | // boolean flag = AlipaySignature.rsaCheckV1(params, alipay_public_key, "UTF-8","RSA2"); |
| | | // if(flag){ |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // String out_trade_no = params.get("out_trade_no"); |
| | | // String subject = params.get("subject"); |
| | | // String total_amount = params.get("total_amount"); |
| | | // String trade_no = params.get("trade_no"); |
| | | // String passback_params = params.get("passback_params"); |
| | | // map.put("out_trade_no", out_trade_no);//商家订单号 |
| | | // map.put("subject", subject); |
| | | // map.put("total_amount", total_amount); |
| | | // map.put("trade_no", trade_no);//支付宝交易号 |
| | | // map.put("passback_params", passback_params);//回传参数 |
| | | // return map; |
| | | // }else{ |
| | | // System.err.println("验签失败"); |
| | | // } |
| | | // |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return null; |
| | | |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | Map<String, String> map = new HashMap<>(); |
| | | String out_trade_no = params.get("out_trade_no"); |
| | | String subject = params.get("subject"); |
| | | String total_amount = params.get("total_amount"); |
| | | String trade_no = params.get("trade_no"); |
| | | String passback_params = params.get("passback_params"); |
| | | map.put("out_trade_no", out_trade_no);//商家订单号 |
| | | map.put("subject", subject); |
| | | map.put("total_amount", total_amount); |
| | | map.put("trade_no", trade_no);//支付宝交易号 |
| | | map.put("passback_params", passback_params);//回传参数 |
| | | return map; |
| | | } |
| | | |
| | | |
| | |
| | | * @param tradeType 交易类型 |
| | | * @return |
| | | */ |
| | | public ResultUtil weixinpay(String body, String attach, String out_trade_no, String total_fee, String notify_url, String tradeType) throws Exception{ |
| | | public ResultUtil weixinpay(String body, String attach, String out_trade_no, String total_fee, String notify_url, String tradeType, String openId) throws Exception{ |
| | | if("JSAPI".equals(tradeType) && ToolUtil.isEmpty(openId)){ |
| | | return ResultUtil.error("请先用微信登录后再进行支付"); |
| | | } |
| | | int i = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); |
| | | String hostAddress = null; |
| | | try { |
| | |
| | | } |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("appid", appid); |
| | | map.put("appid", "APP".equals(tradeType) ? appid : appletsAppid); |
| | | map.put("mch_id", mchId); |
| | | map.put("nonce_str", nonce_str); |
| | | map.put("body", body); |
| | |
| | | map.put("spbill_create_ip", hostAddress); |
| | | map.put("notify_url", callbackPath + notify_url); |
| | | map.put("trade_type", tradeType); |
| | | if("JSAPI".equals(tradeType)){ |
| | | map.put("openid", openId); |
| | | } |
| | | String s = this.weixinSignature(map); |
| | | map.put("sign", s); |
| | | |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String body1 = httpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()); |
| | | String body1 = HttpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()).getData(); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | |
| | | String result_code = map1.get("result_code"); |
| | | if("SUCCESS".equals(result_code)){ |
| | | String type = map1.get("trade_type"); |
| | | String prepay_id = map1.get("prepay_id"); |
| | | switch (type){ |
| | | case "JSAPI": |
| | | break; |
| | | //重新进行签名后返回给前端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("appId", map1.get("appid")); |
| | | map2.put("nonceStr", map1.get("nonce_str")); |
| | | map2.put("package", "prepay_id=" + prepay_id); |
| | | map2.put("signType", "MD5"); |
| | | map2.put("timeStamp", new Date().getTime() + ""); |
| | | String s2 = this.weixinSignature(map2); |
| | | |
| | | map2.put("prepay_id", prepay_id); |
| | | map2.put("mch_id", map1.get("mch_id")); |
| | | map2.put("trade_type", map1.get("trade_type")); |
| | | |
| | | map2.put("sign", s2); |
| | | return ResultUtil.success(map2); |
| | | case "NATIVE": |
| | | String code_url = map1.get("code_url"); |
| | | return ResultUtil.success(code_url); |
| | | case "APP": |
| | | String prepay_id = map1.get("prepay_id"); |
| | | //重新进行签名后返回给前端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("appid", appid); |
| | | map2.put("noncestr", nonce_str); |
| | | map2.put("package", "Sign=WXPay"); |
| | | map2.put("partnerid", mchId); |
| | | map2.put("prepayid", prepay_id); |
| | | map2.put("timestamp", new Date().getTime() / 1000); |
| | | String s1 = this.weixinSignature(map2); |
| | | map2.put("sign", s1); |
| | | System.err.println(map2); |
| | | return ResultUtil.success(map2); |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | map3.put("appid", appid); |
| | | map3.put("noncestr", nonce_str); |
| | | map3.put("package", "Sign=WXPay"); |
| | | map3.put("partnerid", mchId); |
| | | map3.put("prepayid", prepay_id); |
| | | map3.put("timestamp", new Date().getTime() / 1000); |
| | | String s1 = this.weixinSignature(map3); |
| | | map3.put("sign", s1); |
| | | System.err.println(map3); |
| | | return ResultUtil.success(map3); |
| | | } |
| | | return null; |
| | | }else{ |
| | |
| | | if("SUCCESS".equals(result_code)){ |
| | | Map<String, String> map1 = new HashedMap(); |
| | | map1.put("nonce_str", map.get("nonce_str")); |
| | | map1.put("out_trade_no", map.get("out_trade_no").split("_")[1]);//存储的订单code |
| | | map1.put("out_trade_no", map.get("out_trade_no"));//存储的订单code |
| | | map1.put("attach", map.get("attach"));//存储订单id |
| | | map1.put("total_fee", map.get("total_fee")); |
| | | map1.put("transaction_id", map.get("transaction_id"));//微信支付订单号 |
| | |
| | | map1.put("result", result); |
| | | return map1; |
| | | }else{ |
| | | // System.err.println(map.get("err_code_des")); |
| | | System.err.println(map.get("err_code_des")); |
| | | } |
| | | }else{ |
| | | // System.err.println(map.get("return_msg")); |
| | | System.err.println(map.get("return_msg")); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | * @param auth_code 授权码 扫码支付授权码,设备读取用户微信中的条码或者二维码信息(注:用户付款码条形码规则:18位纯数字,以10、11、12、13、14、15开头) |
| | | * @return |
| | | */ |
| | | public ResultUtil wxScanQRCodePay(String body, String attach, String nonce_str, String out_trade_no, String total_fee, String auth_code){ |
| | | public ResultUtil wxScanQRCodePay(String body, String attach, String nonce_str, String out_trade_no, String total_fee, String auth_code) throws Exception{ |
| | | int i = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); |
| | | String hostAddress = null; |
| | | try { |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String body1 = httpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()); |
| | | String body1 = HttpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()).getData(); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | |
| | | map.put("total_fee", tf); |
| | | map.put("refund_fee", rf); |
| | | map.put("notify_url", callbackPath + notify_url); |
| | | String s = this.weixinSignature(map); |
| | | String s = this.weixinSignature(map, key); |
| | | map.put("sign", s); |
| | | |
| | | String url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String body1 = httpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()); |
| | | String body1 = null; |
| | | try { |
| | | String certPath = "/usr/local/server/cert/weixin/apiclient_cert.p12"; |
| | | body1 = HttpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.err.println(body1); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | |
| | | Map<String, String> map1 = new HashMap<>(); |
| | | map1.put("refund_id", map.get("refund_id")); |
| | | map1.put("out_refund_no", map.get("out_refund_no")); |
| | | String result = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"; |
| | | map1.put("result", result); |
| | | return map1; |
| | | }else{ |
| | | // System.err.println(map.get("return_msg")); |
| | |
| | | * @throws AlipayApiException |
| | | */ |
| | | public Map<String, String> aliRefund(String trade_no, String refund_amount) throws AlipayApiException { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey,"json","UTF-8", alipay_public_key,"RSA2"); |
| | | AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("trade_no", trade_no); |
| | | jsonObject.put("refund_amount", refund_amount); |
| | | request.setBizContent(jsonObject.toJSONString()); |
| | | AlipayTradeRefundResponse response = alipayClient.execute(request); |
| | | //构造client |
| | | CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); |
| | | //设置网关地址 |
| | | certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | //设置应用Id |
| | | certAlipayRequest.setAppId(aliAppid); |
| | | //设置应用私钥 |
| | | certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | //设置请求格式,固定值json |
| | | certAlipayRequest.setFormat("json"); |
| | | //设置字符集 |
| | | certAlipayRequest.setCharset("UTF8"); |
| | | //设置签名类型 |
| | | certAlipayRequest.setSignType("RSA2"); |
| | | //设置应用公钥证书路径 |
| | | certAlipayRequest.setCertPath(app_cert_path); |
| | | //设置支付宝公钥证书路径 |
| | | certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | //设置支付宝根证书路径 |
| | | certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | //构造client |
| | | AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | //构造API请求 |
| | | AlipayTradeRefundApplyRequest request = new AlipayTradeRefundApplyRequest(); |
| | | AlipayTradeRefundModel model = new AlipayTradeRefundModel(); |
| | | model.setTradeNo(trade_no); |
| | | model.setRefundAmount(refund_amount); |
| | | request.setBizModel(model); |
| | | //发送请求 |
| | | AlipayTradeRefundApplyResponse response = alipayClient.certificateExecute(request); |
| | | |
| | | // AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey,"json","UTF-8", alipay_public_key,"RSA2"); |
| | | // AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); |
| | | // JSONObject jsonObject = new JSONObject(); |
| | | // jsonObject.put("trade_no", trade_no); |
| | | // jsonObject.put("refund_amount", refund_amount); |
| | | // request.setBizContent(jsonObject.toJSONString()); |
| | | // System.err.println(jsonObject.toJSONString()); |
| | | // AlipayTradeRefundResponse response = alipayClient.execute(request); |
| | | |
| | | Map<String, String> map = new HashMap<>(); |
| | | System.err.println(response.getSubMsg()); |
| | | if(response.isSuccess()){ |
| | | System.out.println("调用成功"); |
| | | String outTradeNo = response.getOutTradeNo(); |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil queryWXOrder() throws Exception{ |
| | | public ResultUtil<Map<String, String>> queryWXOrder(String out_trade_no, String transaction_id) throws Exception{ |
| | | String url = "https://api.mch.weixin.qq.com/pay/orderquery"; |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("appid", appid); |
| | | map.put("mch_id", mchId); |
| | | map.put("transaction_id", nonce_str);//微信订单号 |
| | | map.put("out_trade_no", out_trade_no);//商户订单号 |
| | | map.put("transaction_id", transaction_id);//微信订单号 |
| | | map.put("nonce_str", nonce_str);//随机字符串 |
| | | String s = this.weixinSignature(map); |
| | | map.put("sign", s); |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String body1 = httpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()); |
| | | String body1 = HttpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()).getData(); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | |
| | | if("SUCCESS".equals(return_code)){ |
| | | String result_code = map1.get("result_code"); |
| | | if("SUCCESS".equals(result_code)){ |
| | | String type = map1.get("trade_type"); |
| | | switch (type){ |
| | | case "JSAPI": |
| | | break; |
| | | case "NATIVE": |
| | | String code_url = map1.get("code_url"); |
| | | return ResultUtil.success(code_url); |
| | | case "APP": |
| | | String trade_state = map1.get("trade_state"); |
| | | String time_end = map1.get("time_end"); |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("trade_state", trade_state);//订单状态SUCCESS—支付成功,REFUND—转入退款,NOTPAY—未支付,CLOSED—已关闭,REVOKED—已撤销(刷卡支付),USERPAYING--用户支付中,PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | map2.put("time_end", time_end);//订单支付时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。 |
| | | return ResultUtil.success(map2); |
| | | } |
| | | return null; |
| | | Map<String, String> map2 = new HashMap<>(); |
| | | map2.put("trade_type", map1.get("trade_type")); |
| | | map2.put("trade_state", map1.get("trade_state"));//订单状态SUCCESS—支付成功,REFUND—转入退款,NOTPAY—未支付,CLOSED—已关闭,REVOKED—已撤销(刷卡支付),USERPAYING--用户支付中,PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | map2.put("transaction_id", map1.get("transaction_id")); |
| | | return ResultUtil.success(map2); |
| | | }else{ |
| | | System.err.println(map1.get("err_code_des")); |
| | | return ResultUtil.error(map1.get("err_code_des")); |
| | | } |
| | | }else{ |
| | | System.err.println(map1.get("return_msg") + appid + "----" + mchId); |
| | | return ResultUtil.error(map1.get("return_msg"), new JSONObject()); |
| | | return ResultUtil.error(map1.get("return_msg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 微信转账功能(企业付款到零钱) |
| | | * @param openid 商户appid下,某用户的openid |
| | | * @param desc 企业付款备注,必填。 |
| | | * @param total_fee 企业付款金额 |
| | | * @param partner_trade_no 商户订单号,需保持唯一性 |
| | | * @return |
| | | */ |
| | | public Map<String, String> wxTransfers(String openid, String desc, String total_fee, String partner_trade_no) throws Exception{ |
| | | int amount = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); |
| | | String nonce_str = UUIDUtil.getRandomCode(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mch_appid", appid);//申请商户号的appid或商户号绑定的appid |
| | | map.put("mchid", mchId);//微信支付分配的商户号 |
| | | map.put("nonce_str", nonce_str);//随机字符串,不长于32位 |
| | | map.put("partner_trade_no", partner_trade_no);//商户订单号,需保持唯一性 |
| | | map.put("openid", openid);//商户appid下,某用户的openid |
| | | map.put("check_name", "NO_CHECK");//NO_CHECK:不校验真实姓名 FORCE_CHECK:强校验真实姓名 |
| | | map.put("amount", amount);//企业付款金额,单位为分 |
| | | map.put("desc", desc);//企业付款备注,必填。 |
| | | String s = this.weixinSignature(map, key); |
| | | map.put("sign", s); |
| | | |
| | | String url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; |
| | | //设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_XML); |
| | | StringBuffer xmlString = new StringBuffer(); |
| | | Set<String> strings = map.keySet(); |
| | | String[] keys = {}; |
| | | keys = strings.toArray(keys); |
| | | Arrays.sort(keys); |
| | | xmlString.append("<xml>"); |
| | | for(int l = 0; l < keys.length; l++){ |
| | | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); |
| | | } |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String certPath = "/usr/local/server/cert/weixin/apiclient_cert.p12";//证书地址 |
| | | String body1 = HttpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | | try { |
| | | map1 = this.xmlToMap(body1, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String return_code = map1.get("return_code"); |
| | | Map<String, String> map2 = new HashMap<>(); |
| | | if("SUCCESS".equals(return_code)){ |
| | | String result_code = map1.get("result_code"); |
| | | if("SUCCESS".equals(result_code)){ |
| | | map2.put("return_code", result_code); |
| | | map2.put("payment_no", String.valueOf(map1.get("payment_no")));//付款订单号 |
| | | map2.put("payment_time", String.valueOf(map1.get("payment_time")));//付款时间 |
| | | return map2; |
| | | }else{ |
| | | map2.put("return_code", result_code); |
| | | map2.put("err_code", map1.get("err_code")); |
| | | map2.put("err_code_des", map1.get("err_code_des")); |
| | | return map2; |
| | | } |
| | | }else{ |
| | | map2.put("return_code", return_code); |
| | | map2.put("return_msg", map1.get("return_msg")); |
| | | return map2; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信转账功能(企业付款到银行卡) |
| | | * @param desc 备注信息 |
| | | * @param total_fee 转账金额 |
| | | * @param partner_trade_no 订单号 |
| | | * @param enc_bank_no 银行卡号 |
| | | * @param enc_true_name 收款方用户名 |
| | | * @param bankName 银行名称 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, String> wxPayBank(String desc, String total_fee, String partner_trade_no, String enc_bank_no, String enc_true_name, String bankName) throws Exception{ |
| | | int amount = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); |
| | | String nonce_str = UUIDUtil.getRandomCode(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mch_id", mchId);//微信支付分配的商户号 |
| | | map.put("nonce_str", nonce_str);//随机字符串,不长于32位 |
| | | map.put("partner_trade_no", partner_trade_no);//商户订单号,需保持唯一性 |
| | | map.put("enc_bank_no", enc_bank_no);//收款方银行卡号(采用标准RSA算法,公钥由微信侧提供) |
| | | map.put("enc_true_name", enc_true_name);//收款方用户名(采用标准RSA算法,公钥由微信侧提供) |
| | | map.put("bank_code", findBankCode(bankName));// |
| | | map.put("amount", amount);//企业付款金额,单位为分 |
| | | map.put("desc", desc);//企业付款备注,必填。 |
| | | String s = this.weixinSignature(map, key); |
| | | map.put("sign", s); |
| | | |
| | | String url = "https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank"; |
| | | //设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_XML); |
| | | StringBuffer xmlString = new StringBuffer(); |
| | | Set<String> strings = map.keySet(); |
| | | String[] keys = {}; |
| | | keys = strings.toArray(keys); |
| | | Arrays.sort(keys); |
| | | xmlString.append("<xml>"); |
| | | for(int l = 0; l < keys.length; l++){ |
| | | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); |
| | | } |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String certPath = "/usr/local/server/cert/weixin/apiclient_cert.p12";//证书地址 |
| | | String body1 = HttpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | | body1 = body1.replaceAll("]]>", ""); |
| | | try { |
| | | map1 = this.xmlToMap(body1, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String return_code = map1.get("return_code"); |
| | | Map<String, String> map2 = new HashMap<>(); |
| | | if("SUCCESS".equals(return_code)){ |
| | | String result_code = map1.get("result_code"); |
| | | if("SUCCESS".equals(result_code)){ |
| | | map2.put("return_code", result_code); |
| | | map2.put("payment_no", String.valueOf(map1.get("payment_no")));//付款订单号 |
| | | map2.put("cmms_amt", String.valueOf(map1.get("cmms_amt")));//手续费金额 RMB:分 |
| | | return map2; |
| | | }else{ |
| | | map2.put("return_code", result_code); |
| | | map2.put("err_code", map1.get("err_code")); |
| | | map2.put("err_code_des", map1.get("err_code_des")); |
| | | return map2; |
| | | } |
| | | }else{ |
| | | map2.put("return_code", return_code); |
| | | map2.put("return_msg", map1.get("return_msg")); |
| | | return map2; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 微信转账到银行卡不编号 |
| | | * @param bankName |
| | | * @return |
| | | */ |
| | | public String findBankCode(String bankName){ |
| | | String json = "{\"工商银行 \":1002,\"农业银行\":1005,\"建设银行\":1003,\"中国银行\":1026,\"交通银行 \":1020,\"招商银行 \":1001,\"邮储银行\":1066,\"民生银行 \":1006,\"平安银行 \":1010,\"中信银行\":1021,\"浦发银行 \":1004,\"兴业银行 \":1009,\"光大银行 \":1022,\"广发银行\":1027,\"华夏银行\":1025,\"宁波银行\":1056,\"北京银行\":4836,\"上海银行\":1024,\"南京银行\":1054,\"长子县融汇村镇银行\":4755,\"长沙银行\":4216,\"浙江泰隆商业银行\":4051,\"中原银行 \":4753,\"企业银行(中国)\":4761,\"顺德农商银行 \":4036,\"衡水银行\":4752,\"长治银行\":4756,\"大同银行\":4767,\"河南省农村信用社\":4115,\"宁夏黄河农村商业银行\":4150,\"山西省农村信用社\":4156,\"安徽省农村信用社\":4166,\"甘肃省农村信用社\":4157,\"天津农村商业银行\":4153,\"广西壮族自治区农村信用社\":4113,\"陕西省农村信用社\":4108,\"深圳农村商业银行\":4076,\"宁波鄞州农村商业银行\":4052,\"浙江省农村信用社联合社\":4764,\"江苏省农村信用社联合社\":4217,\"江苏紫金农村商业银行股份有限公司 \":4072,\"北京中关村银行股份有限公司 \":4769,\"星展银行( 中国) 有限公司 \":4778,\"枣庄银行股份有限公司 \":4766,\"海口联合农村商业银行股份有限公司 \":4758,\"南洋商业银行( 中国) 有限公司 \":4763}"; |
| | | JSONObject jsonObject = JSON.parseObject(json); |
| | | Set<String> strings = jsonObject.keySet(); |
| | | for(String key : strings){ |
| | | if(key.indexOf(bankName) >= 0){ |
| | | return jsonObject.getString(key); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 支付宝转账 |
| | | * @param out_biz_no 商家侧唯一订单号,由商家自定义。对于不同转账请求,商家需保证该订单号在自身系统唯一。 |
| | | * @param trans_amount 订单总金额,单位为元,精确到小数点后两位 |
| | | * @param order_title 转账业务的标题,用于在支付宝用户的账单里显示 |
| | | * @param identity 参与方的唯一标识(收款方支付宝账号) |
| | | * @param name 参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。 |
| | | * @param remark 业务备注 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> aliTransfer(String out_biz_no, Double trans_amount, String order_title, String identity, String name, String remark) throws Exception{ |
| | | CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); |
| | | certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); //gateway:支付宝网关(固定)https://openapi.alipay.com/gateway.do |
| | | certAlipayRequest.setAppId(aliAppid); //APPID 即创建应用后生成,详情见创建应用并获取 APPID |
| | | certAlipayRequest.setPrivateKey(appPrivateKey); //开发者应用私钥,由开发者自己生成 |
| | | certAlipayRequest.setFormat("json"); //参数返回格式,只支持 json 格式 |
| | | certAlipayRequest.setCharset("UTF-8"); //请求和签名使用的字符编码格式,支持 GBK和 UTF-8 |
| | | certAlipayRequest.setSignType("RSA2"); //商户生成签名字符串所使用的签名算法类型,目前支持 RSA2 和 RSA,推荐商家使用 RSA2。 |
| | | certAlipayRequest.setCertPath(app_cert_path); //应用公钥证书路径(app_cert_path 文件绝对路径) |
| | | certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径) |
| | | certAlipayRequest.setRootCertPath(alipay_root_cert_path); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径) |
| | | AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); |
| | | request.setBizContent("{" + |
| | | "\"out_biz_no\":\"" + out_biz_no + "\"," + |
| | | "\"trans_amount\":" + trans_amount + "," + |
| | | "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," + |
| | | "\"biz_scene\":\"DIRECT_TRANSFER\"," + |
| | | "\"order_title\":\"" + order_title + "\"," + |
| | | "\"payee_info\":{" + |
| | | "\"identity\":\"" + identity + "\"," + |
| | | "\"identity_type\":\"ALIPAY_USER_ID\"," + |
| | | "\"name\":\"" + name + "\"," + |
| | | "}," + |
| | | "\"remark\":\"" + remark + "\"" + |
| | | "}"); |
| | | AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(response.isSuccess()){ |
| | | String status = response.getStatus(); |
| | | if(status.equals("SUCCESS")){//成功 |
| | | map.put("code", response.getCode()); |
| | | map.put("order_id", response.getOrderId());//支付宝订单号 |
| | | map.put("pay_fund_order_id", response.getPayFundOrderId());//支付宝流水号 |
| | | }else{ |
| | | map.put("code", response.getCode()); |
| | | map.put("sub_msg", response.getSubMsg()); |
| | | } |
| | | } else { |
| | | map.put("code", response.getSubCode()); |
| | | map.put("sub_msg", response.getSubMsg()); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * 微信下单的签名算法 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private String weixinSignature(Map<String, Object> map, String key_){ |
| | | try { |
| | | Set<Map.Entry<String, Object>> entries = map.entrySet(); |
| | | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() { |
| | | public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) { |
| | | return (o1.getKey()).toString().compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (Map.Entry<String, Object> item : infoIds) { |
| | | if (item.getKey() != null || item.getKey() != "") { |
| | | String key = item.getKey(); |
| | | Object val = item.getValue(); |
| | | if (!(val == "" || val == null)) { |
| | | sb.append(key + "=" + val + "&"); |
| | | } |
| | | } |
| | | } |
| | | sb.append("key=" + key_); |
| | | String sign = MD5AndKL.MD5Encode(sb.toString(), "UTF-8").toUpperCase(); //注:MD5签名方式 |
| | | return sign; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信退款成功后的解密 |
| | | * @param req_info |
| | | * @return |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * socket推单处理类 |
| | | */ |
| | | @Component |
| | | public class PushUtil { |
| | | |
| | | Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 推送强迫下线 |
| | | * @param id |
| | | * @param type |
| | | */ |
| | | public void pushOffline(Integer id, Integer type){ |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | | msg.put("msg", "SUCCESS"); |
| | | msg.put("method", "OFFLINE"); |
| | | msg.put("data", new Object()); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | logger.debug(jsonObject1.getString("msg")); |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下班提醒 |
| | | * @param id |
| | | * @param type |
| | | */ |
| | | public void pushOffWork(Integer id, Integer type){ |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | | msg.put("msg", "SUCCESS"); |
| | | msg.put("method", "OFF_WORK"); |
| | | msg.put("data", new Object()); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | logger.debug(jsonObject1.getString("msg")); |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送订单状态 |
| | | * @param id |
| | | * @param type |
| | | * @param orderId |
| | | * @param status |
| | | */ |
| | | public void pushOrderStatus(Integer id, Integer type, Long orderId, Integer status){ |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | | msg.put("msg", "SUCCESS"); |
| | | msg.put("method", "ORDER_STATUS"); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderId", orderId); |
| | | map.put("status", status); |
| | | |
| | | msg.put("data", map); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | logger.debug(jsonObject1.getString("msg")); |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 系统推单推送 |
| | | * @param id 接受对象id |
| | | * @param type 接受对象类型(1=用户,2=司机) |
| | | * @param orderId 订单id |
| | | * @param countdown 抢单倒计时(秒) |
| | | */ |
| | | public void pushGrabOrder(Integer id, Integer type, Long orderId, Integer countdown){ |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | | msg.put("msg", "SUCCESS"); |
| | | msg.put("method", "GRAB_ORDER"); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderId", orderId); |
| | | map.put("countdown", countdown); |
| | | |
| | | msg.put("data", map); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | logger.debug(jsonObject1.getString("msg")); |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 转单成功推送 |
| | | * @param id |
| | | * @param type |
| | | */ |
| | | public void pushTransferSuccessful(Integer id, Integer type, Long orderId){ |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | | msg.put("msg", "SUCCESS"); |
| | | msg.put("method", "TRANSFER_SUCCESS"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | map.put("orderId", orderId); |
| | | msg.put("data", map); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | logger.debug(jsonObject1.getString("msg")); |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 获取redis锁 |
| | | * @return |
| | | */ |
| | | public boolean lock(){ |
| | | try { |
| | | boolean b = lock(5); |
| | | if(!b){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | try { |
| | | Thread.sleep(3000);//等待3秒 |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | b = lock(5); |
| | | if(b){ |
| | | return true; |
| | | }else{ |
| | | num1++; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | return b; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | unlock(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取redis锁 |
| | | * @param time |
| | | * @return |
| | | */ |
| | |
| | | * 参数异常 |
| | | * @return |
| | | */ |
| | | public static ResultUtil paranErr(String...ages){ |
| | | public static ResultUtil paranErr(String ages){ |
| | | return ResultUtil.getResult(ResultUtil.PARAM_ERROR, "【" + ages + "】参数异常", new Object()); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public synchronized static String getTimeStr(){ |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmssS"); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | return simpleDateFormat.format(new Date()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @Description: 获取数字随机码 |
| | | * @Author pzb |
| | | * @Date 2021/8/11 16:52 |
| | | * @Param |
| | | * @Return |
| | | * @Exception |
| | | */ |
| | | public static String getNumberRandom(Integer num){ |
| | | if(null == num){ |
| | | num = 32; |
| | | } |
| | | StringBuffer sb = new StringBuffer(); |
| | | for(int i = 0; i < num; i++){ |
| | | sb.append(Double.valueOf(Math.random() * 10).intValue()); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.juhe; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 天气实况 |
| | | * @author pzb |
| | | * @Date 2023/2/20 11:38 |
| | | */ |
| | | @Data |
| | | public class Realtime { |
| | | /** |
| | | * 天气情况,如:晴、多云 |
| | | */ |
| | | private String info; |
| | | /** |
| | | * 天气标识id,可参考小接口2 |
| | | */ |
| | | private String wid; |
| | | /** |
| | | * 温度,可能为空 |
| | | */ |
| | | private String temperature; |
| | | /** |
| | | * 湿度,可能为空 |
| | | */ |
| | | private String humidity; |
| | | /** |
| | | * 风向,可能为空 |
| | | */ |
| | | private String direct; |
| | | /** |
| | | * 风力,可能为空 |
| | | */ |
| | | private String power; |
| | | /** |
| | | * 空气质量指数,可能为空 |
| | | */ |
| | | private String aqi; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.juhe; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 天气相关城市 |
| | | * @author pzb |
| | | * @Date 2023/2/25 10:56 |
| | | */ |
| | | @Data |
| | | @TableName("t_weather_city") |
| | | public class WeatherCityInfo { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 省 |
| | | */ |
| | | @TableField("province") |
| | | private String province; |
| | | /** |
| | | * 市 |
| | | */ |
| | | @TableField("city") |
| | | private String city; |
| | | /** |
| | | * 区 |
| | | */ |
| | | @TableField("district") |
| | | private String district; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.juhe; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.util.httpClinet.HttpClientUtil; |
| | | import com.supersavedriving.user.modular.system.util.httpClinet.HttpResult; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 天气工具类 |
| | | * @author pzb |
| | | * @Date 2023/2/18 16:54 |
| | | */ |
| | | public class WeatherUtil { |
| | | |
| | | static Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | private final static String weather_type = "[{\"wid\":\"00\",\"weather\":\"晴\"},{\"wid\":\"01\",\"weather\":\"多云\"},{\"wid\":\"02\",\"weather\":\"阴\"},{\"wid\":\"03\",\"weather\":\"阵雨\"},{\"wid\":\"04\",\"weather\":\"雷阵雨\"},{\"wid\":\"05\",\"weather\":\"雷阵雨伴有冰雹\"},{\"wid\":\"06\",\"weather\":\"雨夹雪\"},{\"wid\":\"07\",\"weather\":\"小雨\"},{\"wid\":\"08\",\"weather\":\"中雨\"},{\"wid\":\"09\",\"weather\":\"大雨\"},{\"wid\":\"10\",\"weather\":\"暴雨\"},{\"wid\":\"11\",\"weather\":\"大暴雨\"},{\"wid\":\"12\",\"weather\":\"特大暴雨\"},{\"wid\":\"13\",\"weather\":\"阵雪\"},{\"wid\":\"14\",\"weather\":\"小雪\"},{\"wid\":\"15\",\"weather\":\"中雪\"},{\"wid\":\"16\",\"weather\":\"大雪\"},{\"wid\":\"17\",\"weather\":\"暴雪\"},{\"wid\":\"18\",\"weather\":\"雾\"},{\"wid\":\"19\",\"weather\":\"冻雨\"},{\"wid\":\"20\",\"weather\":\"沙尘暴\"},{\"wid\":\"21\",\"weather\":\"小到中雨\"},{\"wid\":\"22\",\"weather\":\"中到大雨\"},{\"wid\":\"23\",\"weather\":\"大到暴雨\"},{\"wid\":\"24\",\"weather\":\"暴雨到大暴雨\"},{\"wid\":\"25\",\"weather\":\"大暴雨到特大暴雨\"},{\"wid\":\"26\",\"weather\":\"小到中雪\"},{\"wid\":\"27\",\"weather\":\"中到大雪\"},{\"wid\":\"28\",\"weather\":\"大到暴雪\"},{\"wid\":\"29\",\"weather\":\"浮尘\"},{\"wid\":\"30\",\"weather\":\"扬沙\"},{\"wid\":\"31\",\"weather\":\"强沙尘暴\"},{\"wid\":\"53\",\"weather\":\"霾\"}]"; |
| | | |
| | | private final static String bad_weather = "[{\"wid\":\"03\",\"weather\":\"阵雨\"},{\"wid\":\"04\",\"weather\":\"雷阵雨\"},{\"wid\":\"05\",\"weather\":\"雷阵雨伴有冰雹\"},{\"wid\":\"06\",\"weather\":\"雨夹雪\"},{\"wid\":\"07\",\"weather\":\"小雨\"},{\"wid\":\"08\",\"weather\":\"中雨\"},{\"wid\":\"09\",\"weather\":\"大雨\"},{\"wid\":\"10\",\"weather\":\"暴雨\"},{\"wid\":\"11\",\"weather\":\"大暴雨\"},{\"wid\":\"12\",\"weather\":\"特大暴雨\"},{\"wid\":\"13\",\"weather\":\"阵雪\"},{\"wid\":\"14\",\"weather\":\"小雪\"},{\"wid\":\"15\",\"weather\":\"中雪\"},{\"wid\":\"16\",\"weather\":\"大雪\"},{\"wid\":\"17\",\"weather\":\"暴雪\"},{\"wid\":\"19\",\"weather\":\"冻雨\"},{\"wid\":\"20\",\"weather\":\"沙尘暴\"},{\"wid\":\"21\",\"weather\":\"小到中雨\"},{\"wid\":\"22\",\"weather\":\"中到大雨\"},{\"wid\":\"23\",\"weather\":\"大到暴雨\"},{\"wid\":\"24\",\"weather\":\"暴雨到大暴雨\"},{\"wid\":\"25\",\"weather\":\"大暴雨到特大暴雨\"},{\"wid\":\"26\",\"weather\":\"小到中雪\"},{\"wid\":\"27\",\"weather\":\"中到大雪\"},{\"wid\":\"28\",\"weather\":\"大到暴雪\"},{\"wid\":\"30\",\"weather\":\"扬沙\"},{\"wid\":\"31\",\"weather\":\"强沙尘暴\"},{\"wid\":\"53\",\"weather\":\"霾\"}]"; |
| | | |
| | | private final static String key = "aaebb3e5c18fd371257a2ab6b5670efe"; |
| | | |
| | | private static HttpClientUtil httpClientUtil = new HttpClientUtil(); |
| | | |
| | | |
| | | /** |
| | | * 获取天气实况数据 |
| | | * @param city 要查询的城市名称/id,城市名称如:温州、上海、北京,需要utf8 urlencode |
| | | * @return |
| | | */ |
| | | public static Realtime queryNowWeather(String city){ |
| | | if(ToolUtil.isEmpty(city)){ |
| | | return null; |
| | | } |
| | | String url = "http://apis.juhe.cn/simpleWeather/query?city=" + city + "&key=" + key; |
| | | HttpResult httpResult = null; |
| | | try { |
| | | httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(httpResult.getCode() != 200){ |
| | | logger.debug("查询天气失败:" + httpResult.getData()); |
| | | return null; |
| | | } |
| | | String data = httpResult.getData(); |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | Integer error_code = jsonObject.getInteger("error_code"); |
| | | if(0 != error_code){ |
| | | logger.debug("查询天气失败:" + jsonObject.getString("reason")); |
| | | return null; |
| | | } |
| | | Realtime realtime = jsonObject.getObject("realtime", Realtime.class); |
| | | return realtime; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询是否是恶劣天气 |
| | | * @param city |
| | | * @return |
| | | */ |
| | | public static boolean isBadWeather(String city){ |
| | | if(null == city){ |
| | | return false; |
| | | } |
| | | Realtime realtime = queryNowWeather(city); |
| | | if(null == realtime){ |
| | | return false; |
| | | } |
| | | String wid = realtime.getWid(); |
| | | JSONArray badWeather = JSON.parseArray(bad_weather); |
| | | for (int i = 0; i < badWeather.size(); i++) { |
| | | JSONObject jsonObject = badWeather.getJSONObject(i); |
| | | String wid1 = jsonObject.getString("wid"); |
| | | if(wid.equals(wid1)){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取支持城市列表 |
| | | * @return |
| | | */ |
| | | public static List<WeatherCityInfo> queryCityList(){ |
| | | String url = "http://apis.juhe.cn/simpleWeather/cityList?key=" + key; |
| | | HttpResult httpResult = null; |
| | | try { |
| | | httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(httpResult.getCode() != 200){ |
| | | logger.debug("查询支持城市失败:" + httpResult.getData()); |
| | | return null; |
| | | } |
| | | String data = httpResult.getData(); |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | Integer error_code = jsonObject.getInteger("error_code"); |
| | | if(0 != error_code){ |
| | | logger.debug("查询支持城失败:" + jsonObject.getString("reason")); |
| | | return null; |
| | | } |
| | | JSONArray result = jsonObject.getJSONArray("result"); |
| | | List<WeatherCityInfo> weatherCities = result.toJavaList(WeatherCityInfo.class); |
| | | return weatherCities; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.mongodb; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.mongodb.BasicDBObject; |
| | | import com.mongodb.client.AggregateIterable; |
| | | import com.mongodb.client.MongoCursor; |
| | | import com.supersavedriving.user.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.user.modular.system.util.mongodb.model.LocationQuery; |
| | | import org.bson.Document; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import java.util.Map.Entry; |
| | | import java.util.function.Supplier; |
| | | |
| | | |
| | | @Component |
| | | public class MongoUtils<T> { |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | /** |
| | | * lambda |
| | | * @param data 添加数据 |
| | | * @param collectionName 表名 |
| | | */ |
| | | public void insert(Supplier<T> data,String collectionName){ |
| | | mongoTemplate.insert(data.get(),collectionName); |
| | | } |
| | | |
| | | public void insert(Object data, String collectionName){ |
| | | mongoTemplate.insert(data,collectionName); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param sp 查询条件lambda |
| | | * @param sets 更新的字段 |
| | | * @param collectionName 表名 |
| | | */ |
| | | public void update(Supplier<Criteria> sp, Supplier<Map<String,Object>> sets, String collectionName){ |
| | | Query query = Query.query(sp.get()); |
| | | Update update = new Update(); |
| | | |
| | | sets.get().forEach((key,value) ->{ |
| | | //System.out.println(key); |
| | | //System.out.println(value); |
| | | update.set(key,value); |
| | | }); |
| | | mongoTemplate.updateFirst(query, update, collectionName); |
| | | } |
| | | |
| | | public void update(Criteria sp, Supplier<Map<String,Object>> sets, String collectionName){ |
| | | Query query = Query.query(sp); |
| | | Update update = new Update(); |
| | | |
| | | sets.get().forEach((key,value) ->{ |
| | | //System.out.println(key); |
| | | //System.out.println(value); |
| | | update.set(key,value); |
| | | }); |
| | | mongoTemplate.updateFirst(query, update, collectionName); |
| | | } |
| | | |
| | | /**lambda |
| | | * @param sp 查询条件lambda |
| | | * @param collectionName 表名 |
| | | * @return |
| | | */ |
| | | public List<T> query(Supplier<Criteria> sp, String collectionName, Class entityClass){ |
| | | Query query = Query.query(sp.get()); |
| | | List<T> ts = mongoTemplate.find(query,entityClass,collectionName); |
| | | |
| | | return ts; |
| | | } |
| | | |
| | | public List<T> query(Criteria sp, String collectionName, Class entityClass){ |
| | | Query query = Query.query(sp); |
| | | List<T> ts = mongoTemplate.find(query,entityClass,collectionName); |
| | | |
| | | return ts; |
| | | } |
| | | |
| | | /** |
| | | * @param sp 查询条件lambda |
| | | * @param collectionName 表名 |
| | | * @return |
| | | */ |
| | | public void delete(Supplier<Criteria> sp, String collectionName){ |
| | | Query query = Query.query(sp.get()); |
| | | mongoTemplate.remove(query, collectionName); |
| | | } |
| | | |
| | | public void delete(Criteria sp, String collectionName){ |
| | | Query query = Query.query(sp); |
| | | mongoTemplate.remove(query, collectionName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询符合条件总条数 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public long findLogCount(HashMap<String,Object> paras,Class entityClass,String collectionName) throws Exception { |
| | | Query query = new Query(); |
| | | Criteria criteria = new Criteria(); |
| | | if (null != paras ) { |
| | | Iterator<Entry<String, Object>> iterator = paras.entrySet().iterator(); |
| | | while(iterator.hasNext()) { |
| | | Entry<String, Object> entry = iterator.next(); |
| | | String key = entry.getKey(); |
| | | Object value = entry.getValue(); |
| | | criteria.and(key).is(value); |
| | | |
| | | } |
| | | query.addCriteria(criteria); |
| | | } |
| | | long count = mongoTemplate.count(query, entityClass,collectionName); |
| | | |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 查询附近的对象 |
| | | * @param model |
| | | * @return |
| | | */ |
| | | public List<Location> geoNear(LocationQuery model){ |
| | | List<Location> resultList = new ArrayList<>(); |
| | | try{ |
| | | List<BasicDBObject> pipeLine = new ArrayList<>(); |
| | | BasicDBObject aggregate = new BasicDBObject("$geoNear", |
| | | new BasicDBObject("near" |
| | | , new BasicDBObject("type", "Point") |
| | | .append("coordinates", model.getCoordinates())) |
| | | .append("distanceField", "distance") |
| | | .append("maxDistance", model.getDistance()) |
| | | .append("spherical", true) |
| | | |
| | | ); |
| | | |
| | | pipeLine.add(aggregate); |
| | | AggregateIterable<Document> location = mongoTemplate.getCollection("location").aggregate(pipeLine); |
| | | MongoCursor<Document> cursor = location.iterator(); |
| | | |
| | | //将查询的结果,封装成对象返回出去 |
| | | while (cursor.hasNext()) { |
| | | Document document = cursor.next(); |
| | | Location node = JSONObject.parseObject(JSONObject.toJSONString(document),Location.class); |
| | | resultList.add(node); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.mongodb.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class GeoJson { |
| | | private String type; |
| | | private Double[] coordinates; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.mongodb.model; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.index.CompoundIndex; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Document(collection = "driver_location") |
| | | @CompoundIndex(name = "location_index", def = "{'location': '2dsphere'}") |
| | | public class Location implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 4508868382007529970L; |
| | | |
| | | @Id |
| | | private String id; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | private Integer driverId; |
| | | /** |
| | | * x:经度 y:纬度 |
| | | */ |
| | | private GeoJsonPoint location; |
| | | /** |
| | | * 位置名称 |
| | | **/ |
| | | private String name; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Long created; |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Long updated; |
| | | /** |
| | | * 上次更新时间 |
| | | */ |
| | | private Long lastUpdated; |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util.mongodb.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class LocationQuery { |
| | | /** |
| | | * 当前经纬度[xxx,xxx] |
| | | **/ |
| | | private Double[] coordinates; |
| | | /** |
| | | * 距离,如:200,500,1,3,5,10,20 |
| | | **/ |
| | | private Double distance; |
| | | /** |
| | | * 距离单位,如:m,km |
| | | **/ |
| | | private String unit; |
| | | /** |
| | | * 位置类型:1-景点,2-加油站,3-酒店 |
| | | **/ |
| | | private Integer type; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel |
| | | public class CommercialWarpper { |
| | | @ApiModelProperty("广告名称") |
| | | private String name; |
| | | @ApiModelProperty("广告类型(1=弹窗广告,2=底部广告)") |
| | | private Integer type; |
| | | @ApiModelProperty("广告地址") |
| | | private String url; |
| | | @ApiModelProperty("是否跳转(0=否,1=是)") |
| | | private Integer isJump; |
| | | @ApiModelProperty("跳转类型(1=内部跳转,2=外部跳转)") |
| | | private Integer jumpType; |
| | | @ApiModelProperty("跳转链接") |
| | | private String jumpUrl; |
| | | @ApiModelProperty("H5页面") |
| | | private String html; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/3 14:26 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class CouponWarpper { |
| | | @ApiModelProperty("满金额") |
| | | private Double couponConditionalAmount; |
| | | @ApiModelProperty("优惠金额") |
| | | private Double couponPreferentialAmount; |
| | | @ApiModelProperty("优惠券名称") |
| | | private String couponName; |
| | | @ApiModelProperty("有效期") |
| | | private Long expirationDate; |
| | | @ApiModelProperty("张数") |
| | | private Integer number; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/4 17:13 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class EditOrderEndAddress { |
| | | @ApiModelProperty(value = "订单id", required = true, dataType = "long") |
| | | private Long orderId; |
| | | @ApiModelProperty(value = "终点纬度", dataType = "double", required = true) |
| | | private Double endLat; |
| | | @ApiModelProperty(value = "终点经度", dataType = "double", required = true) |
| | | private Double endLng; |
| | | @ApiModelProperty(value = "终点地址", dataType = "string", required = true) |
| | | private String endAddress; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/3 15:07 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class EstimatedCosts { |
| | | @ApiModelProperty(value = "起点纬度", dataType = "double", required = true) |
| | | private Double startLat; |
| | | @ApiModelProperty(value = "起点经度", dataType = "double", required = true) |
| | | private Double startLng; |
| | | @ApiModelProperty(value = "起点地址", dataType = "string", required = true) |
| | | private String startAddress; |
| | | @ApiModelProperty(value = "终点纬度", dataType = "double", required = true) |
| | | private Double endLat; |
| | | @ApiModelProperty(value = "终点经度", dataType = "double", required = true) |
| | | private Double endLng; |
| | | @ApiModelProperty(value = "终点地址", dataType = "string", required = true) |
| | | private String endAddress; |
| | | @ApiModelProperty(value = "当前纬度", dataType = "double", required = true) |
| | | private Double lat; |
| | | @ApiModelProperty(value = "当前经度", dataType = "double", required = true) |
| | | private Double lng; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/3 15:20 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class EstimatedCostsWarpper { |
| | | @ApiModelProperty("预估里程") |
| | | private Double estimatedMileage; |
| | | @ApiModelProperty("预估费用") |
| | | private Double price; |
| | | @ApiModelProperty("优惠金额") |
| | | private Double discountAmount; |
| | | @ApiModelProperty("接驾时间") |
| | | private Integer pickUpTime; |
| | | @ApiModelProperty("行驶时间") |
| | | private Integer travelTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 附近司机 |
| | | * @author pzb |
| | | * @Date 2023/2/28 10:32 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class NearbyDriverWarpper { |
| | | @ApiModelProperty("经纬度") |
| | | private String lonLat; |
| | | @ApiModelProperty("距离") |
| | | private Double distance; |
| | | @ApiModelProperty("司机id") |
| | | private Integer driverId; |
| | | } |
| | |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | @ApiModel("订单详情") |
| | | public class OrderInfoWarpper { |
| | | @ApiModelProperty("订单id") |
| | | private Integer orderId; |
| | | @ApiModelProperty("1=待接单,2=待出发,3=待到达预约地点,4=待乘客上车,5=服务中,6=完成服务,7=待支付,8=待评价,9=已完成,10=已取消,11=改派中)<br/>" + |
| | | "小件物流订单状态(状态(1=待接单,2=待出发,3=待到达预约地点,4=待取货,5=送货中,6=已送达,7=待支付,8=需补差价,9=已取货,10=已取消,11=已支付差价))") |
| | | private Integer orderState; |
| | | @ApiModelProperty("订单名称") |
| | | private String orderName; |
| | | @ApiModelProperty("出行时间") |
| | | private String travelTime; |
| | | @ApiModelProperty("出行时间") |
| | | private String travelTime_; |
| | | @ApiModelProperty("到达预约点时间") |
| | | private String arriveTime; |
| | | @ApiModelProperty("起点") |
| | | private Long orderId; |
| | | @ApiModelProperty("订单编号") |
| | | private String code; |
| | | @ApiModelProperty("起点地址") |
| | | private String startAddress; |
| | | @ApiModelProperty("终点") |
| | | private String endAddress; |
| | | @ApiModelProperty("红包") |
| | | private Double tipMoney; |
| | | @ApiModelProperty("司机当前位置到起点距离(公里)") |
| | | private Double startDistance; |
| | | @ApiModelProperty("全程公里数") |
| | | private Double totalDistance; |
| | | @ApiModelProperty("起点经度") |
| | | private String startLon; |
| | | @ApiModelProperty("起点纬度") |
| | | private String startLat; |
| | | @ApiModelProperty("终点经度") |
| | | private String endLon; |
| | | @ApiModelProperty("起点经度") |
| | | private String startLng; |
| | | @ApiModelProperty("终点地址") |
| | | private String endAddress; |
| | | @ApiModelProperty("终点纬度") |
| | | private String endLat; |
| | | @ApiModelProperty("乘客昵称") |
| | | private String nickName; |
| | | @ApiModelProperty("乘客电话") |
| | | private String phone; |
| | | @ApiModelProperty("乘客历史乘车次数") |
| | | private Integer historyNum; |
| | | @ApiModelProperty("订单总金额") |
| | | private Double orderMoney; |
| | | @ApiModelProperty("支付方式(1=OK平台支付(线上支付),2=其他方式支付(线下支付))") |
| | | private Integer payManner; |
| | | @ApiModelProperty("支付金额") |
| | | private Double payMoney; |
| | | @ApiModelProperty("差价金额") |
| | | private Double differenceMoney; |
| | | @ApiModelProperty("是否是改派单(1=否,2=是)") |
| | | private Integer isReassign; |
| | | @ApiModelProperty("高德猎鹰轨迹id(订单开始后需要上传坐标到指定轨迹中)") |
| | | private String trackId; |
| | | @ApiModelProperty("是否是预约单(1=否,2=是)") |
| | | private Integer reservation; |
| | | @ApiModelProperty("订单类型(乘客下单,调度下单,改派,预约)") |
| | | private String type; |
| | | @ApiModelProperty("报警电话") |
| | | private String emergencyCall; |
| | | @ApiModelProperty("取消原因") |
| | | private String cancelReason; |
| | | @ApiModelProperty("取消备注") |
| | | private String cancelRemark; |
| | | @ApiModelProperty("取消支付金额") |
| | | private Double cancelPayMoney; |
| | | @ApiModelProperty("取消方") |
| | | private String cancelUser; |
| | | @ApiModelProperty("能否改派(1=否,2=是)") |
| | | private Integer reassign; |
| | | @ApiModelProperty("备注") |
| | | private String remark; |
| | | @ApiModelProperty("乘车人数") |
| | | private Integer peopleNumber; |
| | | @ApiModelProperty("座位号") |
| | | private String seatNumber; |
| | | @ApiModelProperty("货物类型(1=普通货物,2=贵重货物)") |
| | | private Integer cargoType; |
| | | @ApiModelProperty("是否加急(1=否,2=是)") |
| | | private Integer urgent; |
| | | @ApiModelProperty("下单用户姓名") |
| | | private String userName; |
| | | @ApiModelProperty("订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单,6:道行龙城,7:智慧屏)") |
| | | private Integer orderSource; |
| | | |
| | | public Integer getOrderId() { |
| | | return orderId; |
| | | } |
| | | |
| | | public void setOrderId(Integer orderId) { |
| | | this.orderId = orderId; |
| | | } |
| | | |
| | | public Integer getOrderState() { |
| | | return orderState; |
| | | } |
| | | |
| | | public void setOrderState(Integer orderState) { |
| | | this.orderState = orderState; |
| | | } |
| | | |
| | | public String getOrderName() { |
| | | return orderName; |
| | | } |
| | | |
| | | public void setOrderName(String orderName) { |
| | | this.orderName = orderName; |
| | | } |
| | | |
| | | public String getTravelTime() { |
| | | return travelTime; |
| | | } |
| | | |
| | | public void setTravelTime(String travelTime) { |
| | | this.travelTime = travelTime; |
| | | } |
| | | |
| | | public String getStartAddress() { |
| | | return startAddress; |
| | | } |
| | | |
| | | public void setStartAddress(String startAddress) { |
| | | this.startAddress = startAddress; |
| | | } |
| | | |
| | | public String getEndAddress() { |
| | | return endAddress; |
| | | } |
| | | |
| | | public void setEndAddress(String endAddress) { |
| | | this.endAddress = endAddress; |
| | | } |
| | | |
| | | public Double getTipMoney() { |
| | | return tipMoney; |
| | | } |
| | | |
| | | public void setTipMoney(Double tipMoney) { |
| | | this.tipMoney = tipMoney; |
| | | } |
| | | |
| | | public Double getStartDistance() { |
| | | return startDistance; |
| | | } |
| | | |
| | | public void setStartDistance(Double startDistance) { |
| | | this.startDistance = startDistance; |
| | | } |
| | | |
| | | public Double getTotalDistance() { |
| | | return totalDistance; |
| | | } |
| | | |
| | | public void setTotalDistance(Double totalDistance) { |
| | | this.totalDistance = totalDistance; |
| | | } |
| | | |
| | | public String getStartLon() { |
| | | return startLon; |
| | | } |
| | | |
| | | public void setStartLon(String startLon) { |
| | | this.startLon = startLon; |
| | | } |
| | | |
| | | public String getStartLat() { |
| | | return startLat; |
| | | } |
| | | |
| | | public void setStartLat(String startLat) { |
| | | this.startLat = startLat; |
| | | } |
| | | |
| | | public String getEndLon() { |
| | | return endLon; |
| | | } |
| | | |
| | | public void setEndLon(String endLon) { |
| | | this.endLon = endLon; |
| | | } |
| | | |
| | | public String getEndLat() { |
| | | return endLat; |
| | | } |
| | | |
| | | public void setEndLat(String endLat) { |
| | | this.endLat = endLat; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public Integer getHistoryNum() { |
| | | return historyNum; |
| | | } |
| | | |
| | | public void setHistoryNum(Integer historyNum) { |
| | | this.historyNum = historyNum; |
| | | } |
| | | |
| | | public Double getOrderMoney() { |
| | | return orderMoney; |
| | | } |
| | | |
| | | public void setOrderMoney(Double orderMoney) { |
| | | this.orderMoney = orderMoney; |
| | | } |
| | | |
| | | public Integer getPayManner() { |
| | | return payManner; |
| | | } |
| | | |
| | | public void setPayManner(Integer payManner) { |
| | | this.payManner = payManner; |
| | | } |
| | | |
| | | public Double getPayMoney() { |
| | | return payMoney; |
| | | } |
| | | |
| | | public void setPayMoney(Double payMoney) { |
| | | this.payMoney = payMoney; |
| | | } |
| | | |
| | | public Integer getIsReassign() { |
| | | return isReassign; |
| | | } |
| | | |
| | | public void setIsReassign(Integer isReassign) { |
| | | this.isReassign = isReassign; |
| | | } |
| | | |
| | | public String getTrackId() { |
| | | return trackId; |
| | | } |
| | | |
| | | public void setTrackId(String trackId) { |
| | | this.trackId = trackId; |
| | | } |
| | | |
| | | public String getArriveTime() { |
| | | return arriveTime; |
| | | } |
| | | |
| | | public void setArriveTime(String arriveTime) { |
| | | this.arriveTime = arriveTime; |
| | | } |
| | | |
| | | public Integer getReservation() { |
| | | return reservation; |
| | | } |
| | | |
| | | public void setReservation(Integer reservation) { |
| | | this.reservation = reservation; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getEmergencyCall() { |
| | | return emergencyCall; |
| | | } |
| | | |
| | | public void setEmergencyCall(String emergencyCall) { |
| | | this.emergencyCall = emergencyCall; |
| | | } |
| | | |
| | | public String getTravelTime_() { |
| | | return travelTime_; |
| | | } |
| | | |
| | | public void setTravelTime_(String travelTime_) { |
| | | this.travelTime_ = travelTime_; |
| | | } |
| | | |
| | | public String getCancelReason() { |
| | | return cancelReason; |
| | | } |
| | | |
| | | public void setCancelReason(String cancelReason) { |
| | | this.cancelReason = cancelReason; |
| | | } |
| | | |
| | | public String getCancelRemark() { |
| | | return cancelRemark; |
| | | } |
| | | |
| | | public void setCancelRemark(String cancelRemark) { |
| | | this.cancelRemark = cancelRemark; |
| | | } |
| | | |
| | | public Double getCancelPayMoney() { |
| | | return cancelPayMoney; |
| | | } |
| | | |
| | | public void setCancelPayMoney(Double cancelPayMoney) { |
| | | this.cancelPayMoney = cancelPayMoney; |
| | | } |
| | | |
| | | public String getCancelUser() { |
| | | return cancelUser; |
| | | } |
| | | |
| | | public void setCancelUser(String cancelUser) { |
| | | this.cancelUser = cancelUser; |
| | | } |
| | | |
| | | public Integer getReassign() { |
| | | return reassign; |
| | | } |
| | | |
| | | public void setReassign(Integer reassign) { |
| | | this.reassign = reassign; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public Integer getPeopleNumber() { |
| | | return peopleNumber; |
| | | } |
| | | |
| | | public void setPeopleNumber(Integer peopleNumber) { |
| | | this.peopleNumber = peopleNumber; |
| | | } |
| | | |
| | | public String getSeatNumber() { |
| | | return seatNumber; |
| | | } |
| | | |
| | | public void setSeatNumber(String seatNumber) { |
| | | this.seatNumber = seatNumber; |
| | | } |
| | | |
| | | public Integer getCargoType() { |
| | | return cargoType; |
| | | } |
| | | |
| | | public void setCargoType(Integer cargoType) { |
| | | this.cargoType = cargoType; |
| | | } |
| | | |
| | | public Integer getUrgent() { |
| | | return urgent; |
| | | } |
| | | |
| | | public void setUrgent(Integer urgent) { |
| | | this.urgent = urgent; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public Double getDifferenceMoney() { |
| | | return differenceMoney; |
| | | } |
| | | |
| | | public void setDifferenceMoney(Double differenceMoney) { |
| | | this.differenceMoney = differenceMoney; |
| | | } |
| | | |
| | | public Integer getOrderSource() { |
| | | return orderSource; |
| | | } |
| | | |
| | | public void setOrderSource(Integer orderSource) { |
| | | this.orderSource = orderSource; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "OrderInfoWarpper{" + |
| | | "orderId=" + orderId + |
| | | ", orderState=" + orderState + |
| | | ", orderName='" + orderName + '\'' + |
| | | ", travelTime='" + travelTime + '\'' + |
| | | ", travelTime_='" + travelTime_ + '\'' + |
| | | ", arriveTime='" + arriveTime + '\'' + |
| | | ", startAddress='" + startAddress + '\'' + |
| | | ", endAddress='" + endAddress + '\'' + |
| | | ", tipMoney=" + tipMoney + |
| | | ", startDistance=" + startDistance + |
| | | ", totalDistance=" + totalDistance + |
| | | ", startLon='" + startLon + '\'' + |
| | | ", startLat='" + startLat + '\'' + |
| | | ", endLon='" + endLon + '\'' + |
| | | ", endLat='" + endLat + '\'' + |
| | | ", nickName='" + nickName + '\'' + |
| | | ", phone='" + phone + '\'' + |
| | | ", historyNum=" + historyNum + |
| | | ", orderMoney=" + orderMoney + |
| | | ", payManner=" + payManner + |
| | | ", payMoney=" + payMoney + |
| | | ", isReassign=" + isReassign + |
| | | ", trackId='" + trackId + '\'' + |
| | | ", reservation=" + reservation + |
| | | ", type='" + type + '\'' + |
| | | ", emergencyCall='" + emergencyCall + '\'' + |
| | | ", cancelReason='" + cancelReason + '\'' + |
| | | ", cancelRemark='" + cancelRemark + '\'' + |
| | | ", cancelPayMoney=" + cancelPayMoney + |
| | | ", cancelUser='" + cancelUser + '\'' + |
| | | ", reassign=" + reassign + |
| | | ", remark='" + remark + '\'' + |
| | | ", peopleNumber=" + peopleNumber + |
| | | ", seatNumber='" + seatNumber + '\'' + |
| | | ", cargoType=" + cargoType + |
| | | ", urgent=" + urgent + |
| | | '}'; |
| | | } |
| | | @ApiModelProperty("终点经度") |
| | | private String endLng; |
| | | @ApiModelProperty("司机头像") |
| | | private String driverAvatar; |
| | | @ApiModelProperty("司机名称") |
| | | private String driverName; |
| | | @ApiModelProperty("司机电话") |
| | | private String driverPhone; |
| | | @ApiModelProperty("司机编号") |
| | | private String driverCode; |
| | | @ApiModelProperty("司机驾龄") |
| | | private Integer driverAge; |
| | | @ApiModelProperty("代驾次数") |
| | | private Integer driverNumber; |
| | | @ApiModelProperty("司机评分") |
| | | private Double driverScore; |
| | | @ApiModelProperty("订单状态(101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中)") |
| | | private Integer state; |
| | | |
| | | public static OrderInfoWarpper getOrderInfoWarpper(Map<String, Object> map){ |
| | | OrderInfoWarpper orderInfoWarpper = new OrderInfoWarpper(); |
| | | if(null != map){ |
| | | orderInfoWarpper.setOrderId(null != map.get("orderId") ? Integer.valueOf(String.valueOf(map.get("orderId"))) : 0); |
| | | orderInfoWarpper.setOrderState(null != map.get("orderState") ? Integer.valueOf(String.valueOf(map.get("orderState"))) : 0); |
| | | orderInfoWarpper.setOrderName(null != map.get("orderName") ? String.valueOf(map.get("orderName")) : ""); |
| | | orderInfoWarpper.setTravelTime(null != map.get("travelTime") ? String.valueOf(map.get("travelTime")) : ""); |
| | | orderInfoWarpper.setTravelTime_(null != map.get("travelTime_") ? String.valueOf(map.get("travelTime_")) : ""); |
| | | orderInfoWarpper.setArriveTime(null != map.get("arriveTime") ? String.valueOf(map.get("arriveTime")) : ""); |
| | | orderInfoWarpper.setStartAddress(null != map.get("startAddress") ? String.valueOf(map.get("startAddress")) : ""); |
| | | orderInfoWarpper.setEndAddress(null != map.get("endAddress") ? String.valueOf(map.get("endAddress")) : ""); |
| | | orderInfoWarpper.setTipMoney(null != map.get("tipMoney") ? Double.valueOf(String.valueOf(map.get("tipMoney"))) : 0); |
| | | orderInfoWarpper.setStartDistance(null != map.get("startDistance") ? Double.valueOf(String.valueOf(map.get("startDistance"))) : 0); |
| | | orderInfoWarpper.setTotalDistance(null != map.get("totalDistance") ? Double.valueOf(String.valueOf(map.get("totalDistance"))) : 0); |
| | | orderInfoWarpper.setStartLon(null != map.get("startLon") ? String.valueOf(map.get("startLon")) : ""); |
| | | orderInfoWarpper.setStartLat(null != map.get("startLat") ? String.valueOf(map.get("startLat")) : ""); |
| | | orderInfoWarpper.setEndLon(null != map.get("endLon") ? String.valueOf(map.get("endLon")) : ""); |
| | | orderInfoWarpper.setEndLat(null != map.get("endLat") ? String.valueOf(map.get("endLat")) : ""); |
| | | orderInfoWarpper.setNickName(null != map.get("nickName") ? String.valueOf(map.get("nickName")) : ""); |
| | | orderInfoWarpper.setPhone(null != map.get("telX") ? String.valueOf(map.get("telX")) : (null != map.get("phone") ? String.valueOf(map.get("phone")) : "")); |
| | | orderInfoWarpper.setHistoryNum(null != map.get("historyNum") ? Integer.valueOf(String.valueOf(map.get("historyNum"))) : 0); |
| | | orderInfoWarpper.setOrderMoney(null != map.get("orderMoney") ? Double.valueOf(String.valueOf(map.get("orderMoney"))) : 0); |
| | | orderInfoWarpper.setPayManner(null != map.get("payManner") ? Integer.valueOf(String.valueOf(map.get("payManner"))) : 0); |
| | | orderInfoWarpper.setPayMoney(null != map.get("payMoney") ? Double.valueOf(String.valueOf(map.get("payMoney"))) : 0); |
| | | orderInfoWarpper.setIsReassign(null != map.get("isReassign") ? Integer.valueOf(String.valueOf(map.get("isReassign"))) : 1); |
| | | orderInfoWarpper.setTrackId(null != map.get("trackId") ? String.valueOf(map.get("trackId")) : ""); |
| | | orderInfoWarpper.setReservation(null != map.get("reservation") ? Integer.valueOf(String.valueOf(map.get("reservation"))) : 0); |
| | | orderInfoWarpper.setType(null != map.get("type") ? String.valueOf(map.get("type")) : ""); |
| | | orderInfoWarpper.setEmergencyCall(null != map.get("emergencyCall") ? String.valueOf(map.get("emergencyCall")) : ""); |
| | | orderInfoWarpper.setCancelReason(null != map.get("cancelReason") ? String.valueOf(map.get("cancelReason")) : ""); |
| | | orderInfoWarpper.setCancelRemark(null != map.get("cancelRemark") ? String.valueOf(map.get("cancelRemark")) : ""); |
| | | orderInfoWarpper.setCancelPayMoney(null != map.get("cancelPayMoney") ? Double.valueOf(String.valueOf(map.get("cancelPayMoney"))) : 0); |
| | | orderInfoWarpper.setCancelUser(null != map.get("cancelUser") ? String.valueOf(map.get("cancelUser")) : ""); |
| | | orderInfoWarpper.setReassign(null != map.get("reassign") ? Integer.valueOf(String.valueOf(map.get("reassign"))) : 1); |
| | | orderInfoWarpper.setPeopleNumber(null != map.get("peopleNumber") ? Integer.valueOf(String.valueOf(map.get("peopleNumber"))) : 1); |
| | | orderInfoWarpper.setRemark(null != map.get("remark") ? String.valueOf(map.get("remark")) : ""); |
| | | orderInfoWarpper.setSeatNumber(null != map.get("seatNumber") ? String.valueOf(map.get("seatNumber")) : ""); |
| | | orderInfoWarpper.setCargoType(null != map.get("cargoType") ? Integer.valueOf(map.get("cargoType").toString()) : 0); |
| | | orderInfoWarpper.setUrgent(null != map.get("urgent") ? Integer.valueOf(map.get("urgent").toString()) : 0); |
| | | orderInfoWarpper.setUserName(null != map.get("userName") ? String.valueOf(map.get("userName")) : ""); |
| | | orderInfoWarpper.setDifferenceMoney(null != map.get("differenceMoney") ? Double.valueOf(map.get("differenceMoney").toString()) : 0D); |
| | | orderInfoWarpper.setOrderSource(null != map.get("orderSource") ? Integer.valueOf(map.get("orderSource").toString()) : 0); |
| | | } |
| | | return orderInfoWarpper; |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/10 10:50 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class OrderPayment { |
| | | @ApiModelProperty(value = "订单id", required = true, dataType = "Long") |
| | | private Long orderId; |
| | | @ApiModelProperty(value = "支付方式(1=微信,2=余额,3=线下,4=微信+余额)", required = true, dataType = "int") |
| | | private Integer payType; |
| | | @ApiModelProperty(value = "优惠券id", required = false, dataType = "int") |
| | | private Integer couponId; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/10 9:06 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class OrderPriceWarpper { |
| | | @ApiModelProperty("订单金额") |
| | | private Double orderMoney; |
| | | @ApiModelProperty("总行驶里程") |
| | | private Double actualMileage; |
| | | @ApiModelProperty("总行驶时间") |
| | | private Integer travelTime; |
| | | @ApiModelProperty("起步里程") |
| | | private Double startDistance; |
| | | @ApiModelProperty("起步价") |
| | | private Double startPrice; |
| | | @ApiModelProperty("超过起步里程") |
| | | private Double overDriveDistance; |
| | | @ApiModelProperty("超过起步里程费") |
| | | private Double overDrivePrice; |
| | | @ApiModelProperty("长途里程") |
| | | private Double longDistance; |
| | | @ApiModelProperty("长途费") |
| | | private Double longDistancePrice; |
| | | @ApiModelProperty("超过长途里程") |
| | | private Double overLongDistance; |
| | | @ApiModelProperty("超过长途里程费") |
| | | private Double overLongDistancePrice; |
| | | @ApiModelProperty("等待时长") |
| | | private Integer waitTime; |
| | | @ApiModelProperty("等待费") |
| | | private Double waitTimePrice; |
| | | @ApiModelProperty("超出等待时长") |
| | | private Integer outWaitTime; |
| | | @ApiModelProperty("超出等待费") |
| | | private Double outWaitTimePrice; |
| | | @ApiModelProperty("恶劣天气里程") |
| | | private Double badWeatherDistance; |
| | | @ApiModelProperty("恶劣天气费") |
| | | private Double badWeatherPrice; |
| | | @ApiModelProperty("恶劣天气超出里程") |
| | | private Double overBadWeatherDistance; |
| | | @ApiModelProperty("恶劣天气超出里程费") |
| | | private Double overBadWeatherPrice; |
| | | @ApiModelProperty("折扣") |
| | | private Double discount; |
| | | @ApiModelProperty("折扣金额") |
| | | private Double discountAmount; |
| | | @ApiModelProperty("优惠券金额") |
| | | private Double discountedPrice; |
| | | @ApiModelProperty("当前余额") |
| | | private Double balance; |
| | | @ApiModelProperty("支付途径(1=微信支付,2=余额支付,3=线下付款,4=微信+余额)") |
| | | private Integer payType; |
| | | @ApiModelProperty("支付金额") |
| | | private Double payMoney; |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/3 14:25 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class SignInToRegisterWarpper { |
| | | @ApiModelProperty("token") |
| | | private String token; |
| | | @ApiModelProperty("优惠券列表") |
| | | private List<CouponWarpper> coupons; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel |
| | | public class StartPriceWarpper { |
| | | @ApiModelProperty("起步价") |
| | | private Double startPrice; |
| | | @ApiModelProperty("起步公里") |
| | | private Double startDistance; |
| | | @ApiModelProperty("超出起步里程单价") |
| | | private Double excessMileageUnitPrice; |
| | | @ApiModelProperty("超出起步里程计算距离") |
| | | private Double overmileage; |
| | | @ApiModelProperty("起步价说明") |
| | | private String description; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/3 14:57 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class TravelOrder { |
| | | @ApiModelProperty(value = "起点纬度", dataType = "double", required = true) |
| | | private Double startLat; |
| | | @ApiModelProperty(value = "起点经度", dataType = "double", required = true) |
| | | private Double startLng; |
| | | @ApiModelProperty(value = "起点地址", dataType = "string", required = true) |
| | | private String startAddress; |
| | | @ApiModelProperty(value = "终点纬度", dataType = "double", required = false) |
| | | private Double endLat; |
| | | @ApiModelProperty(value = "终点经度", dataType = "double", required = false) |
| | | private Double endLng; |
| | | @ApiModelProperty(value = "终点地址", dataType = "string", required = false) |
| | | private String endAddress; |
| | | @ApiModelProperty(value = "司机数量", dataType = "int", required = true) |
| | | private Integer driverNum; |
| | | @ApiModelProperty(value = "乘车人姓名", dataType = "string", required = false) |
| | | private String userName; |
| | | @ApiModelProperty(value = "乘车人电话", dataType = "string", required = false) |
| | | private String userPhone; |
| | | @ApiModelProperty(value = "司机id", dataType = "int", required = false) |
| | | private Integer driverId; |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/10 10:11 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class UserInfoWarpper { |
| | | @ApiModelProperty("用户id") |
| | | private Integer id; |
| | | @ApiModelProperty("头像") |
| | | private String avatar; |
| | | @ApiModelProperty("昵称") |
| | | private String nickname; |
| | | @ApiModelProperty("电话") |
| | | private String phone; |
| | | @ApiModelProperty("账户余额") |
| | | private Double accountBalance; |
| | | @ApiModelProperty("紧急联系人") |
| | | private String emergencyContact; |
| | | @ApiModelProperty("紧急人电话") |
| | | private String emergencyPhone; |
| | | } |
| | |
| | | configuration: |
| | | configuration.map-underscore-to-camel-case: true #是否开启自动驼峰命名规则(camel case)映射 |
| | | log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #输出Sql,如需打印Sql注释该配置 |
| | | mapper-locations: classpath*:com/supersavedriving/user/modular/system/dao/**/*.xml |
| | | |
| | | |
| | | |
| | |
| | | |
| | | wx: |
| | | grantType: authorization_code #填authorization_code |
| | | appid: wx36c966d381cd5d62 #应用唯一标识,在微信开放平台提交应用审核通过后获得 |
| | | appSecret: cf4b21c7175356f41fa3c426f26c20e4 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 |
| | | appletsAppid: #小程序APPid |
| | | appletsAppSecret: # |
| | | mchId: 1593080081 #微信支付分配的商户号 |
| | | key: JnhREmZwHNKyFUQPEhijp1gdaCUzKg8P #key为商户平台设置的密钥key: |
| | | appid: 11 #应用唯一标识,在微信开放平台提交应用审核通过后获得 |
| | | appSecret: 11 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 |
| | | appletsAppid: wx8ae6c610563f2fe6 #小程序APPid |
| | | appletsAppSecret: 8b2c93b0be4f017350050f1e660680fe # |
| | | officialAccountAppid: 11111 |
| | | officialAccountAppSecret: 1111 |
| | | webAppId: 111 |
| | | webAppSecret: 11 |
| | | mchId: 1636941942 #微信支付分配的商户号 |
| | | key: Eri2GR2SB3b6iIhaoD7k3KQ8X0wf1Ybh #key为商户平台设置的密钥key: |
| | | |
| | | --- |
| | | |
| | |
| | | |
| | | #支付回调地址 |
| | | #正式环境 |
| | | callbackPath: https://okyueche.com:443/driver |
| | | callbackPath: https://okyueche.com:443/user |
| | | #正式测试环境 |
| | | #callbackPath: http://39.108.148.228:80/driver |
| | | #callbackPath: http://39.108.148.228:80/user |
| | | |
| | | --- |
| | | #交通部推送数据功能开关 |
| | | pushMinistryOfTransport: false |
| | | |
| | | spring: |
| | | data: |
| | | mongodb: |
| | | uri: mongodb://127.0.0.1:27017/admin |
New file |
| | |
| | | /* |
| | | Navicat Premium Data Transfer |
| | | |
| | | Source Server : localhost |
| | | Source Server Type : MySQL |
| | | Source Server Version : 50719 |
| | | Source Host : localhost:3306 |
| | | Source Schema : guns |
| | | |
| | | Target Server Type : MySQL |
| | | Target Server Version : 50719 |
| | | File Encoding : 65001 |
| | | |
| | | Date: 10/07/2018 14:09:19 |
| | | */ |
| | | |
| | | DROP DATABASE IF EXISTS guns_test; |
| | | CREATE DATABASE IF NOT EXISTS guns_test DEFAULT CHARSET utf8 COLLATE utf8_general_ci; |
| | | |
| | | use guns_test; |
| | | |
| | | SET NAMES utf8mb4; |
| | | SET FOREIGN_KEY_CHECKS = 0; |
| | | |
| | | -- ---------------------------- |
| | | -- Table structure for test |
| | | -- ---------------------------- |
| | | DROP TABLE IF EXISTS `test`; |
| | | CREATE TABLE `test` ( |
| | | `aaa` int(11) NOT NULL AUTO_INCREMENT, |
| | | `bbb` varchar(255) DEFAULT NULL, |
| | | PRIMARY KEY (`aaa`) USING BTREE |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; |
| | | |
| | | SET FOREIGN_KEY_CHECKS = 1; |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-parent</artifactId> |
| | | <version>2.0.4.RELEASE</version> |
| | | <relativePath/> <!-- lookup parent from repository --> |
| | | </parent> |
| | | <groupId>com.sinata</groupId> |
| | | <artifactId>zuul</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>zuul</name> |
| | | <description>Zuul project for Spring Boot</description> |
| | | |
| | | <packaging>jar</packaging> |
| | | |
| | | <properties> |
| | | <java.version>1.8</java.version> |
| | | <spring-cloud.version>Finchley.SR1</spring-cloud.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-netflix-zuul</artifactId> |
| | | </dependency> |
| | | |
| | | <!--引入swagger--> |
| | | <dependency> |
| | | <groupId>com.spring4all</groupId> |
| | | <artifactId>swagger-spring-boot-starter</artifactId> |
| | | <version>1.7.0.RELEASE</version> |
| | | </dependency> |
| | | <!-- jedis --> |
| | | <dependency> |
| | | <groupId>redis.clients</groupId> |
| | | <artifactId>jedis</artifactId> |
| | | <version>2.9.0</version> |
| | | </dependency> |
| | | |
| | | <!--<dependency>--> |
| | | <!--<groupId>org.springframework.boot</groupId>--> |
| | | <!--<artifactId>spring-boot-starter-tomcat</artifactId>--> |
| | | <!--<scope>provided</scope>--> |
| | | <!--</dependency>--> |
| | | <!--<dependency>--> |
| | | <!--<groupId>javax.servlet</groupId>--> |
| | | <!--<artifactId>javax.servlet-api</artifactId>--> |
| | | <!--<version>3.1.0</version>--> |
| | | <!--<scope>provided</scope>--> |
| | | <!--</dependency>--> |
| | | |
| | | |
| | | <!-- netty --> |
| | | <dependency> |
| | | <groupId>io.netty</groupId> |
| | | <artifactId>netty-all</artifactId> |
| | | <version>4.1.27.Final</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.47</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | <scope>test</scope> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.junit.vintage</groupId> |
| | | <artifactId>junit-vintage-engine</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <dependencyManagement> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-dependencies</artifactId> |
| | | <version>${spring-cloud.version}</version> |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.sinata.zuul; |
| | | |
| | | import com.sinata.zuul.util.applets.NettyServer0; |
| | | import com.sinata.zuul.util.echo.NettyServer; |
| | | import com.spring4all.swagger.EnableSwagger2Doc; |
| | | import org.apache.http.client.HttpClient; |
| | | import org.apache.http.config.SocketConfig; |
| | | import org.apache.http.impl.client.HttpClientBuilder; |
| | | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| | | import org.springframework.cloud.client.loadbalancer.LoadBalanced; |
| | | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Primary; |
| | | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
| | | import org.springframework.web.filter.CorsFilter; |
| | | import springfox.documentation.swagger.web.SwaggerResource; |
| | | import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | @EnableSwagger2Doc |
| | | @EnableZuulProxy//开启网关服务 |
| | | @EnableDiscoveryClient//开启eureka客户端的消费者 |
| | | @SpringBootApplication |
| | | public class ZuulApplication extends SpringBootServletInitializer { |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(ZuulApplication.class, args); |
| | | // NettyServer nettyServer = new NettyServer(); |
| | | // nettyServer.bind(); |
| | | // NettyServer0 nettyServer0 = new NettyServer0(); |
| | | // nettyServer0.bind(); |
| | | } |
| | | |
| | | |
| | | @Bean //SpringCloud内部服务质检使用服务名调用 |
| | | @LoadBalanced |
| | | public RestTemplate internalRestTemplate() { |
| | | PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); |
| | | connectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).build()); |
| | | connectionManager.setDefaultMaxPerRoute(100);//最大并发连接 |
| | | connectionManager.setMaxTotal(200); // 总的最大连接数 |
| | | HttpClient httpClient = HttpClientBuilder.create().setConnectionManager(connectionManager).build(); |
| | | HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); |
| | | httpRequestFactory.setConnectionRequestTimeout(30 * 1000); |
| | | httpRequestFactory.setConnectTimeout(30 * 3000); |
| | | httpRequestFactory.setReadTimeout(30 * 3000); |
| | | RestTemplate restTemplate = new RestTemplate(httpRequestFactory); |
| | | restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | return restTemplate; |
| | | } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * 向Spring容器中定义RestTemplate对象 |
| | | // * @return |
| | | // */ |
| | | // @Bean //必须new 一个RestTemplate并放入spring容器当中,否则启动时报错 |
| | | // public RestTemplate restTemplate() { |
| | | // PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); |
| | | // connectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).build()); |
| | | // connectionManager.setDefaultMaxPerRoute(100);//最大并发连接 |
| | | // connectionManager.setMaxTotal(200); // 总的最大连接数 |
| | | // HttpClient httpClient = HttpClientBuilder.create().setConnectionManager(connectionManager).build(); |
| | | // HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); |
| | | // httpRequestFactory.setConnectionRequestTimeout(30 * 1000); |
| | | // httpRequestFactory.setConnectTimeout(30 * 3000); |
| | | // httpRequestFactory.setReadTimeout(30 * 3000); |
| | | // RestTemplate restTemplate = new RestTemplate(httpRequestFactory); |
| | | // restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | // return restTemplate; |
| | | // } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 配置Swagger |
| | | */ |
| | | @Component |
| | | @Primary |
| | | class DocumentationConfig implements SwaggerResourcesProvider { |
| | | @Override |
| | | public List<SwaggerResource> get() { |
| | | List resource=new ArrayList<>(); |
| | | //name可以随便写,location前缀要与zuul配置的path一致。zuul开了token验证,要加上token,否则不用加?token=1 |
| | | resource.add(swaggerResource("user","/user-server/v2/api-docs","1.0")); |
| | | resource.add(swaggerResource("driver","/driver-server/v2/api-docs","1.0")); |
| | | return resource; |
| | | } |
| | | |
| | | //name可以随便写,location前缀要与zuul配置的path一致 |
| | | private SwaggerResource swaggerResource(String name, String location, String version){ |
| | | SwaggerResource swaggerResource=new SwaggerResource(); |
| | | swaggerResource.setName(name); |
| | | swaggerResource.setLocation(location); |
| | | swaggerResource.setSwaggerVersion(version); |
| | | return swaggerResource; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
| | | return builder.sources(ZuulApplication.class); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.config; |
| | | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.PropertySource; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.JedisPoolConfig; |
| | | |
| | | @Configuration |
| | | @PropertySource("classpath:redis.properties") |
| | | public class RedisConfig { |
| | | @Value("${spring.redis.host}") |
| | | private String host; |
| | | |
| | | @Value("${spring.redis.port}") |
| | | private int port; |
| | | |
| | | @Value("${spring.redis.timeout}") |
| | | private int timeout; |
| | | |
| | | @Value("${spring.redis.jedis.pool.max-idle}") |
| | | private int maxIdle; |
| | | |
| | | @Value("${spring.redis.jedis.pool.min-idle}") |
| | | private int minIdle; |
| | | |
| | | @Value("${spring.redis.jedis.pool.max-wait}") |
| | | private long maxWaitMillis; |
| | | |
| | | @Value("${spring.redis.jedis.pool.max-active}") |
| | | private int maxTotal; |
| | | |
| | | @Value("${spring.redis.password}") |
| | | private String password; |
| | | |
| | | @Value("${spring.redis.block-when-exhausted}") |
| | | private boolean blockWhenExhausted; |
| | | |
| | | @Bean |
| | | public JedisPool redisPoolFactory() throws Exception{ |
| | | JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); |
| | | jedisPoolConfig.setMaxIdle(maxIdle); |
| | | jedisPoolConfig.setMinIdle(minIdle); |
| | | jedisPoolConfig.setMaxTotal(maxTotal); |
| | | jedisPoolConfig.setMaxWaitMillis(maxWaitMillis); |
| | | // 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true |
| | | jedisPoolConfig.setBlockWhenExhausted(blockWhenExhausted); |
| | | // 是否启用pool的jmx管理功能, 默认true |
| | | jedisPoolConfig.setJmxEnabled(true); |
| | | JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password); |
| | | return jedisPool; |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sinata.zuul.util.ResultUtil; |
| | | import com.sinata.zuul.util.applets.NettyWebSocketController; |
| | | import com.sinata.zuul.util.echo.NettyChannelMap; |
| | | import com.sinata.zuul.util.echo.NettyServerController; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @RestController |
| | | @RequestMapping("/netty") |
| | | public class NettyController { |
| | | |
| | | |
| | | /** |
| | | * 向客户端推送消息 |
| | | * @param id |
| | | * @param msg |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/sendMsgToClient") |
| | | public String sendMsgToClient(String id, Integer type, String msg){ |
| | | if(type == 1){//用户端 |
| | | ChannelHandlerContext channel = NettyChannelMap.getData("Applets" + id);//小程序 |
| | | if(null != channel){ |
| | | NettyWebSocketController.sendMsgToClient(channel, msg); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | channel = NettyChannelMap.getData("USER" + id); |
| | | if(null != channel){ |
| | | NettyServerController.sendMsgToClient(channel, msg); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | |
| | | //智慧屏(设备号) |
| | | channel = NettyChannelMap.getData(id); |
| | | if(null != channel){ |
| | | NettyServerController.sendMsgToClient(channel, msg); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | return JSON.toJSONString(ResultUtil.error("推送失败-----用户id=" + id)); |
| | | |
| | | } |
| | | |
| | | if(type == 2){//司机端 |
| | | ChannelHandlerContext channel = NettyChannelMap.getData("DRIVER" + id); |
| | | if(null != channel){ |
| | | NettyServerController.sendMsgToClient(channel, msg); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | return JSON.toJSONString(ResultUtil.error("推送失败-----司机id=" + id)); |
| | | } |
| | | |
| | | return JSON.toJSONString(ResultUtil.error("推送失败")); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sinata.zuul.util.RedisUtil; |
| | | import com.sinata.zuul.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/redis") |
| | | public class RedisController { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | | * 从redis中获取数据 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getValue") |
| | | public String getValue(String key){ |
| | | String value = redisUtil.getValue(key); |
| | | return JSON.toJSONString(ResultUtil.success(value)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量获取 |
| | | * @param keys |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getValues") |
| | | public String getValues(String keys){ |
| | | String[] split = keys.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | List<Object> values = redisUtil.getValues(list); |
| | | return JSON.toJSONString(ResultUtil.success(values)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 存值 |
| | | * @param key |
| | | * @param value |
| | | * @param time |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/setValue") |
| | | public String setValue(String key, String value, int time){ |
| | | redisUtil.setStrValue(key, value, time); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/setValue_") |
| | | public String setValue_(String key, String value){ |
| | | redisUtil.setStrValue(key, value); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | |
| | | /** |
| | | * 删除redis数据 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/remove") |
| | | public String remove(String key){ |
| | | redisUtil.remove(key); |
| | | return JSON.toJSONString(ResultUtil.success()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | |
| | | import org.springframework.boot.web.servlet.ServletComponentScan; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.annotation.WebFilter; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 统一配置跨域处理 |
| | | */ |
| | | @Order(-100) |
| | | @Component |
| | | @ServletComponentScan |
| | | @WebFilter(urlPatterns = "/*",filterName = "crossOriginFilter") |
| | | public class CrossOriginFilter implements Filter { |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
| | | HttpServletResponse response = (HttpServletResponse) servletResponse; |
| | | HttpServletRequest request = (HttpServletRequest) servletRequest; |
| | | // 允许哪些Origin发起跨域请求 |
| | | // response.setHeader( "Access-Control-Allow-Origin", config.getInitParameter( "AccessControlAllowOrigin" ) ); |
| | | response.setHeader( "Access-Control-Allow-Origin", "*" ); |
| | | // 允许请求的方法 |
| | | response.setHeader( "Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,PUT" ); |
| | | //多少秒内,不需要再发送预检验请求,可以缓存该结果 |
| | | response.setHeader( "Access-Control-Max-Age", "3600" ); |
| | | // 表明它允许跨域请求包含xxx头 |
| | | response.setHeader( "Access-Control-Allow-Headers", "x-auth-token,Origin,Access-Token,X-Requested-With,Content-Type, Accept, Authorization" ); |
| | | //是否允许浏览器携带用户身份信息(cookie) |
| | | response.setHeader( "Access-Control-Allow-Credentials", "true" ); |
| | | //prefight请求 |
| | | if (request.getMethod().equals( "OPTIONS" )) { |
| | | response.setStatus( 204 ); |
| | | return; |
| | | } |
| | | filterChain.doFilter( servletRequest, response ); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 高德地图的地理编码工具类 |
| | | */ |
| | | @Component |
| | | public class GDMapGeocodingUtil { |
| | | |
| | | private String key = "79293423abef825bf17db8568fa93d98"; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | /** |
| | | * 将行政区域名称转化为坐标 |
| | | * @param province |
| | | * @param city |
| | | * @param county |
| | | * @param address |
| | | * @return |
| | | */ |
| | | public Map<String, Object> geocoding(String province, String city, String county, String address){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(StringUtil.isEmpty(province)){ |
| | | map.put("status", -1); |
| | | map.put("data", "省不能为空"); |
| | | return map; |
| | | } |
| | | if((StringUtil.isEmpty(city) && StringUtil.isNotEmpty(county)) || (StringUtil.isEmpty(city) && StringUtil.isNotEmpty(address))){ |
| | | map.put("status", -1); |
| | | map.put("data", "市不能为空"); |
| | | return map; |
| | | } |
| | | if((StringUtil.isEmpty(county) && StringUtil.isNotEmpty(address))){ |
| | | map.put("status", -1); |
| | | map.put("data", "县/区不能为空"); |
| | | return map; |
| | | } |
| | | |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON"; |
| | | url += "&address=" + province + (StringUtil.isNotEmpty(city) ? city : "") + (StringUtil.isNotEmpty(county) ? county : "") + (StringUtil.isNotEmpty(address) ? address : ""); |
| | | String forObject = restTemplate.getForObject(url, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | | String status = jsonObject.getString("status"); |
| | | List<String> list = new ArrayList<>(); |
| | | if(status.equals("1")){ |
| | | JSONArray geocodes = jsonObject.getJSONArray("geocodes"); |
| | | for(int i = 0; i < geocodes.size(); i++){ |
| | | String location = geocodes.getJSONObject(i).getString("location"); |
| | | list.add(location); |
| | | } |
| | | } |
| | | map.put("status", 0); |
| | | map.put("data", list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据经纬度获取行政区域信息 |
| | | * @param lon |
| | | * @param lan |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, String> geocode(String lon, String lan) throws Exception{ |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan; |
| | | String forObject = restTemplate.getForObject(url, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | | Map<String, String> map = new HashMap<>(); |
| | | if(jsonObject.getString("status").equals("1")){ |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String address = regeocode.getString("formatted_address"); |
| | | map.put("address", address); |
| | | String code = addressComponent.getString("adcode"); |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | | map.put("city", city); |
| | | map.put("cityCode", code.substring(0, 4) + "00"); |
| | | map.put("district", district); |
| | | map.put("districtCode", code); |
| | | } |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import com.sinata.zuul.util.applets.NettyServer0; |
| | | import com.sinata.zuul.util.echo.NettyServer; |
| | | |
| | | import javax.servlet.ServletContextEvent; |
| | | import javax.servlet.ServletContextListener; |
| | | import javax.servlet.annotation.WebListener; |
| | | |
| | | /** |
| | | * 启动netty监听器 |
| | | */ |
| | | @WebListener |
| | | public class NettyStartListener implements ServletContextListener { |
| | | |
| | | |
| | | @Override |
| | | public void contextInitialized(ServletContextEvent sce) { |
| | | Thread thread = new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | NettyServer nettyServer = new NettyServer(); |
| | | nettyServer.bind(); |
| | | |
| | | NettyServer0 nettyServer0 = new NettyServer0(); |
| | | nettyServer0.bind(); |
| | | } |
| | | }); |
| | | thread.start(); |
| | | } |
| | | |
| | | @Override |
| | | public void contextDestroyed(ServletContextEvent sce) { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.Pipeline; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * Redis工具类 |
| | | */ |
| | | @Component |
| | | public class RedisUtil { |
| | | |
| | | @Autowired |
| | | private JedisPool jedisPool; |
| | | |
| | | |
| | | /** |
| | | * 向redis中存储字符串没有过期时间 |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | public void setStrValue(String key, String value){ |
| | | if(StringUtil.isNotEmpty(key)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String set = resource.set(key, value); |
| | | closeJedis(resource); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 以分钟为单位设置存储值(设置过期时间) |
| | | * @param key |
| | | * @param value |
| | | * @param time 秒 |
| | | */ |
| | | public void setStrValue(String key, String value, int time){ |
| | | if(StringUtil.isNotEmpty(key)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String setex = resource.setex(key, time, value); |
| | | closeJedis(resource); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 从redis中获取值 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public String getValue(String key){ |
| | | if(StringUtil.isNotEmpty(key)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String data = resource.get(key); |
| | | closeJedis(resource); |
| | | return data; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量获取 |
| | | * @param kes |
| | | * @return |
| | | */ |
| | | public List<Object> getValues(List<String> kes){ |
| | | if(null != kes){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | Pipeline pipelined = resource.pipelined(); |
| | | for(String key : kes){ |
| | | pipelined.get(key); |
| | | } |
| | | List<Object> list = pipelined.syncAndReturnAll(); |
| | | |
| | | closeJedis(resource); |
| | | pipelined.clear(); |
| | | try { |
| | | pipelined.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | List<Object> data = new ArrayList<>(); |
| | | for(Object o : list){ |
| | | if(null != o){ |
| | | data.add(o); |
| | | } |
| | | } |
| | | return data; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除key |
| | | * @param key |
| | | */ |
| | | public void remove(String key){ |
| | | if(StringUtil.isNotEmpty(key)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | Long del = resource.del(key); |
| | | closeJedis(resource); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除资源 |
| | | * @param jedis |
| | | */ |
| | | public void closeJedis(Jedis jedis){ |
| | | if(null != jedis){ |
| | | jedis.close(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * 定义统一返回对象 |
| | | */ |
| | | @ApiModel(value = "统一返回结果集") |
| | | public class ResultUtil<T> { |
| | | |
| | | public static final Integer SUCCESS = 200; |
| | | |
| | | public static final Integer PARAM_ERROR = 300; |
| | | |
| | | public static final Integer RUNTIME_ERROR = 400; |
| | | |
| | | public static final Integer ERROR = 500; |
| | | |
| | | public static final Integer TOKEN_ERROR = 600; |
| | | |
| | | public static final Integer SIGN_ERROR = 700; |
| | | |
| | | public static final String Token = "TOKEN_INVALID"; |
| | | |
| | | public static final String SIGN = "SIGN_INVALID"; |
| | | |
| | | @ApiModelProperty(name = "code", value = "业务状态码 200:成功,300:参数错误,400:运行异常,500:其他异常, 600:token无效,需重新登录,700:签名无效") |
| | | private Integer code;//备用状态码 |
| | | |
| | | @ApiModelProperty(name = "msg", value = "返回结果说明") |
| | | private String msg;//返回说明 |
| | | |
| | | @ApiModelProperty(name = "data", value = "返回结果值") |
| | | private T data;//返回数据 |
| | | |
| | | |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | private ResultUtil(Integer code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | private ResultUtil(Integer code, String msg, T data) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.data = data; |
| | | } |
| | | |
| | | |
| | | public static <T> ResultUtil<T> getResult(Integer code, String msg){ |
| | | return new ResultUtil<>(code, msg); |
| | | } |
| | | |
| | | public static <T> ResultUtil<T> getResult(Integer code, String msg, T data){ |
| | | return new ResultUtil<>(code, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * 错误信息 |
| | | * @return |
| | | */ |
| | | public static ResultUtil error(String mag){ |
| | | return ResultUtil.getResult(ResultUtil.ERROR, mag, new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | | * 错误信息 |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil <T> error(String mag, T obj){ |
| | | return ResultUtil.getResult(ResultUtil.ERROR, mag, obj); |
| | | } |
| | | |
| | | /** |
| | | * token失效 |
| | | * @return |
| | | */ |
| | | public static ResultUtil tokenErr(){ |
| | | return ResultUtil.getResult(ResultUtil.TOKEN_ERROR, ResultUtil.Token, new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | | * token失效 |
| | | * @return |
| | | */ |
| | | public static ResultUtil tokenErr(String msg){ |
| | | return ResultUtil.getResult(ResultUtil.TOKEN_ERROR, msg, new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | | * 参数异常 |
| | | * @return |
| | | */ |
| | | public static ResultUtil paranErr(){ |
| | | return ResultUtil.getResult(ResultUtil.PARAM_ERROR, "PARAM_ERROR", new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | | * 参数异常 |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil<T> paranErr(T data){ |
| | | return ResultUtil.getResult(ResultUtil.PARAM_ERROR, "SYSTEM_RUN_ERROR", data); |
| | | } |
| | | |
| | | /** |
| | | * 运行异常 |
| | | * @return |
| | | */ |
| | | public static ResultUtil runErr(){ |
| | | return ResultUtil.getResult(ResultUtil.RUNTIME_ERROR, "SYSTEM_RUN_ERROR", new JSONObject()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 运行异常 |
| | | * @return |
| | | */ |
| | | public static <T>ResultUtil<T> runErr(T data){ |
| | | return ResultUtil.getResult(ResultUtil.RUNTIME_ERROR, "SYSTEM_RUN_ERROR", data); |
| | | } |
| | | |
| | | /** |
| | | * 运行异常 |
| | | * @return |
| | | */ |
| | | public static <T>ResultUtil<T> runErr(T data, String msg){ |
| | | return ResultUtil.getResult(ResultUtil.RUNTIME_ERROR, msg, data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回成功 |
| | | * @param |
| | | * @return |
| | | */ |
| | | public static ResultUtil success(){ |
| | | return ResultUtil.getResult(ResultUtil.SUCCESS, "SUCCESS", new JSONObject()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回成功 |
| | | * @param data |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil<T> success(T data){ |
| | | return ResultUtil.getResult(ResultUtil.SUCCESS, "SUCCESS", data); |
| | | } |
| | | |
| | | /** |
| | | * 返回成功 |
| | | * @param msg |
| | | * @param data |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil<T> success(String msg, T data){ |
| | | return ResultUtil.getResult(ResultUtil.SUCCESS, msg, data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 签名无效 |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil<T> sign(){ |
| | | return ResultUtil.getResult(ResultUtil.SIGN_ERROR, SIGN); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.text.DecimalFormat; |
| | | import java.text.NumberFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * 基本数据处理工具类 |
| | | */ |
| | | public class SinataUtil { |
| | | /** |
| | | * List集合分页<br/> |
| | | * 创建人:Mryang<br/> |
| | | * 时间:2016年7月28日-下午2:58:14 <br/> |
| | | * @param <T> |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param list |
| | | * @throws Exception List<UserOrderList> <br/> |
| | | */ |
| | | public static <T> List<T> listpage(int pageNo, int pageSize, List<T> list) throws Exception { |
| | | List<T> result = new ArrayList<T>(); |
| | | if (list != null && list.size() > 0) { |
| | | int allCount = list.size(); |
| | | if(pageNo > 1 && allCount < pageSize) { |
| | | return new ArrayList<>(); |
| | | } |
| | | int pageCount = (allCount + pageSize - 1) / pageSize; |
| | | if (pageNo >= pageCount) { |
| | | pageNo = pageCount; |
| | | } |
| | | int start = (pageNo - 1) * pageSize; |
| | | int end = pageNo * pageSize; |
| | | if (end >= allCount) { |
| | | end = allCount; |
| | | } |
| | | for (int i = start; i < end; i++) { |
| | | result.add(list.get(i)); |
| | | } |
| | | } |
| | | return (result != null && result.size() > 0) ? result : new ArrayList<T>(); |
| | | } |
| | | |
| | | /** |
| | | * Double类型取整 |
| | | * @param num |
| | | * @return |
| | | */ |
| | | public static String doubleTrans(double num) { |
| | | return String.valueOf((long) num); |
| | | } |
| | | |
| | | /** |
| | | * Double类型保留1位小数 |
| | | * |
| | | * @param num |
| | | * @return |
| | | */ |
| | | public static String doubleRetainOne(double num) { |
| | | DecimalFormat dfs = new DecimalFormat("0.0"); |
| | | return dfs.format(num); |
| | | } |
| | | |
| | | /** |
| | | * Double类型保留2位小数 |
| | | * |
| | | * @param num |
| | | * @return |
| | | */ |
| | | public static String doubleRetainTwo(double num) { |
| | | DecimalFormat dfs = new DecimalFormat("0.00"); |
| | | String.format("%.2f", num); |
| | | return dfs.format(num); |
| | | } |
| | | |
| | | /** |
| | | * Double类型保留1位小数(四舍五入) |
| | | * |
| | | * @param num |
| | | * @return |
| | | */ |
| | | public static String doubleForwardOne(double num) { |
| | | return String.format("%.1f", num); |
| | | } |
| | | |
| | | /** |
| | | * Double类型保留2位小数(四舍五入) |
| | | * |
| | | * @param num |
| | | * @return |
| | | */ |
| | | public static String doubleForwardTwo(double num) { |
| | | return String.format("%.2f", num); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转换成Ascii |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static String stringToAscii(String value) { |
| | | StringBuffer sbu = new StringBuffer(); |
| | | char[] chars = value.toCharArray(); |
| | | for (int i = 0; i < chars.length; i++) { |
| | | if (i != chars.length - 1) { |
| | | sbu.append((int) chars[i]); |
| | | } else { |
| | | sbu.append((int) chars[i]); |
| | | } |
| | | } |
| | | return sbu.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 小数转换为百分比 |
| | | * |
| | | * @param decimal |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String decTurnPercent(double decimal) { |
| | | NumberFormat num = NumberFormat.getPercentInstance(); |
| | | num.setMaximumIntegerDigits(3); |
| | | num.setMaximumFractionDigits(2); |
| | | return num.format(decimal); |
| | | } |
| | | |
| | | /** |
| | | * Ascii转换成字符串 |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static String asciiToString(String value) { |
| | | String[] chars = value.split(","); |
| | | StringBuffer sbu = new StringBuffer(); |
| | | for (int i = 0; i < chars.length; i++) { |
| | | sbu.append((char) Integer.parseInt(chars[i])); |
| | | } |
| | | return sbu.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转换unicode |
| | | * |
| | | * @param string |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String string2Unicode(String string) { |
| | | StringBuffer unicode = new StringBuffer(); |
| | | for (int i = 0; i < string.length(); i++) { |
| | | // 取出每一个字符 |
| | | char c = string.charAt(i); |
| | | // 转换为unicode |
| | | unicode.append("\\u" + Integer.toHexString(c)); |
| | | } |
| | | return unicode.toString(); |
| | | } |
| | | |
| | | /** |
| | | * unicode 转字符串 |
| | | * |
| | | * @param unicode |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String unicode2String(String unicode) { |
| | | StringBuffer string = new StringBuffer(); |
| | | String[] hex = unicode.split("\\\\u"); |
| | | for (int i = 1; i < hex.length; i++) { |
| | | // 转换出每一个代码点 |
| | | int data = Integer.parseInt(hex[i], 16); |
| | | // 追加成string |
| | | string.append((char) data); |
| | | } |
| | | return string.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 字符串编码转换的实现方法 |
| | | * |
| | | * @param str |
| | | * 待转换编码的字符串 |
| | | * @param newCharset |
| | | * 目标编码 |
| | | * @return |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | public static String changeCharset(String str, String newCharset) throws UnsupportedEncodingException { |
| | | if (str != null) { |
| | | // 用默认字符编码解码字符串。 |
| | | byte[] bs = str.getBytes(); |
| | | // 用新的字符编码生成字符串 |
| | | return new String(bs, newCharset); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 注: \n 回车( ) \t 水平制表符( ) \s 空格(\u0008) \r 换行( ) |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String replaceBlank(String str) { |
| | | String dest = ""; |
| | | if (str != null) { |
| | | Pattern p = Pattern.compile("\\s*|\t|\r|\n"); |
| | | Matcher m = p.matcher(str); |
| | | dest = m.replaceAll(""); |
| | | } |
| | | return dest; |
| | | } |
| | | |
| | | /** |
| | | * 判断该字符串不能为空 |
| | | * |
| | | * @param str |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static boolean isNotEmpty(Object str) { |
| | | return !isEmpty(str); |
| | | } |
| | | |
| | | |
| | | public static boolean isNotEmptyUndefined(Object str) { |
| | | return !isEmpty(str) && !str.toString().equals("undefined"); |
| | | } |
| | | |
| | | /** |
| | | * 字符串编码转换的实现方法 |
| | | * |
| | | * @param str |
| | | * 待转换编码的字符串 |
| | | * @param oldCharset |
| | | * 原编码 |
| | | * @param newCharset |
| | | * 目标编码 |
| | | * @return |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | public static String changeCharset(String str, String oldCharset, String newCharset) throws UnsupportedEncodingException { |
| | | if (str != null) { |
| | | // 用旧的字符编码解码字符串。解码可能会出现异常。 |
| | | byte[] bs = str.getBytes(oldCharset); |
| | | // 用新的字符编码生成字符串 |
| | | return new String(bs, newCharset); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 给手机号码加分割符 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String splitPhone(String phone) { |
| | | if (isNotEmpty(phone)) { |
| | | String strone = phone.substring(0, 3); |
| | | String strtwo = phone.substring(strone.length(), 7); |
| | | String strthree = phone.substring(strtwo.length() + strone.length(), phone.length()); |
| | | return strone + "-" + strtwo + "-" + strthree; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 非空判断 |
| | | * |
| | | * @param str |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static boolean isEmpty(Object str) { |
| | | return str == null || str.toString().length() == 0 || str.equals("") || str.toString().matches("\\s*"); |
| | | } |
| | | |
| | | /** |
| | | * 把米转换成公里 |
| | | * |
| | | * @param km |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static Double kmTransKilo(Integer m) { |
| | | return Math.round(m / 100d) / 10d; |
| | | } |
| | | |
| | | /** |
| | | * 将List<{@link Object}>转换成List<{@link T}> |
| | | * |
| | | * @param list |
| | | * 将要转换的对象 |
| | | * @param clazs |
| | | * 需要转换的泛型对象 |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> List<T> fromToObject(List<?> list, Class<T> clazs) { |
| | | List<T> t = new ArrayList<T>(); |
| | | for (Object object : list) { |
| | | t.add((T) object); |
| | | } |
| | | return t; |
| | | } |
| | | |
| | | /** |
| | | * 生成 uuid, 即用来标识一笔单,也用做 nonce_str |
| | | * @return |
| | | */ |
| | | public static String generateUUID() { |
| | | return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32); |
| | | } |
| | | |
| | | /** |
| | | * 将List<{@link Object}>转换成List<{@link Map<String, Object>}> |
| | | * |
| | | * @param list |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static List<Map<String, Object>> fromToObject_M(List<?> list) { |
| | | List<Map<String, Object>> t = new ArrayList<Map<String, Object>>(); |
| | | for (Object object : list) { |
| | | t.add((Map<String, Object>) object); |
| | | } |
| | | return t; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将对象中的null转换为空 |
| | | * @param obj |
| | | * @return |
| | | * @throws IllegalAccessException |
| | | */ |
| | | |
| | | public static Object checkObjFieldIsNull(Object obj) throws IllegalAccessException { |
| | | if(obj!=null){ |
| | | for(java.lang.reflect.Field f : obj.getClass().getDeclaredFields()){ |
| | | f.setAccessible(true); |
| | | if(f.get(obj) == null){ |
| | | if(f.getType()==String.class){ |
| | | f.set(obj, ""); |
| | | } |
| | | if(f.getType()==Double.class){ |
| | | f.set(obj, 0d); |
| | | } |
| | | if(f.getType()==Integer.class){ |
| | | f.set(obj, 0); |
| | | } |
| | | if(f.getType()==Date.class){ |
| | | f.set(obj, new Date()); |
| | | } |
| | | } |
| | | } |
| | | return obj; |
| | | } |
| | | return obj; |
| | | } |
| | | /** |
| | | * 获取六位标识码 |
| | | * @param length |
| | | * @return |
| | | */ |
| | | public static String createRandomCharData() |
| | | { |
| | | StringBuilder sb=new StringBuilder(); |
| | | Random rand=new Random();//随机用以下三个随机生成器 |
| | | Random randdata=new Random(); |
| | | int data=0; |
| | | for(int i=0;i<6;i++) |
| | | { |
| | | int index=rand.nextInt(3); |
| | | //目的是随机选择生成数字,大小写字母 |
| | | switch(index) |
| | | { |
| | | case 0: |
| | | data=randdata.nextInt(10);//仅仅会生成0~9 |
| | | sb.append(data); |
| | | break; |
| | | case 1: |
| | | data=randdata.nextInt(26)+65;//保证只会产生65~90之间的整数 |
| | | sb.append((char)data); |
| | | break; |
| | | case 2: |
| | | data=randdata.nextInt(26)+97;//保证只会产生97~122之间的整数 |
| | | sb.append((char)data); |
| | | break; |
| | | } |
| | | } |
| | | String result=sb.toString().toLowerCase(); |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class SpringUtil implements ApplicationContextAware { |
| | | @Autowired |
| | | private static ApplicationContext applicationContext; |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContextParam) throws BeansException { |
| | | applicationContext = applicationContextParam; |
| | | } |
| | | public static Object getObject(String id) { |
| | | Object object = null; |
| | | object = applicationContext.getBean(id); |
| | | return object; |
| | | } |
| | | public static <T> T getObject(Class<T> tClass) { |
| | | return applicationContext.getBean(tClass); |
| | | } |
| | | |
| | | public static Object getBean(String tClass) { |
| | | return applicationContext.getBean(tClass); |
| | | } |
| | | |
| | | public <T> T getBean(Class<T> tClass) { |
| | | return applicationContext.getBean(tClass); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util; |
| | | |
| | | import org.apache.commons.lang.StringUtils; |
| | | |
| | | public class StringUtil { |
| | | |
| | | /** |
| | | * 判断字符串中是否包含表情 |
| | | * @param source |
| | | * @return |
| | | */ |
| | | public static boolean containsEmoji(String source) { |
| | | int len = 0; |
| | | if(null != source){ |
| | | len = source.length(); |
| | | } |
| | | boolean isEmoji = false; |
| | | for (int i = 0; i < len; i++) { |
| | | char hs = source.charAt(i); |
| | | if (0xd800 <= hs && hs <= 0xdbff) { |
| | | if (source.length() > 1) { |
| | | char ls = source.charAt(i + 1); |
| | | int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000; |
| | | if (0x1d000 <= uc && uc <= 0x1f77f) { |
| | | return true; |
| | | } |
| | | } |
| | | } else { |
| | | // non surrogate |
| | | if (0x2100 <= hs && hs <= 0x27ff && hs != 0x263b) { |
| | | return true; |
| | | } else if (0x2B05 <= hs && hs <= 0x2b07) { |
| | | return true; |
| | | } else if (0x2934 <= hs && hs <= 0x2935) { |
| | | return true; |
| | | } else if (0x3297 <= hs && hs <= 0x3299) { |
| | | return true; |
| | | } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d |
| | | || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c |
| | | || hs == 0x2b1b || hs == 0x2b50 || hs == 0x231a) { |
| | | return true; |
| | | } |
| | | if (!isEmoji && source.length() > 1 && i < source.length() - 1) { |
| | | char ls = source.charAt(i + 1); |
| | | if (ls == 0x20e3) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return isEmoji; |
| | | } |
| | | |
| | | /** |
| | | * 判断某个字符是不是表情 |
| | | * @param codePoint |
| | | * @return |
| | | */ |
| | | private static boolean isEmojiCharacter(char codePoint) { |
| | | return (codePoint == 0x0) || (codePoint == 0x9) || (codePoint == 0xA) |
| | | || (codePoint == 0xD) |
| | | || ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) |
| | | || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) |
| | | || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 过滤掉字符串中的表情 |
| | | * @param source |
| | | * @return |
| | | */ |
| | | public static String filterEmoji(String source) { |
| | | if (StringUtils.isBlank(source)) { |
| | | return source; |
| | | } |
| | | StringBuilder buf = null; |
| | | int len = source.length(); |
| | | for (int i = 0; i < len; i++) { |
| | | char codePoint = source.charAt(i); |
| | | if (isEmojiCharacter(codePoint)) { |
| | | if (buf == null) { |
| | | buf = new StringBuilder(source.length()); |
| | | } |
| | | buf.append(codePoint); |
| | | } |
| | | } |
| | | if (buf == null) { |
| | | return source; |
| | | } else { |
| | | if (buf.length() == len) { |
| | | buf = null; |
| | | return source; |
| | | } else { |
| | | return buf.toString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断字符串为空 |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static boolean isEmpty(String value){ |
| | | if(null == value || value.trim().equals("")){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 判断字符串非空 |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static boolean isNotEmpty(String value){ |
| | | return !isEmpty(value); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | /** |
| | | * 缓存消息类型 |
| | | * |
| | | * @author TaoNingBo |
| | | * @data 2016年9月21日 |
| | | * @version 1.0 |
| | | */ |
| | | public class CacheType { |
| | | |
| | | /** |
| | | * 用户通讯通道标识 |
| | | */ |
| | | public static final String userCtx = "USER_CTX_"; |
| | | |
| | | /** |
| | | * 司机通讯通道标识 |
| | | */ |
| | | public static final String driverCtx = "DRIVER_CTX_"; |
| | | |
| | | /** |
| | | * 出行-快车/专车/代驾-订单消息队列-自营车辆 |
| | | */ |
| | | public static final String travelOrder1 = "TRAVEL_ORDER1_"; |
| | | |
| | | /** |
| | | * 出行-快车/专车/代驾-订单消息队列-外来车辆 |
| | | */ |
| | | public static final String travelOrder2 = "TRAVEL_ORDER2_"; |
| | | |
| | | /** |
| | | * 快车-司机位置-自营车辆 |
| | | */ |
| | | public static final String location1 = "_LOCATION1"; |
| | | |
| | | /** |
| | | * 快车-司机位置-外来车辆 |
| | | */ |
| | | public static final String location2 = "_LOCATION2"; |
| | | |
| | | /** |
| | | * 快车-司机抢单成功后的消息 |
| | | */ |
| | | public static final String travelOrder = "TRAVEL_ORDER_"; |
| | | |
| | | /** |
| | | * 开始服务时间 |
| | | */ |
| | | public static final String startServerT = "START_SERVER_TIME_"; |
| | | |
| | | /** |
| | | * 司机上一次的位置(经纬度) |
| | | */ |
| | | public static final String location = "LAST_DRIVER_LOCATION_"; |
| | | |
| | | /** |
| | | * 司机上一次总共行驶距离 |
| | | */ |
| | | public static final String triverd = "LAST_TRIVER_Distance_"; |
| | | |
| | | /** |
| | | * 记录订单数据 司机 异常处理 |
| | | */ |
| | | public static final String dreco = "DRIVER_DATA_RECO"; |
| | | |
| | | /** |
| | | * 记录订单数据 用户 异常处理 |
| | | */ |
| | | public static final String ureco = "USER_DATA_RECO"; |
| | | |
| | | /** |
| | | * 记录司机跟用户的关系ID |
| | | */ |
| | | public final static String udID = "USER_DRIVER_ID_"; |
| | | |
| | | /** |
| | | * 记录下单乘客的出发点位置坐标 |
| | | */ |
| | | public final static String userLoc = "USER_LOCATION_"; |
| | | |
| | | /** |
| | | * 记录计费规则【用订单号获取】 |
| | | */ |
| | | public final static String rules = "RULES_ORDER_"; |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import io.netty.channel.ChannelInitializer; |
| | | import io.netty.channel.socket.SocketChannel; |
| | | import io.netty.handler.codec.http.HttpObjectAggregator; |
| | | import io.netty.handler.codec.http.HttpServerCodec; |
| | | import io.netty.handler.ssl.SslHandler; |
| | | import io.netty.handler.stream.ChunkedWriteHandler; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.SSLEngine; |
| | | |
| | | public class ChildChannelHandler extends ChannelInitializer<SocketChannel> { |
| | | @Override |
| | | protected void initChannel(SocketChannel socketChannel) throws Exception { |
| | | // String path = "C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\cert\\SHA256withRSA_lzhyc.cn.pfx"; |
| | | // String path = "/usr/local/server/apache-tomcat-80/conf/cert/6064978_okyueche.com.pfx"; |
| | | // SSLContext sslContext = createSSLContext.createSSLContext("PKCS12" |
| | | // , path, "lio03Bb9"); |
| | | // //SSLEngine 此类允许使用ssl安全套接层协议进行安全通信 |
| | | // SSLEngine engine = sslContext.createSSLEngine(); |
| | | // engine.setUseClientMode(false); |
| | | // socketChannel.pipeline().addLast("ssl", new SslHandler(engine)); |
| | | |
| | | // 设置30秒没有读到数据,则触发一个READER_IDLE事件。 |
| | | // pipeline.addLast(new IdleStateHandler(30, 0, 0)); |
| | | // HttpServerCodec:将请求和应答消息解码为HTTP消息 |
| | | socketChannel.pipeline().addLast("http-codec", new HttpServerCodec()); |
| | | // HttpObjectAggregator:将HTTP消息的多个部分合成一条完整的HTTP消息 |
| | | socketChannel.pipeline().addLast("aggregator", new HttpObjectAggregator(65536)); |
| | | // ChunkedWriteHandler:向客户端发送HTML5文件 |
| | | socketChannel.pipeline().addLast("http-chunked", new ChunkedWriteHandler()); |
| | | // 在管道中添加我们自己的接收数据实现方法 |
| | | socketChannel.pipeline().addLast("handler", new WebSocketHandler()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 客户端心跳消息处理 |
| | | * |
| | | * @author TaoNingBo |
| | | * @data 2016年7月26日 |
| | | * @version 1.0 |
| | | */ |
| | | public class ClientPingMessage implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -4953410803742767757L; |
| | | |
| | | /** |
| | | * 客户端标识ID |
| | | */ |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 角色【0:用户,1:司机】 |
| | | */ |
| | | private Integer role; |
| | | |
| | | /** |
| | | * 客户端单点登录标识TOKEN |
| | | */ |
| | | private String token; |
| | | |
| | | public ClientPingMessage() { |
| | | |
| | | } |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getRole() { |
| | | return role; |
| | | } |
| | | |
| | | public void setRole(Integer role) { |
| | | this.role = role != null ? role : 0; |
| | | } |
| | | |
| | | public String getToken() { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) { |
| | | this.token = token; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import io.netty.channel.group.ChannelGroup; |
| | | import io.netty.channel.group.DefaultChannelGroup; |
| | | import io.netty.util.concurrent.GlobalEventExecutor; |
| | | |
| | | public class Global { |
| | | public static ChannelGroup group = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import io.netty.bootstrap.ServerBootstrap; |
| | | import io.netty.channel.Channel; |
| | | import io.netty.channel.EventLoopGroup; |
| | | import io.netty.channel.nio.NioEventLoopGroup; |
| | | import io.netty.channel.socket.nio.NioServerSocketChannel; |
| | | |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | |
| | | /** |
| | | * 即时通讯服务启动类 |
| | | * |
| | | * @date 2016年6月25日 |
| | | * @version 1.0 |
| | | */ |
| | | public class NettyServer0 { |
| | | |
| | | /** |
| | | * 延迟启动设置 |
| | | * |
| | | * NettyServer启动方法. |
| | | */ |
| | | public void bind() { |
| | | final Thread thread = new Thread(new NettyRunnable()); |
| | | Timer timer = new Timer(); |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | thread.start(); |
| | | } |
| | | }, 1000 * 2); |
| | | } |
| | | |
| | | /** |
| | | * 即时通讯服务启动 |
| | | * |
| | | * @date 2016年6月24日 |
| | | * @version 1.0 |
| | | */ |
| | | public class NettyRunnable implements Runnable { |
| | | |
| | | /** |
| | | * 获取即时通讯启动端口 |
| | | */ |
| | | @Override |
| | | public void run() { |
| | | System.out.println("===========================Netty端口启动========"); |
| | | // Boss线程:由这个线程池提供的线程是boss种类的,用于创建、连接、绑定socket, |
| | | // (有点像门卫)然后把这些socket传给worker线程池。 |
| | | // 在服务器端每个监听的socket都有一个boss线程来处理。在客户端,只有一个boss线程来处理所有的socket。 |
| | | EventLoopGroup bossGroup = new NioEventLoopGroup(); |
| | | // Worker线程:Worker线程执行所有的异步I/O,即处理操作 |
| | | EventLoopGroup workrGroup = new NioEventLoopGroup(); |
| | | try { |
| | | |
| | | // ServerBootstrap 启动NIO服务的辅助启动类,负责初始话netty服务器,并且开始监听端口的socket请求 |
| | | ServerBootstrap b = new ServerBootstrap(); |
| | | b.group(bossGroup, workrGroup); |
| | | // 设置非阻塞,用它来建立新accept的连接,用于构造serversocketchannel的工厂类 |
| | | b.channel(NioServerSocketChannel.class); |
| | | // ChildChannelHandler 对出入的数据进行的业务操作,其继承ChannelInitializer |
| | | b.childHandler(new ChildChannelHandler()); |
| | | System.out.println("服务端开启等待客户端连接 ... ..."); |
| | | Channel ch = b.bind(9090).sync().channel(); |
| | | ch.closeFuture().sync(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | bossGroup.shutdownGracefully(); |
| | | workrGroup.shutdownGracefully(); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.sinata.zuul.util.RedisUtil; |
| | | import com.sinata.zuul.util.SinataUtil; |
| | | import com.sinata.zuul.util.SpringUtil; |
| | | import com.sinata.zuul.util.StringUtil; |
| | | import com.sinata.zuul.util.echo.Method; |
| | | import com.sinata.zuul.util.echo.NettyChannelMap; |
| | | import com.sinata.zuul.util.echo.NettyMsg; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.Unpooled; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Hashtable; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | public class NettyWebSocketController { |
| | | |
| | | public static Hashtable<String, Hashtable<ChannelHandlerContext, String>> map = new Hashtable<String, Hashtable<ChannelHandlerContext, String>>(); |
| | | |
| | | private RedisUtil redisUtil = SpringUtil.getObject(RedisUtil.class); |
| | | |
| | | public static Hashtable<String, String> table; |
| | | |
| | | static { |
| | | if (table == null) { |
| | | table = new Hashtable<>(); |
| | | } |
| | | } |
| | | |
| | | public static boolean isdebug = false; |
| | | public static int i = 0; |
| | | |
| | | |
| | | /** |
| | | * 判断客户端要执行什么操作 |
| | | * |
| | | * @param ctx |
| | | * @param msg |
| | | * @author TaoNingBo |
| | | */ |
| | | public void JudgeOperation(ChannelHandlerContext ctx, String msg) { |
| | | try { |
| | | // 验证即时通讯命令是否正确有效 |
| | | if (SinataUtil.isEmpty(msg)) { |
| | | return; |
| | | } |
| | | String msgStr = msg.toString(); |
| | | if (msgStr.indexOf("{") == -1 || msgStr.indexOf("}") == -1 || msgStr.indexOf("code") == -1 || msgStr.indexOf("msg") == -1 || msgStr.indexOf("data") == -1 || msgStr.indexOf("method") == -1) { |
| | | return; |
| | | } |
| | | if (isdebug) { |
| | | // System.out.println("<<<--receive-->>>111" + msg); |
| | | } |
| | | |
| | | // 获取socket信息,保存相应的socket |
| | | JSONObject jsonMsg = JSONObject.parseObject(msg.toString()); |
| | | int code = jsonMsg.getIntValue("code"); |
| | | String message = jsonMsg.getString("msg"); |
| | | String method = jsonMsg.getString("method"); |
| | | if (code != 200 || !message.equals("SUCCESS")) { |
| | | return; |
| | | } |
| | | JSONObject jsonCon = JSONObject.parseObject(jsonMsg.get("data").toString()); |
| | | |
| | | if (null != ctx && ctx.channel().isActive()) { |
| | | jsonMsg.put("method", Method.pong); |
| | | sendMsgToClient(ctx, jsonMsg.toJSONString()); |
| | | } |
| | | |
| | | |
| | | // ############################### 心跳 ############################ |
| | | // 心跳 |
| | | if (method.equals(Method.ping)) { |
| | | String token = jsonCon.getString("token"); |
| | | String userId1 = jsonCon.getString("userId"); |
| | | if (StringUtil.isNotEmpty(userId1)) { |
| | | //确保账号在单个设备上登录 |
| | | if (StringUtil.isNotEmpty(token)) { |
| | | NettyChannelMap.update_(token.substring(0, 23), ctx);//存储单点登录的通道 |
| | | String token_ = redisUtil.getValue("USER_Applets_" + userId1);//获取缓存中最新的数据 |
| | | if (StringUtil.isNotEmpty(token_) && !token.equals(token_)) {//不在同一设备上登录,向其他设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString()); |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | } |
| | | if (StringUtil.isEmpty(token_)) {//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("USER_Applets_" + userId1, token); |
| | | } |
| | | } |
| | | |
| | | //存储业务使用的通道 |
| | | if (null != ctx && ctx.channel().isActive()) { |
| | | NettyChannelMap.update("Applets" + userId1, ctx); |
| | | // String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | // ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes())); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | if (isdebug) { |
| | | NettyWebSocketController.sendMsgToClient(ctx, "__error__" + msg.toString()); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 向客户端发送消息 |
| | | * |
| | | * @param ctx |
| | | * @param msg |
| | | * @author TaoNingBo |
| | | */ |
| | | public static void sendMsgToClient(ChannelHandlerContext ctx, String msg) { |
| | | // System.out.println(ctx.channel().isActive()); |
| | | if (ctx != null && ctx.channel().isActive()) { |
| | | ByteBuf buffer = Unpooled.copiedBuffer((msg).getBytes()); |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.channel().writeAndFlush(new TextWebSocketFrame(msg)).sync(); |
| | | if (!sync.isSuccess()) { |
| | | boolean b = true; |
| | | for (int i = 0; i < 10; i++) { |
| | | ctx.wait(3000); |
| | | sync = ctx.channel().write(new TextWebSocketFrame(msg)).sync(); |
| | | if (sync.isSuccess()) { |
| | | b = false; |
| | | break; |
| | | } |
| | | System.err.println("小程序-》推送不成功,将继续推送" + msg); |
| | | } |
| | | if (b) { |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | System.err.println("小程序-》推送发生异常,记录:" + msg); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | if (isdebug) { |
| | | System.err.println("小程序-》 <<<--send-->>>" + msg); |
| | | } |
| | | } else { |
| | | System.err.println("小程序-》推送失败,长连接不存在"); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | } |
| | | |
| | | // **链接断开 将推送消息记录 |
| | | public static void sendMsgToClient(String cacheType, Integer id, String msg) { |
| | | ChannelHandlerContext ctx = NettyChannelMap.getData(cacheType + id); |
| | | if (ctx != null) { |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.channel().write(new TextWebSocketFrame(msg)).sync(); |
| | | if (!sync.isSuccess()) { |
| | | for (int i = 0; i < 10; i++) { |
| | | sync = ctx.channel().write(new TextWebSocketFrame(msg)).sync(); |
| | | ; |
| | | if (!sync.isSuccess()) { |
| | | sync = ctx.channel().write(new TextWebSocketFrame(msg)).sync(); |
| | | ; |
| | | System.err.println("推送不成功,将继续推送" + msg); |
| | | if (i == 9) { |
| | | table.put(cacheType + id, msg); |
| | | ctx.close(); |
| | | System.err.println("推送发生异常,记录:" + msg); |
| | | } |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | table.put(cacheType + id, msg); |
| | | System.err.println("推送发生异常,记录:" + msg); |
| | | } |
| | | if (isdebug) { |
| | | System.err.println("<<<--send-->>>" + msg); |
| | | } |
| | | } else { |
| | | table.put(cacheType + id, msg); |
| | | System.err.println("链接断开,记录:id=" + cacheType + id + ",消息:" + msg); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.sinata.zuul.util.echo.Method; |
| | | import com.sinata.zuul.util.echo.NettyChannelMap; |
| | | import com.sinata.zuul.util.echo.NettyMsg; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.Unpooled; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelFutureListener; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.netty.channel.SimpleChannelInboundHandler; |
| | | import io.netty.handler.codec.http.*; |
| | | import io.netty.handler.codec.http.websocketx.*; |
| | | import io.netty.handler.timeout.IdleState; |
| | | import io.netty.handler.timeout.IdleStateEvent; |
| | | import io.netty.util.CharsetUtil; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | |
| | | public class WebSocketHandler extends SimpleChannelInboundHandler<Object> { |
| | | //用于websocket握手的处理类 |
| | | private WebSocketServerHandshaker handshaker; |
| | | |
| | | private static final String WEB_SOCKET_URL = "wss://localhost:9090/websocket"; |
| | | |
| | | |
| | | |
| | | // @Override |
| | | // protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception { |
| | | // if (msg instanceof FullHttpRequest) { |
| | | // // websocket连接请求 |
| | | // handleHttpRequest(ctx, (FullHttpRequest)msg); |
| | | // } else if (msg instanceof WebSocketFrame) { |
| | | // // websocket业务处理 |
| | | // handleWebSocketRequest(ctx, (WebSocketFrame)msg); |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |
| | | ctx.flush(); |
| | | } |
| | | |
| | | /** 心跳 */ |
| | | @Override |
| | | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { |
| | | if (evt instanceof IdleStateEvent) { |
| | | IdleStateEvent event = (IdleStateEvent) evt; |
| | | if (event.state().equals(IdleState.READER_IDLE)) |
| | | { |
| | | // |
| | | } |
| | | else if (event.state().equals(IdleState.WRITER_IDLE)) |
| | | { |
| | | // |
| | | } |
| | | else if (event.state().equals(IdleState.ALL_IDLE)) |
| | | { |
| | | String msg = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | if(ctx != null && ctx.channel().isActive()) { |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((msg).getBytes())); |
| | | } |
| | | } |
| | | } |
| | | // super.userEventTriggered(ctx, evt); |
| | | } |
| | | |
| | | @Override |
| | | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { |
| | | ctx.close(); |
| | | } |
| | | |
| | | private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) { |
| | | // Http解码失败,向服务器指定传输的协议为Upgrade:websocket |
| | | if(!req.getDecoderResult().isSuccess() || !("websocket").equals(req.headers().get("Upgrade"))){ |
| | | sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)); |
| | | return; |
| | | } |
| | | // 握手相应处理,创建websocket握手的工厂类, |
| | | WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(WEB_SOCKET_URL, null, false); |
| | | // 根据工厂类和HTTP请求创建握手类 |
| | | handshaker = wsFactory.newHandshaker(req); |
| | | if (handshaker == null) { |
| | | // 不支持websocket |
| | | WebSocketServerHandshakerFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel()); |
| | | } else { |
| | | // 通过它构造握手响应消息返回给客户端 |
| | | handshaker.handshake(ctx.channel(), req); |
| | | } |
| | | } |
| | | |
| | | private void handleWebSocketRequest(ChannelHandlerContext ctx, WebSocketFrame req) throws Exception { |
| | | if (req instanceof CloseWebSocketFrame) { |
| | | // 关闭websocket连接 |
| | | handshaker.close(ctx.channel(), (CloseWebSocketFrame)req.retain()); |
| | | return; |
| | | } |
| | | if (req instanceof PingWebSocketFrame) { |
| | | ctx.channel().write(new PongWebSocketFrame(req.content().retain())); |
| | | return; |
| | | } |
| | | if (!(req instanceof TextWebSocketFrame)) { |
| | | throw new UnsupportedOperationException("当前只支持文本消息,不支持二进制消息"); |
| | | } |
| | | if (ctx == null || this.handshaker == null || ctx.isRemoved()) { |
| | | throw new Exception("尚未握手成功,无法向客户端发送WebSocket消息"); |
| | | } |
| | | String requestmsg = ((TextWebSocketFrame) req).text(); |
| | | |
| | | |
| | | //给连接的客户端返回数据 |
| | | //返回心跳 |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("code", 200); |
| | | jsonObject.put("method", Method.ok); |
| | | jsonObject.put("msg", "SUCCESS"); |
| | | jsonObject.put("data", new JSONObject()); |
| | | TextWebSocketFrame tws = new TextWebSocketFrame(jsonObject.toJSONString()); |
| | | // ctx.channel().writeAndFlush(tws); |
| | | |
| | | new NettyWebSocketController().JudgeOperation(ctx,requestmsg);//小程序心跳处理 |
| | | |
| | | // 群发服务端心跳响应 |
| | | Global.group.writeAndFlush(new TextWebSocketFrame((tws).text())); |
| | | } |
| | | |
| | | private void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) { |
| | | // BAD_REQUEST(400) 客户端请求错误返回的应答消息 |
| | | if(res.getStatus().code() != 200){ |
| | | ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8); |
| | | res.content().writeBytes(buf); |
| | | buf.release(); |
| | | } |
| | | //服务端向客户端发送数据 |
| | | ChannelFuture f = ctx.channel().writeAndFlush(res); |
| | | // 非法连接直接关闭连接 |
| | | if(res.getStatus().code() != 200){ |
| | | f.addListener(ChannelFutureListener.CLOSE); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void channelActive(ChannelHandlerContext ctx) throws Exception { |
| | | Global.group.add(ctx.channel()); |
| | | System.err.println("客户端与服务器端开启"); |
| | | } |
| | | |
| | | @Override |
| | | public void channelInactive(ChannelHandlerContext ctx) throws Exception { |
| | | Global.group.remove(ctx.channel()); |
| | | NettyChannelMap.remove(ctx); |
| | | System.err.println("客户端与服务器链接关闭"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { |
| | | if (msg instanceof FullHttpRequest) { |
| | | // websocket连接请求 |
| | | handleHttpRequest(ctx, (FullHttpRequest)msg); |
| | | } else if (msg instanceof WebSocketFrame) { |
| | | // websocket业务处理 |
| | | handleWebSocketRequest(ctx, (WebSocketFrame)msg); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { |
| | | if (msg instanceof FullHttpRequest) { |
| | | // websocket连接请求 |
| | | handleHttpRequest(ctx, (FullHttpRequest)msg); |
| | | } else if (msg instanceof WebSocketFrame) { |
| | | // websocket业务处理 |
| | | handleWebSocketRequest(ctx, (WebSocketFrame)msg); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.applets; |
| | | |
| | | import javax.net.ssl.KeyManagerFactory; |
| | | import javax.net.ssl.SSLContext; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.security.KeyStore; |
| | | |
| | | public class createSSLContext { |
| | | |
| | | /** |
| | | * 获取SSLContext |
| | | * @param type |
| | | * @param path |
| | | * @param password |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static SSLContext createSSLContext(String type , String path , String password) throws Exception { |
| | | KeyStore ks = KeyStore.getInstance(type); /// "JKS" |
| | | InputStream ksInputStream = new FileInputStream(path); /// 证书存放地址 |
| | | ks.load(ksInputStream, password.toCharArray()); |
| | | //KeyManagerFactory充当基于密钥内容源的密钥管理器的工厂。 |
| | | KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());//getDefaultAlgorithm:获取默认的 KeyManagerFactory 算法名称。 |
| | | kmf.init(ks, password.toCharArray()); |
| | | //SSLContext的实例表示安全套接字协议的实现,它充当用于安全套接字工厂或 SSLEngine 的工厂。 |
| | | SSLContext sslContext = SSLContext.getInstance("TLS"); |
| | | sslContext.init(kmf.getKeyManagers(), null, null); |
| | | return sslContext; |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import io.netty.buffer.Unpooled; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.netty.channel.ChannelPromise; |
| | | import io.netty.channel.SimpleChannelInboundHandler; |
| | | import io.netty.handler.timeout.IdleState; |
| | | import io.netty.handler.timeout.IdleStateEvent; |
| | | import io.netty.util.ReferenceCountUtil; |
| | | |
| | | import java.net.InetSocketAddress; |
| | | import java.util.HashMap; |
| | | |
| | | public class DiscardServerHandler extends SimpleChannelInboundHandler<String> { |
| | | |
| | | private NettyServerController nettyServerController = new NettyServerController(); |
| | | |
| | | public static boolean isdebug = true; |
| | | |
| | | @Override |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg) { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | } |
| | | try { |
| | | // 调用service |
| | | nettyServerController.JudgeOperation(ctx, msg); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | ReferenceCountUtil.release(msg); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | } |
| | | try { |
| | | // 调用service |
| | | nettyServerController.JudgeOperation(ctx, msg); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | ReferenceCountUtil.release(msg); |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // protected void messageReceived(ChannelHandlerContext channelHandlerContext, String s) throws Exception { |
| | | // |
| | | // } |
| | | |
| | | // @Override |
| | | // protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception { |
| | | // |
| | | // } |
| | | |
| | | // @Override |
| | | // protected void messageReceived(ChannelHandlerContext channelHandlerContext, String s) throws Exception { |
| | | // |
| | | // } |
| | | |
| | | /** 在连接被建立并且准备进行通信时被调用 */ |
| | | public void channelActive(final ChannelHandlerContext ctx) throws Exception { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": Connect successful......"); |
| | | } |
| | | } |
| | | |
| | | /** 心跳 */ |
| | | @Override |
| | | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { |
| | | if (evt instanceof IdleStateEvent) { |
| | | IdleStateEvent event = (IdleStateEvent) evt; |
| | | if (event.state().equals(IdleState.READER_IDLE)) |
| | | { |
| | | // |
| | | } |
| | | else if (event.state().equals(IdleState.WRITER_IDLE)) |
| | | { |
| | | // |
| | | } |
| | | else if (event.state().equals(IdleState.ALL_IDLE)) |
| | | { |
| | | String msg = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | if(ctx != null && ctx.channel().isActive()) { |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((msg).getBytes())); |
| | | // System.err.println(msg); |
| | | } |
| | | } |
| | | } |
| | | //super.userEventTriggered(ctx, evt); |
| | | } |
| | | |
| | | /** 连接处于不活跃时调用(连接关闭) **/ |
| | | public void channelInactive(ChannelHandlerContext ctx) throws Exception { |
| | | if(isdebug) { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | // System.err.println(insocket.getAddress() + ": Disconnect connection......"); |
| | | } |
| | | NettyChannelMap.remove(ctx); |
| | | // System.err.println("清除通道" + ctx); |
| | | // super.channelInactive(ctx); |
| | | } |
| | | |
| | | public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |
| | | ctx.flush(); |
| | | } |
| | | |
| | | /** 处理方法是当出现Throwable对象才会被调用 **/ |
| | | public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception { |
| | | ctx.close(); |
| | | } |
| | | |
| | | public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { |
| | | if(isdebug) { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | // System.err.println("close......." + insocket.getAddress()); |
| | | } |
| | | ctx.close(promise); |
| | | } |
| | | |
| | | public void read(ChannelHandlerContext ctx) throws Exception { |
| | | ctx.read(); |
| | | } |
| | | |
| | | public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { |
| | | ctx.write(msg, promise); |
| | | } |
| | | |
| | | // @Override |
| | | // protected void channelRead(ChannelHandlerContext ctx, String msg) throws Exception { |
| | | // // TODO Auto-generated method stub |
| | | // InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | // if(isdebug) { |
| | | // System.out.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | // } |
| | | // try { |
| | | // // 调用service |
| | | // nettyServerController.JudgeOperation(ctx, msg); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } finally { |
| | | // ReferenceCountUtil.release(msg); |
| | | // } |
| | | // } |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | /** |
| | | * 即时通讯【通讯类型类】 |
| | | * |
| | | * @author TaoNingBo |
| | | * @createDate 2016年6月14日 |
| | | * @version 1.0 |
| | | */ |
| | | public class Method { |
| | | |
| | | /** 心跳【推送】 */ |
| | | public static final String ok = "OK"; |
| | | |
| | | /** 心跳【接收】 */ |
| | | public final static String ping = "PING"; |
| | | |
| | | /** 心跳【响应】 */ |
| | | public final static String pong = "PONG"; |
| | | |
| | | /** 司机上传位置 */ |
| | | public static final String location = "LOCATION"; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | public class NettyChannelMap { |
| | | |
| | | protected static Map<String, ChannelHandlerContext> map = new ConcurrentHashMap<>(); |
| | | |
| | | public static Map<String, ChannelHandlerContext> ctxMap = new HashMap<>();//单点登录存储的通道 |
| | | |
| | | |
| | | private NettyChannelMap() { |
| | | // 放置外部实例化 |
| | | } |
| | | |
| | | /** |
| | | * Get data from source. |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static ChannelHandlerContext getData(String key) { |
| | | if(map==null){ |
| | | map = new HashMap<String, ChannelHandlerContext>(); |
| | | } |
| | | return map.get(key); |
| | | } |
| | | |
| | | |
| | | public static ChannelHandlerContext getData_(String key) { |
| | | if(ctxMap==null){ |
| | | ctxMap = new HashMap<String, ChannelHandlerContext>(); |
| | | } |
| | | return ctxMap.get(key); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Save data from source. |
| | | * |
| | | * @param key |
| | | * @param val |
| | | */ |
| | | public static synchronized void saveData(String key, ChannelHandlerContext val) { |
| | | map.put(key, val); |
| | | } |
| | | |
| | | /** |
| | | * Determine whether the cache key contains the key. |
| | | * |
| | | * @param key |
| | | * @return true|false |
| | | * @author TaoNingBo |
| | | */ |
| | | public static synchronized boolean containsKey(String key) { |
| | | return map.containsKey(key); |
| | | } |
| | | |
| | | /** |
| | | * Determine whether the cache value contains the value. |
| | | * |
| | | * @param val |
| | | * @return |
| | | */ |
| | | public static synchronized boolean containsVal(ChannelHandlerContext val) { |
| | | return map.containsValue(val); |
| | | } |
| | | |
| | | /** |
| | | * Remove the data resources. |
| | | * |
| | | * @param value |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public static synchronized void remove(ChannelHandlerContext value) { |
| | | Set<String> strings = map.keySet(); |
| | | for(String key : strings){ |
| | | ChannelHandlerContext channelHandlerContext = map.get(key); |
| | | String s = channelHandlerContext.channel().remoteAddress().toString(); |
| | | String s1 = value.channel().remoteAddress().toString(); |
| | | if(s.equals(s1)){ |
| | | channelHandlerContext.close();//关闭通道 |
| | | map.remove(key); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public static synchronized void remove_(ChannelHandlerContext value) { |
| | | Set<String> strings = ctxMap.keySet(); |
| | | for(String key : strings){ |
| | | ChannelHandlerContext channelHandlerContext = ctxMap.get(key); |
| | | String s = channelHandlerContext.channel().remoteAddress().toString(); |
| | | String s1 = value.channel().remoteAddress().toString(); |
| | | if(s.equals(s1)){ |
| | | channelHandlerContext.close();//关闭通道 |
| | | ctxMap.remove(key); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Remove the data resources. |
| | | * |
| | | * @param key |
| | | * @author TaoNingBo |
| | | */ |
| | | public static synchronized void remove(String key) { |
| | | map.remove(key); |
| | | } |
| | | |
| | | /** |
| | | * Update the data resources. |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | public static synchronized void update(String key, ChannelHandlerContext value) { |
| | | map.put(key, value); |
| | | } |
| | | |
| | | |
| | | |
| | | public static synchronized void update_(String key, ChannelHandlerContext value) { |
| | | ctxMap.put(key, value); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.Unpooled; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | public class NettyMsg { |
| | | public static void main(String[] args) { |
| | | Map<String,Object> map = new HashMap<String, Object>(); |
| | | //用户信息 |
| | | map.put("imgUrl","1"); |
| | | map.put("nickName","1"); |
| | | map.put("licensePlate","1"); |
| | | map.put("phone",1); |
| | | map.put("driverId",1); |
| | | map.put("carColor","1"); |
| | | map.put("modelName","1"); |
| | | map.put("brandName","1"); |
| | | map.put("driverOrderNums",1); |
| | | map.put("score",1); |
| | | |
| | | |
| | | map.put("id",1); |
| | | map.put("orderNum", "123456"); |
| | | map.put("startAddress", "测试"); |
| | | map.put("endAddress", "测试1"); |
| | | map.put("departureTime", 1533608196000L); |
| | | map.put("type",1); |
| | | map.put("mileage",1); |
| | | map.put("mileageMoney",10); |
| | | map.put("duration",10); |
| | | map.put("durationMoney",10); |
| | | map.put("nightMoney",1); |
| | | map.put("serverMoney",1); |
| | | map.put("nightMileage",10); |
| | | map.put("longMileage",10); |
| | | map.put("longDurationMoney",10); |
| | | map.put("orderMoney",10); |
| | | map.put("payMoney",10); |
| | | map.put("couponsMoney",10); |
| | | System.out.println(setMsg(Method.ping, new HashMap<String, Object>())); |
| | | } |
| | | |
| | | /** |
| | | * 返回一个正确数据 |
| | | * |
| | | * @param method |
| | | * @param data |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String setMsg(String method, Map<String, Object> data) { |
| | | StringBuffer json = new StringBuffer(); |
| | | json.append(getHeader(200, "SUCCESS", method)); |
| | | json.append(JSON.toJSONString(data)); |
| | | json.append("}"); |
| | | //return JSON.toJSONString(json); |
| | | return json.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 返回一个正确数据 |
| | | * |
| | | * @param method |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public static String setMsg(String method, List<Map<String, Object>> data) { |
| | | StringBuffer json = new StringBuffer(); |
| | | json.append(getHeader(200, "SUCCESS", method)); |
| | | List<JSONObject> jsonList = new ArrayList<JSONObject>(); |
| | | for(Map<String, Object> map : data) { |
| | | JSONObject dataJson = new JSONObject(map); |
| | | jsonList.add(dataJson); |
| | | } |
| | | json.append(jsonList); |
| | | json.append("}"); |
| | | |
| | | // return JSON.toJSONString(json); |
| | | return json.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 返回一个错误数据 |
| | | * |
| | | * @param method |
| | | * @param data |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | public static String setErrMsg(String method, String data) { |
| | | StringBuffer json = new StringBuffer(); |
| | | json.append(getHeader(-1, "FAILURE", method)); |
| | | json.append("\"" + data + "\""); |
| | | json.append("}"); |
| | | // return JSON.toJSONString(json); |
| | | return json.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 生成一个返回JSON的头 |
| | | * |
| | | * @param code |
| | | * @param msg |
| | | * @param method |
| | | * @return |
| | | * @author TaoNingBo |
| | | */ |
| | | private static String getHeader(int code, String msg, String method) { |
| | | StringBuffer header = new StringBuffer(); |
| | | header.append("{"); |
| | | header.append("\"code\":\"" + code); |
| | | header.append("\",\"msg\":\"" + msg); |
| | | header.append("\",\"method\":\"" + method); |
| | | header.append("\",\"data\":"); |
| | | return header.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 发送消息给客户端 |
| | | * |
| | | * @param cacheType |
| | | * @param id |
| | | * @param method |
| | | * @param data |
| | | * @author TaoNingBo |
| | | */ |
| | | public static void sendMsg(String cacheType, Integer id, String method, Map<String, Object> data) { |
| | | //NettyServerController.sendMsgToClient(NettyChannelMap.getData(cacheType + id), setMsg(method, data)); |
| | | NettyServerController.sendMsgToClient(cacheType,id, setMsg(method, data)); |
| | | } |
| | | |
| | | |
| | | public static void resendMsg(String token){ |
| | | String msg = NettyServerController.table.get(token); |
| | | ChannelHandlerContext ctx = NettyChannelMap.getData(token); |
| | | if(null != msg && !"".equals(msg) && ctx != null && ctx.channel().isActive()){ |
| | | ByteBuf buffer = Unpooled.copiedBuffer((msg).getBytes()); |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | System.err.println("重发异常推送状态"+sync.isSuccess()+",位置:"+token+",消息内容:"+msg); |
| | | if(!sync.isSuccess()){ |
| | | resendMsg(token); |
| | | System.err.println("重发异常推送不成功,将继续推送"+msg); |
| | | } |
| | | NettyServerController.table.remove(token); |
| | | } catch (Exception e) { |
| | | resendMsg(token); |
| | | System.err.println("重发推送发生异常,记录:"+msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import io.netty.bootstrap.ServerBootstrap; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelOption; |
| | | import io.netty.channel.ChannelPipeline; |
| | | import io.netty.channel.EventLoopGroup; |
| | | import io.netty.channel.nio.NioEventLoopGroup; |
| | | import io.netty.channel.socket.SocketChannel; |
| | | import io.netty.channel.socket.nio.NioServerSocketChannel; |
| | | import io.netty.handler.codec.LengthFieldBasedFrameDecoder; |
| | | import io.netty.handler.codec.LengthFieldPrepender; |
| | | import io.netty.handler.timeout.IdleStateHandler; |
| | | |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 即时通讯服务启动类 |
| | | * |
| | | * @date 2016年6月25日 |
| | | * @version 1.0 |
| | | */ |
| | | public class NettyServer { |
| | | |
| | | |
| | | /** |
| | | * NettyServer启动方法. |
| | | */ |
| | | public void bind() { |
| | | final Thread thread = new Thread(new NettyRunnable()); |
| | | Timer timer = new Timer(); |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | thread.start(); |
| | | } |
| | | }, 10000); |
| | | } |
| | | |
| | | /** |
| | | * 即时通讯服务启动 |
| | | * |
| | | * @date 2016年6月24日 |
| | | * @version 1.0 |
| | | */ |
| | | public class NettyRunnable implements Runnable { |
| | | |
| | | /** |
| | | * 获取即时通讯启动端口 |
| | | */ |
| | | private Integer nettyPort = 8888; |
| | | @Override |
| | | public void run() { |
| | | EventLoopGroup bossGroup = new NioEventLoopGroup(); |
| | | EventLoopGroup workerGroup = new NioEventLoopGroup(); |
| | | try { |
| | | ServerBootstrap bootstrap = new ServerBootstrap(); |
| | | bootstrap.group(bossGroup, workerGroup); |
| | | bootstrap.channel(NioServerSocketChannel.class); |
| | | bootstrap.option(ChannelOption.SO_BACKLOG, 1024); |
| | | // 通过TCP_NODELAY禁用NAGLE,使消息立即发出去,不用等待到一定的数据量才发出去 |
| | | bootstrap.option(ChannelOption.TCP_NODELAY, true); |
| | | // 保持长连接状态 |
| | | bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true); |
| | | bootstrap.childHandler(new ServerInit() { |
| | | @Override |
| | | protected void initChannel(SocketChannel socketChannel) throws Exception { |
| | | ChannelPipeline pipeline = socketChannel.pipeline(); |
| | | pipeline.addLast("ping", new IdleStateHandler(120, 60, 5, TimeUnit.SECONDS)); |
| | | pipeline.addLast("decoder", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)); |
| | | pipeline.addLast("encoder", new LengthFieldPrepender(4)); |
| | | //pipeline.addLast(new LineBasedFrameDecoder(1048576 * 10)); |
| | | //pipeline.addLast(new StringDecoder(Charset.forName("UTF-8"))); |
| | | //pipeline.addLast(new StringEncoder(Charset.forName("UTF-8"))); |
| | | pipeline.addLast(new DiscardServerHandler()); |
| | | } |
| | | }); |
| | | // 服务器绑定端口监听 |
| | | ChannelFuture f = bootstrap.bind(nettyPort).sync(); |
| | | if(f.isSuccess()) { |
| | | System.out.println("******************************Netty启动成功******************************"); |
| | | } |
| | | // 监听服务器关闭监听 |
| | | f.channel().closeFuture().sync(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | bossGroup.shutdownGracefully(); |
| | | workerGroup.shutdownGracefully(); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.sinata.zuul.util.*; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.Unpooled; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | | * Netty业务逻辑层 |
| | | * @author sinata |
| | | * @createDate 2016年6月3日 |
| | | * @version 1.0 |
| | | */ |
| | | public class NettyServerController { |
| | | |
| | | public static Hashtable<String, Hashtable<ChannelHandlerContext, String>> map = new Hashtable<String, Hashtable<ChannelHandlerContext,String>>(); |
| | | |
| | | public static Hashtable<String,String> table; |
| | | |
| | | private RedisUtil redisUtil = SpringUtil.getObject(RedisUtil.class); |
| | | |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil = SpringUtil.getObject(GDMapGeocodingUtil.class); |
| | | |
| | | private RestTemplate internalRestTemplate = SpringUtil.getObject(RestTemplate.class); |
| | | |
| | | |
| | | |
| | | |
| | | static{ |
| | | if(table == null){ |
| | | table = new Hashtable<>(); |
| | | } |
| | | } |
| | | |
| | | public static boolean isdebug = false; |
| | | public static int i = 0; |
| | | |
| | | |
| | | /** |
| | | * 判断客户端要执行什么操作 |
| | | * |
| | | * @param ctx |
| | | * @param msg |
| | | * @author TaoNingBo |
| | | */ |
| | | public void JudgeOperation(ChannelHandlerContext ctx, Object msg) { |
| | | try { |
| | | // ByteBuf转String |
| | | ByteBuf byteBuf = (ByteBuf) msg; |
| | | |
| | | byte[] req = new byte[byteBuf.readableBytes()]; |
| | | byteBuf.readBytes(req); |
| | | msg = new String(req, "UTF-8"); |
| | | // 验证即时通讯命令是否正确有效 |
| | | if(SinataUtil.isEmpty(msg)) { |
| | | return; |
| | | } |
| | | String msgStr = msg.toString(); |
| | | if(msgStr.indexOf("{") == -1 || msgStr.indexOf("}") == -1 || msgStr.indexOf("code") == -1 || msgStr.indexOf("msg") == -1 || msgStr.indexOf("data") == -1 || msgStr.indexOf("method") == -1) { |
| | | return; |
| | | } |
| | | if(isdebug) { |
| | | // System.out.println("<<<--receive-->>>" + msg); |
| | | } |
| | | |
| | | // 获取socket信息,保存相应的socket |
| | | JSONObject jsonMsg = JSONObject.parseObject(msg.toString()); |
| | | int code = jsonMsg.getInteger("code"); |
| | | String message = jsonMsg.getString("msg"); |
| | | String method = jsonMsg.getString("method"); |
| | | if(code != 200 || !message.equals("SUCCESS")) { |
| | | return; |
| | | } |
| | | JSONObject jsonCon = JSONObject.parseObject(jsonMsg.get("data").toString()); |
| | | |
| | | if(null != ctx && ctx.channel().isActive()){ |
| | | jsonMsg.put("method", Method.pong); |
| | | sendMsgToClient(ctx, jsonMsg.toJSONString()); |
| | | } |
| | | |
| | | //心跳 |
| | | if(method.equals(Method.ping)) { |
| | | Integer type = jsonCon.getInteger("type"); |
| | | String token = jsonCon.getString("token"); |
| | | String userId1 = jsonCon.getString("userId"); |
| | | String device = jsonCon.getString("device"); |
| | | String version = jsonCon.getString("version"); |
| | | if(StringUtil.isNotEmpty(userId1)){ |
| | | |
| | | //判断用户或者司机长连接 |
| | | if(type==1){ |
| | | //确保账号在单个设备上登录 |
| | | if(StringUtil.isNotEmpty(token)){ |
| | | String token_ = redisUtil.getValue("USER_APP_"+ userId1);//获取缓存中最新的数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向其他设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | }else{ |
| | | NettyChannelMap.update_(token.substring(0, 23), ctx); |
| | | NettyChannelMap.update("USER" + userId1, ctx); |
| | | String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes())); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("USER_APP_" + userId1, token); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | //确保账号在单个设备上登录 |
| | | String value = redisUtil.getValue("DEVICE_" + userId1); |
| | | if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(device) && StringUtil.isEmpty(value)){//APP端登录的操作 |
| | | String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向当前设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | }else{ |
| | | NettyChannelMap.update("DRIVER" + userId1, ctx); |
| | | NettyChannelMap.update_(token.substring(0, 23), ctx); |
| | | String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes())); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("DRIVER_" + userId1, token); |
| | | } |
| | | } |
| | | |
| | | |
| | | //存储通讯通道 |
| | | if(null != ctx && ctx.channel().isActive()){ |
| | | NettyChannelMap.update("DRIVER" + userId1, ctx); |
| | | String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //司机上传位置 |
| | | if(method.equals(Method.location)){ |
| | | Integer driverId = jsonCon.getInteger("driverId"); |
| | | Integer orderId = jsonCon.getInteger("orderId"); |
| | | Integer orderType = jsonCon.getInteger("orderType"); |
| | | Double lon = jsonCon.getDouble("lon"); |
| | | Double lat = jsonCon.getDouble("lat"); |
| | | Double computeAzimuth = jsonCon.getDouble("computeAzimuth"); |
| | | Double altitude = jsonCon.getDouble("altitude"); |
| | | if(SinataUtil.isNotEmpty(driverId)){ |
| | | if(null != lon && 0 != lon && null != lat && 0 != lat){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("orderType", null == orderType ? orderType : String.valueOf(orderType)); |
| | | params.add("orderId", null == orderId ? orderId : String.valueOf(orderId)); |
| | | params.add("driverId", String.valueOf(driverId)); |
| | | params.add("lon", String.valueOf(lon)); |
| | | params.add("lat", String.valueOf(lat)); |
| | | params.add("directionAngle", String.valueOf(computeAzimuth)); |
| | | params.add("altitude", String.valueOf(altitude)); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://driver-server/base/driver/addDriverPosition",requestEntity , String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用driver-server存储位置数据出错了"); |
| | | } |
| | | }else{ |
| | | NettyServerController.sendMsgToClient(ctx, "__error__" + msg.toString()); |
| | | } |
| | | }else{ |
| | | NettyServerController.sendMsgToClient(ctx, "__error__" + msg.toString()); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | if(isdebug) { |
| | | NettyServerController.sendMsgToClient(ctx, "__error__" + msg.toString()); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 向客户端发送消息 |
| | | * |
| | | * @param ctx |
| | | * @param msg |
| | | * @author TaoNingBo |
| | | */ |
| | | public static void sendMsgToClient(ChannelHandlerContext ctx, String msg) { |
| | | if (ctx != null && ctx.channel().isActive()) { |
| | | ByteBuf buffer = Unpooled.copiedBuffer((msg).getBytes()); |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | if(!sync.isSuccess()){//如果推送失败则继续推送10次 |
| | | boolean b = true; |
| | | for (int i = 0; i < 10; i++) { |
| | | ctx.wait(3000); |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | if(sync.isSuccess()){ |
| | | b = false; |
| | | break; |
| | | } |
| | | System.err.println("推送不成功,将继续推送"+msg); |
| | | } |
| | | if(b){ |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | System.err.println("推送发生异常,记录:"+msg); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | if(isdebug) { |
| | | System.err.println("<<<--send-->>>" + msg) ; |
| | | } |
| | | }else{ |
| | | System.err.println("推送失败,长连接不存在"); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | } |
| | | |
| | | // **链接断开 将推送消息记录 |
| | | public static void sendMsgToClient(String cacheType, Integer id,String msg) { |
| | | ChannelHandlerContext ctx = NettyChannelMap.getData(cacheType + id); |
| | | if (ctx != null) { |
| | | ByteBuf buffer = Unpooled.copiedBuffer((msg).getBytes()); |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | // System.out.println("推送状态"+sync.isSuccess()); |
| | | if(!sync.isSuccess()){ |
| | | for (int i = 0; i < 10; i++) { |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | if(!sync.isSuccess()){ |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | System.err.println("推送不成功,将继续推送"+msg); |
| | | if(i == 9){ |
| | | table.put(cacheType+id, msg); |
| | | |
| | | ctx.close(); |
| | | System.err.println("推送发生异常,记录:"+msg); |
| | | } |
| | | }else{ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | table.put(cacheType+id, msg); |
| | | System.err.println("推送发生异常,记录:"+msg); |
| | | } |
| | | if(isdebug) { |
| | | // System.out.println("<<<--send-->>>" + msg); |
| | | } |
| | | }else{ |
| | | table.put(cacheType+id, msg); |
| | | System.err.println("链接断开,记录:id="+cacheType+id+",消息:"+msg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 记录推送不成功消息,并在心跳连接续推 |
| | | * @param token |
| | | */ |
| | | public static void resendMsg(String token){ |
| | | String msg = table.get(token); |
| | | ChannelHandlerContext ctx = NettyChannelMap.getData(token); |
| | | if(SinataUtil.isNotEmpty(msg) && ctx != null && ctx.channel().isActive()){ |
| | | ByteBuf buffer = Unpooled.copiedBuffer((msg).getBytes()); |
| | | ChannelFuture sync; |
| | | try { |
| | | sync = ctx.writeAndFlush(buffer).sync(); |
| | | System.err.println("重发异常推送状态"+sync.isSuccess()+",位置:"+token+",消息内容:"+msg); |
| | | if(!sync.isSuccess()){ |
| | | i++; |
| | | if(i == 10){ |
| | | i =0; |
| | | ctx.close(); |
| | | return; |
| | | } |
| | | System.err.println("重发异常推送不成功,将继续推送"+msg); |
| | | resendMsg(token); |
| | | }else{ |
| | | i=0; |
| | | } |
| | | table.remove(token); |
| | | } catch (Exception e) { |
| | | resendMsg(token); |
| | | System.err.println("重发推送发生异常,记录:"+msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.sinata.zuul.util.echo; |
| | | |
| | | import io.netty.channel.ChannelInitializer; |
| | | import io.netty.channel.ChannelPipeline; |
| | | import io.netty.channel.socket.SocketChannel; |
| | | import io.netty.handler.codec.string.StringDecoder; |
| | | import io.netty.handler.codec.string.StringEncoder; |
| | | |
| | | import java.nio.charset.Charset; |
| | | |
| | | public class ServerInit extends ChannelInitializer<SocketChannel> { |
| | | |
| | | private DiscardServerHandler discardServerHandler = new DiscardServerHandler(); |
| | | |
| | | @Override |
| | | protected void initChannel(SocketChannel ch) throws Exception { |
| | | ChannelPipeline pipeline = ch.pipeline(); |
| | | pipeline.addLast(new StringDecoder(Charset.forName("utf-8"))); |
| | | pipeline.addLast(new StringEncoder(Charset.forName("utf-8"))); |
| | | // 心跳监测机制 |
| | | // pipeline.addLast(new IdleStateHandler(5,7,10, TimeUnit.SECONDS)); |
| | | pipeline.addLast(discardServerHandler); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | server: |
| | | port: 80 |
| | | |
| | | spring: |
| | | application: |
| | | name: zuul-gateway #服务名称 |
| | | |
| | | eureka: |
| | | client: |
| | | service-url: #注册中心地址 |
| | | defaultZone: http://sinata:sinata@127.0.0.1:8000/eureka #启用身份验证的方式连接 |
| | | register-with-eureka: true #在注册中心进行注册 |
| | | fetch-registry: true #从Eureka中获取注册信息。 |
| | | |
| | | zuul: |
| | | # prefix: /api #添加URL前缀 |
| | | sensitive-headers: #将默认过滤掉的敏感数据清除,不进行过滤("Cookie", "Set-Cookie", "Authorization") |
| | | routes: |
| | | user-server: #接口调用路由服务,名字任意取。(用户端服务) |
| | | path: /user/** #配置请求URL的请求规则 |
| | | url: http://127.0.0.1:8006 #真正的微服务地址,path匹配的请求都转发到这里 |
| | | serviceid: user-server #指定Eureka注册中心的服务id |
| | | driver-server: #路由司机相关请求 |
| | | path: /driver/** #配置请求URL的请求规则 |
| | | url: http://127.0.0.1:8007 #真正的微服务地址,path匹配的请求都转发到这里 |
| | | serviceid: driver-server #指定Eureka注册中心的服务id |
| | | dispatch-server: #路由调度相关请求 |
| | | path: /dispatch/** #配置请求URL的请求规则 |
| | | url: http://127.0.0.1:8008 #真正的微服务地址,path匹配的请求都转发到这里 |
| | | serviceid: dispatch-server #指定Eureka注册中心的服务id |
| | | # 配置zuul超时时间 |
| | | host: |
| | | connect-timeout-millis: 150000 |
| | | socket-timeout-millis: 15000 |
| | | |
| | | # 配置ribbon超时时间 |
| | | ribbon: |
| | | ReadTimeout: 10000 |
| | | ConnectTimeout: 10000 |
New file |
| | |
| | | #redisÅäÖÿªÊ¼ |
| | | # RedisÊý¾Ý¿âË÷Òý£¨Ä¬ÈÏΪ0£© |
| | | spring.redis.database=0 |
| | | # Redis·þÎñÆ÷µØÖ· |
| | | spring.redis.host=127.0.0.1 |
| | | # Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | #spring.redis.port=16379 |
| | | spring.redis.port=6379 |
| | | # Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | #spring.redis.password=mPMHThYzlT8DWgl8HLqwPEyPOiHDPPB5 |
| | | spring.redis.password=123456 |
| | | # Á¬½Ó³Ø×î´óÁ¬½ÓÊý£¨Ê¹ÓøºÖµ±íʾûÓÐÏÞÖÆ£© |
| | | spring.redis.jedis.pool.max-active=1024 |
| | | # Á¬½Ó³Ø×î´ó×èÈûµÈ´ýʱ¼ä£¨Ê¹ÓøºÖµ±íʾûÓÐÏÞÖÆ£© |
| | | spring.redis.jedis.pool.max-wait=10000 |
| | | # Á¬½Ó³ØÖеÄ×î´ó¿ÕÏÐÁ¬½Ó |
| | | spring.redis.jedis.pool.max-idle=200 |
| | | # Á¬½Ó³ØÖеÄ×îС¿ÕÏÐÁ¬½Ó |
| | | spring.redis.jedis.pool.min-idle=50 |
| | | # Á¬½Ó³¬Ê±Ê±¼ä£¨ºÁÃ룩 |
| | | spring.redis.timeout=10000 |
| | | #redisÅäÖýáÊø |
| | | spring.redis.block-when-exhausted=true |
New file |
| | |
| | | 0ef42640d32181b65822b974b89492d4 |