From 2d08b036f5bdb9c34d686d6d125d5690a948ffa0 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期六, 11 三月 2023 17:33:38 +0800 Subject: [PATCH] 新增加用户端接口 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialUserEjectMapper.xml | 12 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapConfig.java | 14 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/LocationQuery.java | 23 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCostsWarpper.java | 24 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/GeoJson.java | 9 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CouponMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ISystemConfigService.java | 12 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/WeatherCity.java | 38 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/YouTuiDriverServiceImpl.java | 16 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml | 42 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialUserEjectMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IEvaluateService.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/config/SwaggerConfig.java | 4 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverService.java | 23 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/WeatherCityServiceImpl.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverWorkServiceImpl.java | 17 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/SignInToRegisterWarpper.java | 20 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/UserInfoWarpper.java | 28 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java | 980 ++++++++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/EvaluateServiceImpl.java | 15 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/MainContentServiceImpl.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCosts.java | 30 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java | 89 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/YouTuiDriverMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Broadcast.java | 45 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICouponService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ResultUtil.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AppUser.java | 10 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Commercial.java | 88 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialMapper.java | 20 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/BroadcastMapper.xml | 13 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CancelOrderMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/MainContentController.java | 60 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AccountChangeDetailServiceImpl.java | 30 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/WeatherCityMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/BroadcastMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/UserToCouponMapper.java | 35 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AccountChangeDetail.java | 60 user/guns-admin/src/test/sql/test.sql | 35 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/RedisUtil.java | 33 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/BroadcastServiceImpl.java | 16 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java | 204 + user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/Realtime.java | 40 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/DriverWork.java | 47 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/SystemConfigMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/YouTuiDriverMapper.xml | 14 user/guns-admin/src/main/java/com/supersavedriving/user/core/common/aspect/ServiceLogAspect.java | 75 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialUserEjectServiceImpl.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/StartPriceWarpper.java | 20 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/MainContent.java | 45 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IWeatherCityService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Driver.java | 225 + user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IBroadcastService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/SystemConfig.java | 33 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java | 92 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CancelOrder.java | 55 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/AccountChangeDetailMapper.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java | 340 ++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CommercialWarpper.java | 24 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/UUIDUtil.java | 23 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IYouTuiDriverService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Html.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EditOrderEndAddress.java | 22 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CancelOrderServiceImpl.java | 16 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/model/District.java | 36 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/WeatherCityMapper.xml | 12 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/OrderMapper.java | 18 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IMainContentService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherUtil.java | 119 + user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPayment.java | 20 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverMapper.xml | 50 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CommercialUserEject.java | 38 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapUtil.java | 138 + user/guns-admin/src/main/java/com/supersavedriving/user/core/common/exception/BizExceptionEnum.java | 6 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java | 118 + user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/MainContentMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/MongoUtils.java | 166 + user/guns-admin/src/main/resources/application.yml | 28 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Coupon.java | 95 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java | 35 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICancelOrderService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/MainContentMapper.xml | 13 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAppUserService.java | 13 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/CommercialController.java | 65 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AccountChangeDetailMapper.xml | 16 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverWorkMapper.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/Location.java | 50 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Evaluate.java | 54 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialServiceImpl.java | 57 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/TravelOrder.java | 35 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialService.java | 23 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/SystemConfigMapper.xml | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherCityInfo.java | 38 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CouponWarpper.java | 24 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/YouTuiDriver.java | 50 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderInfoWarpper.java | 500 ---- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/EvaluateMapper.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverWorkService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CancelOrderMapper.xml | 15 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CouponMapper.xml | 23 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPriceWarpper.java | 65 user/guns-admin/pom.xml | 4 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialUserEjectService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/SystemConfigServiceImpl.java | 16 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AppUserMapper.xml | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/HtmlController.java | 60 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml | 89 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverWorkMapper.xml | 14 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GeodesyUtil.java | 5 /dev/null | 147 - user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/UserToCoupon.java | 65 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java | 44 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/EvaluateMapper.xml | 15 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CouponServiceImpl.java | 11 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/NearbyDriverWarpper.java | 21 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/UserToCouponMapper.xml | 43 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PayMoneyUtil.java | 554 ++++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Order.java | 300 ++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java | 57 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 106 user/guns-admin/src/main/java/com/supersavedriving/user/GunsApplication.java | 6 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAccountChangeDetailService.java | 19 123 files changed, 6,045 insertions(+), 776 deletions(-) diff --git a/user/guns-admin/pom.xml b/user/guns-admin/pom.xml index 98fd737..843a625 100644 --- a/user/guns-admin/pom.xml +++ b/user/guns-admin/pom.xml @@ -194,6 +194,10 @@ <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> diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/GunsApplication.java b/user/guns-admin/src/main/java/com/supersavedriving/user/GunsApplication.java index 77fd7e9..7b89b43 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/GunsApplication.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/GunsApplication.java @@ -1,10 +1,10 @@ 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; @@ -30,6 +30,7 @@ @SpringBootApplication @EnableScheduling//开启定时任务 @EnableTransactionManagement//启动事务功能 +@MapperScan("com.supersavedriving.user.modular.system.dao") public class GunsApplication { private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); @@ -37,9 +38,6 @@ public static void main(String[] args) { SpringApplication.run(GunsApplication.class, args); logger.info("GunsApplication is success!"); - - GDFalconUtil gdFalconUtil = new GDFalconUtil(); - gdFalconUtil.init();//初始化猎鹰服务 } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/config/SwaggerConfig.java b/user/guns-admin/src/main/java/com/supersavedriving/user/config/SwaggerConfig.java index 9f32a6e..a8c2b5b 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/config/SwaggerConfig.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/config/SwaggerConfig.java @@ -36,8 +36,8 @@ 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") diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/aspect/ServiceLogAspect.java b/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/aspect/ServiceLogAspect.java index 4850d1c..d598a42 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/aspect/ServiceLogAspect.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/aspect/ServiceLogAspect.java @@ -31,42 +31,45 @@ @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(); } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/exception/BizExceptionEnum.java b/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/exception/BizExceptionEnum.java index f284a74..71f242f 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/exception/BizExceptionEnum.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/core/common/exception/BizExceptionEnum.java @@ -58,13 +58,13 @@ /** * token异常 */ - TOKEN_EXPIRED(600, "token过期"), - TOKEN_ERROR(600, "token验证失败"), + TOKEN_EXPIRED(10030, "token过期"), + TOKEN_ERROR(10030, "token验证失败"), /** * 签名异常 */ - SIGN_ERROR(700, "签名验证失败"), + SIGN_ERROR(10040, "签名验证失败"), /** * 其他 diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java index 7781fe9..a5d863a 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java @@ -2,18 +2,23 @@ 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; /** * 用户控制器 @@ -25,10 +30,16 @@ @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"), @@ -50,17 +61,100 @@ @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()); + } + } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java new file mode 100644 index 0000000..8e03a30 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java @@ -0,0 +1,57 @@ +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()); + } + } + + + + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/CommercialController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/CommercialController.java new file mode 100644 index 0000000..edef786 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/CommercialController.java @@ -0,0 +1,65 @@ +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()); + } + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/HtmlController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/HtmlController.java index 4e10ba7..a5177cc 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/HtmlController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/HtmlController.java @@ -1,11 +1,17 @@ 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; @@ -14,6 +20,9 @@ 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; /** * 协议控制器 @@ -25,15 +34,18 @@ @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){ @@ -47,4 +59,48 @@ 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()); + } + } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/MainContentController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/MainContentController.java new file mode 100644 index 0000000..e89701d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/MainContentController.java @@ -0,0 +1,60 @@ +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()); + } + + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java new file mode 100644 index 0000000..4b3da9d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java @@ -0,0 +1,340 @@ +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()); + } + } + + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/AccountChangeDetailMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/AccountChangeDetailMapper.java new file mode 100644 index 0000000..7d6656b --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/AccountChangeDetailMapper.java @@ -0,0 +1,11 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/BroadcastMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/BroadcastMapper.java new file mode 100644 index 0000000..de2edba --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/BroadcastMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CancelOrderMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CancelOrderMapper.java new file mode 100644 index 0000000..504977d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CancelOrderMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialMapper.java new file mode 100644 index 0000000..6f8fa5f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialMapper.java @@ -0,0 +1,20 @@ +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); +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialUserEjectMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialUserEjectMapper.java new file mode 100644 index 0000000..cf22e57 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CommercialUserEjectMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CouponMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CouponMapper.java new file mode 100644 index 0000000..aa755f2 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/CouponMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverMapper.java new file mode 100644 index 0000000..891e549 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverWorkMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverWorkMapper.java new file mode 100644 index 0000000..6a362f0 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/DriverWorkMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/EvaluateMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/EvaluateMapper.java new file mode 100644 index 0000000..25250cd --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/EvaluateMapper.java @@ -0,0 +1,11 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/MainContentMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/MainContentMapper.java new file mode 100644 index 0000000..053bb3a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/MainContentMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/OrderMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/OrderMapper.java new file mode 100644 index 0000000..5c06528 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/OrderMapper.java @@ -0,0 +1,18 @@ +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); +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/SystemConfigMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/SystemConfigMapper.java new file mode 100644 index 0000000..97d41f2 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/SystemConfigMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/UserToCouponMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/UserToCouponMapper.java new file mode 100644 index 0000000..b78b3cf --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/UserToCouponMapper.java @@ -0,0 +1,35 @@ +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); +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/WeatherCityMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/WeatherCityMapper.java new file mode 100644 index 0000000..3c54481 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/WeatherCityMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/YouTuiDriverMapper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/YouTuiDriverMapper.java new file mode 100644 index 0000000..b157cea --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/YouTuiDriverMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AccountChangeDetailMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AccountChangeDetailMapper.xml new file mode 100644 index 0000000..bb32c45 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AccountChangeDetailMapper.xml @@ -0,0 +1,16 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AppUserMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AppUserMapper.xml index 235b934..e067251 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AppUserMapper.xml +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/AppUserMapper.xml @@ -21,5 +21,7 @@ <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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/BroadcastMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/BroadcastMapper.xml new file mode 100644 index 0000000..8813cb0 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/BroadcastMapper.xml @@ -0,0 +1,13 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CancelOrderMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CancelOrderMapper.xml new file mode 100644 index 0000000..6277473 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CancelOrderMapper.xml @@ -0,0 +1,15 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml new file mode 100644 index 0000000..b164791 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml @@ -0,0 +1,42 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialUserEjectMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialUserEjectMapper.xml new file mode 100644 index 0000000..7127449 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialUserEjectMapper.xml @@ -0,0 +1,12 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CouponMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CouponMapper.xml new file mode 100644 index 0000000..c21b743 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CouponMapper.xml @@ -0,0 +1,23 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverMapper.xml new file mode 100644 index 0000000..08af8c0 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverMapper.xml @@ -0,0 +1,50 @@ +<?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> diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverWorkMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverWorkMapper.xml new file mode 100644 index 0000000..cf0b482 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/DriverWorkMapper.xml @@ -0,0 +1,14 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/EvaluateMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/EvaluateMapper.xml new file mode 100644 index 0000000..1a1e7f9 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/EvaluateMapper.xml @@ -0,0 +1,15 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/MainContentMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/MainContentMapper.xml new file mode 100644 index 0000000..3472e59 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/MainContentMapper.xml @@ -0,0 +1,13 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml new file mode 100644 index 0000000..9715b4f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml @@ -0,0 +1,89 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/SystemConfigMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/SystemConfigMapper.xml new file mode 100644 index 0000000..4e870c2 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/SystemConfigMapper.xml @@ -0,0 +1,11 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/UserToCouponMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/UserToCouponMapper.xml new file mode 100644 index 0000000..d755a61 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/UserToCouponMapper.xml @@ -0,0 +1,43 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/WeatherCityMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/WeatherCityMapper.xml new file mode 100644 index 0000000..0a31ff4 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/WeatherCityMapper.xml @@ -0,0 +1,12 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/YouTuiDriverMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/YouTuiDriverMapper.xml new file mode 100644 index 0000000..5049496 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/YouTuiDriverMapper.xml @@ -0,0 +1,14 @@ +<?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> \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AccountChangeDetail.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AccountChangeDetail.java new file mode 100644 index 0000000..38c2c26 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AccountChangeDetail.java @@ -0,0 +1,60 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AppUser.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AppUser.java index 7564177..fdb46b3 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AppUser.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/AppUser.java @@ -100,4 +100,14 @@ */ @TableField("inviterId") private Integer inviterId; + /** + * 取消订单次数,取消一次加一,若成功接单清零 + */ + @TableField("cancelCount") + private Integer cancelCount; + /** + * 是否拥有9折优惠 1是 0否 + */ + @TableField("havDiscount") + private Integer havDiscount; } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Broadcast.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Broadcast.java new file mode 100644 index 0000000..775b28a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Broadcast.java @@ -0,0 +1,45 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CancelOrder.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CancelOrder.java new file mode 100644 index 0000000..b77bb49 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CancelOrder.java @@ -0,0 +1,55 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Commercial.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Commercial.java new file mode 100644 index 0000000..a3597dc --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Commercial.java @@ -0,0 +1,88 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CommercialUserEject.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CommercialUserEject.java new file mode 100644 index 0000000..ef569cb --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/CommercialUserEject.java @@ -0,0 +1,38 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Coupon.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Coupon.java new file mode 100644 index 0000000..62fc95b --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Coupon.java @@ -0,0 +1,95 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Driver.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Driver.java new file mode 100644 index 0000000..85cd45b --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Driver.java @@ -0,0 +1,225 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/DriverWork.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/DriverWork.java new file mode 100644 index 0000000..201f1e8 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/DriverWork.java @@ -0,0 +1,47 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Evaluate.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Evaluate.java new file mode 100644 index 0000000..87cb543 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Evaluate.java @@ -0,0 +1,54 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Html.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Html.java index cad5459..c705d89 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Html.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Html.java @@ -21,7 +21,7 @@ @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; diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/MainContent.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/MainContent.java new file mode 100644 index 0000000..d424fca --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/MainContent.java @@ -0,0 +1,45 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Order.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Order.java new file mode 100644 index 0000000..c8afd9d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/Order.java @@ -0,0 +1,300 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/SystemConfig.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/SystemConfig.java new file mode 100644 index 0000000..73474a1 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/SystemConfig.java @@ -0,0 +1,33 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/UserToCoupon.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/UserToCoupon.java new file mode 100644 index 0000000..8490187 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/UserToCoupon.java @@ -0,0 +1,65 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/WeatherCity.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/WeatherCity.java new file mode 100644 index 0000000..61202d1 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/WeatherCity.java @@ -0,0 +1,38 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/YouTuiDriver.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/YouTuiDriver.java new file mode 100644 index 0000000..e5eb0a2 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/model/YouTuiDriver.java @@ -0,0 +1,50 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAccountChangeDetailService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAccountChangeDetailService.java new file mode 100644 index 0000000..39a3918 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAccountChangeDetailService.java @@ -0,0 +1,19 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAppUserService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAppUserService.java index e392733..4f812a8 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAppUserService.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IAppUserService.java @@ -4,6 +4,9 @@ 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> { @@ -23,5 +26,13 @@ * @return * @throws Exception */ - ResultUtil signInToRegister(SignInToRegister signInToRegister) throws Exception; + ResultUtil<SignInToRegisterWarpper> signInToRegister(SignInToRegister signInToRegister) throws Exception; + + + + /** + * 校验token获取用户信息 + * @return + */ + Integer getUserByRequest() throws Exception; } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IBroadcastService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IBroadcastService.java new file mode 100644 index 0000000..1b111d3 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IBroadcastService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICancelOrderService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICancelOrderService.java new file mode 100644 index 0000000..544212a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICancelOrderService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialService.java new file mode 100644 index 0000000..d61c591 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialService.java @@ -0,0 +1,23 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialUserEjectService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialUserEjectService.java new file mode 100644 index 0000000..04a0d8d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICommercialUserEjectService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICouponService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICouponService.java new file mode 100644 index 0000000..2fa417a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ICouponService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverService.java new file mode 100644 index 0000000..7c80c1e --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverService.java @@ -0,0 +1,23 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverWorkService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverWorkService.java new file mode 100644 index 0000000..4227548 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IDriverWorkService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IEvaluateService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IEvaluateService.java new file mode 100644 index 0000000..7d368ec --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IEvaluateService.java @@ -0,0 +1,11 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IMainContentService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IMainContentService.java new file mode 100644 index 0000000..9cc70a0 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IMainContentService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java new file mode 100644 index 0000000..90e3eb1 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java @@ -0,0 +1,118 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ISystemConfigService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ISystemConfigService.java new file mode 100644 index 0000000..1d75ce4 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/ISystemConfigService.java @@ -0,0 +1,12 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java new file mode 100644 index 0000000..902cb60 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java @@ -0,0 +1,35 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IWeatherCityService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IWeatherCityService.java new file mode 100644 index 0000000..6d2208b --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IWeatherCityService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IYouTuiDriverService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IYouTuiDriverService.java new file mode 100644 index 0000000..34a1442 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IYouTuiDriverService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AccountChangeDetailServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AccountChangeDetailServiceImpl.java new file mode 100644 index 0000000..4758eda --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AccountChangeDetailServiceImpl.java @@ -0,0 +1,30 @@ +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); + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java index ab94bfa..fd81855 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java @@ -4,19 +4,26 @@ 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; @@ -24,8 +31,13 @@ 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; /** @@ -42,12 +54,18 @@ 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(); @@ -107,7 +125,8 @@ * @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"); } @@ -118,7 +137,7 @@ 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(); @@ -143,6 +162,13 @@ 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("账号被冻结"); @@ -151,6 +177,64 @@ 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; + } } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/BroadcastServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/BroadcastServiceImpl.java new file mode 100644 index 0000000..357d38c --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/BroadcastServiceImpl.java @@ -0,0 +1,16 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CancelOrderServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CancelOrderServiceImpl.java new file mode 100644 index 0000000..aa2b87d --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CancelOrderServiceImpl.java @@ -0,0 +1,16 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialServiceImpl.java new file mode 100644 index 0000000..62ede28 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialServiceImpl.java @@ -0,0 +1,57 @@ +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; + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialUserEjectServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialUserEjectServiceImpl.java new file mode 100644 index 0000000..cb6d12f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CommercialUserEjectServiceImpl.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CouponServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CouponServiceImpl.java new file mode 100644 index 0000000..ea4a22f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/CouponServiceImpl.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java new file mode 100644 index 0000000..c2f51f8 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java @@ -0,0 +1,89 @@ +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; + } + + + + + + + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverWorkServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverWorkServiceImpl.java new file mode 100644 index 0000000..db94447 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverWorkServiceImpl.java @@ -0,0 +1,17 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/EvaluateServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/EvaluateServiceImpl.java new file mode 100644 index 0000000..c945c9f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/EvaluateServiceImpl.java @@ -0,0 +1,15 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/MainContentServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/MainContentServiceImpl.java new file mode 100644 index 0000000..f5b502e --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/MainContentServiceImpl.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java new file mode 100644 index 0000000..13c646f --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java @@ -0,0 +1,980 @@ +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(); + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/SystemConfigServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/SystemConfigServiceImpl.java new file mode 100644 index 0000000..ce896ae --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/SystemConfigServiceImpl.java @@ -0,0 +1,16 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java new file mode 100644 index 0000000..fe14ffc --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java @@ -0,0 +1,44 @@ +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); + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/WeatherCityServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/WeatherCityServiceImpl.java new file mode 100644 index 0000000..7c62829 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/WeatherCityServiceImpl.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/YouTuiDriverServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/YouTuiDriverServiceImpl.java new file mode 100644 index 0000000..fc598a9 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/YouTuiDriverServiceImpl.java @@ -0,0 +1,16 @@ +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 { +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ALiApiUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ALiApiUtil.java deleted file mode 100644 index 389f756..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ALiApiUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.supersavedriving.user.modular.system.util; - - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -/** - * 阿里云API接口工具类 - */ -@Component -public class ALiApiUtil { - - @Autowired - private HttpClientUtil httpClientUtil; - - - /** - * 身份认证接口 - * @param name 姓名 - * @param code 身份证号 - * @return - */ - public boolean authentication(String name, String code){ - String url = "https://safrvcert.market.alicloudapi.com/safrv_2meta_id_name/"; - Map<String, String> header = new HashMap<>(); - header.put("Authorization", "APPCODE b7d32437d08149099457dcb50fb57df2"); - Map<String, Object> param = new HashMap<>(); - param.put("__userId", "1732960796168165"); - param.put("verifyKey", "IVO4js5kValcdt"); - param.put("userName", name); - param.put("identifyNum", code); - String get = httpClientUtil.pushHttpRequset("GET", url, param, header, "form"); - JSONObject jsonObject = JSON.parseObject(get); - if(jsonObject.getIntValue("code") == 200){ - JSONObject value = jsonObject.getJSONObject("value"); - if(value.getIntValue("bizCode") == 0){ - return true; - }else{ - return false; - } - }else{ - System.err.println(jsonObject.getString("message")); - } - return false; - } -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ChinaMobileUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ChinaMobileUtil.java deleted file mode 100644 index 809209f..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ChinaMobileUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.supersavedriving.user.modular.system.util; - -import com.alibaba.fastjson.JSONObject; -import com.supersavedriving.user.core.util.MD5Util; -import org.apache.commons.codec.binary.Base64; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -/** - * 中国移动工具类 - */ -@Component -public class ChinaMobileUtil { - - private String APIKey = "zj42494b1bdd416b9762229af6b5cbbd"; - - private String SecretKey = "30323561316534653735613230316339"; - - @Autowired - private HttpClientUtil httpClientUtil; - - - /** - * 绑定小号 - * @param phoneA - * @param phoneB - * @param areaCode - * @return - * @throws Exception - */ - public Map<String, String> midAxbBindSend(String phoneA, String phoneB, Integer areaCode) throws Exception{ - //组装请求对象-具体描述见开发文档-订单小号-AXB接口规范部分内容 - Map<String, Object> request = new HashMap<>(); - request.put("APPID", APIKey); - request.put("bindtype", "AXB"); - request.put("requestId", UUIDUtil.getRandomCode(16)); - request.put("record", "0"); - //用户号码,必填,格式遵循国际电信联盟定义的E.164标准 - request.put("telA", "86" + phoneA); - //用户号码B,必填,格式遵循国际电信联盟定义的E.164标准 - request.put("telB", "86" + phoneB); - //需要选择的小号所属区号,当telX不写时必填,例如:杭州(571) - request.put("areaCode", 571); - //订单小号,非必填,当指定小号绑定时填写,格式遵循国际电信联盟定义的E.164标准 -// request.setTelX("8618867110000"); - //绑定关系过期失效时间,秒,取值必须大于0且最大值不超过4294967296 - request.put("expiration", Integer.valueOf(7 * 24 * 60 * 60)); - - Map<String, String> header = new HashMap<String, String>(3); - header.put("Authorization", "Basic " + new String(Base64.encodeBase64((APIKey + ":" + SecretKey).getBytes()))); - header.put("Content-Type", "application/json;charset=utf-8"); - String post = httpClientUtil.pushHttpRequset("POST", "https://ct.open.10086.cn/ordernumber/v1/binding", request, header, "json"); - Map<String, String> map1 = new HashMap<>(); - if(post.indexOf("0000") != -1){ - JSONObject jsonObject = JSONObject.parseObject(post); - if(jsonObject.getString("code").equals("0000")){ - map1.put("code", "200"); - map1.put("msg", jsonObject.getString("message")); - map1.put("telX", jsonObject.getString("x_no").substring(2)); - map1.put("bindId", jsonObject.getString("bindId")); - }else{ - map1.put("code", jsonObject.getString("code")); - map1.put("msg", jsonObject.getString("message")); - } - }else{ - map1.put("code", "-1"); - map1.put("msg", post); - } - - return map1; - } - - - /** - * 解绑小号关系 - * @param bindId 绑定关系id - * @return - * @throws Exception - */ - public Map<String, String> midAxbUnBindSend(String bindId) throws Exception{ - //组装请求对象-具体描述见开发文档-订单小号-AXB接口规范部分内容 - Map<String, Object> request = new HashMap<>(); - //绑定关系ID - request.put("APPID", APIKey); - request.put("bindId", bindId); - - Map<String, String> header = new HashMap<String, String>(3); - header.put("Authorization", "Basic " + new String(Base64.encodeBase64((APIKey + ":" + SecretKey).getBytes()))); - header.put("Content-Type", "application/json;charset=utf-8"); - String post = httpClientUtil.pushHttpRequset("POST", "https://ct.open.10086.cn/ordernumber/v1/unbinding", request, header, "json"); - Map<String, String> map1 = new HashMap<>(); - if(post.indexOf("0000") != -1){ - JSONObject jsonObject = JSONObject.parseObject(post); - if(jsonObject.getString("code").equals("0000")){ - map1.put("code", "200"); - map1.put("msg", jsonObject.getString("message")); - }else{ - map1.put("code", jsonObject.getString("code")); - map1.put("msg", jsonObject.getString("message")); - } - }else{ - map1.put("code", "-1"); - map1.put("msg", post); - } - return map1; - } - - - - - public Map<String, String> HeaderUtils(String APIKey, String SecretKey) throws Exception{ - Map<String, String> header = new HashMap<>(); - long time = System.currentTimeMillis(); - String signStr = MD5Util.encrypt(APIKey + SecretKey + time); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("apiKey", APIKey); - jsonObject.put("time", time); - jsonObject.put("sign", signStr); - Base64 base64 = new Base64(); - String s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8")); - header.put("header", s); - - jsonObject = new JSONObject(); - jsonObject.put("platformId", ""); - jsonObject.put("secret", ""); - s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8")); - header.put("accessCode", s); - return header; - } -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GDFalconUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GDFalconUtil.java deleted file mode 100644 index 8bb3cc4..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GDFalconUtil.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.supersavedriving.user.modular.system.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.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -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.Map; - - -/** - * 高德猎鹰服务 - */ -@Component -public class GDFalconUtil implements ApplicationRunner { - - private String key = "e17d799b2506d05faf7f88320a266803"; - - @Autowired - private RestTemplate restTemplate; - - private static String serverId = null; - - - public String getServerId() { - return serverId; - } - - /** - * 服务启动后执行的代码 - * @param args - * @throws Exception - */ - @Override - public void run(ApplicationArguments args) throws Exception { - this.init(); - } - - - - /** - * 初始化创建服务 - */ - public void init(){ - if(serverId == null){ - JSONArray jsonArray = this.selectServer(); - if(null == jsonArray){ - serverId = this.createServer("server"); - }else{ - serverId = jsonArray.getJSONObject(0).getString("sid"); - } - } - - } - - - /** - * 创建新的服务 - * @return - */ - public String createServer(String name){ - String url = "https://tsapi.amap.com/v1/track/service/add"; - //调用推送 - HttpHeaders headers = new HttpHeaders(); - // 以表单的方式提交 - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - //将请求头部和参数合成一个请求 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); - params.add("key", key); - params.add("name", name); - HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); - String s = restTemplate.postForObject(url, requestEntity , String.class); - JSONObject jsonObject = JSON.parseObject(s); - if(jsonObject.getIntValue("errcode") == 10000){ - JSONObject data = jsonObject.getJSONObject("data"); - if(null != data){ - return data.getString("sid"); - } - } - return null; - } - - - /** - * 查询服务 - * @return - */ - private JSONArray selectServer(){ - String url = "https://tsapi.amap.com/v1/track/service/list?key=" + key; - String forObject = restTemplate.getForObject(url, String.class); - JSONObject jsonObject = JSON.parseObject(forObject); - if(jsonObject.getIntValue("errcode") == 10000){ - JSONObject data = jsonObject.getJSONObject("data"); - if(null != data){ - return data.getJSONArray("results"); - } - } - return null; - } - - - /** - * 创建终端数据 - * @param name - * @return - */ - public String createTerminal(String name){ - String tid = this.selectTerminal(name); - if(tid != null){ - return tid; - } - String url = "https://tsapi.amap.com/v1/track/terminal/add"; - //调用推送 - HttpHeaders headers = new HttpHeaders(); - // 以表单的方式提交 - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - //将请求头部和参数合成一个请求 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); - params.add("key", key); - params.add("sid", serverId); - params.add("name", name); - HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); - String s = restTemplate.postForObject(url, requestEntity , String.class); - JSONObject jsonObject = JSON.parseObject(s); - if(jsonObject.getIntValue("errcode") == 10000){ - JSONObject data = jsonObject.getJSONObject("data"); - return data.getString("tid"); - } - System.err.println(jsonObject.getString("errmsg")); - return null; - } - - - /** - * 查询终端 - * @param name - * @return - */ - public String selectTerminal(String name){ - String url = "https://tsapi.amap.com/v1/track/terminal/list?key=" + key + "&name=" + name; - String forObject = restTemplate.getForObject(url, String.class); - JSONObject jsonObject = JSON.parseObject(forObject); - if(jsonObject.getIntValue("errcode") == 10000){ - JSONObject data = jsonObject.getJSONObject("data"); - int count = 0; - if(null != data){ - count = data.getIntValue("count"); - } - if(count > 0){ - JSONObject results = data.getJSONArray("results").getJSONObject(0); - return results.getString("tid"); - }else{ - return this.createTerminal(name); - } - } - return null; - } - - - /** - * 创建轨迹 - * @param tid 终端id - * @return - */ - public String createTrack(String tid){ - String url = "https://tsapi.amap.com/v1/track/trace/add"; - //调用推送 - HttpHeaders headers = new HttpHeaders(); - // 以表单的方式提交 - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - //将请求头部和参数合成一个请求 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); - params.add("key", key); - params.add("sid", serverId); - params.add("tid", tid); - HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); - String s = restTemplate.postForObject(url, requestEntity , String.class); - JSONObject jsonObject = JSON.parseObject(s); - if(jsonObject.getIntValue("errcode") == 10000){ - return jsonObject.getString("data"); - } - System.err.println(jsonObject.getString("errmsg")); - return null; - } - - - /** - * 删除轨迹 - * @param tid 终端id - * @param trid 轨迹id - */ - public void deleteTrack(String tid, String trid){ - String url = "https://tsapi.amap.com/v1/track/trace/delete"; - //调用推送 - HttpHeaders headers = new HttpHeaders(); - // 以表单的方式提交 - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - //将请求头部和参数合成一个请求 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); - params.add("key", key); - params.add("sid", serverId); - params.add("tid", tid); - params.add("trid", trid); - HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); - String s = restTemplate.postForObject(url, requestEntity , String.class); - JSONObject jsonObject = JSON.parseObject(s); - if(jsonObject.getIntValue("errcode") != 10000){ - System.err.println(jsonObject.getString("errmsg")); - } - } - - -// -// public Map<String, Object> queryTrsearch(){ -// -// } -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapConfig.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapConfig.java new file mode 100644 index 0000000..db11284 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapConfig.java @@ -0,0 +1,14 @@ +package com.supersavedriving.user.modular.system.util.GaoDe; + +/** +* 高德地图配置 +* @author pzb +* @Date 2023/2/16 18:52 +*/ +public interface MapConfig { + + /** + * 高德key + */ + String key = "e0370a9a4d10739045fb0b8f4742a67e"; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapUtil.java new file mode 100644 index 0000000..109e383 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/MapUtil.java @@ -0,0 +1,138 @@ +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; + } + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/model/District.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/model/District.java new file mode 100644 index 0000000..2aadecd --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GaoDe/model/District.java @@ -0,0 +1,36 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GeodesyUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GeodesyUtil.java index c19b449..747deb0 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GeodesyUtil.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/GeodesyUtil.java @@ -13,7 +13,6 @@ /** * 计算两个金纬度坐标之间的直线距离 */ -@Component public class GeodesyUtil { @@ -23,7 +22,7 @@ * @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<>(); @@ -60,7 +59,7 @@ } - 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(); diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/JuHeUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/JuHeUtil.java deleted file mode 100644 index 7373f7e..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/JuHeUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.supersavedriving.user.modular.system.util; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -/** - * 聚合数据工具类 - */ -@Component -public class JuHeUtil { - - @Value("${juhe.appKey}") - private String key; - - @Autowired - private HttpClientUtil httpClientUtil; - - /** - * 身份证号码实名认证 - * @param name - * @param idcard - * @return - */ - public boolean idcard(String name, String idcard){ - Map<String, Object> map = new HashMap<>(); - map.put("key", key); - map.put("idcard", idcard); - map.put("realname", name); - String content = httpClientUtil.pushHttpRequset("GET", "http://op.juhe.cn/idcard/query", map, new HashMap<>(), "form"); - System.err.println(content); - JSONObject jsonObject = JSON.parseObject(content); - if(jsonObject.getIntValue("error_code") == 0){ - int res = jsonObject.getJSONObject("result").getIntValue("res"); - return res == 1 ? true : false; - } - return false; - } - - - /** - * 根据银行卡号获取银行数据 - * @param code - * @return - */ - public Map<String, String> queryBank(String code){ - String url = "http://apis.juhe.cn/interbank/query?key=" + key + "&bankcard=" + code; - String get = httpClientUtil.pushHttpRequset("GET", url, null, null, "form"); - JSONObject jsonObject = JSON.parseObject(get); - Map<String, String> map = new HashMap<>(); - if(jsonObject.getIntValue("error_code") == 0){ - JSONObject result = jsonObject.getJSONObject("result"); - JSONObject data = result.getJSONObject("data"); - JSONObject record = data.getJSONArray("record").getJSONObject(0); - - String province = record.getString("province"); - String city = record.getString("city"); - String district = record.getString("district"); - String address = record.getString("addr"); - map.put("msg", "success"); - map.put("address", province + city + district); - map.put("bank_name", record.getString("lname")); - map.put("bank", record.getString("bank")); - map.put("bank_code", record.getString("bankcode"));//联行号 - }else{ - map.put("msg", jsonObject.getString("reason")); - } - return map; - } -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PayMoneyUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PayMoneyUtil.java index a2142e5..7e358a2 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PayMoneyUtil.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PayMoneyUtil.java @@ -4,24 +4,20 @@ 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; @@ -64,6 +60,9 @@ @Value("${wx.appid}") private String appid;//微信appid + @Value("${wx.appletsAppid}") + private String appletsAppid;//微信小程序appid + @Value("${wx.mchId}") private String mchId;//微信商户号 @@ -73,8 +72,11 @@ @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<>();//存储支付订单用于主动查询支付结果 @@ -82,9 +84,61 @@ /** * 支付宝支付 */ - 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)。 @@ -95,6 +149,7 @@ model.setTimeoutExpress("30m"); model.setTotalAmount(amount);//付款金额 model.setProductCode("QUICK_MSECURITY_PAY"); + model.setPassbackParams(passbackParams);//自定义参数 request.setBizModel(model); request.setNotifyUrl(callbackPath + notifyUrl); try { @@ -158,7 +213,7 @@ 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"); @@ -166,25 +221,43 @@ } //切记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; } @@ -221,7 +294,10 @@ * @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 { @@ -231,7 +307,7 @@ } 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); @@ -241,6 +317,9 @@ 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); @@ -260,7 +339,7 @@ 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("]]>", ""); @@ -276,26 +355,40 @@ 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{ @@ -328,7 +421,7 @@ 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"));//微信支付订单号 @@ -336,10 +429,10 @@ 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(); @@ -360,7 +453,7 @@ * @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 { @@ -404,7 +497,7 @@ 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("]]>", ""); @@ -487,7 +580,7 @@ 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"; @@ -506,7 +599,14 @@ 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("]]>", ""); @@ -560,6 +660,8 @@ 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")); @@ -593,14 +695,48 @@ * @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(); @@ -621,13 +757,14 @@ * @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); @@ -647,7 +784,7 @@ 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("]]>", ""); @@ -662,32 +799,247 @@ 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; + } /** @@ -749,6 +1101,42 @@ /** + * 微信下单的签名算法 + * @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 diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java new file mode 100644 index 0000000..55520e7 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java @@ -0,0 +1,204 @@ +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")); + } + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/RedisUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/RedisUtil.java index 218ef97..2e7a476 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/RedisUtil.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/RedisUtil.java @@ -203,6 +203,39 @@ /** * 获取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 */ diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ResultUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ResultUtil.java index 8134c57..e1cfedf 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ResultUtil.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/ResultUtil.java @@ -105,7 +105,7 @@ * 参数异常 * @return */ - public static ResultUtil paranErr(String...ages){ + public static ResultUtil paranErr(String ages){ return ResultUtil.getResult(ResultUtil.PARAM_ERROR, "【" + ages + "】参数异常", new Object()); } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/UUIDUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/UUIDUtil.java index 45ff89c..8ba2737 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/UUIDUtil.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/UUIDUtil.java @@ -72,7 +72,28 @@ * @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(); + } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/Realtime.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/Realtime.java new file mode 100644 index 0000000..f488d48 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/Realtime.java @@ -0,0 +1,40 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherCityInfo.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherCityInfo.java new file mode 100644 index 0000000..e182f2a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherCityInfo.java @@ -0,0 +1,38 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherUtil.java new file mode 100644 index 0000000..d765675 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/juhe/WeatherUtil.java @@ -0,0 +1,119 @@ +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; + } + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/MongoUtils.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/MongoUtils.java new file mode 100644 index 0000000..13d2b68 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/MongoUtils.java @@ -0,0 +1,166 @@ +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; + } + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/GeoJson.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/GeoJson.java new file mode 100644 index 0000000..e700108 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/GeoJson.java @@ -0,0 +1,9 @@ +package com.supersavedriving.user.modular.system.util.mongodb.model; + +import lombok.Data; + +@Data +public class GeoJson { + private String type; + private Double[] coordinates; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/Location.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/Location.java new file mode 100644 index 0000000..3feb030 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/Location.java @@ -0,0 +1,50 @@ +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; + +} \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/LocationQuery.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/LocationQuery.java new file mode 100644 index 0000000..98db923 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/mongodb/model/LocationQuery.java @@ -0,0 +1,23 @@ +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; +} \ No newline at end of file diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/SubscribeMessageUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/SubscribeMessageUtil.java deleted file mode 100644 index 9c6d06d..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/SubscribeMessageUtil.java +++ /dev/null @@ -1,264 +0,0 @@ -package com.supersavedriving.user.modular.system.util.weChat; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.stylefeng.guns.modular.system.util.RedisUtil; -import com.stylefeng.guns.modular.system.util.ResultUtil; -import com.stylefeng.guns.modular.system.util.httpClinet.HttpClientUtil; -import com.stylefeng.guns.modular.system.util.httpClinet.HttpResult; -import com.stylefeng.guns.modular.system.util.weChat.model.Category; -import com.stylefeng.guns.modular.system.util.weChat.model.MessageTemplate; -import com.stylefeng.guns.modular.system.util.weChat.model.PubTemplateKeywords; -import com.stylefeng.guns.modular.system.util.weChat.model.PubTemplatetitles; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 订阅消息 - */ -@Component -public class SubscribeMessageUtil { - - @Value("${wx.appletsAppid}") - private String wxAppletsAppid; - - @Autowired - private RedisUtil redisUtil; - - @Autowired - private HttpClientUtil httpClientUtil; - - - /** - * 获取消息类目 - * @return - */ - public ResultUtil<List<Category>> getcategory(){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=" + accessToken; - HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "form"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息类目失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - JSONArray data = jsonObject.getJSONArray("data"); - List<Category> categories = data.toJavaList(Category.class); - return ResultUtil.success(categories); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - - /** - * 获取所属类目下的公共模板 - * @param ids - * @return - */ - public ResultUtil<List<PubTemplatetitles>> getpubtemplatetitles(String ids){ - List<PubTemplatetitles> pubTemplatetitles = new ArrayList<>(); - try { - Integer start = 0; - while (true){ - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=" + accessToken; - Map<String, Object> params = new HashMap<>(); - params.put("ids", ids); - params.put("start", start + ""); - params.put("limit", 30); - HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, params, null, "form"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息类目失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - JSONArray data = jsonObject.getJSONArray("data"); - List<PubTemplatetitles> pubTemplatetitles1 = data.toJavaList(PubTemplatetitles.class); - if(pubTemplatetitles1.size() == 0){ - break; - } - pubTemplatetitles.addAll(pubTemplatetitles1); - start += 30; - } - return ResultUtil.success(pubTemplatetitles); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - - /** - * 获取关键词列表 - * @param tid - * @return - */ - public ResultUtil<List<PubTemplateKeywords>> getpubtemplatekeywords(String tid){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=" + accessToken; - Map<String, Object> params = new HashMap<>(); - params.put("tid", tid); - HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, params, null, "form"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息类目失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - JSONArray data = jsonObject.getJSONArray("data"); - List<PubTemplateKeywords> pubTemplateKeywords = data.toJavaList(PubTemplateKeywords.class); - return ResultUtil.success(pubTemplateKeywords); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - - /** - * 获取个人模板列表 - * @return - */ - public ResultUtil<List<MessageTemplate>> getMessageTemplateList(){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=" + accessToken; - HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "form"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息模板失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - JSONArray data = jsonObject.getJSONArray("data"); - List<MessageTemplate> messageTemplates = data.toJavaList(MessageTemplate.class); - return ResultUtil.success(messageTemplates); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - - /** - * 添加消息模板 - * @param tid 模板标题 id - * @param kidList 开发者自行组合好的模板关键词列表,关键词顺序可以自由搭配(例如 [3,5,4] 或 [4,5,3]),最多支持5个,最少2个关键词组合 - * @param sceneDesc 服务场景描述,15个字以内 - * @return - */ - public ResultUtil<String> addtemplate(String tid, String[] kidList, String sceneDesc){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=" + accessToken; - Map<String, Object> params = new HashMap<>(); - params.put("tid", tid); - params.put("kidList", kidList); - params.put("sceneDesc", sceneDesc); - HttpResult httpResult = httpClientUtil.pushHttpRequset("POST", url, params, null, "json"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息模板失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - String priTmplId = jsonObject.getString("priTmplId"); - return ResultUtil.success(priTmplId); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - - } - - - /** - * 删除模板 - * @param priTmplId 模板id - * @return - */ - public ResultUtil deltemplate(String priTmplId){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token=" + accessToken; - Map<String, Object> params = new HashMap<>(); - params.put("priTmplId", priTmplId); - HttpResult httpResult = httpClientUtil.pushHttpRequset("POST", url, params, null, "json"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息模板失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - return ResultUtil.success(); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - - /** - * 发送消息 - * @param template_id 所需下发的订阅模板id - * @param page 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转 - * @param touser 接收者(用户)的 openid - * @param data 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }的object - * @param miniprogram_state 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 - * @param lang 进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN - * @return - */ - public ResultUtil send(String template_id, String page, String touser, String data, String miniprogram_state, String lang){ - try { - String accessToken = redisUtil.getValue("wxAppletsAccessToken"); - String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken; - Map<String, Object> params = new HashMap<>(); - params.put("template_id", template_id); - params.put("page", page); - params.put("touser", touser); - params.put("data", JSON.parseObject(data)); - params.put("miniprogram_state", miniprogram_state); - params.put("lang", lang); - HttpResult httpResult = httpClientUtil.pushHttpRequset("POST", url, params, null, "json"); - if(httpResult.getCode() != 200){ - return ResultUtil.error("获取消息模板失败"); - } - JSONObject jsonObject = JSON.parseObject(httpResult.getData()); - Integer errcode = jsonObject.getInteger("errcode"); - if(0 != errcode){ - return ResultUtil.error(jsonObject.getString("errmsg")); - } - return ResultUtil.success(); - }catch (Exception e){ - e.printStackTrace(); - return ResultUtil.runErr(); - } - } - - -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/WXBizMsgCryptTest.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/WXBizMsgCryptTest.java deleted file mode 100644 index e8331f6..0000000 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/weChat/WXBizMsgCryptTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.supersavedriving.user.modular.system.util.weChat; - -import org.junit.*; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.io.StringReader; - -import static org.junit.Assert.*; - -public class WXBizMsgCryptTest { - String encodingAesKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG"; - String token = "pamtest"; - String timestamp = "1409304348"; - String nonce = "xxxxxx"; - String appId = "wxb11529c136998cb6"; - String replyMsg = "我是中文abcd123"; - String xmlFormat = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>"; - String afterAesEncrypt = "jn1L23DB+6ELqJ+6bruv21Y6MD7KeIfP82D6gU39rmkgczbWwt5+3bnyg5K55bgVtVzd832WzZGMhkP72vVOfg=="; - String randomStr = "aaaabbbbccccdddd"; - - String replyMsg2 = "<xml><ToUserName><![CDATA[oia2Tj我是中文jewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>"; - String afterAesEncrypt2 = "jn1L23DB+6ELqJ+6bruv23M2GmYfkv0xBh2h+XTBOKVKcgDFHle6gqcZ1cZrk3e1qjPQ1F4RsLWzQRG9udbKWesxlkupqcEcW7ZQweImX9+wLMa0GaUzpkycA8+IamDBxn5loLgZpnS7fVAbExOkK5DYHBmv5tptA9tklE/fTIILHR8HLXa5nQvFb3tYPKAlHF3rtTeayNf0QuM+UW/wM9enGIDIJHF7CLHiDNAYxr+r+OrJCmPQyTy8cVWlu9iSvOHPT/77bZqJucQHQ04sq7KZI27OcqpQNSto2OdHCoTccjggX5Z9Mma0nMJBU+jLKJ38YB1fBIz+vBzsYjrTmFQ44YfeEuZ+xRTQwr92vhA9OxchWVINGC50qE/6lmkwWTwGX9wtQpsJKhP+oS7rvTY8+VdzETdfakjkwQ5/Xka042OlUb1/slTwo4RscuQ+RdxSGvDahxAJ6+EAjLt9d8igHngxIbf6YyqqROxuxqIeIch3CssH/LqRs+iAcILvApYZckqmA7FNERspKA5f8GoJ9sv8xmGvZ9Yrf57cExWtnX8aCMMaBropU/1k+hKP5LVdzbWCG0hGwx/dQudYR/eXp3P0XxjlFiy+9DMlaFExWUZQDajPkdPrEeOwofJb"; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testNormal() throws ParserConfigurationException, SAXException, IOException { - try { - WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); - String afterEncrpt = pc.encryptMsg(replyMsg, timestamp, nonce); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - StringReader sr = new StringReader(afterEncrpt); - InputSource is = new InputSource(sr); - Document document = db.parse(is); - - Element root = document.getDocumentElement(); - NodeList nodelist1 = root.getElementsByTagName("Encrypt"); - NodeList nodelist2 = root.getElementsByTagName("MsgSignature"); - - String encrypt = nodelist1.item(0).getTextContent(); - String msgSignature = nodelist2.item(0).getTextContent(); - String fromXML = String.format(xmlFormat, encrypt); - - // 第三方收到公众号平台发送的消息 - String afterDecrpt = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML); - assertEquals(replyMsg, afterDecrpt); - } catch (AesException e) { - fail("正常流程,怎么就抛出异常了??????"); - } - } - - @Test - public void testAesEncrypt() { - try { - WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); - assertEquals(afterAesEncrypt, pc.encrypt(randomStr, replyMsg)); - } catch (AesException e) { - e.printStackTrace(); - fail("no异常"); - } - } - - @Test - public void testAesEncrypt2() { - try { - WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); - assertEquals(afterAesEncrypt2, pc.encrypt(randomStr, replyMsg2)); - - } catch (AesException e) { - e.printStackTrace(); - fail("no异常"); - } - } - - @Test - public void testIllegalAesKey() { - try { - new WXBizMsgCrypt(token, "abcde", appId); - } catch (AesException e) { - assertEquals(AesException.IllegalAesKey, e.getCode()); - return; - } - fail("错误流程不抛出异常???"); - } - - @Test - public void testValidateSignatureError() throws ParserConfigurationException, SAXException, - IOException { - try { - WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); - String afterEncrpt = pc.encryptMsg(replyMsg, timestamp, nonce); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - StringReader sr = new StringReader(afterEncrpt); - InputSource is = new InputSource(sr); - Document document = db.parse(is); - - Element root = document.getDocumentElement(); - NodeList nodelist1 = root.getElementsByTagName("Encrypt"); - - String encrypt = nodelist1.item(0).getTextContent(); - String fromXML = String.format(xmlFormat, encrypt); - pc.decryptMsg("12345", timestamp, nonce, fromXML); // 这里签名错误 - } catch (AesException e) { - assertEquals(AesException.ValidateSignatureError, e.getCode()); - return; - } - fail("错误流程不抛出异常???"); - } - - @Test - public void testVerifyUrl() throws AesException { - WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("QDG6eK", - "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C", "wx5823bf96d3bd56c7"); - String verifyMsgSig = "5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3"; - String timeStamp = "1409659589"; - String nonce = "263014780"; - String echoStr = "P9nAzCzyDtyTWESHep1vC5X9xho/qYX3Zpb4yKa9SKld1DsH3Iyt3tP3zNdtp+4RPcs8TgAE7OaBO+FZXvnaqQ=="; - wxcpt.verifyUrl(verifyMsgSig, timeStamp, nonce, echoStr); - // 只要不抛出异常就好 - } -} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CommercialWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CommercialWarpper.java new file mode 100644 index 0000000..0855fb9 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CommercialWarpper.java @@ -0,0 +1,24 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CouponWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CouponWarpper.java new file mode 100644 index 0000000..c221b3a --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/CouponWarpper.java @@ -0,0 +1,24 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EditOrderEndAddress.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EditOrderEndAddress.java new file mode 100644 index 0000000..5414384 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EditOrderEndAddress.java @@ -0,0 +1,22 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCosts.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCosts.java new file mode 100644 index 0000000..ce69cd3 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCosts.java @@ -0,0 +1,30 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCostsWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCostsWarpper.java new file mode 100644 index 0000000..d1a1aec --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/EstimatedCostsWarpper.java @@ -0,0 +1,24 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/NearbyDriverWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/NearbyDriverWarpper.java new file mode 100644 index 0000000..fff0616 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/NearbyDriverWarpper.java @@ -0,0 +1,21 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderInfoWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderInfoWarpper.java index 2cd144c..82571d5 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderInfoWarpper.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderInfoWarpper.java @@ -2,488 +2,44 @@ 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; - } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPayment.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPayment.java new file mode 100644 index 0000000..2b70d88 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPayment.java @@ -0,0 +1,20 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPriceWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPriceWarpper.java new file mode 100644 index 0000000..554d3e8 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/OrderPriceWarpper.java @@ -0,0 +1,65 @@ +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; + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/SignInToRegisterWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/SignInToRegisterWarpper.java new file mode 100644 index 0000000..614e350 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/SignInToRegisterWarpper.java @@ -0,0 +1,20 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/StartPriceWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/StartPriceWarpper.java new file mode 100644 index 0000000..baad802 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/StartPriceWarpper.java @@ -0,0 +1,20 @@ +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; +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/TravelOrder.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/TravelOrder.java new file mode 100644 index 0000000..dfff124 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/TravelOrder.java @@ -0,0 +1,35 @@ +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; + +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/UserInfoWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/UserInfoWarpper.java new file mode 100644 index 0000000..fcf7df4 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/UserInfoWarpper.java @@ -0,0 +1,28 @@ +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; +} diff --git a/user/guns-admin/src/main/resources/application.yml b/user/guns-admin/src/main/resources/application.yml index d9d3a87..bca63fa 100644 --- a/user/guns-admin/src/main/resources/application.yml +++ b/user/guns-admin/src/main/resources/application.yml @@ -37,6 +37,7 @@ 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 @@ -83,12 +84,16 @@ 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: --- @@ -122,10 +127,13 @@ #支付回调地址 #正式环境 -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 \ No newline at end of file + +spring: + data: + mongodb: + uri: mongodb://127.0.0.1:27017/admin \ No newline at end of file diff --git a/user/guns-admin/src/test/sql/test.sql b/user/guns-admin/src/test/sql/test.sql new file mode 100644 index 0000000..04b15ca --- /dev/null +++ b/user/guns-admin/src/test/sql/test.sql @@ -0,0 +1,35 @@ +/* + 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; -- Gitblit v1.7.1