puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
修改bug
22个文件已修改
644 ■■■■■ 已修改文件
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 337 ●●●●● 补丁 | 查看 | 原始文档 | 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 47 ●●●●● 补丁 | 查看 | 原始文档 | 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 62 ●●●●● 补丁 | 查看 | 原始文档 | 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 54 ●●●● 补丁 | 查看 | 原始文档 | 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,9 +465,10 @@
    /**
     * 订单推送逻辑
     * @param order
     */
    public void pushOrder(Order order){
    public void pushOrder(Long orderId){
        try {
            Order order = this.selectById(orderId);
        /**
         * 1.先找最大推单范围内的优推司机 -》 距离最近
         * 没有1 - 》
@@ -471,7 +476,6 @@
         *        合适司:积分 > 评分 > 距离
         *      3.司机没有接单直接将订单置入大厅
         */
        try {
            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() {
                        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);
                        Order order1 = OrderServiceImpl.this.selectById(order.getId());
                        if(order1.getState() == 101 || order1.getState() == 201){
                        }
                        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,8 +1405,9 @@
        Driver driver = driverService.selectById(order.getDriverId());
        AppUser appUser = appUserService.selectById(order.getUserId());
        if(null != order.getUserId()){
        //司机推荐首单收入
        List<Integer> state = Arrays.asList(108, 109);
            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());
@@ -1394,39 +1430,88 @@
            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 != 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){
                    //司机推荐用户收入
                    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(num4);
                            revenue.setAmount(num1);
                            revenue.setCreateTime(new Date());
                            revenueService.insert(revenue);
                        }
                        num3 = (num3 >= num1 ? num3 - num1 : 0);
                    }
                    //开始处理层级抽佣
                    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 num5 = jsonObject1.getDouble("num5");
                                Double num6 = jsonObject1.getDouble("num6");
                                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(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,15 +1577,72 @@
                                    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 num3_ = jsonObject1.getDouble("num3");
                                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(num3_);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
                                    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() + num3_);
                                    accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    driverService.updateById(driver1);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num3_ ? num3 - 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(num4);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver2.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num4);
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num4 ? num3 - num4 : 0);
                                }
                                }
                            }else{
                                Double num2_ = jsonObject1.getDouble("num2");
                                Double num3_ = jsonObject1.getDouble("num3");
                                num2_ = (num3 >= num2_ ? num2_ : num3);
                                if(num2_ > 0){
                                    Revenue revenue = new Revenue();
@@ -1526,61 +1669,6 @@
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num2_ ? num3 - num2_ : 0);
                                }
                                num3_ = (num3 >= num3_ ? num3_ : num3);
                                if(num3_ > 0){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
                                    revenue.setUserId(driver2.getId());
                                    revenue.setOrderId(order.getId());
                                    revenue.setAmount(num3_);
                                    revenue.setCreateTime(new Date());
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver2.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num3_);
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num3_ ? num3 - num3_ : 0);
                                }
                            }
                        }else{
                            Double num1_ = jsonObject1.getDouble("num1");
                            num1_ = (num3 >= num1_ ? num1_ : num3);
                            if(num1_ > 0){
                                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);
                                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());
                                driverService.updateById(driver1);
                                accountChangeDetailService.saveData(accountChangeDetail);
                                num3 = (num3 >= num1_ ? num3 - num1_ : 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,15 +1856,12 @@
    @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());
                    Driver driver = driverService.selectById(order.getDriverId());
@@ -1803,17 +1870,17 @@
                    accountChangeDetail.setUserType(2);
                    accountChangeDetail.setUserId(order.getDriverId());
                    accountChangeDetail.setCreateTime(new Date());
                    accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                accountChangeDetail.setOldData(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());
                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,6 +127,27 @@
            cw.type = 2 AND cw.businessType = #{type} AND cw.code = #{code}
    </select>
    <select id="getDataStatisticsIncomeOrCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
        <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 a.agentId = #{agentId}
            </if>
            <if test="monthDate != null and monthDate != ''">
                AND date_format(a.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
            </if>
            ) 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
@@ -146,6 +167,7 @@
        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,6 +191,30 @@
        ORDER BY amount DESC
    </select>
    <select id="getDataStatisticsIncomeOrCommissionByIds" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
        <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 a.agentId IN
                <foreach collection="ids" close=")" open="(" item="id" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="monthDate != null and monthDate != ''">
                AND date_format(a.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
            </if>
            ) 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
@@ -191,6 +237,7 @@
        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
@@ -366,7 +366,7 @@
                    queryOrderCount()
                    break;
                case "map":
                    map("",102.709,25.0635);
                    map("",113.264434,23.129162);
                    break;
                case "order":
                    mapOrder("");
