|
@@ -14,6 +14,9 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
|
|
+import shop.alien.entity.store.vo.ClockInRecordValidateVo;
|
|
|
|
|
+import shop.alien.entity.store.vo.MonthClockInItem;
|
|
|
|
|
+import shop.alien.entity.store.vo.StoreClockInPageVo;
|
|
|
import shop.alien.entity.store.vo.StoreClockInVo;
|
|
import shop.alien.entity.store.vo.StoreClockInVo;
|
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
import shop.alien.mapper.*;
|
|
import shop.alien.mapper.*;
|
|
@@ -132,8 +135,9 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public IPage<StoreClockInVo> getStoreClockInList(Integer userId, int page, int size, String phoneId, int mySelf,Integer storeId) {
|
|
|
|
|
|
|
+ public IPage<StoreClockInVo> getStoreClockInList(Integer userId, int page, int size, String phoneId, int mySelf, Integer storeId, Integer year, Integer month, String city) {
|
|
|
IPage<StoreClockIn> iPage = new Page<>(page, size);
|
|
IPage<StoreClockIn> iPage = new Page<>(page, size);
|
|
|
|
|
+ String cityFilter = normalizeCityFilter(city);
|
|
|
|
|
|
|
|
// 优化:提前查询所有需要的数据,避免在循环中查询
|
|
// 优化:提前查询所有需要的数据,避免在循环中查询
|
|
|
// 查询我的点赞 - 使用Set提高查找效率
|
|
// 查询我的点赞 - 使用Set提高查找效率
|
|
@@ -150,9 +154,12 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
IPage<StoreClockInVo> storeClockInIPage1 = storeClockInMapper.getStoreClockInList(iPage, new QueryWrapper<StoreClockIn>()
|
|
IPage<StoreClockInVo> storeClockInIPage1 = storeClockInMapper.getStoreClockInList(iPage, new QueryWrapper<StoreClockIn>()
|
|
|
.eq("clock.store_id", storeId)
|
|
.eq("clock.store_id", storeId)
|
|
|
.eq("clock.delete_flag", 0)
|
|
.eq("clock.delete_flag", 0)
|
|
|
- .ne("clock.check_flag", 3)
|
|
|
|
|
|
|
+ .and(wrapper1 -> wrapper1.isNull("clock.check_flag").or().ne("clock.check_flag", 3))
|
|
|
.eq("user.delete_flag", 0)
|
|
.eq("user.delete_flag", 0)
|
|
|
.eq("store.delete_flag", 0)
|
|
.eq("store.delete_flag", 0)
|
|
|
|
|
+ .apply(Objects.nonNull(year), "YEAR(clock.created_time) = {0}", year)
|
|
|
|
|
+ .apply(Objects.nonNull(month), "MONTH(clock.created_time) = {0}", month)
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(cityFilter), "store.administrative_region_city_name", cityFilter)
|
|
|
.isNotNull(0 == mySelf, "clock.img_url")
|
|
.isNotNull(0 == mySelf, "clock.img_url")
|
|
|
.and(wrapper1 ->
|
|
.and(wrapper1 ->
|
|
|
wrapper1.eq("clock.permission", 1)
|
|
wrapper1.eq("clock.permission", 1)
|
|
@@ -176,16 +183,19 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
setStoreTypeNew(vo);
|
|
setStoreTypeNew(vo);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- return storeClockInIPage1;
|
|
|
|
|
|
|
+ return attachClockInEchoFields(storeClockInIPage1, userId, year, month, cityFilter);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
QueryWrapper<StoreClockIn> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<StoreClockIn> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq(1 == mySelf, "clock.user_id", userId);
|
|
wrapper.eq(1 == mySelf, "clock.user_id", userId);
|
|
|
wrapper.isNotNull(0 == mySelf, "clock.img_url");
|
|
wrapper.isNotNull(0 == mySelf, "clock.img_url");
|
|
|
wrapper.eq("clock.delete_flag", 0);
|
|
wrapper.eq("clock.delete_flag", 0);
|
|
|
- wrapper.ne("clock.check_flag", 3);
|
|
|
|
|
|
|
+ wrapper.and(wrapper1 -> wrapper1.isNull("clock.check_flag").or().ne("clock.check_flag", 3));
|
|
|
wrapper.eq("user.delete_flag", 0);
|
|
wrapper.eq("user.delete_flag", 0);
|
|
|
wrapper.eq("store.delete_flag", 0);
|
|
wrapper.eq("store.delete_flag", 0);
|
|
|
|
|
+ wrapper.apply(Objects.nonNull(year), "YEAR(clock.created_time) = {0}", year);
|
|
|
|
|
+ wrapper.apply(Objects.nonNull(month), "MONTH(clock.created_time) = {0}", month);
|
|
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(cityFilter), "store.administrative_region_city_name", cityFilter);
|
|
|
wrapper.and(wrapper1 ->
|
|
wrapper.and(wrapper1 ->
|
|
|
wrapper1.eq("clock.permission", 1)
|
|
wrapper1.eq("clock.permission", 1)
|
|
|
.or(wSub ->
|
|
.or(wSub ->
|
|
@@ -199,7 +209,7 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
List<StoreClockInVo> records = storeClockInIPage.getRecords();
|
|
List<StoreClockInVo> records = storeClockInIPage.getRecords();
|
|
|
|
|
|
|
|
if (records.isEmpty()) {
|
|
if (records.isEmpty()) {
|
|
|
- return storeClockInIPage;
|
|
|
|
|
|
|
+ return attachClockInEchoFields(storeClockInIPage, userId, year, month, cityFilter);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 优化:批量查询所有需要的数据
|
|
// 优化:批量查询所有需要的数据
|
|
@@ -243,7 +253,28 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
setStoreTypeNew(vo);
|
|
setStoreTypeNew(vo);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- return storeClockInIPage;
|
|
|
|
|
|
|
+ return attachClockInEchoFields(storeClockInIPage, userId, year, month, cityFilter);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private IPage<StoreClockInVo> attachClockInEchoFields(IPage<StoreClockInVo> pageData, Integer userId, Integer year, Integer month, String cityFilter) {
|
|
|
|
|
+ StoreClockInPageVo resultVo = new StoreClockInPageVo();
|
|
|
|
|
+ resultVo.setCurrent(pageData.getCurrent());
|
|
|
|
|
+ resultVo.setSize(pageData.getSize());
|
|
|
|
|
+ resultVo.setTotal(pageData.getTotal());
|
|
|
|
|
+ resultVo.setRecords(pageData.getRecords());
|
|
|
|
|
+ List<String> cities = storeClockInMapper.listDistinctClockInCityNamesByYear(userId, year, month);
|
|
|
|
|
+ resultVo.setClockInCities(cities == null ? Collections.emptyList() : cities);
|
|
|
|
|
+ Integer placeCount = storeClockInMapper.countDistinctClockInStoreByCondition(userId, year, month, cityFilter);
|
|
|
|
|
+ resultVo.setPlaceCount(placeCount == null ? 0 : placeCount);
|
|
|
|
|
+ return resultVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String normalizeCityFilter(String city) {
|
|
|
|
|
+ if (StringUtils.isBlank(city)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String trimCity = city.trim();
|
|
|
|
|
+ return "全部城市".equals(trimCity) ? null : trimCity;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -496,4 +527,27 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
|
|
|
storeClockInVo.setBusinessSectionName(storeInfo.getBusinessSectionName());
|
|
storeClockInVo.setBusinessSectionName(storeInfo.getBusinessSectionName());
|
|
|
return storeClockInVo;
|
|
return storeClockInVo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ClockInRecordValidateVo getClockInRecordValidate(Integer userId, Integer year, String city) {
|
|
|
|
|
+ ClockInRecordValidateVo vo = new ClockInRecordValidateVo();
|
|
|
|
|
+ vo.setYears(storeClockInMapper.listDistinctClockInYears(userId));
|
|
|
|
|
+ vo.setCities(storeClockInMapper.listDistinctClockInCityNames(userId));
|
|
|
|
|
+ if (year == null) {
|
|
|
|
|
+ vo.setMonths(Collections.emptyList());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+ String cityFilter = StringUtils.isBlank(city) ? null : city.trim();
|
|
|
|
|
+ List<Integer> monthsWithRecord = storeClockInMapper.listClockInMonthsByYear(userId, year, cityFilter);
|
|
|
|
|
+ Set<Integer> monthSet = new HashSet<>(monthsWithRecord != null ? monthsWithRecord : Collections.emptyList());
|
|
|
|
|
+ List<MonthClockInItem> monthItems = new ArrayList<>(12);
|
|
|
|
|
+ for (int m = 1; m <= 12; m++) {
|
|
|
|
|
+ MonthClockInItem item = new MonthClockInItem();
|
|
|
|
|
+ item.setMonth(m);
|
|
|
|
|
+ item.setHasClockIn(monthSet.contains(m));
|
|
|
|
|
+ monthItems.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setMonths(monthItems);
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|