puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
修改bug
22个文件已修改
2052 ■■■■■ 已修改文件
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/api/DriverController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/dao/mapping/RechargeRecordMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/model/RechargeRecord.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/IDriverWorkService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/DriverServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java 327 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/util/PayMoneyUtil.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/util/TaskUtil.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/warpper/DriverRegisterWarpper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/THomePageController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TOrderController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/UploadUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml 107 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITDriverService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/webapp/WEB-INF/view/blackboardBlank.html 1162 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/guns-admin/src/main/webapp/WEB-INF/view/system/tOrder/tOrder_add.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user/guns-admin/src/main/java/com/agentdriving/user/modular/system/service/impl/AppUserServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
user/guns-admin/src/main/java/com/agentdriving/user/modular/system/service/impl/OrderServiceImpl.java 312 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/api/DriverController.java
@@ -718,6 +718,8 @@
                PrintWriter out;
                out = response.getWriter();
                out.println("success"); // 请不要修改或删除
                out.flush();
                out.close();
            }
        }catch (Exception e){
            e.printStackTrace();
@@ -863,7 +865,7 @@
                return ResponseWarpper.success();
            }
            ResultUtil resultUtil = ResultUtil.success();
            phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone;
            phone = "+86" + phone;
            String value = redisUtil.getValue(phone);
            if(ToolUtil.isEmpty(value) || !value.equals(code)){
                resultUtil = ResultUtil.error("验证码无效");
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml
@@ -72,7 +72,7 @@
        UNIX_TIMESTAMP(createTime) * 1000 as createTime,
        (newData - oldData) as amount,
        newData as balance
        from t_account_change_detail where userType = 2 and userId = #{driverId} and changeType in (1, 3, 4, 7, 8)
        from t_account_change_detail where userType = 2 and userId = #{driverId} and changeType in (1, 3, 4, 7, 8, 9, 10)
        <if test="null != time and '' != time">
            and DATE_FORMAT(createTime, '%Y年%m月') = #{time}
        </if>
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/dao/mapping/RechargeRecordMapper.xml
@@ -6,6 +6,7 @@
    <resultMap id="BaseResultMap" type="com.agentdriving.driver.modular.system.model.RechargeRecord">
        <id column="id" property="id" />
        <result column="type" property="type" />
        <result column="payMethod" property="payMethod"/>
        <result column="userId" property="userId" />
        <result column="code" property="code" />
        <result column="amount" property="amount"/>
@@ -15,5 +16,6 @@
        <result column="orderNumber" property="orderNumber" />
        <result column="createTime" property="createTime" />
        <result column="agentId" property="agentId" />
        <result column="remark" property="remark"/>
    </resultMap>
</mapper>
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/model/RechargeRecord.java
@@ -27,6 +27,11 @@
    @TableField("type")
    private Integer type;
    /**
     * 支付方式(1=微信,2=支付宝)
     */
    @TableField("payMethod")
    private Integer payMethod;
    /**
     * 用户id
     */
    @TableField("userId")
@@ -71,4 +76,9 @@
     */
    @TableField("agentId")
    private Integer agentId;
    /**
     * 备注
     */
    @TableField("remark")
    private String remark;
}
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/IDriverWorkService.java
@@ -24,4 +24,10 @@
     * @throws Exception
     */
    ResultUtil driverOffWork(Integer driverId, Long onlineTime) throws Exception;
    /**
     * 定时任务检查司机余额是否充足
     */
    void taskDriverOffWork();
}
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/DriverServiceImpl.java
@@ -127,11 +127,13 @@
        //账号审核拒绝后的处理
        if(null != driver && driver.getApprovalStatus() == 3){
            try {
                driver = new Driver();
                driver = setDriverParamete(driver, driverRegisterWarpper);
                driver.setCreateTime(new Date());
            }catch (Exception e){
                return ResultUtil.error(e.getMessage());
            }
            this.updateAllColumnById(driver);
            this.insert(driver);
        }
        //新账号
        if(null == driver){
@@ -188,7 +190,7 @@
        driver.setIdcard(driverRegisterWarpper.getIdcard());
        driver.setIdcardBack(driverRegisterWarpper.getIdcardBack());
        driver.setIdcardFront(driverRegisterWarpper.getIdcardFront());
        driver.setDriverLicenseNumber(driverRegisterWarpper.getDriverLicenseNumber());
        driver.setDriverLicenseNumber(driverRegisterWarpper.getIdcard());
        driver.setDriverLicense(driverRegisterWarpper.getDriverLicense());
        driver.setFirstCertificateTime(driverRegisterWarpper.getFirstCertificateTime());
        //注册地
@@ -227,6 +229,9 @@
     */
    @Override
    public ResultUtil<TokenWarpper> driverLogin(String receiver, String phone, String code) throws Exception {
        if(ToolUtil.isEmpty(receiver)){
            receiver = "+86";
        }
        String value = redisUtil.getValue(receiver + phone);
        if(!"12345".equals(code) && ToolUtil.isEmpty(value)){
            return ResultUtil.error("短信验证码无效");
@@ -693,6 +698,7 @@
        String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3);
        RechargeRecord rechargeRecord = new RechargeRecord();
        rechargeRecord.setType(2);
        rechargeRecord.setPayMethod(type);
        rechargeRecord.setUserId(uid);
        rechargeRecord.setCode(out_trade_no);
        rechargeRecord.setAmount(amount);
@@ -738,10 +744,14 @@
                                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)){
                                    rechargeRecordService.deleteById(rechargeRecord1.getId());
                                    rechargeRecord1.setRemark(trade_state);
                                    rechargeRecordService.updateById(rechargeRecord1);
                                    return;
                                }
                                if("SUCCESS".equals(trade_state)){
                                    rechargeRecord1.setRemark("SUCCESS");
                                    rechargeRecordService.updateById(rechargeRecord1);
                                    Driver driver1 = DriverServiceImpl.this.selectById(uid);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setUserType(2);
@@ -772,7 +782,8 @@
                                num++;
                            }
                            if(10 == num){
                                rechargeRecordService.deleteById(rechargeRecord1.getId());
                                rechargeRecord1.setRemark("支付超时");
                                rechargeRecordService.updateById(rechargeRecord1);
                            }
                        }
                    }catch (Exception e){
@@ -814,10 +825,13 @@
                                String tradeStatus = map.get("tradeStatus");
                                String tradeNo = map.get("tradeNo");
                                if("TRADE_CLOSED".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)){
                                    rechargeRecordService.deleteById(rechargeRecord1.getId());
                                    rechargeRecord1.setRemark(tradeStatus);
                                    rechargeRecordService.updateById(rechargeRecord1);
                                    return;
                                }
                                if("TRADE_SUCCESS".equals(tradeStatus)){
                                    rechargeRecord1.setRemark("TRADE_SUCCESS");
                                    rechargeRecordService.updateById(rechargeRecord1);
                                    Driver driver1 = DriverServiceImpl.this.selectById(uid);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setUserType(2);
@@ -848,7 +862,8 @@
                                num++;
                            }
                            if(10 == num){
                                rechargeRecordService.deleteById(rechargeRecord1.getId());
                                rechargeRecord1.setRemark("支付超时");
                                rechargeRecordService.updateById(rechargeRecord1);
                            }
                        }
                    }catch (Exception e){
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java
@@ -116,4 +116,20 @@
        driverService.updateById(driver);
        return ResultUtil.success();
    }
    @Override
    public void taskDriverOffWork() {
        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 6));
        Double num1 = JSON.parseObject(systemConfig.getContent()).getDouble("num1");
        List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("status", 1).lt("balance", num1));
        for (Driver driver : drivers) {
            DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver.getId()).eq("status", 1));
            if(null != driverWork){
                driverWork.setStatus(2);
                driverWork.setOffWorkTime(new Date());
                this.updateById(driverWork);
            }
        }
    }
}
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java
@@ -23,6 +23,8 @@
import com.agentdriving.driver.modular.system.warpper.AddOrderWarpper;
import com.agentdriving.driver.modular.system.warpper.HallOrderList;
import com.agentdriving.driver.modular.system.warpper.OrderInfoWarpper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Circle;
@@ -48,6 +50,8 @@
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
    Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
    @Autowired
    private IDriverWorkService driverWorkService;
@@ -210,7 +214,7 @@
            new Thread(new Runnable() {
                @Override
                public void run() {
                    pushOrder(finalOrder);
                    pushOrder(finalOrder.getId());
                }
            }).start();
        }
@@ -461,17 +465,17 @@
    /**
     * 订单推送逻辑
     * @param order
     */
    public void pushOrder(Order order){
        /**
         * 1.先找最大推单范围内的优推司机 -》 距离最近
         * 没有1 - 》
         *      2.按照后台推送配置在范围内查找合适司机
         *        合适司:积分 > 评分 > 距离
         *      3.司机没有接单直接将订单置入大厅
         */
    public void pushOrder(Long orderId){
        try {
            Order order = this.selectById(orderId);
            /**
             * 1.先找最大推单范围内的优推司机 -》 距离最近
             * 没有1 - 》
             *      2.按照后台推送配置在范围内查找合适司机
             *        合适司:积分 > 评分 > 距离
             *      3.司机没有接单直接将订单置入大厅
             */
            boolean lock = redisUtil.lock(5);
            if(!lock){
                int num1 = 1;
@@ -486,11 +490,10 @@
                }
            }
            if(!lock){
                redisUtil.unlock();
                order.setHallOrder(1);
                this.updateById(order);
                ExtraPushOrder(order);
                return;
                redisUtil.unlock();
            }
            SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1));
            if(null == systemConfig){
@@ -519,14 +522,18 @@
            YouTuiDriver youTuiDriver1 = null;
            if(driverIds.size() > 0){
                List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds)
                        .eq("state", 2).last(" and (surplusQuantity > 0 or now() < endTime) and now() < failureTime"));
                        .eq("state", 2).last(" and surplusQuantity > 0 and now() < endTime and now() < failureTime"));
                Double d = null;
                for (YouTuiDriver youTuiDriver : youTuiDrivers) {
                    String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId());
                    if(ToolUtil.isEmpty(value)){
                        continue;
                    }
                    DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", youTuiDriver.getDriverId()).eq("status", 1));
                    Driver driver1 = driverService.selectById(youTuiDriver.getDriverId());
                    if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1){
                        continue;
                    }
                    DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1));
                    if(null == driverWork){
                        continue;
                    }
