修改商城商品展示方式

master
15004070936 8 hours ago
parent dc0bd6288e
commit 19c32c2c80

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.mall;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.RestResponse;
import com.ruoyi.course.domain.req.ReqSearchClaTime;
import com.ruoyi.course.domain.time.RespBusinessClaTimeCalendar;
@ -21,6 +22,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -65,7 +67,10 @@ public class ProductController {
@PostMapping("/list")
public ResponseEntity<Page<AppProductVO>> queryGoodByPage(@RequestBody ProductQuery query, Pageable page) {
List<Product> pageRes = productService.selectList(query, page);
return ResponseEntity.ok(new PageImpl<>(BeanUtil.copyToList(pageRes,AppProductVO.class), page, ((com.github.pagehelper.Page) pageRes).getTotal()));
if (ObjectUtil.isNotEmpty(pageRes)){
return ResponseEntity.ok(new PageImpl<>(BeanUtil.copyToList(pageRes,AppProductVO.class), page, ((com.github.pagehelper.Page) pageRes).getTotal()));
}
return ResponseEntity.ok(new PageImpl<>(new ArrayList<>(), page, 0));
}
/**

@ -12,7 +12,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.ruoyi.RestResponse;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.YjAppUserService;
import com.ruoyi.basic.service.YjStoreService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.AppUser;
import com.ruoyi.common.core.domain.entity.SysDept;
@ -69,7 +71,7 @@ public class ScClaTimeServiceImpl extends ServiceImpl<ScClaTimeMapper, ScClaTime
private ScCourseClaMapper claMapper;
@Autowired
private ScStudentCourseLogMapper studentCourseLogMapper;
private YjStoreService storeService;
@Autowired
private ScClaTimeAttendService attendService;
@ -105,10 +107,16 @@ public class ScClaTimeServiceImpl extends ServiceImpl<ScClaTimeMapper, ScClaTime
*/
@Override
public RespBusinessClaTimeCalendar searchListForCalendar(ReqSearchClaTime reqSearchClaTime) {
Long appUserId=SecurityUtils.getAppLoginUser().getAppUserId();
AppUser appUser= appUserService.getById(appUserId);
if (ObjectUtil.isEmpty(appUser.getVisitStore())){
return null;
}
YjStore store=storeService.getOne(appUser.getVisitStore());
if (ObjectUtil.isEmpty(store)){
return null;
}
if (ObjectUtil.isEmpty(reqSearchClaTime.getTeacherId())){
Long appUserId=SecurityUtils.getAppLoginUser().getAppUserId();
AppUser appUser= appUserService.getById(appUserId);
if (ObjectUtil.isEmpty(appUser.getVisitStore())){
return null;
}
@ -238,6 +246,10 @@ public class ScClaTimeServiceImpl extends ServiceImpl<ScClaTimeMapper, ScClaTime
if (ObjectUtil.isEmpty(appUser.getVisitStore())){
return RestResponse.failure("请选择访问门店!");
}
YjStore store=storeService.getOne(appUser.getVisitStore());
if (ObjectUtil.isEmpty(store)){
return RestResponse.failure("门店不在运营状态!");
}
List<ClaTimeCalendarItem> list=claTimeMapper.getCourseList(date,null,appUser.getVisitStore());
return new RestResponse().setData(list);
}

@ -1,6 +1,7 @@
package com.ruoyi.mall.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -86,21 +87,29 @@ public class MemberCartService extends ServiceImpl<MemberCartMapper, MemberCart>
//查门店
List<Long> storeIdList = memberCartList.stream().map(MemberCart::getStoreId).collect(Collectors.toList());
QueryWrapper<YjStore> storeQw = new QueryWrapper<>();
storeQw.in("dept_id", storeIdList);
Map<Long, YjStore> storeMap = storeMapper.selectList(storeQw).stream().collect(Collectors.toMap(YjStore::getId, it -> it));
Set<Long> keys= storeMap.keySet();
for (Long key : keys) {
System.out.println(key);
YjStore y= storeMap.get(key);
System.out.println(y.getStoreName());
List<YjStore> storeList = new ArrayList<>();
for (Long aLong : storeIdList) {
YjStore store= storeMapper.getOne(aLong);
if (ObjectUtil.isNotEmpty(store) && !storeList.contains(store)){
storeList.add(store);
}
}
if (CollectionUtil.isEmpty(storeList)){
return Collections.emptyList();
}
Map<Long, YjStore> storeMap = storeList.stream().collect(Collectors.toMap(YjStore::getId, it -> it));
Map<Long, List<MemberCart>> storeCartMap = memberCartList.stream().collect(Collectors.groupingBy(MemberCart::getStoreId));
List<Map> resList = new ArrayList<>();
storeCartMap.forEach((storeId,cartList)->{
Map<String,Object> resMap = new HashMap<>();
List<MemberCartVO> list = new ArrayList<>();
if (!storeMap.containsKey(storeId)){
return;
}
resMap.put("storeName",storeMap.get(storeId).getStoreName());
for (MemberCart item:cartList){

@ -44,6 +44,7 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
qw.select("id", "parent_id", "type_name", "level", "sort", "icon");
qw.eq("show_status", 1);//展示
qw.eq("store_id", 1);//全部
qw.orderByAsc("sort");
// qw.le("level", 2);
return mapper.selectList(qw);
}

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.basic.domain.YjStore;
import com.ruoyi.basic.service.YjStoreService;
import com.ruoyi.course.domain.req.ReqSearchClaTime;
import com.ruoyi.course.service.ScClaTimeService;
import com.ruoyi.mall.domain.Product;
@ -47,7 +49,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Autowired
private BrandMapper brandMapper;
@Autowired
private ScClaTimeService scClaTimeService;
private YjStoreService storeService;
/**
*
@ -73,24 +75,34 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
* @return
*/
public List<Product> selectList(ProductQuery query, Pageable page) {
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
Long categoryId = query.getCategoryId();
if (categoryId != null && categoryId.equals(1L)) {
YjStore store= storeService.getOne(Long.valueOf(query.getStoreId()));
if (store==null){
return new ArrayList<>();
}
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<Product> qw = new QueryWrapper<>();
qw.eq("publish_status", 1);
qw.orderByAsc("sort");
qw.eq("category_id", categoryId);
qw.eq("store_id", query.getStoreId());//门店id
String search = query.getSearch();
if (StringUtils.isNoneEmpty(search)){
qw.like("name", "%".concat(query.getSearch().trim()).concat("%"));
}
qw.orderByAsc("sort");
return productMapper.selectList(qw);
}
//商城商品
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
return productMapper.getMallProductList(categoryId,query.getSearch(),null);
}

@ -7,6 +7,8 @@
from yj_store a,sys_dept b
WHERE a.dept_id=b.dept_id
and a.dept_id=#{deptId}
and b.status='0'
and b.delete_flag='0'
and b.activation_date <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> b.expiry_date
</select>

@ -99,17 +99,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.customer_service,
a.instructor,
a.tenant_id
from mall_product a LEFT JOIN mall_product_show b
on a.id=b.product_id
from mall_product a
INNER JOIN sys_dept dept ON a.store_id = dept.dept_id
LEFT JOIN mall_product_show b on a.id=b.product_id
WHERE
dept.status='0' and
dept.delete_flag='0' and
dept.activation_date <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> dept.expiry_date and
a.publish_status=1 and
(a.store_id=1 <if test="categoryId != null "> and a.category_id = #{categoryId}</if> )
or
(b.show_flag='1'
(
(a.store_id=1 <if test="categoryId != null "> and a.category_id = #{categoryId}</if> )
or
(b.show_flag='1'
and b.show_start_time <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> b.show_end_time
and b.apply_status='2'
<if test="categoryId != null "> and b.show_category = #{categoryId}</if>
)
and b.apply_status='3'
<if test="categoryId != null "> and b.show_category = #{categoryId}</if>
)
)
<if test="isCourse != null "> and a.is_course = #{isCourse}</if>
<if test="search != null "> and a.name like concat('%', #{search}, '%')</if>
order by b.sort,a.sort

Loading…
Cancel
Save