From 5ee4dfad6e7b48885e205f8f945276b5d4ca5670 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 18 五月 2023 16:34:27 +0800
Subject: [PATCH] 修改支付

---
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java         |    6 +
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java    |    2 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java       |    2 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml               |    2 
 user/guns-admin/src/main/resources/redis.properties                                                              |   13 +-
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java      |    4 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java         |    6 +
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml          |    2 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java |   14 +++
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java                         |    8 +
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java                     |    4 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java                |    2 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java                       |    4 
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java        |   96 +++++++++++++++++++----
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java                        |   71 +++++++++++++++++
 15 files changed, 204 insertions(+), 32 deletions(-)

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 3fcf80f..77ec4cf 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
@@ -112,7 +112,7 @@
 
     @ResponseBody
     @PostMapping("/base/appUser/queryNearbyDrivers")
-//    @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers")
+    @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers")
     @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"),
@@ -553,7 +553,7 @@
             phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone;
             String value = redisUtil.getValue(phone);
             if(ToolUtil.isEmpty(value) || !value.equals(code)){
-                resultUtil = ResultUtil.error("验证码无效");
+                return ResponseWarpper.success(ResultUtil.error("验证码无效"));
             }
             redisUtil.remove(phone);
             return ResponseWarpper.success(resultUtil);
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
index 8e03a30..9436e1b 100644
--- 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
@@ -39,7 +39,9 @@
     })
     public ResponseWarpper<List<String>> queryBroadcast(){
         try {
-            List<Broadcast> broadcasts = broadcastService.selectList(new EntityWrapper<Broadcast>().eq("status", 1).orderBy("sort desc limit 0, 5"));
+            List<Broadcast> broadcasts = broadcastService.selectList(new EntityWrapper<Broadcast>()
+                    .eq("`status`", 1).eq("`show`", 1)
+                    .eq("`upDown`", 1).orderBy("`sort` desc limit 0, 5"));
             List<String> list = new ArrayList<>();
             for (Broadcast broadcast : broadcasts) {
                 list.add(broadcast.getContent());
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
index 5b37b5e..5f499ee 100644
--- 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
@@ -241,8 +241,8 @@
 
     @ResponseBody
     @PostMapping("/api/order/queryOrderPrice")
-//    @ServiceLog(name = "获取待支付页面订单费用明细", url = "/api/order/queryOrderPrice")
-    @ApiOperation(value = "获取待支付页面订单费用明细", tags = {"用户端-首页"}, notes = "")
+//    @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice")
+    @ApiOperation(value = "获取订单费用明细", tags = {"用户端-首页"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
@@ -611,4 +611,8 @@
             return new ResponseWarpper(500, e.getMessage());
         }
     }
+
+
+
+
 }
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
index b164791..14b1f47 100644
--- 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
@@ -30,7 +30,7 @@
         jumpType,
         jumpUrl,
         html
-        from t_commercial where status = 1
+        from t_commercial where status = 1 and onOffLine = 1
         <if test="null != type">
             and `type` = #{type}
         </if>
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
index 5885545..be52de2 100644
--- 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
@@ -80,7 +80,7 @@
         b.`name` as driverName,
         b.phone as driverPhone,
         b.`code` as driverCode,
-        (DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y')) as driverAge,
+        ifnull(DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y'), 0) 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,
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
index 0320c9d..50486e7 100644
--- 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
@@ -149,4 +149,6 @@
      * @throws Exception
      */
     List<OrderListWarpper> queryNotInvoiceOrder(Integer uid, NotInvoiceOrder notInvoiceOrder) throws Exception;
+
+
 }
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
index cd6adaf..4e071cf 100644
--- 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
@@ -52,4 +52,10 @@
      * @return
      */
     Integer queryUsedCouponNum(Integer uid);
+
+
+    /**
+     * 删除优惠券数据
+     */
+    void delUserCoupon();
 }
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 7264bc4..9db79f1 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
@@ -128,6 +128,7 @@
                 key = token.substring(token.length() - 16);
             }
             redisUtil.setStrValue(key, appUser.getId().toString(), 7 * 24 * 60 * 60);
+            redisUtil.setStrValue("USER_" + appUser.getPhone(), key, 7 * 24 * 60 * 60);
             return token;
         }
         return null;