@@ -539,7 +546,6 @@
                    }
                }
            }
            if(null != youTuiDriver1 && youTuiDriver1.getType() == 1){
                youTuiDriver1.setSurplusQuantity(youTuiDriver1.getSurplusQuantity() - 1);
                youTuiDriverService.updateById(youTuiDriver1);
@@ -562,13 +568,14 @@
                    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));
                        List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2)
                                .eq("serverStatus", 1).eq("openOrderQRCode", 0).eq("status", 1).in("id", driverIds));
                        if(drivers.size() == 0){
                            continue;
                        }
                        Integer integral = null;
                        Double score = null;
                        Integer integral = null;//积分
                        Double score = null;//评分
                        Double d = null;
                        for (Driver driver1 : drivers) {
                            String value = redisUtil.getValue("DRIVER" + driver1.getId());
@@ -579,24 +586,32 @@
                            if(null == driverWork){
                                continue;
                            }
                            if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大
                                integral = driver1.getIntegral();
                                score = driver1.getScore();
                                driver = driver1.getId();
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                d = wgs84;
                                continue;
                            }
                            if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分
                                integral = driver1.getIntegral();
                                score = driver1.getScore();
                                driver = driver1.getId();
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                d = wgs84;
                                continue;
                            }
                            if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                if(d == null || d.compareTo(wgs84) > 0){
                                if(d.compareTo(wgs84) > 0){
                                    d = wgs84;
                                    integral = driver1.getIntegral();
                                    score = driver1.getScore();
                                    driver = driver1.getId();
                                    continue;
                                }
@@ -608,25 +623,32 @@
            }
            if(null != driver){
                //防止多笔订单推给一个司机
                Driver driver1 = driverService.selectById(driver);
                driver1.setServerStatus(2);
                driverService.updateById(driver1);
                pushUtil.pushGrabOrder(driver, 2, order.getId(), num4);
                //创建定时任务处理订单到大厅
                new Timer().schedule(new TimerTask() {
                    @Override
                    public void run() {
                        driver1.setServerStatus(1);
                        driverService.updateById(driver1);
                        Order order1 = OrderServiceImpl.this.selectById(order.getId());
                        if(order1.getState() == 101 || order1.getState() == 201){
                        if(order1.getState() != 101 && order1.getState() != 201 && order1.getState() != 301 && order1.getDriverId().compareTo(driver1.getId()) != 0){
                            driver1.setServerStatus(1);
                            driverService.updateById(driver1);
                        }
                        if(order1.getState() == 201 || order1.getState() == 301 || (order1.getState() == 101 && null == order1.getDriverId())){
                            driver1.setServerStatus(1);
                            driverService.updateById(driver1);
                        }
                        if(order1.getState() == 201 || (order1.getState() == 101 && null == order1.getDriverId())){
                            order1.setHallOrder(1);
                            OrderServiceImpl.this.updateById(order1);
                            ExtraPushOrder(order1);
                            ExtraPushOrder(order);
                        }
                    }
                }, num4 * 1000);
            }else{
@@ -636,10 +658,9 @@
            }
            redisUtil.unlock();
        }catch (Exception e){
            redisUtil.unlock();
            e.printStackTrace();
            redisUtil.unlock();
        }
    }
@@ -1142,7 +1163,7 @@
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushOrder(finalOrder);
                pushOrder(finalOrder.getId());
            }
        }).start();
        return ResultUtil.success();
@@ -1297,6 +1318,17 @@
     */
    @Override
    public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer payType, Integer state) throws Exception {
        if(108 == state){
            String value = redisUtil.getValue("repeat_" + orderId.toString());
            if(ToolUtil.isEmpty(value)){
                redisUtil.setStrValue("repeat_" + orderId, System.currentTimeMillis() + "", 10 * 60);
            }else{
                Long s = System.currentTimeMillis() - Long.valueOf(value);
                if(s < 60000){//1分钟
                    return ResultUtil.error("数据处理中");
                }
            }
        }
        List<Integer> s = Arrays.asList(107, 108);
        if(!s.contains(state)){
            return ResultUtil.error("操作失败");
@@ -1356,6 +1388,9 @@
        if(null != order.getUserId()){
            pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState());
        }
        if(108 == state){
            redisUtil.remove("repeat_" + orderId.toString());
        }
        return ResultUtil.success();
    }
@@ -1370,63 +1405,113 @@
        Driver driver = driverService.selectById(order.getDriverId());
        AppUser appUser = appUserService.selectById(order.getUserId());
        //司机推荐首单收入
        List<Integer> state = Arrays.asList(108, 109);
        int count = this.selectCount(new EntityWrapper<Order>().eq("userId", order.getUserId()).eq("status", 1).in("state", state));
        if(null != appUser.getInviterType() && appUser.getInviterType() == 2 && count == 1){
            Driver driver1 = driverService.selectById(appUser.getInviterId());
            //首单积分奖励
            SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4));
            JSONObject jsonObject2 = JSON.parseObject(systemConfig1.getContent());
            Integer num4 = jsonObject2.getInteger("num4");
            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
            accountChangeDetail.setUserType(2);
            accountChangeDetail.setUserId(driver1.getId());
            accountChangeDetail.setType(2);
            accountChangeDetail.setChangeType(5);
            accountChangeDetail.setOrderId(order.getId());
            accountChangeDetail.setOldData(driver1.getIntegral().doubleValue());
            accountChangeDetail.setExplain("邀请用户首单积分奖励");
            accountChangeDetail.setCreateTime(new Date());
            driver1.setIntegral(driver1.getIntegral() + num4);
            accountChangeDetail.setNewData(driver1.getIntegral().doubleValue());
            accountChangeDetailService.insert(accountChangeDetail);
            driverService.updateById(driver1);
        if(null != order.getUserId()){
            //司机推荐首单收入
            List<Integer> state = Arrays.asList(107, 108, 109);
            int count = this.selectCount(new EntityWrapper<Order>().eq("userId", order.getUserId()).eq("status", 1).in("state", state));
            if(null != appUser.getInviterType() && appUser.getInviterType() == 2 && count == 1){
                Driver driver1 = driverService.selectById(appUser.getInviterId());
                //首单积分奖励
                SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4));
                JSONObject jsonObject2 = JSON.parseObject(systemConfig1.getContent());
                Integer num4 = jsonObject2.getInteger("num4");
                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                accountChangeDetail.setUserType(2);
                accountChangeDetail.setUserId(driver1.getId());
                accountChangeDetail.setType(2);
                accountChangeDetail.setChangeType(5);
                accountChangeDetail.setOrderId(order.getId());
                accountChangeDetail.setOldData(driver1.getIntegral().doubleValue());
                accountChangeDetail.setExplain("邀请用户首单积分奖励");
                accountChangeDetail.setCreateTime(new Date());
                driver1.setIntegral(driver1.getIntegral() + num4);
                accountChangeDetail.setNewData(driver1.getIntegral().doubleValue());
                accountChangeDetailService.insert(accountChangeDetail);
                driverService.updateById(driver1);
            }
        }
        Double payMoney = order.getPayMoney();
        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3));
        Double n = 0D;
        if(null != systemConfig){
            JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
            Double num2 = jsonObject.getDouble("num2");
            Double num3 = jsonObject.getDouble("num3");
            n = num3;
            if(order.getPayMoney() >= num2){
                payMoney = payMoney - num3;//司机收入
            if(order.getOrderMoney() >= num2){//订单金额大于num2才有抽佣金
                driver = driverService.selectById(order.getDriverId());
                AccountChangeDetail accountChangeDetail1 = new AccountChangeDetail();
                accountChangeDetail1.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                accountChangeDetail1.setUserType(2);
                accountChangeDetail1.setUserId(driver.getId());
                accountChangeDetail1.setType(1);
                accountChangeDetail1.setChangeType(9);
                accountChangeDetail1.setOrderId(order.getId());
                accountChangeDetail1.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                accountChangeDetail1.setExplain("订单信息费");
                accountChangeDetail1.setCreateTime(new Date());
                driver.setBalance(driver.getBalance() - num3);
                accountChangeDetail1.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                driverService.updateById(driver);
                accountChangeDetailService.saveData(accountChangeDetail1);
                //有分佣的情况,分佣的金额从司机充值金额中扣除转给分佣对象
                SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 2));
                if(null != systemConfig1){
                    JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent());
                    //司机推荐用户收入
                    if(null != appUser && null != appUser.getInviterType() && appUser.getInviterType() == 2){
                        Double num1 = jsonObject1.getDouble("num1");
                        num1 = (num3 >= num1 ? num1 : num3);
                        if(num1 > 0){
                            Driver driver1 = driverService.selectById(appUser.getInviterId());
                            //首单积分奖励
                            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                            accountChangeDetail.setUserType(2);
                            accountChangeDetail.setUserId(driver1.getId());
                            accountChangeDetail.setType(1);
                            accountChangeDetail.setChangeType(5);
                            accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                            accountChangeDetail.setExplain("邀请用户奖励");
                            accountChangeDetail.setCreateTime(new Date());
                            driver1.setCommission(driver1.getCommission() + num1);
                            accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                            accountChangeDetailService.saveData(accountChangeDetail);
                            driverService.updateById(driver1);
                            Revenue revenue = new Revenue();
                            revenue.setType(2);
                            revenue.setUserType(2);
                            revenue.setUserId(driver1.getId());
                            revenue.setOrderId(order.getId());
                            revenue.setAmount(num1);
                            revenue.setCreateTime(new Date());
                            revenueService.insert(revenue);
                        }
                        num3 = (num3 >= num1 ? num3 - num1 : 0);
                    }
                    //开始处理层级抽佣
                    if(null != driver.getInviterType() && driver.getInviterType() == 2){
                    if(num3 > 0 && null != driver.getInviterType() && driver.getInviterType() == 2){
                        Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机
                        if(null != driver1 && null != driver1.getInviterType() && driver1.getInviterType() == 2){
                            Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机
                            if(null != driver2 && null != driver2.getInviterType() && driver2.getInviterType() == 2){
                                Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机
                                Double num4 = jsonObject1.getDouble("num4");
                                Double num5 = jsonObject1.getDouble("num5");
                                Double num6 = jsonObject1.getDouble("num6");
                                num4 = (num3 >= num4 ? num4 : num3);
                                if(num4 > 0){
                                Double num7 = jsonObject1.getDouble("num7");
                                num5 = (num3 >= num5 ? num5 : num3);
                                if(num5 > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver1.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num4);
                                    revenue.setAmount(num5);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
@@ -1439,20 +1524,20 @@
                                    accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver1.setCommission(driver1.getCommission() + num4);
                                    driver1.setCommission(driver1.getCommission() + num5);
                                    accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    driverService.updateById(driver1);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num4 ? num3 - num4 : 0);
                                    num3 = (num3 >= num5 ? num3 - num5 : 0);
                                }
                                num5 = (num3 >= num5 ? num5 : num3);
                                if(num5 > 0){
                                num6 = (num3 >= num6 ? num6 : num3);
                                if(num6 > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver2.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num5);
                                    revenue.setAmount(num6);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
@@ -1465,20 +1550,21 @@
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num5);
                                    driver2.setCommission(driver2.getCommission() + num6);
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num5 ? num3 - num5 : 0);
                                    num3 = (num3 >= num6 ? num3 - num6 : 0);
                                }
                                num6 = (num3 >= num6 ? num6 : num3);
                                if(num6 > 0){
                                num7 = (num3 >= num7 ? num7 : num3);
                                if(num7 > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver3.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num6);
                                    revenue.setAmount(num7);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
@@ -1491,23 +1577,24 @@
                                    accountChangeDetail.setOldData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver3.setCommission(driver3.getCommission() + num6);
                                    driver3.setCommission(driver3.getCommission() + num7);
                                    accountChangeDetail.setNewData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
                                    driverService.updateById(driver3);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num6 ? num3 - num6 : 0);
                                    num3 = (num3 >= num7 ? num3 - num7 : 0);
                                }
                            }else{
                                Double num2_ = jsonObject1.getDouble("num2");
                                Double num3_ = jsonObject1.getDouble("num3");
                                num2_ = (num3 >= num2_ ? num2_ : num3);
                                if(num2_ > 0){
                                Double num4 = jsonObject1.getDouble("num4");
                                num3_ = (num3 >= num3_ ? num3_ : num3);
                                if(num3_ > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver1.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num2_);
                                    revenue.setAmount(num3_);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
@@ -1520,20 +1607,21 @@
                                    accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver1.setCommission(driver1.getCommission() + num2_);
                                    driver1.setCommission(driver1.getCommission() + num3_);
                                    accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    driverService.updateById(driver1);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num2_ ? num3 - num2_ : 0);
                                    num3 = (num3 >= num3_ ? num3 - num3_ : 0);
                                }
                                num3_ = (num3 >= num3_ ? num3_ : num3);
                                if(num3_ > 0){
                                num4 = (num3 >= num4 ? num4 : num3);
                                if(num4 > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver2.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num3_);
                                    revenue.setAmount(num4);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
@@ -1546,23 +1634,23 @@
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num3_);
                                    driver2.setCommission(driver2.getCommission() + num4);
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num3_ ? num3 - num3_ : 0);
                                    num3 = (num3 >= num4 ? num3 - num4 : 0);
                                }
                            }
                        }else{
                            Double num1_ = jsonObject1.getDouble("num1");
                            num1_ = (num3 >= num1_ ? num1_ : num3);
                            if(num1_ > 0){
                            Double num2_ = jsonObject1.getDouble("num2");
                            num2_ = (num3 >= num2_ ? num2_ : num3);
                            if(num2_ > 0){
                                Revenue revenue = new Revenue();
                                revenue.setType(2);
                                revenue.setUserType(2);
                                revenue.setUserId(driver1.getId());
                                revenue.setOrderId(order.getId());
                                revenue.setAmount(num1_);
                                revenue.setAmount(num2_);
                                revenue.setCreateTime(new Date());
                                revenueService.insert(revenue);
@@ -1575,11 +1663,11 @@
                                accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                accountChangeDetail.setExplain("订单分佣收入");
                                accountChangeDetail.setCreateTime(new Date());
                                driver1.setCommission(driver1.getCommission() + num1_);
                                driver1.setCommission(driver1.getCommission() + num2_);
                                accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                driverService.updateById(driver1);
                                accountChangeDetailService.saveData(accountChangeDetail);
                                num3 = (num3 >= num1_ ? num3 - num1_ : 0);
                                num3 = (num3 >= num2_ ? num3 - num2_ : 0);
                            }
                        }
                    }
