From 8e9440ea0a09fc6d9cea1c205904c51ccbf62a2a Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期一, 24 七月 2023 15:07:53 +0800 Subject: [PATCH] 超省2.0 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java | 78 ++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 9 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java index 966a7ee..39c2621 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java @@ -13,6 +13,9 @@ import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.dao.DriverMapper; import com.supersavedriving.driver.modular.system.util.*; +import com.supersavedriving.driver.modular.system.util.MallBook.model.InterfaceResponse; +import com.supersavedriving.driver.modular.system.util.MallBook.model.Register; +import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest; import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; import com.supersavedriving.driver.modular.system.warpper.*; @@ -95,6 +98,9 @@ @Autowired private RongYunUtil rongYunUtil; + @Autowired + private PushUtil pushUtil; + /** @@ -159,7 +165,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()); @@ -176,6 +185,7 @@ driver.setApprovalTime(null); driver.setApprovalUserId(null); driver.setStatus(1); + driver.setSource(driverRegisterWarpper.getSource()); return driver; } @@ -309,12 +319,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 ""; @@ -540,17 +559,17 @@ Driver driver = this.selectById(uid); DriverInfoWarpper driverInfo = new DriverInfoWarpper(); BeanUtils.copyProperties(driver, driverInfo); + 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){ driverInfo.setYouTuiEnd(youTuiDriver.getType() == 1 ? youTuiDriver.getFailureTime().getTime() : youTuiDriver.getEndTime().getTime()); } List<Integer> state = Arrays.asList(107, 108, 109); - int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m-%d', createTime) = DATE_FORMAT('%Y-%m-%d', now())")); + int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT(createTime, '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d')")); driverInfo.setTodayNum(count); - count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m', createTime) = DATE_FORMAT('%Y-%m', now())")); + count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT(createTime, '%Y-%m') = DATE_FORMAT(now(), '%Y-%m')")); driverInfo.setMonthNum(count); DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); driverInfo.setWork(null == driverWork ? 0 : 1); @@ -702,9 +721,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); @@ -755,9 +774,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); @@ -841,4 +860,45 @@ this.updateById(driver); return ResultUtil.success(); } + + + /** + * 开通小微商户 + * @param name + * @param number + * @param phone + * @return + * @throws Exception + */ + @Override + public ResultUtil microenterprise(Integer uid, String name, String number, String phone) throws Exception { + Driver driver = this.selectById(uid); + Register registerVO = new Register(); + registerVO.setMerUserId("driver_" + uid); + registerVO.setPhone(phone); + registerVO.setUserType("0"); + registerVO.setUserName(name); + registerVO.setCertId(number); + registerVO.setNotifyUrl(""); + TrhRequest<Register> request = new TrhRequest(); + InterfaceResponse execute = request.execute(registerVO, Register.SERVICE_CODE); + if(!"0000".equals(execute.getResult())){ + return ResultUtil.error(execute.getMsg()); + } + JSONObject jsonObject = JSON.parseObject(execute.getResult()); + String status = jsonObject.getString("status"); + if("2".equals(status)){ + return ResultUtil.error("失败"); + } + if("0".equals(status)){ + return ResultUtil.error("处理中"); + } + String userId = jsonObject.getString("userId"); + driver.setMerchantNumber(userId); + driver.setMerchantIDCode(number); + driver.setMerchantName(name); + driver.setMerchantPhone(phone); + this.updateById(driver); + return ResultUtil.success(); + } } -- Gitblit v1.7.1