| | |
| | | import com.doumee.dao.vo.DriverCancelLimitVO; |
| | | import com.doumee.dao.vo.DriverCenterVO; |
| | | import com.doumee.dao.vo.DriverGrabOrderVO; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import com.doumee.dao.vo.DriverOrderDetailVO; |
| | | import com.doumee.core.utils.aliyun.AliSmsService; |
| | | import com.doumee.service.business.DriverInfoService; |
| | |
| | | |
| | | @Autowired |
| | | private AreasBizImpl areasBiz; |
| | | |
| | | @Autowired |
| | | private SystemUserService systemUserService; |
| | | |
| | | /** |
| | | * 发送订单站内信通知 |
| | |
| | | .select(" ( select ifnull(sum(r.OPT_TYPE * r.AMOUNT),0) from revenue r where r.MEMBER_TYPE = 1 and r.MEMBER_ID= t.id and r.VAILD_STATUS = 1 ) as memberAmount ") |
| | | .selectAs(Category::getName,DriverInfo::getCarTypeName) |
| | | .leftJoin(Category.class, Category::getId,DriverInfo::getCarType); |
| | | for (PageWrap.SortData sortData : pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | queryWrapper.orderByDesc(DriverInfo::getId); |
| | | PageData<DriverInfo> pageData = PageData.from(driverInfoMapper.selectPage(page, queryWrapper)); |
| | | for (DriverInfo d : pageData.getRecords()) { |
| | | d.setGender(Constants.getGenderByIdCard(d.getIdcard())); |
| | |
| | | String code = RandomStringUtils.randomNumeric(6); |
| | | // 发送短信 |
| | | String templateParam = "{\"code\":\"" + code + "\"}"; |
| | | AliSmsService.sendSms(telephone, "SMS_491325122", templateParam); |
| | | AliSmsService.sendSms(telephone, Constants.SmsNotify.VERIFY_CODE.getTemplateCode(), templateParam); |
| | | // 保存短信记录 |
| | | Smsrecord smsrecord = new Smsrecord(); |
| | | smsrecord.setDeleted(Constants.ZERO); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 查询审批人名称 |
| | | if (driverInfo.getAuditUser() != null) { |
| | | try { |
| | | SystemUser auditUser = systemUserService.findById(driverInfo.getAuditUser()); |
| | | if (auditUser != null) { |
| | | driverInfo.setAuditUserName(auditUser.getRealname()); |
| | | } |
| | | } catch (Exception e) { |
| | | // 审批人已删除等异常忽略 |
| | | } |
| | | } |
| | | return driverInfo; |
| | | } |
| | | |
| | |
| | | vo.setCarCode(driver.getCarCode()); |
| | | vo.setScore(driver.getScore() != null ? driver.getScore().toPlainString() : "0"); |
| | | vo.setDriverLevel(driver.getDriverLevel()); |
| | | vo.setDriverLevelName(Constants.getDriverLevelName(driver.getDriverLevel())); |
| | | vo.setAuditStatus(driver.getAuditStatus()); |
| | | vo.setAuditRemark(driver.getAuditRemark()); |
| | | vo.setBalance(driver.getBalance() != null ? driver.getBalance() : 0L); |
| | |
| | | vo.setFullImgUrl(imgPrefix + driver.getImgurl()); |
| | | } |
| | | |
| | | // 今日预计佣金:revenue表中今天的收入记录金额之和 |
| | | // 今日预计佣金:今日接单的司机佣金 + 平台奖励金 |
| | | Date now = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(now); |
| | |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | Date todayStart = cal.getTime(); |
| | | |
| | | QueryWrapper<Revenue> revenueWrapper = new QueryWrapper<>(); |
| | | revenueWrapper.lambda() |
| | | .eq(Revenue::getMemberId, memberId) |
| | | .eq(Revenue::getMemberType, Constants.ONE) |
| | | .eq(Revenue::getOptType, Constants.ONE) |
| | | .eq(Revenue::getDeleted, Constants.ZERO) |
| | | .ge(Revenue::getCreateTime, todayStart); |
| | | revenueWrapper.select("IFNULL(SUM(AMOUNT),0) as amount"); |
| | | Revenue sumResult = revenueMapper.selectOne(revenueWrapper); |
| | | vo.setTodayCommission(sumResult != null && sumResult.getAmount() != null ? sumResult.getAmount() : 0L); |
| | | QueryWrapper<Orders> commissionWrapper = new QueryWrapper<>(); |
| | | commissionWrapper.lambda() |
| | | .eq(Orders::getAcceptDriver, driver.getId()) |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .ge(Orders::getAcceptTime, todayStart); |
| | | commissionWrapper.select("IFNULL(SUM(DRIVER_FEE),0) as driverFee", "IFNULL(SUM(PLATFORM_REWARD_AMOUNT),0) as platformRewardAmount"); |
| | | Orders commissionResult = ordersMapper.selectOne(commissionWrapper); |
| | | long driverFee = commissionResult != null && commissionResult.getDriverFee() != null ? commissionResult.getDriverFee() : 0L; |
| | | long rewardAmount = commissionResult != null && commissionResult.getPlatformRewardAmount() != null ? commissionResult.getPlatformRewardAmount() : 0L; |
| | | vo.setTodayCommission(driverFee + rewardAmount); |
| | | |
| | | // 今日接单数:今天完成的订单数(acceptDriver=司机主键,状态=已完成) |
| | | Long todayOrderCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | |
| | | .select("c2.other_field as c2OtherField") |
| | | .select("c2.name as goodLevelName") |
| | | // 是否存在特大尺寸 |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.OTHER_FIELD = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.detail = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | // JOIN |
| | | .leftJoin("shop_info s1 on s1.id = t.DEPOSIT_SHOP_ID and s1.DELETED = 0") |
| | | .leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID and s2.DELETED = 0") |
| | |
| | | |
| | | // 7. 通知会员:司机已抢单 |
| | | sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_PICKUP_GRABBED, orderId, |
| | | "orderNo", order.getCode(), |
| | | "driverName", driver.getName()); |
| | | |
| | | // 通知存件门店:订单已抢单待取件 |
| | |
| | | for (int i = 0; i < paramPairs.length - 1; i += 2) { |
| | | templateParam.put(paramPairs[i], paramPairs[i + 1]); |
| | | } |
| | | boolean result = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | String error = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | templateParam.toJSONString()); |
| | | if (result) { |
| | | log.info("短信发送成功: phone={}, template={}", phone, smsNotify.name()); |
| | | } else { |
| | | log.warn("短信发送失败: phone={}, template={}", phone, smsNotify.name()); |
| | | } |
| | | // 存储短信记录 |
| | | Smsrecord record = new Smsrecord(); |
| | | record.setPhone(phone); |
| | | record.setContent(content); |
| | | record.setType(Constants.ONE); // 1=订单通知 |
| | | record.setStatus(result ? Constants.ONE : Constants.ZERO); |
| | | record.setType(Constants.ONE); |
| | | record.setStatus(error == null ? Constants.ONE : Constants.ZERO); |
| | | if (error != null) { |
| | | record.setRemark(error); |
| | | } |
| | | record.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |
| | |
| | | record.setContent(content); |
| | | record.setType(Constants.ONE); |
| | | record.setStatus(Constants.ZERO); |
| | | record.setRemark(e.getMessage()); |
| | | record.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |