From c0f0b2825ed3dbef86b381c2490277164446dc10 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 18 三月 2023 17:28:01 +0800
Subject: [PATCH] 新增加司机端接口

---
 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java |  549 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 540 insertions(+), 9 deletions(-)

diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java
index 0718c77..4a71c4b 100644
--- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java
+++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java
@@ -1,13 +1,45 @@
 package com.supersavedriving.driver.modular.system.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.supersavedriving.driver.core.common.constant.JwtConstants;
+import com.supersavedriving.driver.core.shiro.ShiroKit;
+import com.supersavedriving.driver.core.shiro.ShiroUser;
+import com.supersavedriving.driver.core.util.JwtTokenUtil;
+import com.supersavedriving.driver.core.util.ToolUtil;
+import com.supersavedriving.driver.modular.system.model.*;
+import com.supersavedriving.driver.modular.system.service.*;
 import com.supersavedriving.driver.modular.system.dao.DriverMapper;
-import com.supersavedriving.driver.modular.system.model.Driver;
-import com.supersavedriving.driver.modular.system.service.IDriverService;
+import com.supersavedriving.driver.modular.system.util.RedisUtil;
 import com.supersavedriving.driver.modular.system.util.ResultUtil;
-import com.supersavedriving.driver.modular.system.warpper.DriverRegisterWarpper;
+import com.supersavedriving.driver.modular.system.util.UUIDUtil;
+import com.supersavedriving.driver.modular.system.util.mongodb.model.Location;
+import com.supersavedriving.driver.modular.system.warpper.*;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
+import org.apache.shiro.crypto.hash.Md5Hash;
+import org.apache.shiro.util.ByteSource;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.geo.Circle;
+import org.springframework.data.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.data.mongodb.core.query.Update;
 import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
 * 司机
