Compare commits

..

No commits in common. "feature_1717" and "master" have entirely different histories.

20 changed files with 90 additions and 233 deletions

View File

@ -8,17 +8,16 @@
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
//移动端商城API
let domain = 'http://192.168.2.192:8084'
let domain = 'http://your Front API domain'
module.exports = {
// 请求域名 格式: https://您的域名
HTTP_REQUEST_URL:domain,
// h5商城地址
HTTP_H5_URL:'https://app',
// #ifdef MP
HTTP_REQUEST_URL: domain,
// #endif
HTTP_ADMIN_URL:'http://127.0.0.1:8080', //PC后台的API请求地址上传图片用,影响h5上传头像
HTTP_ADMIN_URL:'http://your h5 domain', //PC后台的API请求地址上传图片用,影响h5上传头像
// #ifdef H5
//H5接口是浏览器地址
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,
@ -26,7 +25,6 @@ module.exports = {
HTTP_REQUEST_URL:domain,
// #endif
HEADER:{
'content-type': 'application/json'
},

View File

@ -110,7 +110,7 @@ export default {
};
</script>
<style lang="scss">
::v-deep .empty-box{
/deep/ .empty-box{
background-color: #f5f5f5;
}
.swiper,swiper,swiper-item,.slide-image{

View File

@ -7,7 +7,7 @@ crmeb:
wechat-js-api-beta: true #微信js api是否是beta版本
asyncConfig: false #是否同步config表数据到redis
asyncWeChatProgramTempList: false #是否同步小程序公共模板库
imagePath: /idea/shopping2/crmeb_java/crmeb/crmeb/crmebimage/ # 服务器图片路径配置 斜杠结尾
imagePath: /当前项目更根目录的素材文件(绝对路径)/crmebimage/ # 服务器图片路径配置 斜杠结尾
database: mysql
# 配置端口
@ -34,17 +34,18 @@ spring:
locale: zh_CN
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
#数据库配置
# 数据库配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
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
username: root
password: z2003m10L15
username: crmeb
password: 111111
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password:
password: 111111
timeout: 30000 # 连接超时时间(毫秒)
database: 15 #默认数据库
jedis:

View File

@ -324,11 +324,6 @@ public class Constants {
public static final int INDEX_LIMIT_DEFAULT = 3; //首页默认list分页条数
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_FIRST_LIMIT = "firstNumber"; //首发新品个数
public static final String INDEX_SALES_LIMIT = "promotionNumber"; //促销单品个数

View File

@ -5,7 +5,6 @@ import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -167,19 +166,4 @@ public class StoreProduct implements Serializable {
@ApiModelProperty(value = "商品详情")
@TableField(exist = false)
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;
}

View File

@ -65,10 +65,4 @@ public class IndexProductResponse {
@ApiModelProperty(value = "展示图")
private String flatPattern;
@ApiModelProperty(value = "规格")
private String size;
@ApiModelProperty(value = "水果尺寸")
private String dimensions;
}

View File

@ -126,11 +126,9 @@ public class FrontTokenComponent {
*/
public String getToken(HttpServletRequest request) {
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)) {
token = token.replace(Constants.USER_TOKEN_REDIS_KEY_PREFIX, "");
}
System.out.println("处理后的token:" + token);
return token;
}
@ -169,7 +167,6 @@ public class FrontTokenComponent {
"api/front/bargain/list",
"api/front/combination/list",
"api/front/index/product",
"api/front/pagelist/product",
"api/front/combination/index",
"api/front/bargain/index",
"api/front/index/color/config",
@ -199,23 +196,4 @@ public class FrontTokenComponent {
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;
// }
//}
}

View File

@ -52,11 +52,10 @@ public class CartController {
@ApiImplicitParams({
@ApiImplicitParam(name="isValid", value="类型true-有效商品false-无效商品", required = true),
@ApiImplicitParam(name="page", value="页码", required = true),
@ApiImplicitParam(name="limit", value="每页数量", required = true),
@ApiImplicitParam(name="keyword", value="搜索关键词", required = false)
@ApiImplicitParam(name="limit", value="每页数量", required = true)
})
public CommonResult<CommonPage<CartInfoResponse>> getList(@RequestParam Boolean isValid, @RequestParam String keyword,@Validated PageParamRequest pageParamRequest) {
CommonPage<CartInfoResponse> restPage = CommonPage.restPage(storeCartService.getList(pageParamRequest, isValid,keyword));
public CommonResult<CommonPage<CartInfoResponse>> getList(@RequestParam Boolean isValid, @Validated PageParamRequest pageParamRequest) {
CommonPage<CartInfoResponse> restPage = CommonPage.restPage(storeCartService.getList(pageParamRequest, isValid));
return CommonResult.success(restPage);
}

View File

@ -10,11 +10,13 @@ import com.zbkj.common.response.IndexProductResponse;
import com.zbkj.front.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
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.List;
@ -61,24 +63,6 @@ public class IndexController {
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());
}
/**
* 热门搜索
*/

View File

@ -49,14 +49,6 @@ public interface IndexService{
*/
CommonPage<IndexProductResponse> findIndexProductList(Integer type, PageParamRequest pageParamRequest);
/**
* 首页水果列表
* @param searchStatus
* @param pageParamRequest
* @return
*/
CommonPage<IndexProductResponse> findIndexFruitList(String searchStatus, String keyword,PageParamRequest pageParamRequest);
/**
* 获取颜色配置
* @return SystemConfig

View File

@ -22,7 +22,6 @@ import com.zbkj.common.model.user.User;
import com.zbkj.front.service.IndexService;
import com.zbkj.service.delete.ProductUtils;
import com.zbkj.service.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -30,7 +29,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* IndexServiceImpl 接口实现
@ -44,7 +42,6 @@ import java.util.stream.Collectors;
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Slf4j
@Service
public class IndexServiceImpl implements IndexService {
@ -192,42 +189,6 @@ public class IndexServiceImpl implements IndexService {
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

View File

@ -68,8 +68,7 @@ public class LoginServiceImpl implements LoginService {
}
// 校验密码
//String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
String password = loginRequest.getPassword();
String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
if (!user.getPwd().equals(password)) {
throw new CrmebException("密码错误");
}

View File

@ -19,7 +19,7 @@ spring:
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password:
password: 123456
timeout: 10000 # 连接超时时间(毫秒)
database: 3 #默认数据库
jedis:

View File

@ -19,7 +19,7 @@ spring:
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password:
password: 123456
timeout: 10000 # 连接超时时间(毫秒)
database: 10 #默认数据库
jedis:

View File

@ -19,7 +19,7 @@ spring:
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password:
password: 123456
timeout: 10000 # 连接超时时间(毫秒)
database: 15 #默认数据库
jedis:

View File

@ -4,7 +4,7 @@ crmeb:
# 配置端口
server:
port: 8084
port: 8081
servlet:
context-path: / # 访问path
tomcat:
@ -34,12 +34,12 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
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
username: root
password: z2003m10L15
username: crmeb
password: 111111
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password:
password: 111111
timeout: 30000 # 连接超时时间(毫秒)
database: 3 #默认数据库
jedis:

View File

@ -32,7 +32,7 @@ public interface StoreCartService extends IService<StoreCart> {
* @param isValid 是否失效
* @return 购物车列表
*/
PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid,String keyword);
PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid);
/**
* 获取当前购物车数量

View File

@ -154,14 +154,6 @@ public interface StoreProductService extends IService<StoreProduct> {
*/
List<StoreProduct> getIndexProduct(Integer type, PageParamRequest pageParamRequest);
/**
* 首页水果列表
* @param searchStatus
* @param pageParamRequest
* @return
*/
List<StoreProduct> getFruitList(String searchStatus,String keyword, PageParamRequest pageParamRequest);
/**
* 获取商品移动端列表
* @param request 筛选参数

View File

@ -75,67 +75,73 @@ public class StoreCartServiceImpl extends ServiceImpl<StoreCartDao, StoreCart> i
private RedisUtil redisUtil;
/**
* 购物车分页查询
* @param pageParam
* @param isValid
* @return
* 列表
* @param pageParamRequest 分页类参数
* @param isValid 是否失效
* @return List<CartInfoResponse>
*/
@Override
public PageInfo<CartInfoResponse> getList(PageParamRequest pageParam, boolean isValid,String keyword) {
// 1. 当前用户ID
public PageInfo<CartInfoResponse> getList(PageParamRequest pageParamRequest, boolean isValid) {
Integer userId = userService.getUserIdException();
// 2. 构建查询条件
LambdaQueryWrapper<StoreCart> query = new LambdaQueryWrapper<StoreCart>()
.eq(StoreCart::getUid, userId) //where userid = #{userid}
.orderByDesc(StoreCart::getId);//购物车表里商品id
// 3. 按有效性筛选可选
// if (isValid != null) {
// query.eq(StoreCart::getStatus, isValid);//筛选有效和失效商品
// }
// 4. 关键词搜索支持商品名称模糊查询
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 + "%'))"
);
Page<StoreCart> page = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
// StoreCart 类的多条件查询
LambdaQueryWrapper<StoreCart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StoreCart::getUid, userId);
lambdaQueryWrapper.eq(StoreCart::getStatus, isValid);
lambdaQueryWrapper.eq(StoreCart::getIsNew, false);
lambdaQueryWrapper.orderByDesc(StoreCart::getId);
List<StoreCart> storeCarts = dao.selectList(lambdaQueryWrapper);
if (CollUtil.isEmpty(storeCarts)) {
return CommonPage.copyPageInfo(page, new ArrayList<>());
}
// 5. 执行分页查询
Page<StoreCart> page = PageHelper.startPage(pageParam.getPage(), pageParam.getLimit());
List<StoreCart> cartItems = dao.selectList(query);
// 6. 转换为响应对象
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());
User user = userService.getInfo();
SystemUserLevel userLevel = null;
if (ObjectUtil.isNotNull(user) && user.getLevel() > 0) {
userLevel = systemUserLevelService.getByLevelId(user.getLevel());
}
// 处理商品有效性
if (Boolean.FALSE.equals(item.getStatus())) {
resp.setAttrStatus(false); // 标记为失效商品
return resp;
List<CartInfoResponse> response = new ArrayList<>();
for (StoreCart storeCart : storeCarts) {
CartInfoResponse cartInfoResponse = new CartInfoResponse();
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(
new LambdaQueryWrapper<StoreProductAttrValue>()
.eq(StoreProductAttrValue::getProductId, item.getProductId())
.eq(StoreProductAttrValue::getUnique, item.getProductAttrUnique())
);
if (spec != null) {
resp.setAttrStatus(spec.getStock() > 0)
.setStock(spec.getStock())
.setPrice(spec.getPrice())
.setSuk(spec.getSuk())
.setImage(StrUtil.isBlank(spec.getImage()) ? resp.getImage() : spec.getImage());
} else {
resp.setAttrStatus(false); // 规格不存在则标记失效
// 获取对应的商品规格信息(只会有一条信息)
List<StoreProductAttrValue> attrValueList = storeProductAttrValueService.getListByProductIdAndAttrId(storeCart.getProductId(),
storeCart.getProductAttrUnique(), Constants.PRODUCT_TYPE_NORMAL);
// 规格不存在即失效
if (CollUtil.isEmpty(attrValueList)) {
cartInfoResponse.setAttrStatus(false);
response.add(cartInfoResponse);
continue ;
}
return resp;
}).collect(Collectors.toList());
return CommonPage.copyPageInfo(page, result);
StoreProductAttrValue attrValue = attrValueList.get(0);
if (StrUtil.isNotBlank(attrValue.getImage())) {
cartInfoResponse.setImage(attrValue.getImage());
}
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);
}
/**

View File

@ -1150,32 +1150,6 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
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 筛选参数