@@ -381,6 +381,10 @@
        // orderByMonth(new Date().getMonth() + 1)
        // orderByYear(new Date().getFullYear())
        // queryOrderCount()
        setInterval(function () {
            console.log(1111111111)
            getData()
        }, 30000);
    })
    function selectYear(e){
@@ -417,11 +421,16 @@
            selectMonth(value)// change 每点一次都会监听一遍
        }
    });
    laydate.render({
        elem: '#createTime',
        type: 'date',
        range: true
    });
    // 进度条加载
    function loading(){
        var options = $.extend({
            percentage : $('#agentTotal').text(),
            percentage : $('#agentTotal').text()<100?$('#agentTotal').text():($('#agentTotal').text()>1000?$('#agentTotal').text()/100:$('#agentTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
@@ -434,7 +443,7 @@
        });
        $('#pro1').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#agentMonthTotal').text(),
            percentage : $('#agentMonthTotal').text()<100?$('#agentMonthTotal').text():($('#agentMonthTotal').text()>1000?$('#agentMonthTotal').text()/100:$('#agentMonthTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
@@ -447,7 +456,7 @@
        });
        $('#pro2').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverTotal').text(),
            percentage : $('#driverTotal').text()<100?$('#driverTotal').text():($('#driverTotal').text()>1000?$('#driverTotal').text()/100:$('#driverTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
@@ -460,7 +469,7 @@
        });
        $('#pro3').LineProgressbar(options);
        var options = $.extend({
            percentage : $('#driverMonthTotal').text(),
            percentage : $('#driverMonthTotal').text()<100?$('#driverMonthTotal').text():($('#driverMonthTotal').text()>1000?$('#driverMonthTotal').text()/100:$('#driverMonthTotal').text()/10),
            ShowProgressCount: false,
            duration: 10,
@@ -706,13 +715,6 @@
    })
    /**
     * 定时器
     */
    setInterval(function () {
        getData();
    }, 30000);
    function getData(){
@@ -722,9 +724,9 @@
            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)
            $('#onLineDriver').val(data.onLineDriver);
            console.log(data.onLineDriver)
            map(data.onLineDriver,data.addressLon,data.addressLat)
            getOrderData()
        }, function (data) {
@@ -742,8 +744,8 @@
            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)
            $('#onLineDriver').val(data.onLineDriver);
            map(data.onLineDriver,data.addressLon,data.addressLat)
            getOrderData()
        }, function (data) {
        });
@@ -794,11 +796,6 @@
        window._AMapSecurityConfig = {
            securityJsCode:'b62d9146929db08c4c2f4537d045320d',
        };
        laydate.render({
            elem: '#createTime',
            type: 'date',
            range: true
        });
        AMapLoader.reset() // 需要把这个reset一下
        AMapLoader.load({
@@ -821,13 +818,30 @@
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
            const  onLineDriver = $('#onLineDriver').val();
            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',
@@ -868,7 +882,7 @@
            var map = new AMap.Map('containerOrder', {
                viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
                zoom:10, //初始化地图层级
                center: [102.709,25.0635] //初始化地图中心点
                center: [113.264434,23.129162] //初始化地图中心点
            });
            // map.clearMap();  // 清除地图覆盖物
            // 经纬度坐标数组
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,6 +554,7 @@
     * 订单推送逻辑
     */
    public void pushOrder(Long orderId){
        try {
        Order order = this.selectById(orderId);
        /**
         * 1.先找最大推单范围内的优推司机 -》 距离最近
@@ -562,8 +563,28 @@
         *        合适司:积分 > 评分 > 距离
         *      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(!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());
@@ -584,14 +605,12 @@
        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"));
                        .eq("state", 2).last(" and surplusQuantity > 0 and 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)){
@@ -611,7 +630,6 @@
                    d = wgs84;
                    driver = youTuiDriver.getDriverId();
                    youTuiDriver1 = youTuiDriver;
                    logger.warn("最优优推司机--》" + JSON.toJSONString(driver));
                }
            }
        }
@@ -636,11 +654,9 @@
                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){
                        continue;
                    }
@@ -657,6 +673,7 @@
                        if(null == driverWork){
                            continue;
                        }
                        if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大
                            integral = driver1.getIntegral();
                            score = driver1.getScore();
@@ -691,18 +708,31 @@
                }
            }
        }
        logger.warn("最终的司机--》" + JSON.toJSONString(driver));
        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){
                        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);
@@ -711,6 +741,12 @@
            this.updateById(order);
            ExtraPushOrder(order);
        }
            redisUtil.unlock();
        }catch (Exception e){
            e.printStackTrace();
            redisUtil.unlock();
        }
    }
    public void ExtraPushOrder(Order order){