@@ -1596,24 +1684,6 @@
                    }
                }
            }
        }
        //司机余额扣减抽佣金额
        if(n > 0){
            driver = driverService.selectById(order.getDriverId());
            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
            accountChangeDetail.setUserType(2);
            accountChangeDetail.setUserId(driver.getId());
            accountChangeDetail.setType(1);
            accountChangeDetail.setChangeType(9);
            accountChangeDetail.setOrderId(order.getId());
            accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
            accountChangeDetail.setExplain("线下收款服务费支出");
            accountChangeDetail.setCreateTime(new Date());
            driver.setBalance(driver.getBalance() - n);
            accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
            driverService.updateById(driver);
            accountChangeDetailService.saveData(accountChangeDetail);
        }
    }
@@ -1786,34 +1856,31 @@
    @Override
    public void completeCollection() {
        List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1)
                .eq("payType", 3).last(" and UNIX_TIMESTAMP(getoffTime) + 120 <= UNIX_TIMESTAMP(now())"));
                .eq("payType", 3).last(" and UNIX_TIMESTAMP(getoffTime) + 600 <= UNIX_TIMESTAMP(now())"));
        for (Order order : orders) {
            order.setState(108);
            order.setPayTime(new Date());
            if(null != order.getCouponId()){
                UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId());
                if(userToCoupon.getValidCount() > 0){
                    userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
                    userToCouponService.updateById(userToCoupon);
                    Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                    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.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                    accountChangeDetail.setType(1);
                    accountChangeDetail.setChangeType(7);
                    accountChangeDetail.setOrderId(order.getId());
                    accountChangeDetail.setExplain("优惠券收入");
                    driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
                    accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                    driverService.updateById(driver);
                    accountChangeDetailService.insert(accountChangeDetail);
                }
                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() + driver.getCommission());
                accountChangeDetail.setType(1);
                accountChangeDetail.setChangeType(7);
                accountChangeDetail.setOrderId(order.getId());
                accountChangeDetail.setExplain("优惠券收入");
                driver.setCommission(driver.getCommission() + coupon.getCouponPreferentialAmount());
                accountChangeDetail.setNewData(driver.getCouponBalance() + driver.getCommission());
                driverService.updateById(driver);
                accountChangeDetailService.insert(accountChangeDetail);
            }
            this.updateById(order);
            try {
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/util/PayMoneyUtil.java
@@ -169,9 +169,9 @@
        }
        //切记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){
//        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");
@@ -182,12 +182,12 @@
                map.put("total_amount", total_amount);
                map.put("trade_no", trade_no);//支付宝交易号
                return map;
            }
//            }
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        return null;
//        } catch (AlipayApiException e) {
//            e.printStackTrace();
//        }
//        return null;
    }
@@ -201,8 +201,8 @@
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppid, appPrivateKey,"json","UTF-8", alipay_public_key,"RSA2");
        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
        request.setBizContent("{" +
                "\"out_trade_no\":" + out_trade_no +
                "  }");
                "\"out_trade_no\":\"" + out_trade_no +
                "\"}");
        AlipayTradeQueryResponse response = alipayClient.execute(request);
        if(response.isSuccess()){
            String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/util/TaskUtil.java
@@ -1,10 +1,7 @@
package com.agentdriving.driver.modular.system.util;
import com.agentdriving.driver.modular.system.service.IAccountChangeDetailService;
import com.agentdriving.driver.modular.system.service.IDriverService;
import com.agentdriving.driver.modular.system.service.IOrderService;
import com.agentdriving.driver.modular.system.service.IYouTuiDriverService;
import com.agentdriving.driver.modular.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -28,6 +25,9 @@
    @Autowired
    private IYouTuiDriverService youTuiDriverService;
    @Autowired
    private IDriverWorkService driverWorkService;
@@ -37,7 +37,7 @@
    @Scheduled(fixedRate = 1000 * 60)
    public void taskMinute(){
        try {
            orderService.completeCollection();
            driverWorkService.taskDriverOffWork();
            youTuiDriverService.editState();
        } catch (Exception e) {
            e.printStackTrace();
@@ -51,7 +51,7 @@
    @Scheduled(cron = "0 0 0 * * *")
    public void taskDay(){
        try {
            orderService.completeCollection();
        }catch (Exception e){
            e.printStackTrace();
        }
driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/warpper/DriverRegisterWarpper.java
@@ -34,8 +34,6 @@
    private String idcardFront;
    @ApiModelProperty(value = "身份证背面照", required = true, dataType = "string")
    private String idcardBack;
    @ApiModelProperty(value = "驾驶证号码", required = true, dataType = "string")
    private String driverLicenseNumber;
    @ApiModelProperty(value = "初领驾驶证时间", required = true, dataType = "string")
    private Date firstCertificateTime;
    @ApiModelProperty(value = "驾驶证照片", required = true, dataType = "string")
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -353,7 +353,7 @@
    @RequestMapping(value = "/commission/list")
    @ResponseBody
    public Object commissionList(String name,String phone,Integer status) {
        EntityWrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status);
        Wrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status);
        List<TDriver> tDrivers = tDriverService.selectList(wrapper);
        List<TDriverCommissionResp> commissionResp = tDriverService.getTDriverCommissionResp(tDrivers);
        for (TDriverCommissionResp tDriverCommissionResp : commissionResp) {
@@ -848,7 +848,7 @@
            String fileName = "CommissionInfo"+time1+".xls";
            String[] title = new String[] {"姓名","手机号","所属代理商","推广人数","关联人数",
                    "累计获得佣金","可提现佣金","已提现金额","状态"};
            EntityWrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status);
            Wrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status);
//            wrapper.ne("isException",2);
            // 是否异常
            List<TDriver> list = tDriverService.selectList(wrapper);
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/THomePageController.java
@@ -652,7 +652,7 @@
            }
        }else {
            // 业绩排名 performanceTable
            List<TAgent> tAgentList = tAgentService.selectList(null);
            List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>().eq("status", 1));
            List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList());
            if (1 == type){
                // 单量
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TOrderController.java
@@ -23,6 +23,7 @@
import com.stylefeng.guns.modular.system.model.TOrderPosition;
import com.stylefeng.guns.modular.system.service.ITAppUserService;
import com.stylefeng.guns.modular.system.service.ITCancelOrderService;
import com.stylefeng.guns.modular.system.service.ITDriverService;
import com.stylefeng.guns.modular.system.service.ITOrderService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import io.swagger.annotations.ApiImplicitParam;
@@ -70,6 +71,9 @@
    private ITCancelOrderService tCancelOrderService;
    @Resource
    private TCancelOrderMapper tCancelOrderMapper;
    @Autowired
    private ITDriverService driverService;
    @Value("${filePath}")
    private String filePath;
@@ -497,6 +501,11 @@
        TOrder tOrder = tOrderService.selectById(tOrderId);
        tOrder.setState(OrderStateEnum.CANCELED.getCode());
        tOrderService.updateById(tOrder);
        if(null != tOrder.getDriverId()){
            TDriver tDriver = driverService.selectById(tOrder.getDriverId());
            tDriver.setServerStatus(1);
            driverService.updateById(tDriver);
        }
        return SUCCESS_TIP;
    }
}
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/UploadUtil.java
@@ -29,7 +29,7 @@
 * 上传文件
 */
