puzhibing
2023-05-29 9154555e3bee0767b4aff7a8eaa36456b7b5dea7
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java
@@ -98,6 +98,12 @@
    @Autowired
    private RongYunUtil rongYunUtil;
    @Autowired
    private PushUtil pushUtil;
    @Value("${callbackPath}")
    private String callbackPath;
    /**
@@ -162,7 +168,10 @@
        String code = driverRegisterWarpper.getCode();
        BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("districtCode", code).eq("status", 1));
        if(null == branchOffice){
            throw new Exception("该区域无服务商");
            branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("cityCode", code).eq("status", 1));
            if(null == branchOffice){
                throw new Exception("该区域无服务商");
            }
        }
        driver.setBranchOfficeId(branchOffice.getId());
        driver.setAgentId(branchOffice.getAgentId());
@@ -313,13 +322,21 @@
                usernamePasswordToken, simpleAuthenticationInfo);
        if (passwordTrueFlag) {
            String token = JwtTokenUtil.generateToken(phone);
            String token = JwtTokenUtil.generateToken(phone + System.currentTimeMillis());
            String key = token;
            if(token.length() > 16){
                key = token.substring(token.length() - 16);
            }
            redisUtil.setStrValue(key, driver.getId().toString(), 7 * 24 * 60 * 60);//7天
            redisUtil.setStrValue("DRIVER_" + phone, key, 7 * 24 * 60 * 60);//7天
            //下线
            for (int i = 0; i < 5; i++) {
                Integer code = pushUtil.pushOffline(driver.getId(), 2);
                if(200 == code){
                    break;
                }
            }
            return token;
        }
        return "";
@@ -468,7 +485,7 @@
    @Override
    public PromotionWarpper queryPromotionQRCode(Integer uid) throws Exception {
        PromotionWarpper promotionWarpper = new PromotionWarpper();
        promotionWarpper.setUrl("http://121.37.15.157/share/driverShare/index.html?inviterId=" + uid);
        promotionWarpper.setUrl("https://chaoshengdaijia.com/share/driverShare/index.html?inviterId=" + uid);
        int user = appUserService.selectCount(new EntityWrapper<AppUser>().eq("inviterType", 2).eq("inviterId", uid).eq("status", 1));
        int driver = this.selectCount(new EntityWrapper<Driver>().eq("inviterType", 2).eq("inviterId", uid).eq("approvalStatus", 2).eq("status", 1));
        promotionWarpper.setTotal(user + driver);
@@ -545,8 +562,8 @@
        Driver driver = this.selectById(uid);
        DriverInfoWarpper driverInfo = new DriverInfoWarpper();
        BeanUtils.copyProperties(driver, driverInfo);
        driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
        driverInfo.setWithdrawBalance(driver.getBalance());
        driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
        YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid)
                .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1"));
        if(null != youTuiDriver){
@@ -707,9 +724,9 @@
                                accountChangeDetail.setType(1);
                                accountChangeDetail.setCreateTime(new Date());
                                accountChangeDetail.setExplain("余额充值");
                                accountChangeDetail.setOldData(driver1.getBalance());
                                accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                driver1.setBalance(driver1.getBalance() + amount);
                                accountChangeDetail.setNewData(driver1.getBalance());
                                accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                DriverServiceImpl.this.updateById(driver1);
                                accountChangeDetailService.saveData(accountChangeDetail);
@@ -760,9 +777,9 @@
        accountChangeDetail.setType(1);
        accountChangeDetail.setCreateTime(new Date());
        accountChangeDetail.setExplain("余额充值");
        accountChangeDetail.setOldData(driver1.getBalance());
        accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
        driver1.setBalance(driver1.getBalance() + rechargeRecord1.getAmount());
        accountChangeDetail.setNewData(driver1.getBalance());
        accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
        this.updateById(driver1);
        accountChangeDetailService.saveData(accountChangeDetail);
@@ -857,7 +874,7 @@
     * @throws Exception
     */
    @Override
    public ResultUtil microenterprise(Integer uid, String name, String number, String phone) throws Exception {
    public ResultUtil microenterprise(Integer uid, String name, String number, String phone, String notifyUrl) throws Exception {
        Driver driver = this.selectById(uid);
        Register registerVO = new Register();
        registerVO.setMerUserId("driver_" + uid);
@@ -865,10 +882,10 @@
        registerVO.setUserType("0");
        registerVO.setUserName(name);
        registerVO.setCertId(number);
        registerVO.setNotifyUrl("");
        registerVO.setNotifyUrl(callbackPath + notifyUrl);
        TrhRequest<Register> request = new TrhRequest();
        InterfaceResponse execute = request.execute(registerVO, Register.SERVICE_CODE);
        if(!"0000".equals(execute.getResult())){
        if(!"0000".equals(execute.getCode())){
            return ResultUtil.error(execute.getMsg());
        }
        JSONObject jsonObject = JSON.parseObject(execute.getResult());