|
@@ -1,5 +1,6 @@
|
|
|
package shop.alien.store.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -18,6 +19,7 @@ import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
|
|
|
import shop.alien.entity.store.vo.StoreMenuVo;
|
|
|
import shop.alien.mapper.*;
|
|
|
import shop.alien.store.service.LifeGroupBuyService;
|
|
|
+import shop.alien.util.common.JwtUtil;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -41,20 +43,28 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
|
|
|
|
|
|
@Override
|
|
|
public boolean saveThali(LifeGroupBuyDto lifeGroupBuyDto) {
|
|
|
+ JSONObject currentUserInfo = JwtUtil.getCurrentUserInfo();
|
|
|
+ Integer userId = null;
|
|
|
+ if (!ObjectUtils.isEmpty(currentUserInfo)) {
|
|
|
+ userId = currentUserInfo.getInteger("userId");
|
|
|
+ }
|
|
|
LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
|
|
|
List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyDto.getLifeGroupBuyThalis();
|
|
|
if (ObjectUtils.isEmpty(lifeGroupBuyMain.getId())) {
|
|
|
+ lifeGroupBuyMain.setCreatedUserId(userId);
|
|
|
lifeGroupBuyMainMapper.insert(lifeGroupBuyMain);
|
|
|
if (ObjectUtils.isNotEmpty(lifeGroupBuyThalis)) {
|
|
|
for (int i = 0; i < lifeGroupBuyThalis.size(); i++) {
|
|
|
LifeGroupBuyThali lifeGroupBuyThali = lifeGroupBuyThalis.get(i);
|
|
|
lifeGroupBuyThali.setParentId(lifeGroupBuyMain.getId().toString());
|
|
|
lifeGroupBuyThali.setDetailSort(i + 1);
|
|
|
+ lifeGroupBuyThali.setCreatedUserId(userId);
|
|
|
lifeGroupBuyThaliMapper.insert(lifeGroupBuyThali);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
} else {
|
|
|
+ lifeGroupBuyMain.setUpdatedUserId(userId);
|
|
|
lifeGroupBuyMainMapper.updateById(lifeGroupBuyMain);
|
|
|
lifeGroupBuyThaliMapper.update(null, new LambdaUpdateWrapper<LifeGroupBuyThali>().eq(LifeGroupBuyThali::getParentId, lifeGroupBuyMain.getId()).set(LifeGroupBuyThali::getDeleteFlag, 1));
|
|
|
if (ObjectUtils.isNotEmpty(lifeGroupBuyThalis)) {
|
|
@@ -62,6 +72,7 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
|
|
|
LifeGroupBuyThali lifeGroupBuyThali = lifeGroupBuyThalis.get(i);
|
|
|
lifeGroupBuyThali.setParentId(lifeGroupBuyMain.getId().toString());
|
|
|
lifeGroupBuyThali.setDetailSort(i + 1);
|
|
|
+ lifeGroupBuyThali.setCreatedUserId(userId);
|
|
|
lifeGroupBuyThaliMapper.insert(lifeGroupBuyThali);
|
|
|
}
|
|
|
}
|
|
@@ -106,7 +117,7 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
|
|
|
|
|
|
Map<String, List<LifeGroupBuyThali>> collect = lifeGroupBuyThalis.stream().collect(Collectors.groupingBy(LifeGroupBuyThali::getGroupName));
|
|
|
List<LifeGroupBuyNameThaliVo> resultMap = new ArrayList<>();
|
|
|
- List<String> keys = collect.entrySet().stream().sorted(Comparator.comparingInt(i -> i.getValue().stream().map(LifeGroupBuyThali::getDetailSort).reduce(0, Integer::sum))).map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
+ List<String> keys = collect.entrySet().stream().sorted(Comparator.comparingInt(i -> i.getValue().get(0).getDetailSort())).map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
for (String key : keys) {
|
|
|
LifeGroupBuyNameThaliVo lifeGroupBuyNameThaliVo = new LifeGroupBuyNameThaliVo();
|
|
|
lifeGroupBuyNameThaliVo.setGroupName(key);
|