@RestController
@RequestMapping("/image")
@RequestMapping("/upload")
public class UploadUtil extends BaseController {
    private final static Logger log = LoggerFactory.getLogger(UploadUtil.class);
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
@@ -127,25 +127,47 @@
            cw.type = 2 AND cw.businessType = #{type} AND cw.code = #{code}
    </select>
    <select id="getDataStatisticsIncomeOrCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
        FROM t_revenue r
        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
        LEFT JOIN t_order o ON r.orderId = o.id
        <where>
        <if test="type == 1">
            select aa.monthTime,aa.userName,sum(aa.amount) as amount from (
            select
            DATE_FORMAT(a.createTime, '%Y-%m') as monthTime,
            b.id as driverId,
            a.payMoney as amount,
            b.`name` as userName
            from t_order a
            left join t_driver b on (a.driverId = b.id)
            where a.payMoney > 0
            <if test="agentId != null">
                AND o.agentId = #{agentId}
                and a.agentId = #{agentId}
            </if>
            <if test="monthDate != null and monthDate != ''">
                AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
                AND date_format(a.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
            </if>
            <if test="type != null">
                AND r.type = #{type}
            </if>
            AND r.userType = 2
        </where>
        GROUP BY monthTime,userName
        ORDER BY amount DESC
        LIMIT 10
            ) as aa GROUP BY aa.monthTime,aa.driverId
            ORDER BY amount DESC
            LIMIT 10
        </if>
        <if test="2 == type">
            SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
            FROM t_revenue r
            LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
            LEFT JOIN t_order o ON r.orderId = o.id
            <where>
                <if test="agentId != null">
                    AND o.agentId = #{agentId}
                </if>
                <if test="monthDate != null and monthDate != ''">
                    AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
                </if>
                <if test="type != null">
                    AND r.type = #{type}
                </if>
                AND r.userType = 2
            </where>
            GROUP BY monthTime,userName
            ORDER BY amount DESC
            LIMIT 10
        </if>
    </select>
    <select id="getDataStatisticsCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
@@ -169,28 +191,53 @@
        ORDER BY amount DESC
    </select>
    <select id="getDataStatisticsIncomeOrCommissionByIds" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
        FROM t_revenue r
        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
        LEFT JOIN t_order o ON r.orderId = o.id
        <where>
        <if test="type == 1">
            select aa.monthTime,aa.userName,sum(aa.amount) as amount from (
            select
            DATE_FORMAT(a.createTime, '%Y-%m') as monthTime,
            b.id as driverId,
            a.payMoney as amount,
            b.`name` as userName
            from t_order a
            left join t_driver b on (a.driverId = b.id)
            where a.payMoney > 0
            <if test="ids != null and ids.size() > 0">
                AND o.agentId IN
                AND a.agentId IN
                <foreach collection="ids" close=")" open="(" item="id" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="monthDate != null and monthDate != ''">
                AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
                AND date_format(a.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
            </if>
            <if test="type != null">
                AND r.type = #{type}
            </if>
            AND r.userType = 2
        </where>
        GROUP BY monthTime,userName
        ORDER BY amount DESC
        LIMIT 10
            ) as aa GROUP BY aa.monthTime,aa.driverId
            ORDER BY amount DESC
            LIMIT 10
        </if>
        <if test="type == 2">
            SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
            FROM t_revenue r
            LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
            LEFT JOIN t_order o ON r.orderId = o.id
            <where>
                <if test="ids != null and ids.size() > 0">
                    AND o.agentId IN
                    <foreach collection="ids" close=")" open="(" item="id" separator=",">
                        #{id}
                    </foreach>
                </if>
                <if test="monthDate != null and monthDate != ''">
                    AND date_format(r.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
                </if>
                <if test="type != null">
                    AND r.type = #{type}
                </if>
                AND r.userType = 2
            </where>
            GROUP BY monthTime,userName
            ORDER BY amount DESC
            LIMIT 10
        </if>
    </select>
</mapper>
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITDriverService.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.modular.system.controller.resp.TDriverCommissionResp;
import com.stylefeng.guns.modular.system.controller.resp.TDriverResp;
import com.stylefeng.guns.modular.system.model.TDriver;
@@ -65,7 +66,7 @@
     * @param status
     * @return
     */
    EntityWrapper<TDriver> getCommissionPageList(String name, String phone, Integer status);
    Wrapper<TDriver> getCommissionPageList(String name, String phone, Integer status);
    /**
     * 封装佣金集合
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.core.base.tips.SuccessTip;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.DateUtil;
@@ -387,8 +388,8 @@
    }
    @Override
    public EntityWrapper<TDriver> getCommissionPageList(String name, String phone, Integer status) {
        EntityWrapper<TDriver> wrapper = new EntityWrapper<>();
    public Wrapper<TDriver> getCommissionPageList(String name, String phone, Integer status) {
        Wrapper<TDriver> wrapper = new EntityWrapper<TDriver>().eq("approvalStatus", 2).eq("status", 1);
        // 手机号
        if(StringUtils.hasLength(phone)){
            wrapper.like("phone",phone);
management/guns-admin/src/main/webapp/WEB-INF/view/blackboardBlank.html
@@ -328,611 +328,625 @@
</style>
<script type="text/javascript">
    $(function (){
    $(function (){
        $('#mapDiv').hide()
        $('#orderDiv').hide()
        loading()
        orderByMonth(new Date().getMonth() + 1)
        orderByYear(new Date().getFullYear())
        queryOrderCount()
        $('#mapDiv').hide()
        $('#orderDiv').hide()
        loading()
        orderByMonth(new Date().getMonth() + 1)
        orderByYear(new Date().getFullYear())
        queryOrderCount()
        var first = $('.breadcrumb').children('li:first').children('a');
        first.css({
            'color': '#AB2626'
        })
        var className = first.attr('class');
        $('.content').hide();
        $('#' + className + 'Div').show();
        var first = $('.breadcrumb').children('li:first').children('a');
        first.css({
            'color': '#AB2626'
        })
        var className = first.attr('class');
        $('.content').hide();
        $('#' + className + 'Div').show();
        $('.breadcrumb').find('a').on('click', function () {
            $('.breadcrumb').children('li').each(function () {
                $(this).children('a').removeAttr('style');
            })
        $('.breadcrumb').find('a').on('click', function () {
            $('.breadcrumb').children('li').each(function () {
                $(this).children('a').removeAttr('style');
            })
            $(this).css({
                'color': '#AB2626'
            });
            var className = $(this).attr('class');
            $('.content').hide();
            $('#' + className + "Div").show();
            switch (className) {
                case "statistics":
                    $('#mapDiv').hide()
                    $('#orderDiv').hide()
                    loading()
                    orderByMonth(new Date().getMonth() + 1)
                    orderByYear(new Date().getFullYear())
                    queryOrderCount()
                    break;
                case "map":
                    map("",102.709,25.0635);
                    break;
                case "order":
                    mapOrder("");
                    getOrderData();
                    break;
            }
            $(this).css({
                'color': '#AB2626'
            });
            var className = $(this).attr('class');
            $('.content').hide();
            $('#' + className + "Div").show();
            switch (className) {
                case "statistics":
                    $('#mapDiv').hide()
                    $('#orderDiv').hide()
                    loading()
                    orderByMonth(new Date().getMonth() + 1)
                    orderByYear(new Date().getFullYear())
                    queryOrderCount()
                    break;
                case "map":
                    map("",113.264434,23.129162);
                    break;
                case "order":
                    mapOrder("");
                    getOrderData();
                    break;
            }
        })
        // $('#mapDiv').hide()
        // $('#orderDiv').hide()
        // loading()
        // orderByMonth(new Date().getMonth() + 1)
        // orderByYear(new Date().getFullYear())
        // queryOrderCount()
    })
        })
        // $('#mapDiv').hide()
        // $('#orderDiv').hide()
        // loading()
        // orderByMonth(new Date().getMonth() + 1)
        // orderByYear(new Date().getFullYear())
        // queryOrderCount()
        setInterval(function () {
            console.log(1111111111)
            getData()
        }, 30000);
    })
    function selectYear(e){
        orderByYear(e)
    }
    function selectMonth(e){
        // 查询排行榜
        if($('#btn1').val() != null && $('#btn1').val() != ''){
            console.log(11111)
            getOrder($('#btn1').val(),e)
        }
        if($('#btn2').val() != null && $('#btn2').val() != ''){
            console.log(22222)
            getOrder($('#btn2').val(),e)
        }
        if($('#btn3').val() != null && $('#btn3').val() != ''){
            console.log(33333)
            getOrder($('#btn3').val(),e)
        }
    }
    laydate.render({
        elem: '#insertTime',
        range: false,
        type: "year",
        change:function(value,date) {
            selectYear(value)// change 每点一次都会监听一遍
        }
    });
    laydate.render({
        elem: '#insertTimeMonth',
        range: false,
        type: "month",
        change:function(value,date) {
            selectMonth(value)// change 每点一次都会监听一遍
        }
    });
    function selectYear(e){
        orderByYear(e)
    }
    function selectMonth(e){
        // 查询排行榜
        if($('#btn1').val() != null && $('#btn1').val() != ''){
            console.log(11111)
            getOrder($('#btn1').val(),e)
        }
        if($('#btn2').val() != null && $('#btn2').val() != ''){
            console.log(22222)
            getOrder($('#btn2').val(),e)
        }
        if($('#btn3').val() != null && $('#btn3').val() != ''){
            console.log(33333)
            getOrder($('#btn3').val(),e)
        }
    }
    laydate.render({
        elem: '#insertTime',
        range: false,
        type: "year",
        change:function(value,date) {
            selectYear(value)// change 每点一次都会监听一遍
        }
    });
    laydate.render({
        elem: '#insertTimeMonth',
        range: false,
        type: "month",
        change:function(value,date) {
            selectMonth(value)// change 每点一次都会监听一遍
        }
    });
    laydate.render({
        elem: '#createTime',
        type: 'date',
        range: true
    });
    // 进度条加载
    function loading(){
        var options = $.extend({
            percentage : $('#agentTotal').text(),
            ShowProgressCount: false,
            duration: 10,
    // 进度条加载
    function loading(){
        var options = $.extend({
            percentage : $('#agentTotal').text()<100?$('#agentTotal').text():($('#agentTotal').text()>1000?$('#agentTotal').text()/100:$('#agentTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro1').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#agentMonthTotal').text(),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro1').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#agentMonthTotal').text()<100?$('#agentMonthTotal').text():($('#agentMonthTotal').text()>1000?$('#agentMonthTotal').text()/100:$('#agentMonthTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro2').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverTotal').text(),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro2').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverTotal').text()<100?$('#driverTotal').text():($('#driverTotal').text()>1000?$('#driverTotal').text()/100:$('#driverTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro3').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverMonthTotal').text(),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro3').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverMonthTotal').text()<100?$('#driverMonthTotal').text():($('#driverMonthTotal').text()>1000?$('#driverMonthTotal').text()/100:$('#driverMonthTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro4').LineProgressbar(options);
    }
            // Styling Options
            fillBackgroundColor: '#3498db',
            backgroundColor: '#EEEEEE',
            radius: '10px',
            height: '20px',
            width: '80%'
        });
        $('#pro4').LineProgressbar(options);
    }
    // 单量
    function queryOrderCount(){
        $('#btn1').css("backgroundColor","dodgerblue")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","#FFFFFF")
        $('#btn2').css("backgroundColor","#FFFFFF")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","black")
        $('#btn3').css("backgroundColor","#FFFFFF")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","black")
        $('#btn1').val(1)
        $('#btn2').val('')
        $('#btn3').val('')
        getOrder($('#btn1').val(),$('#insertTimeMonth').val())
    }
    // 收入
    function queryIncome(){
        $('#btn1').css("backgroundColor","#FFFFFF")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","black")
        $('#btn2').css("backgroundColor","dodgerblue")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","#FFFFFF")
        $('#btn3').css("backgroundColor","#FFFFFF")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","black")
        $('#btn1').val('')
        $('#btn2').val(2)
        $('#btn3').val('')
        getOrder($('#btn2').val(),$('#insertTimeMonth').val())
    }
    // 佣金
    function queryCommission(){
        $('#btn1').css("backgroundColor","#FFFFFF")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","black")
        $('#btn2').css("backgroundColor","#FFFFFF")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","black")
        $('#btn3').css("backgroundColor","dodgerblue")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","#FFFFFF")
        $('#btn1').val('')
        $('#btn2').val('')
        $('#btn3').val(3)
        getOrder($('#btn3').val(),$('#insertTimeMonth').val())
    }
    // 单量
    function queryOrderCount(){
        $('#btn1').css("backgroundColor","dodgerblue")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","#FFFFFF")
        $('#btn2').css("backgroundColor","#FFFFFF")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","black")
        $('#btn3').css("backgroundColor","#FFFFFF")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","black")
        $('#btn1').val(1)
        $('#btn2').val('')
        $('#btn3').val('')
        getOrder($('#btn1').val(),$('#insertTimeMonth').val())
    }
    // 收入
    function queryIncome(){
        $('#btn1').css("backgroundColor","#FFFFFF")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","black")
        $('#btn2').css("backgroundColor","dodgerblue")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","#FFFFFF")
        $('#btn3').css("backgroundColor","#FFFFFF")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","black")
        $('#btn1').val('')
        $('#btn2').val(2)
        $('#btn3').val('')
        getOrder($('#btn2').val(),$('#insertTimeMonth').val())
    }
    // 佣金
    function queryCommission(){
        $('#btn1').css("backgroundColor","#FFFFFF")
        $('#btn1').css("borderColor","dodgerblue")
        $('#btn1').css("color","black")
        $('#btn2').css("backgroundColor","#FFFFFF")
        $('#btn2').css("borderColor","dodgerblue")
        $('#btn2').css("color","black")
        $('#btn3').css("backgroundColor","dodgerblue")
        $('#btn3').css("borderColor","dodgerblue")
        $('#btn3').css("color","#FFFFFF")
        $('#btn1').val('')
        $('#btn2').val('')
        $('#btn3').val(3)
        getOrder($('#btn3').val(),$('#insertTimeMonth').val())
    }
    // 通过年查询订单数量(查询每月)
    function orderByYear(e){
        var dom = document.getElementById('chart1');
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsYearByAgentId",function(data){
            data = data.yearResp
            var myChart = echarts.init(dom, null, {
                renderer: 'canvas',
                useDirtyRect: false
            });
            var option;
            option = {
                tooltip: {
                    trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
                    axisPointer: {// 坐标轴指示器,坐标轴触发有效
                        type: 'line' // 默认为直线,可选为:'line' | 'shadow'
                    },
                    formatter: '日期: {b} <br/>订单数量 : {c}'
                },
                xAxis: {
                    type: 'category',
                    data: [data[0].month+'月',data[1].month+'月', data[2].month+'月', data[3].month+'月',data[4].month+'月',data[5].month+'月',data[6].month+'月',data[7].month+'月',data[8].month+'月',data[9].month+'月',data[10].month+'月',data[11].month+'月']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: [data[0].orderCount,data[1].orderCount, data[2].orderCount, data[3].orderCount,data[4].orderCount,data[5].orderCount,data[6].orderCount,data[7].orderCount,data[8].orderCount,data[9].orderCount,data[10].orderCount,data[11].orderCount],
                        type: 'line',
                        color: '#00b7ee'
                    }
                ]
            };
            option && myChart.setOption(option);
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        if(e==''){
            ajax.set("yearDate",$("#year").val());
        }else{
            ajax.set("yearDate",e);
        }
    // 通过年查询订单数量(查询每月)
    function orderByYear(e){
        var dom = document.getElementById('chart1');
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsYearByAgentId",function(data){
            data = data.yearResp
            var myChart = echarts.init(dom, null, {
                renderer: 'canvas',
                useDirtyRect: false
            });
            var option;
            option = {
                tooltip: {
                    trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
                    axisPointer: {// 坐标轴指示器,坐标轴触发有效
                        type: 'line' // 默认为直线,可选为:'line' | 'shadow'
                    },
                    formatter: '日期: {b} <br/>订单数量 : {c}'
                },
                xAxis: {
                    type: 'category',
                    data: [data[0].month+'月',data[1].month+'月', data[2].month+'月', data[3].month+'月',data[4].month+'月',data[5].month+'月',data[6].month+'月',data[7].month+'月',data[8].month+'月',data[9].month+'月',data[10].month+'月',data[11].month+'月']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: [data[0].orderCount,data[1].orderCount, data[2].orderCount, data[3].orderCount,data[4].orderCount,data[5].orderCount,data[6].orderCount,data[7].orderCount,data[8].orderCount,data[9].orderCount,data[10].orderCount,data[11].orderCount],
                        type: 'line',
                        color: '#00b7ee'
                    }
                ]
            };
            option && myChart.setOption(option);
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        if(e==''){
            ajax.set("yearDate",$("#year").val());
        }else{
            ajax.set("yearDate",e);
        }
        ajax.start();
    }
        ajax.start();
    }
    // 通过本月查询订单数量(查询本月每天)
    function orderByMonth(){
        var dom = document.getElementById('chart2');
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsMonthByAgentId",function(data){
            data = data.monthResp
            var mon = new Date().getMonth()+1;
            if(mon < 10){
                mon = '0'+mon;
            }
            var yResp = [];
            var xResp = [];
            for (var i =0;i<data.length;i++){
                yResp.push({
                    value:data[i].orderCount,
                })
                xResp.push({
                    value:mon+'-'+data[i].month,
                })
            }
            var myChart = echarts.init(dom, null, {
                renderer: 'canvas',
                useDirtyRect: false
            });
            var option;
            option = {
                tooltip: {
                    trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
                    axisPointer: {// 坐标轴指示器,坐标轴触发有效
                        type: 'line' // 默认为直线,可选为:'line' | 'shadow'
                    },
                    formatter: '日期: {b} <br/>订单数量 : {c}'
                },
    // 通过本月查询订单数量(查询本月每天)
    function orderByMonth(){
        var dom = document.getElementById('chart2');
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsMonthByAgentId",function(data){
            data = data.monthResp
            var mon = new Date().getMonth()+1;
            if(mon < 10){
                mon = '0'+mon;
            }
            var yResp = [];
            var xResp = [];
            for (var i =0;i<data.length;i++){
                yResp.push({
                    value:data[i].orderCount,
                })
                xResp.push({
                    value:mon+'-'+data[i].month,
                })
            }
            var myChart = echarts.init(dom, null, {
                renderer: 'canvas',
                useDirtyRect: false
            });
            var option;
            option = {
                tooltip: {
                    trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
                    axisPointer: {// 坐标轴指示器,坐标轴触发有效
                        type: 'line' // 默认为直线,可选为:'line' | 'shadow'
                    },
                    formatter: '日期: {b} <br/>订单数量 : {c}'
                },
                xAxis: {
                    type: 'category',
                    data: xResp
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: yResp,
                        type: 'line',
                        color: '#00b7ee'
                    }
                ]
            };
            option && myChart.setOption(option);
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        ajax.start();
    }
                xAxis: {
                    type: 'category',
                    data: xResp
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: yResp,
                        type: 'line',
                        color: '#00b7ee'
                    }
                ]
            };
            option && myChart.setOption(option);
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        ajax.start();
    }
    function getOrder(type,e){
        $.ajax({
            url: Feng.ctxPath + '/tHomePage/statisticsOrderByAgentId',
            type: 'POST',
            data: {
                agentId: $("#agentName").val(),
                monthDate: e,
                type: type
            },
            success: function (res) {
                var str = '<table border="1" style="border: #c2ccd1;border-radius: 1px;height: 90%;width: 100%;text-align:center;table-layout:fixed;tword-break:break-all;">\n' +
                        '                                        <tr style="text-align: center;width:100px;height:40px">\n' +
                        '                                            <th class="orderTh">排名</th>\n' +
                        '                                            <th class="orderTh">时间</th>\n' +
                        '                                            <th class="orderTh">姓名</th>\n';
                if(type == 1){
                    str +=  '                                            <th class="orderTh">单量</th>\n' +
                            '                                        </tr>';
                }
                if(type == 2){
                    str +=  '                                            <th class="orderTh">收入</th>\n' +
                            '                                        </tr>';
                }
                if(type == 3){
                    str +=  '                                            <th class="orderTh">佣金</th>\n' +
                            '                                        </tr>';
                }
                if(!$.isEmptyObject(res)){
                    var order = res.performanceResp
                    if(order.length > 0){
                        for(var i in order){
                            var a=parseInt(i)+1
                            str +=
                                    '<tr><td class="orderTd">' + a + '</td><td class="orderTd">' + order[i].monthTime + '</td><td class="orderTd">' + order[i].userName + '</td><td class="orderTd">' + order[i].amount + '</td></tr>';
                        }
                    }
                }
                str += '</table>';
                $('#performanceResp').html('');
                $('#performanceResp').html(str);
            }
        });
    }
    function getOrder(type,e){
        $.ajax({
            url: Feng.ctxPath + '/tHomePage/statisticsOrderByAgentId',
            type: 'POST',
            data: {
                agentId: $("#agentName").val(),
                monthDate: e,
                type: type
            },
            success: function (res) {
                var str = '<table border="1" style="border: #c2ccd1;border-radius: 1px;height: 90%;width: 100%;text-align:center;table-layout:fixed;tword-break:break-all;">\n' +
                    '                                        <tr style="text-align: center;width:100px;height:40px">\n' +
                    '                                            <th class="orderTh">排名</th>\n' +
                    '                                            <th class="orderTh">时间</th>\n' +
                    '                                            <th class="orderTh">姓名</th>\n';
                if(type == 1){
                    str +=  '                                            <th class="orderTh">单量</th>\n' +
                        '                                        </tr>';
                }
                if(type == 2){
                    str +=  '                                            <th class="orderTh">收入</th>\n' +
                        '                                        </tr>';
                }
                if(type == 3){
                    str +=  '                                            <th class="orderTh">佣金</th>\n' +
                        '                                        </tr>';
                }
                if(!$.isEmptyObject(res)){
                    var order = res.performanceResp
                    if(order.length > 0){
                        for(var i in order){
                            var a=parseInt(i)+1
                            str +=
                                '<tr><td class="orderTd">' + a + '</td><td class="orderTd">' + order[i].monthTime + '</td><td class="orderTd">' + order[i].userName + '</td><td class="orderTd">' + order[i].amount + '</td></tr>';
                        }
                    }
                }
                str += '</table>';
                $('#performanceResp').html('');
                $('#performanceResp').html(str);
            }
        });
    }
    // 动态查询代理商司机数量
    function getInfo(){
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsDriverByAgentId",function(data){
            $("#agentTotal").text(data.agentTotal)
            $("#agentMonthTotal").text(data.agentMonthTotal)
            $("#driverTotal").text(data.driverTotal)
            $("#driverMonthTotal").text(data.driverMonthTotal)
            loading()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        ajax.start();
    }
    // 动态查询代理商司机数量
    function getInfo(){
        var ajax = new $ax(Feng.ctxPath+"/tHomePage/statisticsDriverByAgentId",function(data){
            $("#agentTotal").text(data.agentTotal)
            $("#agentMonthTotal").text(data.agentMonthTotal)
            $("#driverTotal").text(data.driverTotal)
            $("#driverMonthTotal").text(data.driverMonthTotal)
            loading()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentName").val());
        ajax.start();
    }
    // 代理商选择事件
    $('#agentName').change(function(){
        // 查询代理商 查询司机
        getInfo()
        // 查询月度报表
        orderByMonth()
        // 通过年查询订单报表
        orderByYear($('#insertTime').val())
        // 查询排行榜
        if($('#btn1').val() != null && $('#btn1').val() != ''){
            console.log(111)
            getOrder($('#btn1').val(),$('#insertTimeMonth').val())
        }
        if($('#btn2').val() != null && $('#btn2').val() != ''){
            console.log(222)
            getOrder($('#btn2').val(),$('#insertTimeMonth').val())
        }
        if($('#btn3').val() != null && $('#btn3').val() != ''){
            console.log(333)
            getOrder($('#btn3').val(),$('#insertTimeMonth').val())
        }
    })
    /**
     * 定时器
     */
    setInterval(function () {
        getData();
    }, 30000);
    // 代理商选择事件
    $('#agentName').change(function(){
        // 查询代理商 查询司机
        getInfo()
        // 查询月度报表
        orderByMonth()
        // 通过年查询订单报表
        orderByYear($('#insertTime').val())
        // 查询排行榜
        if($('#btn1').val() != null && $('#btn1').val() != ''){
            console.log(111)
            getOrder($('#btn1').val(),$('#insertTimeMonth').val())
        }
        if($('#btn2').val() != null && $('#btn2').val() != ''){
            console.log(222)
            getOrder($('#btn2').val(),$('#insertTimeMonth').val())
        }
        if($('#btn3').val() != null && $('#btn3').val() != ''){
            console.log(333)
            getOrder($('#btn3').val(),$('#insertTimeMonth').val())
        }
    })
    function getData(){
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            console.log(data.allList)
            map(data.allList,data.addressLon,data.addressLat)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function reset(){
        $("#agentId").val('')
        $("#orderType").val('')
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            map(data.allList,data.addressLon,data.addressLat)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function getData(){
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#onLineDriver').val(data.onLineDriver);
            console.log(data.onLineDriver)
            map(data.onLineDriver,data.addressLon,data.addressLat)
            getOrderData()
    function getDataOrder(){
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            console.log(data.allList)
            mapOrder(data.allList)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function reset(){
        $("#agentId").val('')
        $("#orderType").val('')
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#onLineDriver').val(data.onLineDriver);
            map(data.onLineDriver,data.addressLon,data.addressLat)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function resetOrder(){
        $("#agentId").val('')
        $("#orderType").val('')
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            mapOrder(data.allList)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function getDataOrder(){
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            console.log(data.allList)
            mapOrder(data.allList)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function resetOrder(){
        $("#agentId").val('')
        $("#orderType").val('')
        var ajax = new $ax(Feng.ctxPath + "/tHomePage/getMap", function (data) {
            document.getElementById("onLineDriverCount").innerText=data.onLineDriverCount
            document.getElementById("pendingOrderCount").innerText=data.pendingOrderCount
            document.getElementById("serverCount").innerText=data.serverCount
            document.getElementById("finishCount").innerText=data.finishCount
            document.getElementById("cancelCount").innerText=data.cancelCount
            $('#allList').val(data.allList);
            mapOrder(data.allList)
            getOrderData()
        }, function (data) {
        });
        ajax.set("agentId",$("#agentId").val());
        ajax.set("type",$("#orderType").val());
        ajax.start();
    }
    function map(e,addressLon,addressLat){
        window._AMapSecurityConfig = {
            securityJsCode:'b62d9146929db08c4c2f4537d045320d',
        };
        laydate.render({
            elem: '#createTime',
            type: 'date',
            range: true
        });
    function map(e,addressLon,addressLat){
        window._AMapSecurityConfig = {
            securityJsCode:'b62d9146929db08c4c2f4537d045320d',
        };
        AMapLoader.reset() // 需要把这个reset一下
        AMapLoader.load({
            "key": "1d43098bcd98ab124623e7e4bcc9595e",              // 申请好的Web端开发者Key,首次调用 load 时必填
            "version": "2.0",   // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
            "plugins": ['AMap.Driving'],           // 需要使用的的插件列表,如比例尺'AMap.Scale'等
            "AMapUI": {             // 是否加载 AMapUI,缺省不加载
                "version": '1.1',   // AMapUI 版本
                "plugins":['overlay/SimpleMarker'],       // 需要加载的 AMapUI ui插件
            },
            "Loca":{                // 是否加载 Loca, 缺省不加载
                "version": '2.0'  // Loca 版本
            },
        }).then((AMap)=>{
            //初始化地图对象,加载地图
            var map = new AMap.Map('container', {
                viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
                zoom:10, //初始化地图层级
                center: [addressLon,addressLat] //初始化地图中心点
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
            const  onLineDriver = $('#onLineDriver').val();
            var list1 = JSON.stringify(onLineDriver)
            const jsonArr = JSON.parse(list1)
            const jsonArr1 = JSON.parse(jsonArr);
            console.log(jsonArr1)
            M = jsonArr1;
            M.forEach(function(marker) {
                new AMap.Marker({
                    map: map,
                    icon: marker[2]==1?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/c1d2f38187de40daa353fcc70993288e.png':'https://csxdj.obs.cn-south-1.myhuaweicloud.com/c1d2f38187de40daa353fcc70993288e.png',
                    position: [marker[0], marker[1]],
                    offset: new AMap.Pixel(-13, -30)
                });
            });
        AMapLoader.reset() // 需要把这个reset一下
        AMapLoader.load({
            "key": "1d43098bcd98ab124623e7e4bcc9595e",              // 申请好的Web端开发者Key,首次调用 load 时必填
            "version": "2.0",   // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
            "plugins": ['AMap.Driving'],           // 需要使用的的插件列表,如比例尺'AMap.Scale'等
            "AMapUI": {             // 是否加载 AMapUI,缺省不加载
                "version": '1.1',   // AMapUI 版本
                "plugins":['overlay/SimpleMarker'],       // 需要加载的 AMapUI ui插件
            },
            "Loca":{                // 是否加载 Loca, 缺省不加载
                "version": '2.0'  // Loca 版本
            },
        }).then((AMap)=>{
            //初始化地图对象,加载地图
            var map = new AMap.Map('container', {
                viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
                zoom:10, //初始化地图层级
                center: [addressLon,addressLat] //初始化地图中心点
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
            // var center = map.getCenter();
            // var centerText = '当前中心点坐标:' + center.getLng() + ',' + center.getLat();
            // 添加事件监听, 使地图自适应显示到合适的范围
            AMap.event.addDomListener(document.getElementById('container'), 'click', function() {
                var newCenter = map.setFitView();
            });
        }).catch((e)=>{
            console.error(e);  //加载错误提示
        });
    }
            var  onLineDriver;
            if(e==""){
                onLineDriver = $('#onLineDriver').val();
                console.log("onLineDriver========================")
                console.log(onLineDriver)
                var list1 = JSON.stringify(onLineDriver)
                console.log("list1========================")
                console.log(list1)
                const jsonArr = JSON.parse(list1)
                console.log("jsonArr========================")
                console.log(jsonArr)
                const jsonArr1 = JSON.parse(jsonArr);
                console.log("jsonArr1========================")
                console.log(jsonArr1)
                M = jsonArr1;
            }else{
                M=e;
            }
            console.log("M =========================")
            console.log(M)
            M.forEach(function(marker) {
                console.log("========================")
                console.log(marker)
                new AMap.Marker({
                    map: map,
                    icon: marker[2]==1?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/c1d2f38187de40daa353fcc70993288e.png':'https://csxdj.obs.cn-south-1.myhuaweicloud.com/c1d2f38187de40daa353fcc70993288e.png',
                    position: [marker[0], marker[1]],
                    offset: new AMap.Pixel(-13, -30)
                });
            });
    function mapOrder(e){
        window._AMapSecurityConfig = {
            securityJsCode:'b62d9146929db08c4c2f4537d045320d',
        };
        AMapLoader.reset() // 需要把这个reset一下
        AMapLoader.load({
            "key": "1d43098bcd98ab124623e7e4bcc9595e",              // 申请好的Web端开发者Key,首次调用 load 时必填
            "version": "2.0",   // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
            "plugins": ['AMap.Driving'],           // 需要使用的的插件列表,如比例尺'AMap.Scale'等
            "AMapUI": {             // 是否加载 AMapUI,缺省不加载
                "version": '1.1',   // AMapUI 版本
                "plugins":['overlay/SimpleMarker'],       // 需要加载的 AMapUI ui插件
            },
            "Loca":{                // 是否加载 Loca, 缺省不加载
                "version": '2.0'  // Loca 版本
            },
        }).then((AMap)=>{
            //初始化地图对象,加载地图
            var map = new AMap.Map('containerOrder', {
                viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
                zoom:10, //初始化地图层级
                center: [102.709,25.0635] //初始化地图中心点
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
            var  allList;
            if(e==""){
                allList = $('#allList').val();
                var list = JSON.stringify(allList)
                const jsonArray = JSON.parse(list)
                const jsonArray1 = JSON.parse(jsonArray);
                console.log(jsonArray1)
                M = jsonArray1;
            }else{
                M=e;
            }
            console.log(M)
            M.forEach(function(marker) {
                new AMap.Marker({
                    map: map,
                    icon: marker[2]==301?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/8a6bb84da305438faba9fa1552c59f64.png':((marker[2]==109||marker[2]==107||marker[2]==108)?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/6132e18884e24916a507b4b55d38d07b.png':
                                    (marker[2]==101?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/7461e4a7e4004c548e91aafa538246a1.png':'https://csxdj.obs.cn-south-1.myhuaweicloud.com/d8739241fa36482b80df7cacac2cc3d1.png')
                    ),
                    position: [marker[0], marker[1]],
                    offset: new AMap.Pixel(-13, -30)
                });
            });
            // var center = map.getCenter();
            // var centerText = '当前中心点坐标:' + center.getLng() + ',' + center.getLat();
            // 添加事件监听, 使地图自适应显示到合适的范围
            AMap.event.addDomListener(document.getElementById('containerOrder'), 'click', function() {
                var newCenter = map.setFitView();
            });
        }).catch((e)=>{
            console.error(e);  //加载错误提示
        });
    }
            // var center = map.getCenter();
            // var centerText = '当前中心点坐标:' + center.getLng() + ',' + center.getLat();
            // 添加事件监听, 使地图自适应显示到合适的范围
            AMap.event.addDomListener(document.getElementById('container'), 'click', function() {
                var newCenter = map.setFitView();
            });
        }).catch((e)=>{
            console.error(e);  //加载错误提示
        });
    }
    function getOrderData(){
        $.ajax({
            url: Feng.ctxPath + '/tHomePage/getServerOrder',
            type: 'POST',
            data: {
                agentId: $("#agentId").val()
            },
            success: function (res) {
                var order = res.serverList
                var str = '<table><tr><h3>服务中</h3></tr><hr/><br>';
                if(order.length > 0){
                    for(var i in order){
                        console.log(order[i].startTime)
                        str +=
                                '<tr><img src=' + order[i].avatar + ' style="height: 40px;width: 40px"></img>' + order[i].driverName +'</tr><br>' +
                                '<table><tr><td class="name1">驾龄</td><td class="name1">' + order[i].drivingExperience + '年'+'</td><td class="name1">代驾次数</td><td class="name1">' + order[i].valetDrivingCount + '次'+'</td></tr><br></table>' +
                                '<table><br><tr><td class="name1">出行时间</td><td class="name1">' + order[i].startTime + '</td></tr>' +
                                '<tr><td class="name1">起点</td><td class="name1">' + order[i].startAddress + '</td></tr>' +
                                '<tr><td class="name1">终点</td><td class="name1">' + order[i].endAddress + '</td></tr></table><br>' +
                                '<table><tr><td class="name1">预估费用</td><td class="name1">' + order[i].estimatedPrice + '元'+'</td><td class="name1">行驶里程</td><td class="name1">' + order[i].mileageTraveled + '公里'+'</td></tr>' +
                                '<tr><td class="name1">等待时间</td><td class="name1">' + order[i].waitTime + '分钟'+'</td><td class="name1">行驶时间</td><td class="name1">' + order[i].goTime + '分钟'+'</td></tr></table><hr/>';
                    }
                }
                str += '</table>';
                $('#serverOrder').html(str);
            }
        });
    }
    function mapOrder(e){
        window._AMapSecurityConfig = {
            securityJsCode:'b62d9146929db08c4c2f4537d045320d',
        };
        AMapLoader.reset() // 需要把这个reset一下
        AMapLoader.load({
            "key": "1d43098bcd98ab124623e7e4bcc9595e",              // 申请好的Web端开发者Key,首次调用 load 时必填
            "version": "2.0",   // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
            "plugins": ['AMap.Driving'],           // 需要使用的的插件列表,如比例尺'AMap.Scale'等
            "AMapUI": {             // 是否加载 AMapUI,缺省不加载
                "version": '1.1',   // AMapUI 版本
                "plugins":['overlay/SimpleMarker'],       // 需要加载的 AMapUI ui插件
            },
            "Loca":{                // 是否加载 Loca, 缺省不加载
                "version": '2.0'  // Loca 版本
            },
        }).then((AMap)=>{
            //初始化地图对象,加载地图
            var map = new AMap.Map('containerOrder', {
                viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
                zoom:10, //初始化地图层级
                center: [113.264434,23.129162] //初始化地图中心点
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
            var  allList;
            if(e==""){
                allList = $('#allList').val();
                var list = JSON.stringify(allList)
                const jsonArray = JSON.parse(list)
                const jsonArray1 = JSON.parse(jsonArray);
                console.log(jsonArray1)
                M = jsonArray1;
            }else{
                M=e;
            }
            console.log(M)
            M.forEach(function(marker) {
                new AMap.Marker({
                    map: map,
                    icon: marker[2]==301?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/8a6bb84da305438faba9fa1552c59f64.png':((marker[2]==109||marker[2]==107||marker[2]==108)?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/6132e18884e24916a507b4b55d38d07b.png':
                            (marker[2]==101?'https://csxdj.obs.cn-south-1.myhuaweicloud.com/7461e4a7e4004c548e91aafa538246a1.png':'https://csxdj.obs.cn-south-1.myhuaweicloud.com/d8739241fa36482b80df7cacac2cc3d1.png')
                    ),
                    position: [marker[0], marker[1]],
                    offset: new AMap.Pixel(-13, -30)
                });
            });
            // var center = map.getCenter();
            // var centerText = '当前中心点坐标:' + center.getLng() + ',' + center.getLat();
            // 添加事件监听, 使地图自适应显示到合适的范围
            AMap.event.addDomListener(document.getElementById('containerOrder'), 'click', function() {
                var newCenter = map.setFitView();
            });
        }).catch((e)=>{
            console.error(e);  //加载错误提示
        });
    }
    function getOrderData(){
        $.ajax({
            url: Feng.ctxPath + '/tHomePage/getServerOrder',
            type: 'POST',
            data: {
                agentId: $("#agentId").val()
            },
            success: function (res) {
                var order = res.serverList
                var str = '<table><tr><h3>服务中</h3></tr><hr/><br>';
                if(order.length > 0){
                    for(var i in order){
                        console.log(order[i].startTime)
                        str +=
                            '<tr><img src=' + order[i].avatar + ' style="height: 40px;width: 40px"></img>' + order[i].driverName +'</tr><br>' +
                            '<table><tr><td class="name1">驾龄</td><td class="name1">' + order[i].drivingExperience + '年'+'</td><td class="name1">代驾次数</td><td class="name1">' + order[i].valetDrivingCount + '次'+'</td></tr><br></table>' +
                            '<table><br><tr><td class="name1">出行时间</td><td class="name1">' + order[i].startTime + '</td></tr>' +
                            '<tr><td class="name1">起点</td><td class="name1">' + order[i].startAddress + '</td></tr>' +
                            '<tr><td class="name1">终点</td><td class="name1">' + order[i].endAddress + '</td></tr></table><br>' +
                            '<table><tr><td class="name1">预估费用</td><td class="name1">' + order[i].estimatedPrice + '元'+'</td><td class="name1">行驶里程</td><td class="name1">' + order[i].mileageTraveled + '公里'+'</td></tr>' +
                            '<tr><td class="name1">等待时间</td><td class="name1">' + order[i].waitTime + '分钟'+'</td><td class="name1">行驶时间</td><td class="name1">' + order[i].goTime + '分钟'+'</td></tr></table><hr/>';
                    }
                }
                str += '</table>';
                $('#serverOrder').html(str);
            }
        });
    }
</script>
@}
management/guns-admin/src/main/webapp/WEB-INF/view/system/tOrder/tOrder_add.html
@@ -75,7 +75,6 @@
    //地图加载
    var map1 = new AMap.Map("container1", {
        zoom: 13,
        center: [104.064, 30.6576],
        resizeEnable: true
    });
@@ -168,7 +167,6 @@
    var map2 = new AMap.Map("container2", {
        zoom: 13,
        center: [104.064, 30.6576],
        resizeEnable: true
    });
user/guns-admin/src/main/java/com/agentdriving/user/modular/system/service/impl/AppUserServiceImpl.java
@@ -176,7 +176,19 @@
            appUser.setInviterType(signInToRegister.getInviterType());
            this.insert(appUser);
            //发送优惠券
            boolean lock = redisUtil.lock();
            boolean lock = redisUtil.lock(5);
            if(!lock){
                int num1 = 1;
                while (num1 <= 10){
                    Thread.sleep(3000);//等待3秒
                    lock = redisUtil.lock(5);
                    if(lock){
                        break;
                    }else{
                        num1++;
                    }
                }
            }
            if(lock){
                List<CouponWarpper> list = pushCoupon(appUser.getId());
                redisUtil.unlock();
@@ -212,7 +224,7 @@
            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)));
            userToCoupon.setExpireTime(new Date(System.currentTimeMillis() + (coupon.getCouponValidity().longValue() * 24L * 60L * 60L * 1000L)));
            userToCouponService.insert(userToCoupon);
            coupon.setRemainingQuantity(coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? 0 :
user/guns-admin/src/main/java/com/agentdriving/user/modular/system/service/impl/OrderServiceImpl.java
@@ -554,163 +554,199 @@
     * 订单推送逻辑
     */
    public void pushOrder(Long orderId){
        Order order = this.selectById(orderId);
        /**
         * 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(startLng), Double.valueOf(startLat));
        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());
        logger.warn("范围内司机--》" + JSON.toJSONString(driverIds));
        Integer driver = null;
        YouTuiDriver youTuiDriver1 = null;
        if(driverIds.size() > 0){
            List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds)
                    .eq("state", 2).last(" and (surplusQuantity > 0 or now() < endTime) and now() < failureTime"));
            Double d = null;
            logger.warn("优推司机--》" + JSON.toJSONString(youTuiDrivers));
            for (YouTuiDriver youTuiDriver : youTuiDrivers) {
                String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId());
                if(ToolUtil.isEmpty(value)){
                    continue;
                }
                Driver driver1 = driverService.selectById(youTuiDriver.getDriverId());
                if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1){
                    continue;
                }
                DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1));
                if(null == driverWork){
                    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();
                    youTuiDriver1 = youTuiDriver;
                    logger.warn("最优优推司机--》" + JSON.toJSONString(driver));
        try {
            Order order = this.selectById(orderId);
            /**
             * 1.先找最大推单范围内的优推司机 -》 距离最近
             * 没有1 - 》
             *      2.按照后台推送配置在范围内查找合适司机
             *        合适司:积分 > 评分 > 距离
             *      3.司机没有接单直接将订单置入大厅
             */
            boolean lock = redisUtil.lock(5);
            if(!lock){
                int num1 = 1;
                while (num1 <= 10){
                    Thread.sleep(3000);//等待3秒
                    lock = redisUtil.lock(5);
                    if(lock){
                        break;
                    }else{
                        num1++;
                    }
                }
            }
        }
        if(null != youTuiDriver1 && youTuiDriver1.getType() == 1){
            youTuiDriver1.setSurplusQuantity(youTuiDriver1.getSurplusQuantity() - 1);
            youTuiDriverService.updateById(youTuiDriver1);
        }
            if(!lock){
                order.setHallOrder(1);
                this.updateById(order);
                ExtraPushOrder(order);
                redisUtil.unlock();
            }
            SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1));
            if(null == systemConfig){
                redisUtil.unlock();
                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();
        //开始范围查找
        if(null == driver){
            for (int i = 1; i < 4; i++) {
                if(null != driver){
                    break;
                }
                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());
                logger.warn("范围内司机--》" + JSON.toJSONString(driverIds));
                if(driverIds.size() > 0){
                    List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2)
                            .eq("serverStatus", 1).eq("openOrderQRCode", 0).eq("status", 1).in("id", driverIds));
                    logger.warn("范围内空闲司机--》" + JSON.toJSONString(drivers));
                    if(drivers.size() == 0){
            //1
            //找到中心点
            GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(startLng), Double.valueOf(startLat));
            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;
            YouTuiDriver youTuiDriver1 = null;
            if(driverIds.size() > 0){
                List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds)
                        .eq("state", 2).last(" and surplusQuantity > 0 and now() < endTime and now() < failureTime"));
                Double d = null;
                for (YouTuiDriver youTuiDriver : youTuiDrivers) {
                    String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId());
                    if(ToolUtil.isEmpty(value)){
                        continue;
                    }
                    Driver driver1 = driverService.selectById(youTuiDriver.getDriverId());
                    if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1){
                        continue;
                    }
                    DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1));
                    if(null == driverWork){
                        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();
                        youTuiDriver1 = youTuiDriver;
                    }
                }
            }
            if(null != youTuiDriver1 && youTuiDriver1.getType() == 1){
                youTuiDriver1.setSurplusQuantity(youTuiDriver1.getSurplusQuantity() - 1);
                youTuiDriverService.updateById(youTuiDriver1);
            }
                    Integer integral = null;//积分
                    Double score = null;//评分
                    Double d = null;
                    for (Driver driver1 : drivers) {
                        String value = redisUtil.getValue("DRIVER" + driver1.getId());
                        if(ToolUtil.isEmpty(value)){
            //开始范围查找
            if(null == driver){
                for (int i = 1; i < 4; i++) {
                    if(null != driver){
                        break;
                    }
                    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("openOrderQRCode", 0).eq("status", 1).in("id", driverIds));
                        if(drivers.size() == 0){
                            continue;
                        }
                        DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1));
                        if(null == driverWork){
                            continue;
                        }
                        if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大
                            integral = driver1.getIntegral();
                            score = driver1.getScore();
                            driver = driver1.getId();
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            d = wgs84;
                            continue;
                        }
                        if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分
                            integral = driver1.getIntegral();
                            score = driver1.getScore();
                            driver = driver1.getId();
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            d = wgs84;
                            continue;
                        }
                        if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            if(d.compareTo(wgs84) > 0){
                                d = wgs84;
                        Integer integral = null;//积分
                        Double score = null;//评分
                        Double d = null;
                        for (Driver driver1 : drivers) {
                            String value = redisUtil.getValue("DRIVER" + driver1.getId());
                            if(ToolUtil.isEmpty(value)){
                                continue;
                            }
                            DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1));
                            if(null == driverWork){
                                continue;
                            }
                            if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大
                                integral = driver1.getIntegral();
                                score = driver1.getScore();
                                driver = driver1.getId();
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                d = wgs84;
                                continue;
                            }
                            if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分
                                integral = driver1.getIntegral();
                                score = driver1.getScore();
                                driver = driver1.getId();
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                d = wgs84;
                                continue;
                            }
                            if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离
                                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                                Double wgs84 = distance.get("WGS84");
                                if(d.compareTo(wgs84) > 0){
                                    d = wgs84;
                                    integral = driver1.getIntegral();
                                    score = driver1.getScore();
                                    driver = driver1.getId();
                                    continue;
                                }
                            }
                        }
                    }
                    }
                }
            }
        }
        logger.warn("最终的司机--》" + JSON.toJSONString(driver));
        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);
                        ExtraPushOrder(order1);
            if(null != driver){
                //防止多笔订单推给一个司机
                Driver driver1 = driverService.selectById(driver);
                driver1.setServerStatus(2);
                driverService.updateById(driver1);
                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.getState() != 301 && order1.getDriverId().compareTo(driver1.getId()) != 0){
                            driver1.setServerStatus(1);
                            driverService.updateById(driver1);
                        }
                        if(order1.getState() == 201 || order1.getState() == 301 || (order1.getState() == 101 && null == order1.getDriverId())){
                            driver1.setServerStatus(1);
                            driverService.updateById(driver1);
                        }
                        if(order1.getState() == 201 || (order1.getState() == 101 && null == order1.getDriverId())){
                            order1.setHallOrder(1);
                            OrderServiceImpl.this.updateById(order1);
                            ExtraPushOrder(order);
                        }
                    }
                }
            }, num4 * 1000);
        }else{
            order.setHallOrder(1);
            this.updateById(order);
            ExtraPushOrder(order);
                }, num4 * 1000);
            }else{
                order.setHallOrder(1);
                this.updateById(order);
                ExtraPushOrder(order);
            }
            redisUtil.unlock();
        }catch (Exception e){
            e.printStackTrace();
            redisUtil.unlock();
        }
    }
    public void ExtraPushOrder(Order order){