作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、Python项目、前端项目、人工智能与大数据、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:L-BS-SC-03
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
二,项目简介
该项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现。前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
后端技术
mall采用现阶主流技术实现,涵盖了一般项目中几乎所有使用的技术。
技术 | 版本 | 说明 |
---|---|---|
SpringBoot | 2.7.5 | 容器+MVC框架 |
SpringSecurity | 5.7.4 | 认证和授权框架 |
MyBatis | 3.5.10 | ORM框架 |
MyBatisGenerator | 1.4.1 | 数据层代码生成 |
RabbitMQ | 3.10.5 | 消息队列 |
Redis | 7.0 | 分布式缓存 |
MongoDB | 5.0 | NoSql数据库 |
Elasticsearch | 7.17.3 | 搜索引擎 |
LogStash | 7.17.3 | 日志收集工具 |
Kibana | 7.17.3 | 日志可视化查看工具 |
Nginx | 1.22 | 静态资源服务器 |
Druid | 1.2.14 | 数据库连接池 |
MinIO/OSS | 8.4.5 | 对象存储 |
Hutool | 5.8.0 | Java工具类库 |
PageHelper | 5.3.2 | MyBatis物理分页插件 |
Swagger-UI | 3.0.0 | 文档生成工具 |
logstash-logback-encoder | 7.2 | Logstash日志收集插件 |
docker-maven-plugin | 0.40.2 | 应用打包成Docker镜像的Maven插件 |
前端技术
项目采用现阶段流行的前后端分离开发模式,电商管理系统的前端项目,基于Vue+Element实现。
技术 | 说明 |
---|---|
Vue | 前端框架 |
Vue-router | 路由框架 |
Vuex | 全局状态管理框架 |
Element | 前端UI框架 |
Axios | 前端HTTP框架 |
v-charts | 基于Echarts的图表框架 |
Js-cookie | cookie管理工具 |
nprogress | 进度条控件 |
vue-element-admin | 项目脚手架参考 |
移动端技术
电商系统的移动端项目,基于uni-app
实现。主要包括首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等功能。
技术 | 说明 |
---|---|
Vue | 核心前端框架 |
Vuex | 全局状态管理框架 |
uni-app | 移动端前端框架 |
mix-mall | 电商项目模板 |
luch-request | HTTP请求框架 |
后台管理系统
-
商品模块包括:商品管理、商品分类管理、商品类型管理、品牌管理
-
订单模块包括:订单管理、订单设置、退货申请处理、退货原因设置
-
营销模块包括:秒杀活动管理、优惠券管理、品牌推荐管理、新品推荐管理、人气推荐管理、专题推荐管理、首页广告管理
-
权限模块包括:用户管理、菜单管理、角色管理、资源管理
移动端商城
-
首页:轮播广告、功能模块、品牌制造商直供、秒杀专区、新鲜好物、人气推荐、猜你喜欢
-
商品:商品分类【支持二级】、商品列表、商品详情、商品操作(加入购物车、收藏、购物车)
-
购物车:购物车商品列表、订单支付、订单列表、订单详情
-
我的:会员信息、优惠券、订单管理、地址管理、足迹、我的关注、我的收藏、我的评价
三,系统展示
四,核心代码展示
4.1 会员接口
@Service
public class MemberCollectionServiceImpl implements MemberCollectionService {
@Value("${mongo.insert.sqlEnable}")
private Boolean sqlEnable;
@Autowired
private PmsProductMapper productMapper;
@Autowired
private MemberProductCollectionRepository productCollectionRepository;
@Autowired
private UmsMemberService memberService;
@Override
public int add(MemberProductCollection productCollection) {
int count = 0;
if (productCollection.getProductId() == null) {
return 0;
}
UmsMember member = memberService.getCurrentMember();
productCollection.setMemberId(member.getId());
productCollection.setMemberNickname(member.getNickname());
productCollection.setMemberIcon(member.getIcon());
MemberProductCollection findCollection = productCollectionRepository.findByMemberIdAndProductId(productCollection.getMemberId(), productCollection.getProductId());
if (findCollection == null) {
if (sqlEnable) {
PmsProduct product = productMapper.selectByPrimaryKey(productCollection.getProductId());
if (product == null || product.getDeleteStatus() == 1) {
return 0;
}
productCollection.setProductName(product.getName());
productCollection.setProductSubTitle(product.getSubTitle());
productCollection.setProductPrice(product.getPrice() + "");
productCollection.setProductPic(product.getPic());
}
productCollectionRepository.save(productCollection);
count = 1;
}
return count;
}
@Override
public int delete(Long productId) {
UmsMember member = memberService.getCurrentMember();
return productCollectionRepository.deleteByMemberIdAndProductId(member.getId(), productId);
}
@Override
public Page<MemberProductCollection> list(Integer pageNum, Integer pageSize) {
UmsMember member = memberService.getCurrentMember();
Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
return productCollectionRepository.findByMemberId(member.getId(), pageable);
}
@Override
public MemberProductCollection detail(Long productId) {
UmsMember member = memberService.getCurrentMember();
return productCollectionRepository.findByMemberIdAndProductId(member.getId(), productId);
}
@Override
public void clear() {
UmsMember member = memberService.getCurrentMember();
productCollectionRepository.deleteAllByMemberId(member.getId());
}
}
4.2 商品接口
@Service
public class PmsProductServiceImpl implements PmsProductService {
private static final Logger LOGGER = LoggerFactory.getLogger(PmsProductServiceImpl.class);
@Autowired
private PmsProductMapper productMapper;
@Autowired
private PmsMemberPriceDao memberPriceDao;
@Autowired
private PmsMemberPriceMapper memberPriceMapper;
@Autowired
private PmsProductLadderDao productLadderDao;
@Autowired
private PmsProductLadderMapper productLadderMapper;
@Autowired
private PmsProductFullReductionDao productFullReductionDao;
@Autowired
private PmsProductFullReductionMapper productFullReductionMapper;
@Autowired
private PmsSkuStockDao skuStockDao;
@Autowired
private PmsSkuStockMapper skuStockMapper;
@Autowired
private PmsProductAttributeValueDao productAttributeValueDao;
@Autowired
private PmsProductAttributeValueMapper productAttributeValueMapper;
@Autowired
private CmsSubjectProductRelationDao subjectProductRelationDao;
@Autowired
private CmsSubjectProductRelationMapper subjectProductRelationMapper;
@Autowired
private CmsPrefrenceAreaProductRelationDao prefrenceAreaProductRelationDao;
@Autowired
private CmsPrefrenceAreaProductRelationMapper prefrenceAreaProductRelationMapper;
@Autowired
private PmsProductDao productDao;
@Autowired
private PmsProductVertifyRecordDao productVertifyRecordDao;
@Override
public int create(PmsProductParam productParam) {
int count;
//创建商品
PmsProduct product = productParam;
product.setId(null);
productMapper.insertSelective(product);
//根据促销类型设置价格:会员价格、阶梯价格、满减价格
Long productId = product.getId();
//会员价格
relateAndInsertList(memberPriceDao, productParam.getMemberPriceList(), productId);
//阶梯价格
relateAndInsertList(productLadderDao, productParam.getProductLadderList(), productId);
//满减价格
relateAndInsertList(productFullReductionDao, productParam.getProductFullReductionList(), productId);
//处理sku的编码
handleSkuStockCode(productParam.getSkuStockList(),productId);
//添加sku库存信息
relateAndInsertList(skuStockDao, productParam.getSkuStockList(), productId);
//添加商品参数,添加自定义商品规格
relateAndInsertList(productAttributeValueDao, productParam.getProductAttributeValueList(), productId);
//关联专题
relateAndInsertList(subjectProductRelationDao, productParam.getSubjectProductRelationList(), productId);
//关联优选
relateAndInsertList(prefrenceAreaProductRelationDao, productParam.getPrefrenceAreaProductRelationList(), productId);
count = 1;
return count;
}
private void handleSkuStockCode(List<PmsSkuStock> skuStockList, Long productId) {
if(CollectionUtils.isEmpty(skuStockList))return;
for(int i=0;i<skuStockList.size();i++){
PmsSkuStock skuStock = skuStockList.get(i);
if(StrUtil.isEmpty(skuStock.getSkuCode())){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
StringBuilder sb = new StringBuilder();
//日期
sb.append(sdf.format(new Date()));
//四位商品id
sb.append(String.format("%04d", productId));
//三位索引id
sb.append(String.format("%03d", i+1));
skuStock.setSkuCode(sb.toString());
}
}
}
@Override
public PmsProductResult getUpdateInfo(Long id) {
return productDao.getUpdateInfo(id);
}
@Override
public int update(Long id, PmsProductParam productParam) {
int count;
//更新商品信息
PmsProduct product = productParam;
product.setId(id);
productMapper.updateByPrimaryKeySelective(product);
//会员价格
PmsMemberPriceExample pmsMemberPriceExample = new PmsMemberPriceExample();
pmsMemberPriceExample.createCriteria().andProductIdEqualTo(id);
memberPriceMapper.deleteByExample(pmsMemberPriceExample);
relateAndInsertList(memberPriceDao, productParam.getMemberPriceList(), id);
//阶梯价格
PmsProductLadderExample ladderExample = new PmsProductLadderExample();
ladderExample.createCriteria().andProductIdEqualTo(id);
productLadderMapper.deleteByExample(ladderExample);
relateAndInsertList(productLadderDao, productParam.getProductLadderList(), id);
//满减价格
PmsProductFullReductionExample fullReductionExample = new PmsProductFullReductionExample();
fullReductionExample.createCriteria().andProductIdEqualTo(id);
productFullReductionMapper.deleteByExample(fullReductionExample);
relateAndInsertList(productFullReductionDao, productParam.getProductFullReductionList(), id);
//修改sku库存信息
handleUpdateSkuStockList(id, productParam);
//修改商品参数,添加自定义商品规格
PmsProductAttributeValueExample productAttributeValueExample = new PmsProductAttributeValueExample();
productAttributeValueExample.createCriteria().andProductIdEqualTo(id);
productAttributeValueMapper.deleteByExample(productAttributeValueExample);
relateAndInsertList(productAttributeValueDao, productParam.getProductAttributeValueList(), id);
//关联专题
CmsSubjectProductRelationExample subjectProductRelationExample = new CmsSubjectProductRelationExample();
subjectProductRelationExample.createCriteria().andProductIdEqualTo(id);
subjectProductRelationMapper.deleteByExample(subjectProductRelationExample);
relateAndInsertList(subjectProductRelationDao, productParam.getSubjectProductRelationList(), id);
//关联优选
CmsPrefrenceAreaProductRelationExample prefrenceAreaExample = new CmsPrefrenceAreaProductRelationExample();
prefrenceAreaExample.createCriteria().andProductIdEqualTo(id);
prefrenceAreaProductRelationMapper.deleteByExample(prefrenceAreaExample);
relateAndInsertList(prefrenceAreaProductRelationDao, productParam.getPrefrenceAreaProductRelationList(), id);
count = 1;
return count;
}
private void handleUpdateSkuStockList(Long id, PmsProductParam productParam) {
//当前的sku信息
List<PmsSkuStock> currSkuList = productParam.getSkuStockList();
//当前没有sku直接删除
if(CollUtil.isEmpty(currSkuList)){
PmsSkuStockExample skuStockExample = new PmsSkuStockExample();
skuStockExample.createCriteria().andProductIdEqualTo(id);
skuStockMapper.deleteByExample(skuStockExample);
return;
}
//获取初始sku信息
PmsSkuStockExample skuStockExample = new PmsSkuStockExample();
skuStockExample.createCriteria().andProductIdEqualTo(id);
List<PmsSkuStock> oriStuList = skuStockMapper.selectByExample(skuStockExample);
//获取新增sku信息
List<PmsSkuStock> insertSkuList = currSkuList.stream().filter(item->item.getId()==null).collect(Collectors.toList());
//获取需要更新的sku信息
List<PmsSkuStock> updateSkuList = currSkuList.stream().filter(item->item.getId()!=null).collect(Collectors.toList());
List<Long> updateSkuIds = updateSkuList.stream().map(PmsSkuStock::getId).collect(Collectors.toList());
//获取需要删除的sku信息
List<PmsSkuStock> removeSkuList = oriStuList.stream().filter(item-> !updateSkuIds.contains(item.getId())).collect(Collectors.toList());
handleSkuStockCode(insertSkuList,id);
handleSkuStockCode(updateSkuList,id);
//新增sku
if(CollUtil.isNotEmpty(insertSkuList)){
relateAndInsertList(skuStockDao, insertSkuList, id);
}
//删除sku
if(CollUtil.isNotEmpty(removeSkuList)){
List<Long> removeSkuIds = removeSkuList.stream().map(PmsSkuStock::getId).collect(Collectors.toList());
PmsSkuStockExample removeExample = new PmsSkuStockExample();
removeExample.createCriteria().andIdIn(removeSkuIds);
skuStockMapper.deleteByExample(removeExample);
}
//修改sku
if(CollUtil.isNotEmpty(updateSkuList)){
for (PmsSkuStock pmsSkuStock : updateSkuList) {
skuStockMapper.updateByPrimaryKeySelective(pmsSkuStock);
}
}
}
@Override
public List<PmsProduct> list(PmsProductQueryParam productQueryParam, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum, pageSize);
PmsProductExample productExample = new PmsProductExample();
PmsProductExample.Criteria criteria = productExample.createCriteria();
criteria.andDeleteStatusEqualTo(0);
if (productQueryParam.getPublishStatus() != null) {
criteria.andPublishStatusEqualTo(productQueryParam.getPublishStatus());
}
if (productQueryParam.getVerifyStatus() != null) {
criteria.andVerifyStatusEqualTo(productQueryParam.getVerifyStatus());
}
if (!StrUtil.isEmpty(productQueryParam.getKeyword())) {
criteria.andNameLike("%" + productQueryParam.getKeyword() + "%");
}
if (!StrUtil.isEmpty(productQueryParam.getProductSn())) {
criteria.andProductSnEqualTo(productQueryParam.getProductSn());
}
if (productQueryParam.getBrandId() != null) {
criteria.andBrandIdEqualTo(productQueryParam.getBrandId());
}
if (productQueryParam.getProductCategoryId() != null) {
criteria.andProductCategoryIdEqualTo(productQueryParam.getProductCategoryId());
}
return productMapper.selectByExample(productExample);
}
@Override
public int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail) {
PmsProduct product = new PmsProduct();
product.setVerifyStatus(verifyStatus);
PmsProductExample example = new PmsProductExample();
example.createCriteria().andIdIn(ids);
List<PmsProductVertifyRecord> list = new ArrayList<>();
int count = productMapper.updateByExampleSelective(product, example);
//修改完审核状态后插入审核记录
for (Long id : ids) {
PmsProductVertifyRecord record = new PmsProductVertifyRecord();
record.setProductId(id);
record.setCreateTime(new Date());
record.setDetail(detail);
record.setStatus(verifyStatus);
record.setVertifyMan("test");
list.add(record);
}
productVertifyRecordDao.insertList(list);
return count;
}
@Override
public int updatePublishStatus(List<Long> ids, Integer publishStatus) {
PmsProduct record = new PmsProduct();
record.setPublishStatus(publishStatus);
PmsProductExample example = new PmsProductExample();
example.createCriteria().andIdIn(ids);
return productMapper.updateByExampleSelective(record, example);
}
@Override
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
PmsProduct record = new PmsProduct();
record.setRecommandStatus(recommendStatus);
PmsProductExample example = new PmsProductExample();
example.createCriteria().andIdIn(ids);
return productMapper.updateByExampleSelective(record, example);
}
@Override
public int updateNewStatus(List<Long> ids, Integer newStatus) {
PmsProduct record = new PmsProduct();
record.setNewStatus(newStatus);
PmsProductExample example = new PmsProductExample();
example.createCriteria().andIdIn(ids);
return productMapper.updateByExampleSelective(record, example);
}
@Override
public int updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
PmsProduct record = new PmsProduct();
record.setDeleteStatus(deleteStatus);
PmsProductExample example = new PmsProductExample();
example.createCriteria().andIdIn(ids);
return productMapper.updateByExampleSelective(record, example);
}
@Override
public List<PmsProduct> list(String keyword) {
PmsProductExample productExample = new PmsProductExample();
PmsProductExample.Criteria criteria = productExample.createCriteria();
criteria.andDeleteStatusEqualTo(0);
if(!StrUtil.isEmpty(keyword)){
criteria.andNameLike("%" + keyword + "%");
productExample.or().andDeleteStatusEqualTo(0).andProductSnLike("%" + keyword + "%");
}
return productMapper.selectByExample(productExample);
}
/**
* 建立和插入关系表操作
*
* @param dao 可以操作的dao
* @param dataList 要插入的数据
* @param productId 建立关系的id
*/
private void relateAndInsertList(Object dao, List dataList, Long productId) {
try {
if (CollectionUtils.isEmpty(dataList)) return;
for (Object item : dataList) {
Method setId = item.getClass().getMethod("setId", Long.class);
setId.invoke(item, (Long) null);
Method setProductId = item.getClass().getMethod("setProductId", Long.class);
setProductId.invoke(item, productId);
}
Method insertList = dao.getClass().getMethod("insertList", List.class);
insertList.invoke(dao, dataList);
} catch (Exception e) {
LOGGER.warn("创建产品出错:{}", e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
}
五,相关作品展示
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统