@@ -204,7 +205,8 @@
      * @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<Coupon> coupons = couponService.selectList(new EntityWrapper<Coupon>().eq("coupon_type", 2)
+                .eq("coupon_state", 1).eq("status", 1).gt("remaining_quantity", 0));
         List<CouponWarpper> list = new ArrayList<>();
         for (Coupon coupon : coupons) {
             UserToCoupon userToCoupon = new UserToCoupon();
diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java
index 9301de9..2432a2f 100644
--- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java
@@ -43,6 +43,6 @@
         complaint.setState(1);
         complaint.setStatus(1);
         complaint.setCreateTime(new Date());
-        this.updateById(complaint);
+        this.insert(complaint);
     }
 }
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
index c2f51f8..cb78e30 100644
--- 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
@@ -1,5 +1,6 @@
 package com.supersavedriving.user.modular.system.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.supersavedriving.user.core.util.ToolUtil;
@@ -64,6 +65,7 @@
         // 构造query对象
         Query query = Query.query(Criteria.where("location").withinSphere(circle));
         List<Location> locations = mongoTemplate.find(query, Location.class);
+//        System.err.println("附近空闲司机" + JSON.toJSONString(locations));
         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) {
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
index fd6c398..af5bc2e 100644
--- 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
@@ -431,6 +431,9 @@
                 return ResultUtil.error("司机还未上班");
             }
             Driver driver = driverService.selectById(travelOrder.getDriverId());
+            if(driver.getServerStatus() == 2){
+                return ResultUtil.error("司机正在服务中");
+            }
             order.setAgentId(driver.getAgentId());
             order.setBranchOfficeId(driver.getBranchOfficeId());
             order.setOrderTakingTime(new Date());
@@ -439,6 +442,7 @@
             driverService.updateById(driver);
 
             appUser.setCancelCount(0);
+            appUser.setIsException(1);
             appUserService.updateById(appUser);
         }
 
@@ -631,6 +635,9 @@
         this.updateById(order);
         AppUser appUser = appUserService.selectById(uid);
         appUser.setCancelCount(appUser.getCancelCount() + 1);
+        if(appUser.getCancelCount() >= 3){
+            appUser.setIsException(2);
+        }
         appUserService.updateById(appUser);
         Driver driver = driverService.selectById(order.getDriverId());
         if(null != driver){
@@ -710,6 +717,14 @@
         Order orderPrice = getOrderPrice(1, d, 0, order1, city);
         order.setEstimatedPrice(orderPrice.getEstimatedPrice());
         this.updateById(order);
+
+        PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper();
+        pushOrderInfoWarpper.setId(order.getId());
+        pushOrderInfoWarpper.setState(order.getState());
+        pushOrderInfoWarpper.setEndAddress(order.getEndAddress());
+        pushOrderInfoWarpper.setEndLat(order.getEndLat());
+        pushOrderInfoWarpper.setEndLng(order.getEndLng());
+        pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
         return ResultUtil.success();
     }
 
@@ -725,20 +740,24 @@
         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();
-            orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
-            orderPriceWarpper.setCouponId(coupon.getId());
+        orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+        orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue());
+        if(null == order.getPayTime()){
+            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();
+                orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
+                orderPriceWarpper.setCouponId(coupon.getId());
+            }
+            orderPriceWarpper.setDiscount(0D);
+            orderPriceWarpper.setDiscountAmount(0D);
+            orderPriceWarpper.setPayType(1);//微信支付
+            orderPriceWarpper.setPayMoney(orderMoney);
         }
-        orderPriceWarpper.setDiscount(0D);
-        orderPriceWarpper.setDiscountAmount(0D);
-        orderPriceWarpper.setPayType(1);//微信支付
-        orderPriceWarpper.setPayMoney(orderMoney);
         return orderPriceWarpper;
     }
 
@@ -758,6 +777,8 @@
         OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper();
         BeanUtils.copyProperties(order, orderPriceWarpper);
         AppUser appUser = appUserService.selectById(uid);
+        orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+        orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue());
         orderPriceWarpper.setBalance(appUser.getAccountBalance());
         orderPriceWarpper.setDiscount(0D);
         orderPriceWarpper.setDiscountAmount(0D);
