|
@@ -22,6 +22,7 @@ import com.ruoyi.wx.web.domain.vo.SaleInfoVo;
|
|
import com.ruoyi.wx.web.domain.vo.WxContentVo;
|
|
import com.ruoyi.wx.web.domain.vo.WxContentVo;
|
|
import com.ruoyi.wx.web.mapper.WxHomeMapper;
|
|
import com.ruoyi.wx.web.mapper.WxHomeMapper;
|
|
import com.ruoyi.wx.web.service.IWxHomeService;
|
|
import com.ruoyi.wx.web.service.IWxHomeService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -30,12 +31,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
|
+import java.time.ZoneOffset;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
|
+@Slf4j
|
|
public class WxHomeServiceImpl implements IWxHomeService {
|
|
public class WxHomeServiceImpl implements IWxHomeService {
|
|
@Autowired
|
|
@Autowired
|
|
private IRecSaleInfoService recSaleInfoService;
|
|
private IRecSaleInfoService recSaleInfoService;
|
|
@@ -65,7 +68,6 @@ public class WxHomeServiceImpl implements IWxHomeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public AjaxResult getIndex() throws ExecutionException, InterruptedException {
|
|
public AjaxResult getIndex() throws ExecutionException, InterruptedException {
|
|
- AjaxResult result = new AjaxResult();
|
|
|
|
// 查询最近创建的活动并且处于活动期间的内容
|
|
// 查询最近创建的活动并且处于活动期间的内容
|
|
DateTime dateTime = DateUtil.beginOfDay(new Date());
|
|
DateTime dateTime = DateUtil.beginOfDay(new Date());
|
|
Date startTime = DateUtil.offsetDay(dateTime, -1);
|
|
Date startTime = DateUtil.offsetDay(dateTime, -1);
|
|
@@ -91,21 +93,20 @@ public class WxHomeServiceImpl implements IWxHomeService {
|
|
}
|
|
}
|
|
String display = wxHomeMapper.selectLotteryDisplay("is_lottery");
|
|
String display = wxHomeMapper.selectLotteryDisplay("is_lottery");
|
|
List<RecSaleInfo> saleInfos = saleInfoTask.get();
|
|
List<RecSaleInfo> saleInfos = saleInfoTask.get();
|
|
- saleInfos.sort(Comparator.comparing(RecSaleInfo::getTopIndex, Integer::compareTo));
|
|
|
|
- contentVos.sort(Comparator.comparing(WxContentVo::getCreateDate, (t1, t2) -> t2.compareTo(t1)));
|
|
|
|
- result.put("saleInfo", saleInfos);
|
|
|
|
- result.put("content", contentVos);
|
|
|
|
- result.put("is_lottery", display);
|
|
|
|
- return result;
|
|
|
|
|
|
+// saleInfos.sort(Comparator.comparing(RecSaleInfo::getTopIndex, Integer::compareTo));
|
|
|
|
+ contentVos.sort(Comparator.comparing(WxContentVo::getCreateDate, Comparator.reverseOrder()));
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
+ resultMap.put("saleInfo", saleInfos);
|
|
|
|
+ resultMap.put("content", contentVos);
|
|
|
|
+ resultMap.put("is_lottery", display);
|
|
|
|
+ return AjaxResult.success(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<SaleInfoVo> getSaleInfo(Long id) {
|
|
|
|
|
|
+ public List<SaleInfoVo> getSaleInfo(Long id, String storeIds) {
|
|
RecSaleInfo saleInfo = saleInfoMapper.selectRecSaleInfoById(id);
|
|
RecSaleInfo saleInfo = saleInfoMapper.selectRecSaleInfoById(id);
|
|
- // 获取到商品id,并将商品id转换为Integer到数据库中查询
|
|
|
|
- List<String> ids = Arrays.asList(saleInfo.getStoreId().split(","));
|
|
|
|
// 根据商品获取所有门店信息
|
|
// 根据商品获取所有门店信息
|
|
- List<RecStores> stores = wxHomeMapper.selectRecStoresByCommondityIds(ids);
|
|
|
|
|
|
+ List<RecStores> stores = wxHomeMapper.selectRecStoresByCommondityIds(storeIds);
|
|
Map<String, List<RecStores>> cityMap = stores.stream().filter(vo -> StringUtils.isNotEmpty(vo.getCity())).collect(Collectors.groupingBy(RecStores::getCity));
|
|
Map<String, List<RecStores>> cityMap = stores.stream().filter(vo -> StringUtils.isNotEmpty(vo.getCity())).collect(Collectors.groupingBy(RecStores::getCity));
|
|
List<SaleInfoVo> result = new ArrayList<>();
|
|
List<SaleInfoVo> result = new ArrayList<>();
|
|
SaleInfoVo saleInfoVo = new SaleInfoVo();
|
|
SaleInfoVo saleInfoVo = new SaleInfoVo();
|
|
@@ -120,20 +121,23 @@ public class WxHomeServiceImpl implements IWxHomeService {
|
|
});
|
|
});
|
|
saleInfoVo.setStores(cityList);
|
|
saleInfoVo.setStores(cityList);
|
|
result.add(saleInfoVo);
|
|
result.add(saleInfoVo);
|
|
|
|
+ log.info("查询发售信息详情结束");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<SaleInfoVo> getSaleCalendar() {
|
|
public List<SaleInfoVo> getSaleCalendar() {
|
|
- List<RecSaleInfo> recSaleInfos = saleInfoMapper.selectRecSaleInfoList(new RecSaleInfo());
|
|
|
|
|
|
+ RecSaleInfo saleInfo = new RecSaleInfo();
|
|
|
|
+ saleInfo.setEndTimeOfActivity(LocalDateTime.now());
|
|
|
|
+ List<RecSaleInfo> recSaleInfos = saleInfoMapper.selectRecSaleInfoList(saleInfo);
|
|
List<SaleInfoVo> result = new ArrayList<>();
|
|
List<SaleInfoVo> result = new ArrayList<>();
|
|
for (RecSaleInfo info : recSaleInfos) {
|
|
for (RecSaleInfo info : recSaleInfos) {
|
|
SaleInfoVo vo = new SaleInfoVo();
|
|
SaleInfoVo vo = new SaleInfoVo();
|
|
BeanUtils.copyProperties(info, vo);
|
|
BeanUtils.copyProperties(info, vo);
|
|
- vo.setStore(belongCalendar(new Date(), vo.getEventStartTime(), vo.getEndTimeOfActivity()));
|
|
|
|
|
|
+ vo.setStore(belongCalendar(LocalDateTime.now(ZoneId.of("Asia/Shanghai")), vo.getEventStartTime(), vo.getEndTimeOfActivity()));
|
|
result.add(vo);
|
|
result.add(vo);
|
|
}
|
|
}
|
|
- result.sort((t1, t2) -> t2.getEndTimeOfActivity().compareTo(t1.getEndTimeOfActivity()));
|
|
|
|
|
|
+ result.sort(Comparator.comparing(SaleInfoVo::getEndTimeOfActivity));
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -195,20 +199,8 @@ public class WxHomeServiceImpl implements IWxHomeService {
|
|
* @param endTime
|
|
* @param endTime
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static boolean belongCalendar(Date nowTime, Date beginTime, Date endTime) {
|
|
|
|
- Calendar date = Calendar.getInstance();
|
|
|
|
- date.setTime(nowTime);
|
|
|
|
-
|
|
|
|
- Calendar begin = Calendar.getInstance();
|
|
|
|
- begin.setTime(beginTime);
|
|
|
|
-
|
|
|
|
- Calendar end = Calendar.getInstance();
|
|
|
|
- end.setTime(endTime);
|
|
|
|
-
|
|
|
|
- if (date.after(begin) && date.before(end)) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
+ public static boolean belongCalendar(LocalDateTime nowTime, LocalDateTime beginTime, LocalDateTime endTime) {
|
|
|
|
+ log.info("当前时间:{}, 开始时间:{}, 结束时间:{}", nowTime, beginTime, endTime);
|
|
|
|
+ return nowTime.isAfter(beginTime) && nowTime.isBefore(endTime);
|
|
}
|
|
}
|
|
}
|
|
}
|