Compare commits
3 Commits
master
...
feature_17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a2a77e59a | ||
|
|
0736256395 | ||
|
|
644697bd3b |
@ -8,16 +8,17 @@
|
|||||||
// | Author: CRMEB Team <admin@crmeb.com>
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
//移动端商城API
|
//移动端商城API
|
||||||
let domain = 'http://your Front API domain'
|
let domain = 'http://192.168.2.192:8084'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// 请求域名 格式: https://您的域名
|
// 请求域名 格式: https://您的域名
|
||||||
HTTP_REQUEST_URL:domain,
|
HTTP_REQUEST_URL:domain,
|
||||||
|
// h5商城地址
|
||||||
|
HTTP_H5_URL:'https://app',
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
HTTP_REQUEST_URL: domain,
|
HTTP_REQUEST_URL: domain,
|
||||||
// #endif
|
// #endif
|
||||||
HTTP_ADMIN_URL:'http://your h5 domain', //PC后台的API请求地址,上传图片用,影响h5上传头像
|
HTTP_ADMIN_URL:'http://127.0.0.1:8080', //PC后台的API请求地址,上传图片用,影响h5上传头像
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
//H5接口是浏览器地址
|
//H5接口是浏览器地址
|
||||||
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,
|
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,
|
||||||
@ -25,6 +26,7 @@ module.exports = {
|
|||||||
HTTP_REQUEST_URL:domain,
|
HTTP_REQUEST_URL:domain,
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
HEADER:{
|
HEADER:{
|
||||||
'content-type': 'application/json'
|
'content-type': 'application/json'
|
||||||
},
|
},
|
||||||
|
|||||||
@ -110,7 +110,7 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/deep/ .empty-box{
|
::v-deep .empty-box{
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
.swiper,swiper,swiper-item,.slide-image{
|
.swiper,swiper,swiper-item,.slide-image{
|
||||||
|
|||||||
@ -7,7 +7,7 @@ crmeb:
|
|||||||
wechat-js-api-beta: true #微信js api是否是beta版本
|
wechat-js-api-beta: true #微信js api是否是beta版本
|
||||||
asyncConfig: false #是否同步config表数据到redis
|
asyncConfig: false #是否同步config表数据到redis
|
||||||
asyncWeChatProgramTempList: false #是否同步小程序公共模板库
|
asyncWeChatProgramTempList: false #是否同步小程序公共模板库
|
||||||
imagePath: /当前项目更根目录的素材文件(绝对路径)/crmebimage/ # 服务器图片路径配置 斜杠结尾
|
imagePath: /idea/shopping2/crmeb_java/crmeb/crmeb/crmebimage/ # 服务器图片路径配置 斜杠结尾
|
||||||
database: mysql
|
database: mysql
|
||||||
|
|
||||||
# 配置端口
|
# 配置端口
|
||||||
@ -39,13 +39,12 @@ spring:
|
|||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://127.0.0.1:3306/crmeb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
|
url: jdbc:mysql://127.0.0.1:3306/crmeb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
|
||||||
username: crmeb
|
username: root
|
||||||
password: 111111
|
password: z2003m10L15
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
password: 111111
|
password:
|
||||||
timeout: 30000 # 连接超时时间(毫秒)
|
timeout: 30000 # 连接超时时间(毫秒)
|
||||||
database: 15 #默认数据库
|
database: 15 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -324,6 +324,11 @@ public class Constants {
|
|||||||
public static final int INDEX_LIMIT_DEFAULT = 3; //首页默认list分页条数
|
public static final int INDEX_LIMIT_DEFAULT = 3; //首页默认list分页条数
|
||||||
public static final int INDEX_GOOD_BANNER = 5; //优选推荐
|
public static final int INDEX_GOOD_BANNER = 5; //优选推荐
|
||||||
|
|
||||||
|
//首页水果搜索类型
|
||||||
|
public static final String INDEX_FRUIT_ONGOING = "0"; //首页正在售卖的水果
|
||||||
|
public static final String INDEX_FRUIT_BOOKING = "1"; //首页预售的水果
|
||||||
|
public static final String INDEX_FRUIT_SETTLED = "2"; //首页团购结束的水果
|
||||||
|
|
||||||
public static final String INDEX_BAST_LIMIT = "bastNumber"; //精品推荐个数
|
public static final String INDEX_BAST_LIMIT = "bastNumber"; //精品推荐个数
|
||||||
public static final String INDEX_FIRST_LIMIT = "firstNumber"; //首发新品个数
|
public static final String INDEX_FIRST_LIMIT = "firstNumber"; //首发新品个数
|
||||||
public static final String INDEX_SALES_LIMIT = "promotionNumber"; //促销单品个数
|
public static final String INDEX_SALES_LIMIT = "promotionNumber"; //促销单品个数
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -166,4 +167,19 @@ public class StoreProduct implements Serializable {
|
|||||||
@ApiModelProperty(value = "商品详情")
|
@ApiModelProperty(value = "商品详情")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始售卖时间")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束售卖时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "搜索类型")
|
||||||
|
private String searchStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果规格")
|
||||||
|
private String size;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果尺寸")
|
||||||
|
private String dimensions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,4 +65,10 @@ public class IndexProductResponse {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "展示图")
|
@ApiModelProperty(value = "展示图")
|
||||||
private String flatPattern;
|
private String flatPattern;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格")
|
||||||
|
private String size;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水果尺寸")
|
||||||
|
private String dimensions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,9 +126,11 @@ public class FrontTokenComponent {
|
|||||||
*/
|
*/
|
||||||
public String getToken(HttpServletRequest request) {
|
public String getToken(HttpServletRequest request) {
|
||||||
String token = request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
String token = request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
||||||
|
System.out.println("从请求头获取的原始token: " + token);
|
||||||
if (StrUtil.isNotEmpty(token) && token.startsWith(Constants.USER_TOKEN_REDIS_KEY_PREFIX)) {
|
if (StrUtil.isNotEmpty(token) && token.startsWith(Constants.USER_TOKEN_REDIS_KEY_PREFIX)) {
|
||||||
token = token.replace(Constants.USER_TOKEN_REDIS_KEY_PREFIX, "");
|
token = token.replace(Constants.USER_TOKEN_REDIS_KEY_PREFIX, "");
|
||||||
}
|
}
|
||||||
|
System.out.println("处理后的token:" + token);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +169,7 @@ public class FrontTokenComponent {
|
|||||||
"api/front/bargain/list",
|
"api/front/bargain/list",
|
||||||
"api/front/combination/list",
|
"api/front/combination/list",
|
||||||
"api/front/index/product",
|
"api/front/index/product",
|
||||||
|
"api/front/pagelist/product",
|
||||||
"api/front/combination/index",
|
"api/front/combination/index",
|
||||||
"api/front/bargain/index",
|
"api/front/bargain/index",
|
||||||
"api/front/index/color/config",
|
"api/front/index/color/config",
|
||||||
@ -196,4 +199,23 @@ public class FrontTokenComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//public Boolean check(String token, HttpServletRequest request){
|
||||||
|
// try {
|
||||||
|
// boolean exists = redisUtil.exists(getTokenKey(token));
|
||||||
|
// if(exists){
|
||||||
|
// Integer uid = redisUtil.get(getTokenKey(token));
|
||||||
|
// redisUtil.set(getTokenKey(token), uid, Constants.TOKEN_EXPRESS_MINUTES, TimeUnit.MINUTES);
|
||||||
|
// System.out.println("Token 有效,用户信息已刷新");
|
||||||
|
// return true;
|
||||||
|
// }else{
|
||||||
|
// //判断路由,部分路由不管用户是否登录/token过期都可以访问
|
||||||
|
// boolean isAllowedRoute = checkRouter(RequestUtil.getUri(request));
|
||||||
|
// System.out.println("Token 无效,检查路由:" + isAllowedRoute);
|
||||||
|
// return isAllowedRoute;
|
||||||
|
// }
|
||||||
|
// }catch (Exception e){
|
||||||
|
// System.out.println("Token 验证出现异常:" + e.getMessage());
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,10 +52,11 @@ public class CartController {
|
|||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name="isValid", value="类型,true-有效商品,false-无效商品", required = true),
|
@ApiImplicitParam(name="isValid", value="类型,true-有效商品,false-无效商品", required = true),
|
||||||
@ApiImplicitParam(name="page", value="页码", required = true),
|
@ApiImplicitParam(name="page", value="页码", required = true),
|
||||||
@ApiImplicitParam(name="limit", value="每页数量", required = true)
|
@ApiImplicitParam(name="limit", value="每页数量", required = true),
|
||||||
|
@ApiImplicitParam(name="keyword", value="搜索关键词", required = false)
|
||||||
})
|
})
|
||||||
public CommonResult<CommonPage<CartInfoResponse>> getList(@RequestParam Boolean isValid, @Validated PageParamRequest pageParamRequest) {
|
public CommonResult<CommonPage<CartInfoResponse>> getList(@RequestParam Boolean isValid, @RequestParam String keyword,@Validated PageParamRequest pageParamRequest) {
|
||||||
CommonPage<CartInfoResponse> restPage = CommonPage.restPage(storeCartService.getList(pageParamRequest, isValid));
|
CommonPage<CartInfoResponse> restPage = CommonPage.restPage(storeCartService.getList(pageParamRequest, isValid,keyword));
|
||||||
return CommonResult.success(restPage);
|
return CommonResult.success(restPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,13 +10,11 @@ import com.zbkj.common.response.IndexProductResponse;
|
|||||||
import com.zbkj.front.service.IndexService;
|
import com.zbkj.front.service.IndexService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -63,6 +61,24 @@ public class IndexController {
|
|||||||
return CommonResult.success(indexService.findIndexProductList(type, pageParamRequest));
|
return CommonResult.success(indexService.findIndexProductList(type, pageParamRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "首页水果列表")
|
||||||
|
@RequestMapping(value = "/pagelist/product/{searchStatus}", method = RequestMethod.GET)
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "searchStatus", value = "搜索类型 【0 售卖中 1 预售 2 结束】", dataType = "String", required = true),
|
||||||
|
@ApiImplicitParam(name = "keyword", value = "搜索关键词", dataType = "String")
|
||||||
|
})
|
||||||
|
public CommonResult<List<IndexProductResponse>> getProductList(
|
||||||
|
@PathVariable(value = "searchStatus") String searchStatus,
|
||||||
|
@RequestParam(value = "keyword", required = false) String keyword,
|
||||||
|
PageParamRequest pageParamRequest) {
|
||||||
|
//分页
|
||||||
|
CommonPage<IndexProductResponse> pageResult = indexService.findIndexFruitList(searchStatus, keyword, pageParamRequest);
|
||||||
|
return CommonResult.success(pageResult.getList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 热门搜索
|
* 热门搜索
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -49,6 +49,14 @@ public interface IndexService{
|
|||||||
*/
|
*/
|
||||||
CommonPage<IndexProductResponse> findIndexProductList(Integer type, PageParamRequest pageParamRequest);
|
CommonPage<IndexProductResponse> findIndexProductList(Integer type, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonPage<IndexProductResponse> findIndexFruitList(String searchStatus, String keyword,PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取颜色配置
|
* 获取颜色配置
|
||||||
* @return SystemConfig
|
* @return SystemConfig
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import com.zbkj.common.model.user.User;
|
|||||||
import com.zbkj.front.service.IndexService;
|
import com.zbkj.front.service.IndexService;
|
||||||
import com.zbkj.service.delete.ProductUtils;
|
import com.zbkj.service.delete.ProductUtils;
|
||||||
import com.zbkj.service.service.*;
|
import com.zbkj.service.service.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -29,6 +30,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexServiceImpl 接口实现
|
* IndexServiceImpl 接口实现
|
||||||
@ -42,6 +44,7 @@ import java.util.List;
|
|||||||
* | Author: CRMEB Team <admin@crmeb.com>
|
* | Author: CRMEB Team <admin@crmeb.com>
|
||||||
* +----------------------------------------------------------------------
|
* +----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class IndexServiceImpl implements IndexService {
|
public class IndexServiceImpl implements IndexService {
|
||||||
|
|
||||||
@ -189,6 +192,42 @@ public class IndexServiceImpl implements IndexService {
|
|||||||
return productResponseCommonPage;
|
return productResponseCommonPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonPage<IndexProductResponse> findIndexFruitList(String searchStatus, String keyword, PageParamRequest pageParamRequest) {
|
||||||
|
// 验证searchStatus是否在允许的范围内
|
||||||
|
if (!searchStatus.equals(Constants.INDEX_FRUIT_ONGOING)
|
||||||
|
&& !searchStatus.equals(Constants.INDEX_FRUIT_BOOKING)
|
||||||
|
&& !searchStatus.equals(Constants.INDEX_FRUIT_SETTLED)) {
|
||||||
|
return CommonPage.restPage(new ArrayList<>());
|
||||||
|
}
|
||||||
|
// 分页查询(传入keyword)
|
||||||
|
List<StoreProduct> fruitList = storeProductService.getFruitList(searchStatus, keyword, pageParamRequest);
|
||||||
|
log.info("fruitList: {}", fruitList);//crmebimage/public/maintain/2025/04/25/juzi.jpg
|
||||||
|
// 查出来为空
|
||||||
|
if(CollUtil.isEmpty(fruitList)) {
|
||||||
|
return CommonPage.restPage(new ArrayList<>());
|
||||||
|
}
|
||||||
|
// 转换为响应对象
|
||||||
|
List<IndexProductResponse> responseList = fruitList.stream()
|
||||||
|
.map(this::convertToIndexProductResponse)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
log.info("responseList: {}", responseList);
|
||||||
|
return CommonPage.restPage(responseList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换方法:StoreProduct -> IndexProductResponse
|
||||||
|
private IndexProductResponse convertToIndexProductResponse(StoreProduct product) {
|
||||||
|
IndexProductResponse response = new IndexProductResponse();
|
||||||
|
BeanUtils.copyProperties(product, response); // 拷贝同名属性
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取颜色配置
|
* 获取颜色配置
|
||||||
* @return SystemConfig
|
* @return SystemConfig
|
||||||
|
|||||||
@ -68,7 +68,8 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验密码
|
// 校验密码
|
||||||
String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
|
//String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
|
||||||
|
String password = loginRequest.getPassword();
|
||||||
if (!user.getPwd().equals(password)) {
|
if (!user.getPwd().equals(password)) {
|
||||||
throw new CrmebException("密码错误");
|
throw new CrmebException("密码错误");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
password: 123456
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 3 #默认数据库
|
database: 3 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -19,7 +19,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
password: 123456
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 10 #默认数据库
|
database: 10 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -19,7 +19,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
password: 123456
|
password:
|
||||||
timeout: 10000 # 连接超时时间(毫秒)
|
timeout: 10000 # 连接超时时间(毫秒)
|
||||||
database: 15 #默认数据库
|
database: 15 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -4,7 +4,7 @@ crmeb:
|
|||||||
|
|
||||||
# 配置端口
|
# 配置端口
|
||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8084
|
||||||
servlet:
|
servlet:
|
||||||
context-path: / # 访问path
|
context-path: / # 访问path
|
||||||
tomcat:
|
tomcat:
|
||||||
@ -34,12 +34,12 @@ spring:
|
|||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://127.0.0.1:3306/crmeb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
|
url: jdbc:mysql://127.0.0.1:3306/crmeb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
|
||||||
username: crmeb
|
username: root
|
||||||
password: 111111
|
password: z2003m10L15
|
||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 #地址
|
host: 127.0.0.1 #地址
|
||||||
port: 6379 #端口
|
port: 6379 #端口
|
||||||
password: 111111
|
password:
|
||||||
timeout: 30000 # 连接超时时间(毫秒)
|
timeout: 30000 # 连接超时时间(毫秒)
|
||||||
database: 3 #默认数据库
|
database: 3 #默认数据库
|
||||||
jedis:
|
jedis:
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public interface StoreCartService extends IService<StoreCart> {
|
|||||||
* @param isValid 是否失效
|
* @param isValid 是否失效
|
||||||
* @return 购物车列表
|
* @return 购物车列表
|
||||||
*/
|
*/
|
||||||
PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid);
|
PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid,String keyword);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前购物车数量
|
* 获取当前购物车数量
|
||||||
|
|||||||
@ -154,6 +154,14 @@ public interface StoreProductService extends IService<StoreProduct> {
|
|||||||
*/
|
*/
|
||||||
List<StoreProduct> getIndexProduct(Integer type, PageParamRequest pageParamRequest);
|
List<StoreProduct> getIndexProduct(Integer type, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StoreProduct> getFruitList(String searchStatus,String keyword, PageParamRequest pageParamRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品移动端列表
|
* 获取商品移动端列表
|
||||||
* @param request 筛选参数
|
* @param request 筛选参数
|
||||||
|
|||||||
@ -75,73 +75,67 @@ public class StoreCartServiceImpl extends ServiceImpl<StoreCartDao, StoreCart> i
|
|||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 购物车分页查询
|
||||||
* @param pageParamRequest 分页类参数
|
* @param pageParam
|
||||||
* @param isValid 是否失效
|
* @param isValid
|
||||||
* @return List<CartInfoResponse>
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid) {
|
public PageInfo<CartInfoResponse> getList(PageParamRequest pageParam, boolean isValid,String keyword) {
|
||||||
|
// 1. 当前用户ID
|
||||||
Integer userId = userService.getUserIdException();
|
Integer userId = userService.getUserIdException();
|
||||||
Page<StoreCart> page = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
// 2. 构建查询条件
|
||||||
//带 StoreCart 类的多条件查询
|
LambdaQueryWrapper<StoreCart> query = new LambdaQueryWrapper<StoreCart>()
|
||||||
LambdaQueryWrapper<StoreCart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
.eq(StoreCart::getUid, userId) //where userid = #{userid}
|
||||||
lambdaQueryWrapper.eq(StoreCart::getUid, userId);
|
.orderByDesc(StoreCart::getId);//购物车表里商品id
|
||||||
lambdaQueryWrapper.eq(StoreCart::getStatus, isValid);
|
// 3. 按有效性筛选(可选)
|
||||||
lambdaQueryWrapper.eq(StoreCart::getIsNew, false);
|
// if (isValid != null) {
|
||||||
lambdaQueryWrapper.orderByDesc(StoreCart::getId);
|
// query.eq(StoreCart::getStatus, isValid);//筛选有效和失效商品
|
||||||
List<StoreCart> storeCarts = dao.selectList(lambdaQueryWrapper);
|
// }
|
||||||
if (CollUtil.isEmpty(storeCarts)) {
|
// 4. 关键词搜索(支持商品名称模糊查询)
|
||||||
return CommonPage.copyPageInfo(page, new ArrayList<>());
|
if (StrUtil.isNotBlank(keyword)) {
|
||||||
|
query.exists(
|
||||||
|
"SELECT 1 FROM store_cart sc WHERE sc.product_id = id AND " +
|
||||||
|
"(sc.product_id LIKE '%" + keyword + "%' OR " + // 按ID模糊查询
|
||||||
|
"EXISTS (SELECT 1 FROM store_product sp WHERE sp.id = sc.product_id AND sp.store_name LIKE '%" + keyword + "%'))"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
// 5. 执行分页查询
|
||||||
User user = userService.getInfo();
|
Page<StoreCart> page = PageHelper.startPage(pageParam.getPage(), pageParam.getLimit());
|
||||||
SystemUserLevel userLevel = null;
|
List<StoreCart> cartItems = dao.selectList(query);
|
||||||
if (ObjectUtil.isNotNull(user) && user.getLevel() > 0) {
|
// 6. 转换为响应对象
|
||||||
userLevel = systemUserLevelService.getByLevelId(user.getLevel());
|
List<CartInfoResponse> result = cartItems.stream().map(item -> {
|
||||||
|
CartInfoResponse resp = new CartInfoResponse();
|
||||||
|
BeanUtils.copyProperties(item, resp);
|
||||||
|
// 设置商品基本信息
|
||||||
|
StoreProduct product = storeProductService.getById(item.getProductId());
|
||||||
|
if (product != null) {
|
||||||
|
resp.setStoreName(product.getStoreName())
|
||||||
|
.setImage(product.getImage());
|
||||||
}
|
}
|
||||||
|
// 处理商品有效性
|
||||||
List<CartInfoResponse> response = new ArrayList<>();
|
if (Boolean.FALSE.equals(item.getStatus())) {
|
||||||
for (StoreCart storeCart : storeCarts) {
|
resp.setAttrStatus(false); // 标记为失效商品
|
||||||
CartInfoResponse cartInfoResponse = new CartInfoResponse();
|
return resp;
|
||||||
BeanUtils.copyProperties(storeCart, cartInfoResponse);
|
|
||||||
// 获取商品信息
|
|
||||||
StoreProduct storeProduct = storeProductService.getCartByProId(storeCart.getProductId());
|
|
||||||
cartInfoResponse.setImage(storeProduct.getImage());
|
|
||||||
cartInfoResponse.setStoreName(storeProduct.getStoreName());
|
|
||||||
|
|
||||||
if (!isValid) {// 失效商品直接掠过
|
|
||||||
cartInfoResponse.setAttrStatus(false);
|
|
||||||
response.add(cartInfoResponse);
|
|
||||||
continue ;
|
|
||||||
}
|
}
|
||||||
|
// 有效商品设置规格信息
|
||||||
// 获取对应的商品规格信息(只会有一条信息)
|
StoreProductAttrValue spec = storeProductAttrValueService.getOne(
|
||||||
List<StoreProductAttrValue> attrValueList = storeProductAttrValueService.getListByProductIdAndAttrId(storeCart.getProductId(),
|
new LambdaQueryWrapper<StoreProductAttrValue>()
|
||||||
storeCart.getProductAttrUnique(), Constants.PRODUCT_TYPE_NORMAL);
|
.eq(StoreProductAttrValue::getProductId, item.getProductId())
|
||||||
// 规格不存在即失效
|
.eq(StoreProductAttrValue::getUnique, item.getProductAttrUnique())
|
||||||
if (CollUtil.isEmpty(attrValueList)) {
|
);
|
||||||
cartInfoResponse.setAttrStatus(false);
|
if (spec != null) {
|
||||||
response.add(cartInfoResponse);
|
resp.setAttrStatus(spec.getStock() > 0)
|
||||||
continue ;
|
.setStock(spec.getStock())
|
||||||
|
.setPrice(spec.getPrice())
|
||||||
|
.setSuk(spec.getSuk())
|
||||||
|
.setImage(StrUtil.isBlank(spec.getImage()) ? resp.getImage() : spec.getImage());
|
||||||
|
} else {
|
||||||
|
resp.setAttrStatus(false); // 规格不存在则标记失效
|
||||||
}
|
}
|
||||||
StoreProductAttrValue attrValue = attrValueList.get(0);
|
return resp;
|
||||||
if (StrUtil.isNotBlank(attrValue.getImage())) {
|
}).collect(Collectors.toList());
|
||||||
cartInfoResponse.setImage(attrValue.getImage());
|
return CommonPage.copyPageInfo(page, result);
|
||||||
}
|
|
||||||
cartInfoResponse.setAttrId(attrValue.getId());
|
|
||||||
cartInfoResponse.setSuk(attrValue.getSuk());
|
|
||||||
cartInfoResponse.setPrice(attrValue.getPrice());
|
|
||||||
cartInfoResponse.setAttrId(attrValue.getId());
|
|
||||||
cartInfoResponse.setAttrStatus(attrValue.getStock() > 0);
|
|
||||||
cartInfoResponse.setStock(attrValue.getStock());
|
|
||||||
if (ObjectUtil.isNotNull(userLevel)) {
|
|
||||||
BigDecimal vipPrice = attrValue.getPrice().multiply(new BigDecimal(userLevel.getDiscount())).divide(new BigDecimal(100), 2 ,BigDecimal.ROUND_HALF_UP);
|
|
||||||
cartInfoResponse.setVipPrice(vipPrice);
|
|
||||||
}
|
|
||||||
response.add(cartInfoResponse);
|
|
||||||
}
|
|
||||||
return CommonPage.copyPageInfo(page, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1150,6 +1150,32 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
|||||||
return dao.selectList(lambdaQueryWrapper);
|
return dao.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页水果列表
|
||||||
|
* @param searchStatus
|
||||||
|
* @param pageParamRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<StoreProduct> getFruitList(String searchStatus, String keyword, PageParamRequest pageParamRequest) {
|
||||||
|
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());//分页
|
||||||
|
LambdaQueryWrapper<StoreProduct> lambdaQueryWrapper = Wrappers.lambdaQuery();//使用 MyBatis-Plus 的 Lambda 表达式构建动态查询条件,避免硬编码字段名。
|
||||||
|
// 选择返回字段(其他字段不返回),减少数据传输量。
|
||||||
|
lambdaQueryWrapper.select(StoreProduct::getId, StoreProduct::getImage, StoreProduct::getStoreName,
|
||||||
|
StoreProduct::getPrice, StoreProduct::getOtPrice, StoreProduct::getActivity,
|
||||||
|
StoreProduct::getSize, StoreProduct::getDimensions);
|
||||||
|
// 基础条件:按searchStatus筛选
|
||||||
|
lambdaQueryWrapper.eq(StoreProduct::getSearchStatus, searchStatus);//where searchStatus = ${searchStatus}
|
||||||
|
// 添加关键词搜索条件(如果keyword不为空)
|
||||||
|
if (StrUtil.isNotBlank(keyword)) {
|
||||||
|
lambdaQueryWrapper.and(wrapper -> wrapper
|
||||||
|
.like(StoreProduct::getStoreName, keyword) // 商品名称模糊匹配
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// 排序
|
||||||
|
lambdaQueryWrapper.orderByDesc(StoreProduct::getBeginTime);
|
||||||
|
return dao.selectList(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品移动端列表
|
* 获取商品移动端列表
|
||||||
* @param request 筛选参数
|
* @param request 筛选参数
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user