|
@@ -13,17 +13,16 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.second.SecondGoods;
|
|
|
import shop.alien.entity.store.LifeCollect;
|
|
|
+import shop.alien.entity.store.LifeCoupon;
|
|
|
+import shop.alien.entity.store.StoreImg;
|
|
|
import shop.alien.entity.store.vo.StoreInfoVo;
|
|
|
+import shop.alien.mapper.*;
|
|
|
import shop.alien.mapper.second.SecondGoodsMapper;
|
|
|
import shop.alien.store.config.GaoDeMapUtil;
|
|
|
-import shop.alien.mapper.LifeCollectMapper;
|
|
|
-import shop.alien.mapper.StoreInfoMapper;
|
|
|
import shop.alien.util.common.ListToPage;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -45,33 +44,92 @@ public class LifeCollectController {
|
|
|
|
|
|
private final GaoDeMapUtil gaoDeMapUtil;
|
|
|
|
|
|
+ private final LifeCouponMapper lifeCouponMapper;
|
|
|
+
|
|
|
+ private final StoreEvaluationMapper storeEvaluationMapper;
|
|
|
+
|
|
|
+ private final LifeUserOrderMapper lifeUserOrderMapper;
|
|
|
+
|
|
|
+ private final StoreImgMapper storeImgMapper;
|
|
|
+
|
|
|
@ApiOperation("收藏列表")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "String", paramType = "query", required = true),
|
|
|
@ApiImplicitParam(name = "size", value = "分页条数", dataType = "String", paramType = "query", required = true),
|
|
|
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "jingdu", value = "jingdu", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "weidu", value = "weidu", dataType = "String", paramType = "query")})
|
|
|
+ @ApiImplicitParam(name = "weidu", value = "weidu", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "businessSection", value = "经营板块", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "keyword", value = "关键词", dataType = "String", paramType = "query")
|
|
|
+ })
|
|
|
@GetMapping("selectCollectList")
|
|
|
public R<IPage<StoreInfoVo>> selectCollectList(@RequestParam(defaultValue = "1") int page,
|
|
|
@RequestParam(defaultValue = "10") int size,
|
|
|
@RequestParam String userId,
|
|
|
@RequestParam String jingdu,
|
|
|
- @RequestParam String weidu) {
|
|
|
- log.info("LifeCollectController.selectCollectList?userId={},page={},size={},jingdu={},weidu={}", userId, page, size, jingdu, weidu);
|
|
|
+ @RequestParam String weidu,
|
|
|
+ @RequestParam String businessSection,
|
|
|
+ @RequestParam String keyword
|
|
|
+ ) {
|
|
|
+ log.info("LifeCollectController.selectCollectList?userId={},page={},size={},jingdu={},weidu={},businessSection={},keyword={}", userId, page, size, jingdu, weidu,businessSection,keyword);
|
|
|
LambdaUpdateWrapper<LifeCollect> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(LifeCollect::getUserId, userId);
|
|
|
- wrapper.eq(LifeCollect::getDeleteFlag, 0).orderByDesc(LifeCollect::getCreatedTime);
|
|
|
+ wrapper.eq(LifeCollect::getDeleteFlag, 0).isNotNull(LifeCollect::getStoreId).orderByDesc(LifeCollect::getCreatedTime);
|
|
|
List<LifeCollect> lifeCollectList = lifeCollectMapper.selectList(wrapper);
|
|
|
List<StoreInfoVo> storeVoList = new ArrayList<>();
|
|
|
+
|
|
|
if (!CollectionUtils.isEmpty(lifeCollectList)) {
|
|
|
- List<String> ids = lifeCollectList.stream().map(LifeCollect::getStoreId).collect(Collectors.toList());
|
|
|
+ // 获取收藏的店铺id
|
|
|
+ List<String> ids = lifeCollectList.stream().filter(x->null != x.getStoreId()).map(LifeCollect::getStoreId).collect(Collectors.toList());
|
|
|
QueryWrapper<StoreInfoVo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.in("a.id", ids).eq("a.delete_flag", 0);
|
|
|
+ // 查询店铺团购信息
|
|
|
+ LambdaUpdateWrapper<LifeCoupon> quanWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ quanWrapper.in(LifeCoupon::getStoreId, ids)
|
|
|
+ .eq(LifeCoupon::getStatus, 1)
|
|
|
+ .orderByDesc(LifeCoupon::getCreatedTime);
|
|
|
+ List<LifeCoupon> quanList = lifeCouponMapper.selectList(quanWrapper);
|
|
|
+ // 八大类分类
|
|
|
+ if (!StringUtils.isEmpty(businessSection)) {
|
|
|
+ queryWrapper.eq("a.business_section", businessSection);
|
|
|
+ }
|
|
|
+ // 关键词查询
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ queryWrapper.like("a.store_name", keyword);
|
|
|
+ }
|
|
|
+ // 计算店铺平均分 和 人均花销
|
|
|
+ Map<Object, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
|
|
|
+ Map<Object, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
|
|
|
List<StoreInfoVo> storeInfoVoList = storeInfoMapper.getStoreInfoVoList(queryWrapper);
|
|
|
lifeCollectList.forEach(a -> {
|
|
|
storeInfoVoList.forEach(b -> {
|
|
|
if (a.getStoreId().equals(b.getId().toString())) {
|
|
|
+ // 团购券设置
|
|
|
+ List<Map<String, Object>> quanMapList = new ArrayList<>();
|
|
|
+ if (!quanList.isEmpty()) {
|
|
|
+ for (LifeCoupon quan : quanList) {
|
|
|
+ if (b.getId().toString().equals(quan.getStoreId())) {
|
|
|
+ Map<String, Object> quanMap = new HashMap<>();
|
|
|
+ quanMap.put("quanType", quan.getType());
|
|
|
+ quanMap.put("name", quan.getName());
|
|
|
+ quanMap.put("price", quan.getPrice());
|
|
|
+ // 折扣价
|
|
|
+ quanMap.put("offprice", quan.getOffprice());
|
|
|
+ quanMap.put("quanId", quan.getId());
|
|
|
+ quanMapList.add(quanMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b.setQuanList(quanMapList);
|
|
|
+ // 得分,人均
|
|
|
+ b.setAvgScore("0");
|
|
|
+ b.setAvgPrice("0");
|
|
|
+ if (avgScoreMap.containsKey(String.valueOf(b.getId()))) {
|
|
|
+ b.setAvgScore(String.valueOf(avgScoreMap.get(String.valueOf(b.getId())).get(0).get("avg_score")));
|
|
|
+ }
|
|
|
+ if (avgPriceMap.containsKey(String.valueOf(b.getId()))) {
|
|
|
+ b.setAvgPrice(String.valueOf(avgPriceMap.get(String.valueOf(b.getId())).get(0).get("avg_price")));
|
|
|
+ }
|
|
|
if ((jingdu != null && !jingdu.isEmpty()) && (weidu != null && !weidu.isEmpty())) {
|
|
|
String[] split = b.getStorePosition().split(",");
|
|
|
double storeDistance;
|
|
@@ -91,6 +149,58 @@ public class LifeCollectController {
|
|
|
return R.data(ListToPage.setPage(storeVoList, page, size));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("团购收藏列表")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "String", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "size", value = "分页条数", dataType = "String", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "businessSection", value = "经营板块", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "keyword", value = "关键词", dataType = "String", paramType = "query")
|
|
|
+ })
|
|
|
+ @GetMapping("selectCouponCollectList")
|
|
|
+ public R<IPage<LifeCoupon>> selectCouponCollectList(@RequestParam(defaultValue = "1") int page,
|
|
|
+ @RequestParam(defaultValue = "10") int size,
|
|
|
+ @RequestParam String userId,
|
|
|
+ @RequestParam String businessSection,
|
|
|
+ @RequestParam String keyword){
|
|
|
+ log.info("LifeCollectController.selectCouponCollectList?userId={},page={},size={},businessSection={},keyword={}", userId, page, size,businessSection,keyword);
|
|
|
+ LambdaUpdateWrapper<LifeCollect> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(LifeCollect::getUserId, userId);
|
|
|
+ wrapper.eq(LifeCollect::getDeleteFlag, 0).isNotNull(LifeCollect::getCouponId).orderByDesc(LifeCollect::getCreatedTime);
|
|
|
+ List<LifeCollect> lifeCollectList = lifeCollectMapper.selectList(wrapper);
|
|
|
+ List<LifeCoupon> lifeCoupons = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(lifeCollectList)) {
|
|
|
+ // 获取收藏的优惠券id
|
|
|
+ List<String> ids = lifeCollectList.stream().map(LifeCollect::getCouponId).collect(Collectors.toList());
|
|
|
+ QueryWrapper<LifeCoupon> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("id", ids).eq("delete_flag", 0).orderByDesc("created_time");
|
|
|
+ // 八大类分类
|
|
|
+ if (!StringUtils.isEmpty(businessSection)) {
|
|
|
+ queryWrapper.eq("store_type", businessSection);
|
|
|
+ }
|
|
|
+ // 关键词查询
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ queryWrapper.like("name", keyword);
|
|
|
+ }
|
|
|
+ lifeCoupons = lifeCouponMapper.selectList(queryWrapper);
|
|
|
+ // 设置团购券图片
|
|
|
+ List<String> imagesId = lifeCoupons.stream().map(LifeCoupon::getImagePath).collect(Collectors.toList());
|
|
|
+ if ( !CollectionUtils.isEmpty(imagesId) ){
|
|
|
+ QueryWrapper<StoreImg> imgQueryWrapper = new QueryWrapper<>();
|
|
|
+ imgQueryWrapper.in("id", imagesId);
|
|
|
+ List<StoreImg> storeImgs = storeImgMapper.selectList(imgQueryWrapper);
|
|
|
+ Map<String, List<StoreImg>> collect = storeImgs.stream().collect(Collectors.groupingBy(x -> String.valueOf(x.getId())));
|
|
|
+ lifeCoupons.forEach(coupon -> {
|
|
|
+ String imgId = coupon.getImagePath().split(",")[0];
|
|
|
+ if ( collect.containsKey(imgId) ){
|
|
|
+ coupon.setImagePath(collect.get(imgId).get(0).getImgUrl());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(ListToPage.setPage(lifeCoupons, page, size));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("添加收藏")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@PostMapping("addCollect")
|
|
@@ -120,10 +230,16 @@ public class LifeCollectController {
|
|
|
@RequestParam(value = "userId", required = false) String userId,
|
|
|
@RequestParam(value = "storeId", required = false) String storeId,
|
|
|
@RequestParam(value = "businessId", required = false) String businessId,
|
|
|
- @RequestParam(value = "businessType", required = false) String businessType) {
|
|
|
+ @RequestParam(value = "businessType", required = false) String businessType,
|
|
|
+ @RequestParam(value = "couponId", required = false) String couponId) {
|
|
|
log.info("LifeCollectController.cancelCollect?userId={},storeId={}", userId, storeId);
|
|
|
LambdaUpdateWrapper<LifeCollect> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(LifeCollect::getUserId, userId);
|
|
|
+ if(!StringUtils.isEmpty(storeId)) {
|
|
|
+ wrapper.eq(LifeCollect::getStoreId, storeId);
|
|
|
+ } else if (!StringUtils.isEmpty(couponId)){
|
|
|
+ wrapper.eq(LifeCollect::getCouponId, couponId);
|
|
|
+ }
|
|
|
if (StringUtil.isBlank(businessType) && businessType.equals(1)) {
|
|
|
wrapper.eq(LifeCollect::getBusinessId, businessId);
|
|
|
wrapper.eq(LifeCollect::getBusinessType, businessType);
|