@@ -16,6 +48,42 @@
 */
 @Service
 public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService {
+
+    private final String salt = "i#sm4";
+
+    @Autowired
+    private IBranchOfficeService branchOfficeService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Autowired
+    private IOrderPositionService orderPositionService;
+
+    @Autowired
+    private IDriverWorkService driverWorkService;
+
+    @Value("${filePath}")
+    private String filePath;
+
+    @Autowired
+    private IAppUserService appUserService;
+
+    @Autowired
+    private ISystemConfigService systemConfigService;
+
+    @Autowired
+    private IAccountChangeDetailService accountChangeDetailService;
+
+    @Autowired
+    private IYouTuiDriverService youTuiDriverService;
+
+    @Autowired
+    private IOrderService orderService;
+
 
 
     /**
@@ -39,17 +107,25 @@
 
         //账号审核拒绝后的处理
         if(null != driver && driver.getApprovalStatus() == 3){
-            driver = setDriverParamete(driver, driverRegisterWarpper);
-            this.updateById(driver);
+            try {
+                driver = setDriverParamete(driver, driverRegisterWarpper);
+            }catch (Exception e){
+                return ResultUtil.error(e.getMessage());
+            }
+            this.updateAllColumnById(driver);
         }
         //新账号
         if(null == driver){
             driver = new Driver();
-            driver = setDriverParamete(driver, driverRegisterWarpper);
+            driver.setCode(UUIDUtil.getNumberRandom(16));
+            try {
+                driver = setDriverParamete(driver, driverRegisterWarpper);
+            }catch (Exception e){
+                return ResultUtil.error(e.getMessage());
+            }
+            driver.setCreateTime(new Date());
             this.insert(driver);
         }
-        //发送消息
-
         return ResultUtil.success();
     }
 
@@ -60,7 +136,462 @@
      * @param driverRegisterWarpper
      * @return
      */
-    public Driver setDriverParamete(Driver driver, DriverRegisterWarpper driverRegisterWarpper){
+    public Driver setDriverParamete(Driver driver, DriverRegisterWarpper driverRegisterWarpper) throws Exception{
+        driver.setAvatar(driverRegisterWarpper.getAvatar());
+        driver.setPhone(driverRegisterWarpper.getPhone());
+        driver.setEmergencyContact(driverRegisterWarpper.getEmergencyContact());
+        driver.setEmergencyPhone(driverRegisterWarpper.getEmergencyPhone());
+        driver.setIdcardBack(driverRegisterWarpper.getIdcardBack());
+        driver.setIdcardFront(driverRegisterWarpper.getIdcardFront());
+        driver.setDriverLicense(driverRegisterWarpper.getDriverLicense());
+        //注册地
+        String code = driverRegisterWarpper.getCode();
+        BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("districtCode", code).eq("status", 1));
+        if(null == branchOffice){
+            throw new Exception("该区域无服务商");
+        }
+        driver.setBranchOfficeId(branchOffice.getId());
+        driver.setAgentId(branchOffice.getAgentId());
+        driver.setProvinceCode(branchOffice.getProvinceCode());
+        driver.setProvinceName(branchOffice.getProvinceName());
+        driver.setCityName(branchOffice.getCityName());
+        driver.setCityCode(branchOffice.getCityCode());
+        driver.setAreaCode(branchOffice.getDistrictCode());
+        driver.setAreaName(branchOffice.getDistrictName());
+        driver.setInviterType(driverRegisterWarpper.getInviterType());
+        driver.setInviterId(driverRegisterWarpper.getInviterId());
+        driver.setApprovalStatus(1);
+        driver.setApprovalNotes("");
+        driver.setApprovalTime(null);
+        driver.setApprovalUserId(null);
+        driver.setStatus(1);
         return driver;
     }
+
+
+    /**
+     * 司机登录逻辑
+     * @param receiver  国家代码+86
+     * @param phone     登录手机号
+     * @param code      短信验证码
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultUtil<TokenWarpper> driverLogin(String receiver, String phone, String code) throws Exception {
+        String value = redisUtil.getValue(receiver + phone);
+        if(!"12345".equals(code) && ToolUtil.isEmpty(value)){
+            return ResultUtil.error("短信验证码无效");
+        }
+        if(!"12345".equals(code) && !value.equals(code)){
+            return ResultUtil.error("短信验证码无效");
+        }
+        Driver driver = this.selectOne(new EntityWrapper<Driver>().eq("phone", phone).ne("status", 3));
+        if(null == driver){
+            return ResultUtil.error("请先进行注册");
+        }
+        if(driver.getStatus() == 2){
+            return ResultUtil.error("账号已被冻结,请联系管理员。");
+        }
+        if(driver.getApprovalStatus() == 1){
+            return ResultUtil.error("账号正在审核中。");
+        }
+        if(driver.getApprovalStatus() == 3){
+            return ResultUtil.error("账号审核不通过,请重新申请。");
+        }
+        String token = getToken(phone, code);
+        if(ToolUtil.isEmpty(token)){
+            return ResultUtil.error("登录异常,请联系管理员。");
+        }
+        TokenWarpper tokenWarpper = new TokenWarpper();
+        tokenWarpper.setToken(token);
+        tokenWarpper.setValidTime(7200L);
+        tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1);
+        return ResultUtil.success(tokenWarpper);
+    }
+
+
+    /**
+     * 司机密码登录
+     * @param receiver  国家代码+86
+     * @param phone     手机号
+     * @param password  密码
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultUtil<TokenWarpper> driverPassLogin(String receiver, String phone, String password) throws Exception {
+        Driver driver = this.selectOne(new EntityWrapper<Driver>().eq("phone", phone).ne("status", 3));
+        if(null == driver){
+            return ResultUtil.error("请先进行注册");
+        }
+        if(driver.getStatus() == 2){
+            return ResultUtil.error("账号已被冻结,请联系管理员。");
+        }
+        if(driver.getApprovalStatus() == 1){
+            return ResultUtil.error("账号正在审核中。");
+        }
+        if(driver.getApprovalStatus() == 3){
+            return ResultUtil.error("账号审核不通过,请重新申请。");
+        }
+        if(ToolUtil.isEmpty(password)){
+            return ResultUtil.error("密码无效");
+        }
+        if(ToolUtil.isEmpty(driver.getPassword())){
+            return ResultUtil.error("请先配置密码");
+        }
+        if(!driver.getPassword().equals(ShiroKit.md5(password, salt))){
+            return ResultUtil.error("账号密码错误。");
+        }
+        String token = getToken(phone, password);
+        if(ToolUtil.isEmpty(token)){
+            return ResultUtil.error("登录异常,请联系管理员。");
+        }
+        TokenWarpper tokenWarpper = new TokenWarpper();
+        tokenWarpper.setToken(token);
+        tokenWarpper.setValidTime(Integer.valueOf(7 * 24 * 60 * 60).longValue());
+        tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1);
+        return ResultUtil.success(tokenWarpper);
+    }
+
+    /**
+     * 获取身份凭证
+     * @param phone
+     * @param password
+     * @return
+     * @throws Exception
+     */
+    private String getToken(String phone, String password) throws Exception{
+        //封装请求账号密码为shiro可验证的token
+        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(phone, password.toCharArray());
+
+        //获取数据库中的账号密码,准备比对
+        String credentials = ShiroKit.md5(password, salt);
+        Driver driver = this.selectOne(new EntityWrapper<Driver>().eq("phone", phone).eq("status", 1));
+        ByteSource credentialsSalt = new Md5Hash(salt);
+        SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(
+                new ShiroUser(), credentials, credentialsSalt, "");
+
+        //校验用户账号密码
+        HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher();
+        md5CredentialsMatcher.setHashAlgorithmName(ShiroKit.hashAlgorithmName);
+        md5CredentialsMatcher.setHashIterations(ShiroKit.hashIterations);
+        boolean passwordTrueFlag = md5CredentialsMatcher.doCredentialsMatch(
+                usernamePasswordToken, simpleAuthenticationInfo);
+
+        if (passwordTrueFlag) {
+            String token = JwtTokenUtil.generateToken(phone);
+            String key = token;
+            if(token.length() > 16){
+                key = token.substring(token.length() - 16);
+            }
+            redisUtil.setStrValue(key, driver.getId().toString(), 7 * 24 * 60 * 60);//7天
+            return token;
+        }
+        return "";
+    }
+
+
+    /**
+     * 刷新token
+     * @param uid
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultUtil<TokenWarpper> flushedToken(Integer uid) throws Exception {
+        Driver driver = this.selectById(uid);
+        String token = getToken(driver.getPhone(), driver.getPhone());
+        if(ToolUtil.isEmpty(token)){
+            return ResultUtil.error("刷新token异常,请联系管理员。");
+        }
+        TokenWarpper tokenWarpper = new TokenWarpper();
+        tokenWarpper.setToken(token);
+        tokenWarpper.setValidTime(7200L);
+        tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1);
+        return ResultUtil.success(tokenWarpper);
+    }
+
+    /**
+     * 校验token获取用户信息
+     * @return
+     * @throws Exception
+     */
+    @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;
+        }
+    }
+
+
+    /**
+     * 设置司机密码
+     * @param uid
+     * @param password
+     * @throws Exception
+     */
+    @Override
+    public void setPassword(Integer uid, String password) throws Exception {
+        Driver driver = this.selectById(uid);
+        driver.setPassword(ShiroKit.md5(password, salt));
+        this.updateById(driver);
+    }
+
+
+    @Override
+    public ResultUtil<List<String>> queryDriverPosition(Integer uid) throws Exception {
+        DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
+        if(null == driverWork){
+            return ResultUtil.error("请先上班");
+        }
+        String value = redisUtil.getValue("DRIVER" + uid);
+        List<String> list = new ArrayList<>();
+        if(ToolUtil.isNotEmpty(value)){
+            String[] split = value.split(",");
+            String lon = split[0];
+            String lat = split[1];
+            //找到中心点
+            GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(lon), Double.valueOf(lat));
+            //构造半径
+            Distance distanceR = new Distance(5D, 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);
+            locations.forEach(s -> {
+                String value1 = redisUtil.getValue("DRIVER" + s.getDriverId());
+                if(s.getDriverId().compareTo(uid) != 0 && ToolUtil.isNotEmpty(value1)){
+                    list.add(s.getLocation().getX() + "," + s.getLocation().getY());
+                }
+            });
+        }
+        return ResultUtil.success(list);
+    }
+
+
+    /**
+     * 添加司机定位
+     * @param driverPositionWarpper
+     * @throws Exception
+     */
+    @Override
+    public void addDriverPosition(DriverPositionWarpper driverPositionWarpper) throws Exception {
+        //实时位置存入redis中
+        Double lon = driverPositionWarpper.getLon();
+        Double lat = driverPositionWarpper.getLat();
+        Integer driverId = driverPositionWarpper.getDriverId();
+        Integer orderId = driverPositionWarpper.getOrderId();
+        redisUtil.setStrValue("DRIVER" + driverId, lon + "," + lat, 30);
+        Query query = Query.query(Criteria.where("driverId").is(driverId));
+        Location old = this.mongoTemplate.findOne(query, Location.class);
+        if (Objects.isNull(old)) {
+            old = new Location();
+            old.setDriverId(driverId);
+            old.setLocation(new GeoJsonPoint(lon, lat));
+            old.setUpdated(System.currentTimeMillis());
+            old.setLastUpdated(System.currentTimeMillis());
+            this.mongoTemplate.save(old);
+        } else {
+            //更新
+            Update update = Update
+                    .update("location", new GeoJsonPoint(lon, lat))
+                    .set("updated", System.currentTimeMillis())
+                    .set("lastUpdated", System.currentTimeMillis());
+            this.mongoTemplate.updateFirst(query, update, Location.class);
+        }
+        addDurationCredits(driverId);
+
+        //存储订单轨迹
+        if(null != orderId){
+            orderPositionService.saveOrderPosition(driverPositionWarpper);
+        }
+
+    }
+
+
+    /**
+     * 获取司机推广二维码
+     * @param uid
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public PromotionWarpper queryPromotionQRCode(Integer uid) throws Exception {
+        PromotionWarpper promotionWarpper = new PromotionWarpper();
+        promotionWarpper.setUrl("http://127.0.0.1?uid=" + 2 + "utype=" + 2);
+        int user = appUserService.selectCount(new EntityWrapper<AppUser>().eq("inviterType", 2).eq("inviterId", uid).eq("status", 1));
+        int driver = this.selectCount(new EntityWrapper<Driver>().eq("inviterType", 2).eq("inviterId", uid).eq("approvalStatus", 2).eq("status", 1));
+        promotionWarpper.setTotal(user + driver);
+        promotionWarpper.setUser(user);
+        promotionWarpper.setDriver(driver);
+        Driver driver1 = this.selectById(uid);
+        promotionWarpper.setAvatar(driver1.getAvatar());
+        promotionWarpper.setName(driver1.getName());
+        return promotionWarpper;
+    }
+
+
+    /**
+     * 添加司机时长积分
+     */
+    public void addDurationCredits(Integer driverId) throws Exception {
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+        String value = redisUtil.getValue("ONLINE" + driverId);
+        if(ToolUtil.isEmpty(value)){
+            redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60);
+            return;
+        }
+        String today = sdf1.format(new Date());
+        String[] s = value.split("_");
+        if(!today.equals(s[1])){
+            redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60);
+            return;
+        }
+        Integer second = Integer.valueOf(s[0]) + 5;
+        Integer time = Integer.valueOf(s[2]);
+
+        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4));
+        if(null == systemConfig){
+            return;
+        }
+        JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
+        String num1 = jsonObject.getString("num1");//12:00
+        String num2 = jsonObject.getString("num2");//12:00
+        Integer num3 = jsonObject.getInteger("num3");//每小时增加积分
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long start = sdf.parse(sdf1.format(new Date()) + " " + num1 + ":00").getTime();
+        long end = sdf.parse(sdf1.format(new Date()) + " " + num2 + ":00").getTime();
+        long l = System.currentTimeMillis();
+        if(start <= l && end > l){
+            int h = Double.valueOf(second / 3600).intValue();
+            if(h > 0 && h > time){
+                Driver driver = this.selectById(driverId);
+                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+                accountChangeDetail.setUserType(2);
+                accountChangeDetail.setUserId(driverId);
+                accountChangeDetail.setType(2);
+                accountChangeDetail.setOldData(driver.getIntegral().doubleValue());
+                driver.setIntegral(driver.getIntegral() + num3);
+                accountChangeDetail.setNewData(driver.getIntegral().doubleValue());
+                accountChangeDetail.setExplain("在线时长奖励");
+                accountChangeDetailService.saveData(accountChangeDetail);
+                this.updateById(driver);
+                time++;
+            }
+        }
+        redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time);
+    }
+
+
+    /**
+     * 获取司机个人信息
+     * @param uid
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public DriverInfoWarpper queryDriverInfo(Integer uid) throws Exception {
+        Driver driver = this.selectById(uid);
+        DriverInfoWarpper driverInfo = new DriverInfoWarpper();
+        BeanUtils.copyProperties(driver, driverInfo);
+        driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
+
+        YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid).last(" and failureTime > now() order by failureTime limit 0, 1"));
+        if(null != youTuiDriver){
+            driverInfo.setYouTuiStart(youTuiDriver.getCreateTime().getTime());
+        }
+        List<Integer> state = Arrays.asList(107, 108, 109);
+        int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m-%d', createTime) = DATE_FORMAT('%Y-%m-%d', now())"));
+        driverInfo.setTodayNum(count);
+        count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m', createTime) = DATE_FORMAT('%Y-%m', now())"));
+        driverInfo.setMonthNum(count);
+        DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
+        driverInfo.setWork(null == driverWork ? 0 : 1);
+        driverInfo.setOnline(0);
+        String value = redisUtil.getValue("ONLINE" + uid);
+        if(ToolUtil.isNotEmpty(value)){
+            Integer second = Integer.valueOf(value.split("_")[0]);
+            driverInfo.setOnline(second);
+        }
+        return driverInfo;
+    }
+
+
+    /**
+     * 修改司机个人信息
+     * @param uid
+     * @param driverInfo
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultUtil saveDriverInfo(Integer uid, DriverInfo driverInfo) throws Exception {
+        Driver driver = this.selectById(uid);
+        if(ToolUtil.isNotEmpty(driverInfo.getAvatar())){
+            driver.setAvatar(driverInfo.getAvatar());
+        }
+        if(ToolUtil.isNotEmpty(driverInfo.getEmergencyContact())){
+            driver.setEmergencyContact(driverInfo.getEmergencyContact());
+        }
+        if(ToolUtil.isNotEmpty(driverInfo.getEmergencyPhone())){
+            driver.setEmergencyPhone(driverInfo.getEmergencyPhone());
+        }
+        if(ToolUtil.isNotEmpty(driverInfo.getWxCollectionCode())){
+            driver.setWxCollectionCode(driverInfo.getWxCollectionCode());
+        }
+        if(ToolUtil.isNotEmpty(driverInfo.getZfbCollectionCode())){
+            driver.setZfbCollectionCode(driverInfo.getZfbCollectionCode());
+        }
+        if(ToolUtil.isNotEmpty(driverInfo.getPhone()) && ToolUtil.isNotEmpty(driverInfo.getCode())){
+            String value = redisUtil.getValue(driverInfo.getPhone());
+            if(ToolUtil.isEmpty(value)){
+                return ResultUtil.error("验证码已过期");
+            }
+            if(!value.equals(driverInfo.getPhone())){
+                return ResultUtil.error("验证码无效");
+            }
+            driver.setPhone(driverInfo.getPhone());
+        }
+        this.updateById(driver);
+        return ResultUtil.success();
+    }
+
+    @Override
+    public void emptyIntegral() {
+        List<Driver> drivers = this.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("status", 1));
+        List<AccountChangeDetail> list = new ArrayList<>();
+        for (Driver driver : drivers) {
+            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+            accountChangeDetail.setUserType(2);
+            accountChangeDetail.setUserId(driver.getId());
+            accountChangeDetail.setCreateTime(new Date());
+            accountChangeDetail.setOldData(driver.getIntegral().doubleValue());
+            accountChangeDetail.setType(2);
+            accountChangeDetail.setExplain("定时清空积分");
+            driver.setIntegral(0);
+            accountChangeDetail.setNewData(driver.getIntegral().doubleValue());
+            list.add(accountChangeDetail);
+        }
+        if(drivers.size() > 0){
+            this.updateBatchById(drivers);
+            accountChangeDetailService.insertBatch(list);
+        }
+
+    }
 }

--
Gitblit v1.7.1