@@ -766,7 +787,6 @@
         //先算优惠券
         Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney);
         if(null != coupon && null == couponId){
-            orderMoney = orderMoney - coupon.getCouponPreferentialAmount();
             orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
             orderPriceWarpper.setCouponId(coupon.getId());
         }
@@ -777,10 +797,10 @@
             orderPriceWarpper.setDiscountedPrice(coupon1.getCouponPreferentialAmount());
             orderPriceWarpper.setCouponId(couponId);
         }
-        if(payType == 1 && appUser.getHavDiscount() == 1){//使用余额抵扣
+        if(payType == 1 && appUser.getHavDiscount() == 1 && balance >= orderMoney){//使用余额抵扣
             orderPriceWarpper.setDiscount(9D);
-            orderPriceWarpper.setDiscountAmount(orderMoney * 0.1);
-            orderMoney = orderMoney * 0.9;
+            orderPriceWarpper.setDiscountAmount(new BigDecimal(orderMoney * 0.1).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+            orderMoney = new BigDecimal(orderMoney * 0.9).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
         }
         if(payType == 0){//不使用余额抵扣
             orderPriceWarpper.setPayType(1);
@@ -859,10 +879,12 @@
             UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
             if(userToCoupon.getValidCount() > 0){
                 userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
+                userToCouponService.updateById(userToCoupon);
                 Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                 payMoney = payMoney - coupon.getCouponPreferentialAmount();
                 order.setCouponId(coupon.getId());
                 order.setDiscountedPrice(coupon.getCouponPreferentialAmount());
+                userToCouponService.updateById(userToCoupon);
             }
         }
         order.setPayType(1);
@@ -924,10 +946,27 @@
             UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
             if(userToCoupon.getValidCount() > 0){
                 userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
+                userToCouponService.updateById(userToCoupon);
                 Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                 payMoney = payMoney - coupon.getCouponPreferentialAmount();
                 order.setCouponId(coupon.getId());
                 order.setDiscountedPrice(coupon.getCouponPreferentialAmount());
+
+                Driver driver = driverService.selectById(order.getDriverId());
+                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
+                accountChangeDetail.setUserType(2);
+                accountChangeDetail.setUserId(order.getDriverId());
+                accountChangeDetail.setCreateTime(new Date());
+                accountChangeDetail.setOldData(driver.getCouponBalance());
+                accountChangeDetail.setType(1);
+                accountChangeDetail.setChangeType(7);
+                accountChangeDetail.setOrderId(order.getId());
+                accountChangeDetail.setExplain("优惠券收入");
+                driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
+                accountChangeDetail.setNewData(driver.getCouponBalance());
+                driverService.updateById(driver);
+                accountChangeDetailService.insert(accountChangeDetail);
             }
         }
 
@@ -987,6 +1026,7 @@
             UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
             if(userToCoupon.getValidCount() > 0){
                 userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
+                userToCouponService.updateById(userToCoupon);
                 Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                 payMoney = payMoney - coupon.getCouponPreferentialAmount();
                 order.setCouponId(coupon.getId());
@@ -1054,6 +1094,7 @@
             this.updateById(order);
             return ResultUtil.success(payCode);
 
+            // TODO: 2023/5/18 取消支付后需要处理优惠券数据回退
 //
 //
 //            new Thread(new Runnable() {
@@ -1237,6 +1278,25 @@
             List<PlatformRechargeRecord> platformRechargeRecords = platformRechargeRecordService.selectList(new EntityWrapper<PlatformRechargeRecord>().eq("state", 2).last(" and balance > 0 order by payTime"));
             Double discountedPrice = order.getDiscountedPrice();
             Driver driver = driverService.selectById(order.getDriverId());
+
+            UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId());
+            Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
+            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
+            accountChangeDetail.setUserType(2);
+            accountChangeDetail.setUserId(order.getDriverId());
+            accountChangeDetail.setCreateTime(new Date());
+            accountChangeDetail.setOldData(driver.getCouponBalance());
+            accountChangeDetail.setType(1);
+            accountChangeDetail.setChangeType(7);
+            accountChangeDetail.setOrderId(order.getId());
+            accountChangeDetail.setExplain("优惠券收入");
+            driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
+            accountChangeDetail.setNewData(driver.getCouponBalance());
+            driverService.updateById(driver);
+            accountChangeDetailService.insert(accountChangeDetail);
+
+
             for (PlatformRechargeRecord platformRechargeRecord : platformRechargeRecords) {
                 if(discountedPrice == 0){
                     break;
@@ -1661,4 +1721,6 @@
         notInvoiceOrder.setPageNum((notInvoiceOrder.getPageNum() - 1) * notInvoiceOrder.getPageSize());;
         return this.baseMapper.queryNotInvoiceOrder(uid, notInvoiceOrder);
     }
+
+
 }
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
index 1665047..c3b7696 100644
--- 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
@@ -1,5 +1,6 @@
 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.UserToCouponMapper;
 import com.supersavedriving.user.modular.system.model.Coupon;
@@ -62,4 +63,17 @@
     public Integer queryUsedCouponNum(Integer uid) {
         return this.baseMapper.queryUsedCouponNum(uid);
     }
+
+
+    /**
+     * 删除优惠券
+     */
+    @Override
+    public void delUserCoupon() {
+        List<UserToCoupon> userToCoupons = this.selectList(new EntityWrapper<UserToCoupon>().eq("status", 1).last(" and UNIX_TIMESTAMP(expireTime) + 1296000 <= UNIX_TIMESTAMP(now())"));
+        for (UserToCoupon userToCoupon : userToCoupons) {
+            userToCoupon.setStatus(3);
+            this.updateById(userToCoupon);
+        }
+    }
 }
diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java
new file mode 100644
index 0000000..00e6ee1
--- /dev/null
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java
@@ -0,0 +1,71 @@
+package com.supersavedriving.user.modular.system.util;
+
+
+import com.supersavedriving.user.modular.system.service.IUserToCouponService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * 定时任务工具类
+ */
+@Component
+public class TaskUtil {
+
+    @Autowired
+    private IUserToCouponService userToCouponService;
+
+
+
+
+    /**
+     * 每隔一分钟去处理的定时任务
+     */
+    @Scheduled(fixedRate = 1000 * 60)
+    public void taskMinute(){
+        try {
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 每天的凌晨执行的任务
+     */
+    @Scheduled(cron = "0 0 0 * * *")
+    public void taskDay(){
+        try {
+            userToCouponService.delUserCoupon();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+
+    /**
+     * 每月1日凌晨执行的任务
+     */
+    @Scheduled(cron = "0 0 0 1 * *")
+    public void taskMonth1(){
+        try {
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 每月16日凌晨执行的任务
+     */
+    @Scheduled(cron = "0 0 0 16 * *")
+    public void taskMonth16(){
+        try {
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java
index ccff87c..dc76e72 100644
--- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java
@@ -19,6 +19,12 @@
     private Double actualMileage;
     @ApiModelProperty("行驶时间(分钟)")
     private Integer travelTime;
+    @ApiModelProperty("终点地址")
+    private String endAddress;
+    @ApiModelProperty("终点纬度")
+    private String endLat;
+    @ApiModelProperty("终点经度")
+    private String endLng;
     @ApiModelProperty("101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中")
     private Integer state;
 }
diff --git a/user/guns-admin/src/main/resources/redis.properties b/user/guns-admin/src/main/resources/redis.properties
index 8e63a9f..8386340 100644
--- a/user/guns-admin/src/main/resources/redis.properties
+++ b/user/guns-admin/src/main/resources/redis.properties
@@ -1,14 +1,15 @@
 #redis���ÿ�ʼ
 # Redis���ݿ�������Ĭ��Ϊ0��
 spring.redis.database=0
-## Redis��������ַ
-#spring.redis.host=127.0.0.1
-### Redis���������Ӷ˿�
-#spring.redis.port=16379
-### Redis�������������루Ĭ��Ϊ�գ�
-#spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ
 
 ## Redis��������ַ
+#spring.redis.host=127.0.0.1
+## Redis���������Ӷ˿�
+#spring.redis.port=16379
+## Redis�������������루Ĭ��Ϊ�գ�
+#spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ
+
+# Redis��������ַ
 spring.redis.host=127.0.0.1
 # Redis���������Ӷ˿�
 spring.redis.port=6379

--
Gitblit v1.7.1