|
|
@@ -10,14 +10,17 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.store.LifeGroupBuyCount;
|
|
|
+import shop.alien.entity.store.LifeGroupBuyMain;
|
|
|
import shop.alien.entity.store.LifeUserOrder;
|
|
|
import shop.alien.entity.store.vo.LifeGroupBuyCountDateVo;
|
|
|
import shop.alien.entity.store.vo.LifeGroupBuyCountVo;
|
|
|
import shop.alien.mapper.LifeGroupBuyCountMapper;
|
|
|
+import shop.alien.mapper.LifeGroupBuyMainMapper;
|
|
|
import shop.alien.mapper.LifeUserOrderMapper;
|
|
|
import shop.alien.store.service.LifeGroupBuyCountService;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.MathContext;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -35,6 +38,9 @@ public class LifeGroupBuyCountServiceImpl extends ServiceImpl<LifeGroupBuyCountM
|
|
|
@Autowired
|
|
|
private LifeUserOrderMapper lifeUserOrderMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LifeGroupBuyMainMapper lifeGroupBuyMainMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void insertGroupBuyCount(Integer storeId, Integer groupId, Integer userId, String countType) {
|
|
|
LambdaQueryWrapper<LifeGroupBuyCount> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -114,11 +120,21 @@ public class LifeGroupBuyCountServiceImpl extends ServiceImpl<LifeGroupBuyCountM
|
|
|
bfb(todayList);
|
|
|
|
|
|
Map<String, LifeGroupBuyCountVo> map = new HashMap<>();
|
|
|
- map.put("tcfwl", new LifeGroupBuyCountVo());
|
|
|
- map.put("tcfks", new LifeGroupBuyCountVo());
|
|
|
- map.put("sjtcs", new LifeGroupBuyCountVo());
|
|
|
- map.put("xjtcs", new LifeGroupBuyCountVo());
|
|
|
- map.put("sfrs", new LifeGroupBuyCountVo());
|
|
|
+ LifeGroupBuyCountVo tcfwl = new LifeGroupBuyCountVo();
|
|
|
+ tcfwl.setCountType("0");
|
|
|
+ LifeGroupBuyCountVo tcfks = new LifeGroupBuyCountVo();
|
|
|
+ tcfks.setCountType("1");
|
|
|
+ LifeGroupBuyCountVo sjtcs = new LifeGroupBuyCountVo();
|
|
|
+ sjtcs.setCountType("2");
|
|
|
+ LifeGroupBuyCountVo xjtcs = new LifeGroupBuyCountVo();
|
|
|
+ xjtcs.setCountType("3");
|
|
|
+ LifeGroupBuyCountVo sfrs = new LifeGroupBuyCountVo();
|
|
|
+ sfrs.setCountType("4");
|
|
|
+ map.put("tcfwl", tcfwl);
|
|
|
+ map.put("tcfks", tcfks);
|
|
|
+ map.put("sjtcs", sjtcs);
|
|
|
+ map.put("xjtcs", xjtcs);
|
|
|
+ map.put("sfrs", sfrs);
|
|
|
todayList.stream().filter(item -> "0".equals(item.getCountType())).findFirst().ifPresent(item -> map.put("tcfwl", item));
|
|
|
todayList.stream().filter(item -> "1".equals(item.getCountType())).findFirst().ifPresent(item -> map.put("tcfks", item));
|
|
|
todayList.stream().filter(item -> "2".equals(item.getCountType())).findFirst().ifPresent(item -> map.put("sjtcs", item));
|
|
|
@@ -138,15 +154,46 @@ public class LifeGroupBuyCountServiceImpl extends ServiceImpl<LifeGroupBuyCountM
|
|
|
public List<LifeGroupBuyCountDateVo> getDpzbpm(String storeId) {
|
|
|
List<LifeGroupBuyCountDateVo> lifeGroupBuyCountDateVos = lifeGroupBuyCountMapper.selectDpzbpmListByStoreId(storeId);
|
|
|
for (LifeGroupBuyCountDateVo lifeGroupBuyCountDateVo : lifeGroupBuyCountDateVos) {
|
|
|
- lifeGroupBuyCountDateVo.setRjfws(StringUtils.isNotEmpty(lifeGroupBuyCountDateVo.getSpfks()) ? new BigDecimal(lifeGroupBuyCountDateVo.getSpfwl()).divide(new BigDecimal(lifeGroupBuyCountDateVo.getSpfks()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)) + "%" : "0.0%");
|
|
|
+ lifeGroupBuyCountDateVo.setRjfws(StringUtils.isNotEmpty(lifeGroupBuyCountDateVo.getSpfks()) ? (new BigDecimal(lifeGroupBuyCountDateVo.getSpfwl()).divide(new BigDecimal(lifeGroupBuyCountDateVo.getSpfks()), 0, RoundingMode.HALF_UP)).toString() : "0");
|
|
|
lifeGroupBuyCountDateVo.setScl(StringUtils.isNotEmpty(lifeGroupBuyCountDateVo.getSpfks()) ? new BigDecimal(lifeGroupBuyCountDateVo.getSpscl()).divide(new BigDecimal(lifeGroupBuyCountDateVo.getSpfks()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)) + "%" : "0.0%");
|
|
|
}
|
|
|
return lifeGroupBuyCountDateVos;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void test() {
|
|
|
+ List<LifeGroupBuyCount> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<LifeGroupBuyMain> sjQuery = new LambdaQueryWrapper<>();
|
|
|
+ sjQuery.eq(LifeGroupBuyMain::getStatus, "5").eq(LifeGroupBuyMain::getDeleteFlag, 0).eq(LifeGroupBuyMain::getGroupType, 1);
|
|
|
+ Map<String, List<LifeGroupBuyMain>> sjCollect = lifeGroupBuyMainMapper.selectList(sjQuery).stream().collect(Collectors.groupingBy(LifeGroupBuyMain::getStoreId));
|
|
|
+ for (String s : sjCollect.keySet()) {
|
|
|
+ LifeGroupBuyCount sj = new LifeGroupBuyCount();
|
|
|
+ sj.setStoreId(Integer.valueOf(sjCollect.get(s).get(0).getStoreId()));
|
|
|
+ sj.setCountType("2");
|
|
|
+ sj.setCountNum(sjCollect.get(s).size());
|
|
|
+ sj.setCountDate(new Date());
|
|
|
+ list.add(sj);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<LifeGroupBuyMain> xjQuery = new LambdaQueryWrapper<>();
|
|
|
+ xjQuery.in(LifeGroupBuyMain::getStatus, "7", "8").eq(LifeGroupBuyMain::getDeleteFlag, 0).eq(LifeGroupBuyMain::getGroupType, 1);
|
|
|
+ Map<String, List<LifeGroupBuyMain>> xjCollect = lifeGroupBuyMainMapper.selectList(xjQuery).stream().collect(Collectors.groupingBy(LifeGroupBuyMain::getStoreId));
|
|
|
+ for (String s : xjCollect.keySet()) {
|
|
|
+ LifeGroupBuyCount xj = new LifeGroupBuyCount();
|
|
|
+ xj.setStoreId(Integer.valueOf(xjCollect.get(s).get(0).getStoreId()));
|
|
|
+ xj.setCountType("3");
|
|
|
+ xj.setCountNum(xjCollect.get(s).size());
|
|
|
+ xj.setCountDate(new Date());
|
|
|
+ list.add(xj);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ lifeGroupBuyCountMapper.insertList(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void bfb(List<LifeGroupBuyCountVo> list) {
|
|
|
for (LifeGroupBuyCountVo item : list) {
|
|
|
- item.setJqrBfb(StringUtils.isNotEmpty(item.getYesCountNum()) && !"0".equals(item.getYesCountNum()) ? new BigDecimal(item.getYesCountNum()).subtract(new BigDecimal(item.getCountNum())).divide(new BigDecimal(item.getYesCountNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)) + "%" : "0.00%");
|
|
|
+ item.setJqrBfb(StringUtils.isNotEmpty(item.getYesCountNum()) && !"0".equals(item.getYesCountNum()) ? new BigDecimal(item.getYesCountNum()).subtract(new BigDecimal(item.getCountNum())).divide(new BigDecimal(item.getYesCountNum()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP) + "%" : "0.00%");
|
|
|
}
|
|
|
}
|
|
|
}
|