|
|
@@ -11,6 +11,7 @@ import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -23,6 +24,7 @@ import com.ylx.common.core.domain.model.LoginUser;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
+import com.ylx.fareSetting.service.IMaProjectFareSettingService;
|
|
|
import com.ylx.massage.controller.CityOperationApplicationController;
|
|
|
import com.ylx.massage.domain.*;
|
|
|
import com.ylx.massage.domain.dto.*;
|
|
|
@@ -48,6 +50,8 @@ import com.ylx.massage.mapper.ContractRecordMapper;
|
|
|
import com.ylx.massage.mapper.MaProjectMapper;
|
|
|
import com.ylx.massage.mapper.MaTeProjectMapper;
|
|
|
import com.ylx.massage.service.TbFileService;
|
|
|
+import com.ylx.merchant.domain.dto.MerchantListDTO;
|
|
|
+import com.ylx.merchant.domain.vo.MerchantListVO;
|
|
|
import com.ylx.order.domain.TOrder;
|
|
|
import com.ylx.order.mapper.TOrderMapper;
|
|
|
import com.ylx.project.domain.Project;
|
|
|
@@ -121,6 +125,8 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
private IMaTechnicianService maTechnicianService;
|
|
|
@Resource
|
|
|
private CityOperationApplicationMapper cityOperationApplicationMapper;
|
|
|
+ @Resource
|
|
|
+ private IMaProjectFareSettingService maProjectFareSettingService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -957,7 +963,39 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<MerchantListVO> getMerchantPage(MerchantListDTO dto) {
|
|
|
+
|
|
|
+ // 1. 执行分页查询 (不带免车费过滤)
|
|
|
+ Page<MerchantListVO> page = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
+ page = this.baseMapper.getMerchantPage(page, dto);
|
|
|
+ List<MerchantListVO> records = page.getRecords();
|
|
|
+ if (CollUtil.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 如果用户勾选了“免车费”,则在内存中进行精准过滤
|
|
|
+ if (Boolean.TRUE.equals(dto.getFreeCarFee())) {
|
|
|
+ boolean isDay = this.maProjectFareSettingService.isDayTimePeriod(LocalDateTime.now());
|
|
|
+
|
|
|
+ // 3. 过滤列表
|
|
|
+ Iterator<MerchantListVO> iterator = records.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ MerchantListVO vo = iterator.next();
|
|
|
+ double currentDistance = vo.getDistance(); // 数据库算出的距离(km)
|
|
|
|
|
|
+ // 获取该商户的有效免费里程
|
|
|
+ BigDecimal freeKm = this.maProjectFareSettingService.getMerchantFreeKm(vo.getId(), dto.getProjectId(),isDay);
|
|
|
+
|
|
|
+ // 核心判断:如果没配置(为0) 或者 距离超过了免费里程,则剔除
|
|
|
+ if (freeKm == null || freeKm.doubleValue() <= 0 || currentDistance > freeKm.doubleValue()) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private void extracted(MaProjectSaveDto dto) {
|