/**
* 严肃声明:
* 开源版本请务必保留此注释头信息,若删除我方将保留所有法律责任追究!
* 本软件已申请软件著作权,受国家版权局知识产权以及国家计算机软件著作权保护!
* 可正常分享和学习源码,不得用于违法犯罪活动,违者必究!
* Copyright (c) 2019-2021 十三 all rights reserved.
* 版权所有,侵权必究!
*/
package ltd.newbee.mall.service.impl;
import ltd.newbee.mall.api.mall.vo.NewBeeMallOrderDetailVO;
import ltd.newbee.mall.api.mall.vo.NewBeeMallOrderItemVO;
import ltd.newbee.mall.api.mall.vo.NewBeeMallOrderListVO;
import ltd.newbee.mall.api.mall.vo.NewBeeMallShoppingCartItemVO;
import ltd.newbee.mall.common.*;
import ltd.newbee.mall.dao.*;
import ltd.newbee.mall.entity.*;
import ltd.newbee.mall.service.NewBeeMallOrderService;
import ltd.newbee.mall.util.BeanUtil;
import ltd.newbee.mall.util.NumberUtil;
import ltd.newbee.mall.util.PageQueryUtil;
import ltd.newbee.mall.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
@Service
public class NewBeeMallOrderServiceImpl implements NewBeeMallOrderService {
@Autowired
private NewBeeMallOrderMapper newBeeMallOrderMapper;
@Autowired
private NewBeeMallOrderItemMapper newBeeMallOrderItemMapper;
@Autowired
private NewBeeMallShoppingCartItemMapper newBeeMallShoppingCartItemMapper;
@Autowired
private NewBeeMallGoodsMapper newBeeMallGoodsMapper;
@Autowired
private NewBeeMallOrderAddressMapper newBeeMallOrderAddressMapper;
@Override
public NewBeeMallOrderDetailVO getOrderDetailByOrderId(Long orderId) {
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderMapper.selectByPrimaryKey(orderId);
if (newBeeMallOrder == null) {
NewBeeMallException.fail(ServiceResultEnum.DATA_NOT_EXIST.getResult());
}
List<NewBeeMallOrderItem> orderItems = newBeeMallOrderItemMapper.selectByOrderId(newBeeMallOrder.getOrderId());
//获取订单项数据
if (!CollectionUtils.isEmpty(orderItems)) {
List<NewBeeMallOrderItemVO> newBeeMallOrderItemVOS = BeanUtil.copyList(orderItems, NewBeeMallOrderItemVO.class);
NewBeeMallOrderDetailVO newBeeMallOrderDetailVO = new NewBeeMallOrderDetailVO();
BeanUtil.copyProperties(newBeeMallOrder, newBeeMallOrderDetailVO);
newBeeMallOrderDetailVO.setOrderStatusString(NewBeeMallOrderStatusEnum.getNewBeeMallOrderStatusEnumByStatus(newBeeMallOrderDetailVO.getOrderStatus()).getName());
newBeeMallOrderDetailVO.setPayTypeString(PayTypeEnum.getPayTypeEnumByType(newBeeMallOrderDetailVO.getPayType()).getName());
newBeeMallOrderDetailVO.setNewBeeMallOrderItemVOS(newBeeMallOrderItemVOS);
return newBeeMallOrderDetailVO;
} else {
NewBeeMallException.fail(ServiceResultEnum.ORDER_ITEM_NULL_ERROR.getResult());
return null;
}
}
@Override
public NewBeeMallOrderDetailVO getOrderDetailByOrderNo(String orderNo, Long userId) {
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderMapper.selectByOrderNo(orderNo);
if (newBeeMallOrder == null) {
NewBeeMallException.fail(ServiceResultEnum.DATA_NOT_EXIST.getResult());
}
if (!userId.equals(newBeeMallOrder.getUserId())) {
NewBeeMallException.fail(ServiceResultEnum.REQUEST_FORBIDEN_ERROR.getResult());
}
List<NewBeeMallOrderItem> orderItems = newBeeMallOrderItemMapper.selectByOrderId(newBeeMallOrder.getOrderId());
//获取订单项数据
if (!CollectionUtils.isEmpty(orderItems)) {
List<NewBeeMallOrderItemVO> newBeeMallOrderItemVOS = BeanUtil.copyList(orderItems, NewBeeMallOrderItemVO.class);
NewBeeMallOrderDetailVO newBeeMallOrderDetailVO = new NewBeeMallOrderDetailVO();
BeanUtil.copyProperties(newBeeMallOrder, newBeeMallOrderDetailVO);
newBeeMallOrderDetailVO.setOrderStatusString(NewBeeMallOrderStatusEnum.getNewBeeMallOrderStatusEnumByStatus(newBeeMallOrderDetailVO.getOrderStatus()).getName());
newBeeMallOrderDetailVO.setPayTypeString(PayTypeEnum.getPayTypeEnumByType(newBeeMallOrderDetailVO.getPayType()).getName());
newBeeMallOrderDetailVO.setNewBeeMallOrderItemVOS(newBeeMallOrderItemVOS);
return newBeeMallOrderDetailVO;
} else {
NewBeeMallException.fail(ServiceResultEnum.ORDER_ITEM_NULL_ERROR.getResult());
return null;
}
}
@Override
public PageResult getMyOrders(PageQueryUtil pageUtil) {
int total = newBeeMallOrderMapper.getTotalNewBeeMallOrders(pageUtil);
List<NewBeeMallOrder> newBeeMallOrders = newBeeMallOrderMapper.findNewBeeMallOrderList(pageUtil);
List<NewBeeMallOrderListVO> orderListVOS = new ArrayList<>();
if (total > 0) {
//数据转换 将实体类转成vo
orderListVOS = BeanUtil.copyList(newBeeMallOrders, NewBeeMallOrderListVO.class);
//设置订单状态中文显示值
for (NewBeeMallOrderListVO newBeeMallOrderListVO : orderListVOS) {
newBeeMallOrderListVO.setOrderStatusString(NewBeeMallOrderStatusEnum.getNewBeeMallOrderStatusEnumByStatus(newBeeMallOrderListVO.getOrderStatus()).getName());
}
List<Long> orderIds = newBeeMallOrders.stream().map(NewBeeMallOrder::getOrderId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(orderIds)) {
List<NewBeeMallOrderItem> orderItems = newBeeMallOrderItemMapper.selectByOrderIds(orderIds);
Map<Long, List<NewBeeMallOrderItem>> itemByOrderIdMap = orderItems.stream().collect(groupingBy(NewBeeMallOrderItem::getOrderId));
for (NewBeeMallOrderListVO newBeeMallOrderListVO : orderListVOS) {
//封装每个订单列表对象的订单项数据
if (itemByOrderIdMap.containsKey(newBeeMallOrderListVO.getOrderId())) {
List<NewBeeMallOrderItem> orderItemListTemp = itemByOrderIdMap.get(newBeeMallOrderListVO.getOrderId());
//将NewBeeMallOrderItem对象列表转换成NewBeeMallOrderItemVO对象列表
List<NewBeeMallOrderItemVO> newBeeMallOrderItemVOS = BeanUtil.copyList(orderItemListTemp, NewBeeMallOrderItemVO.class);
newBeeMallOrderListVO.setNewBeeMallOrderItemVOS(newBeeMallOrderItemVOS);
}
}
}
}
PageResult pageResult = new PageResult(orderListVOS, total, pageUtil.getLimit(), pageUtil.getPage());
return pageResult;
}
@Override
public String cancelOrder(String orderNo, Long userId) {
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderMapper.selectByOrderNo(orderNo);
if (newBeeMallOrder != null) {
//todo 验证是否是当前userId下的订单,否则报错
//todo 订单状态判断
if (newBeeMallOrderMapper.closeOrder(Collections.singletonList(newBeeMallOrder.getOrderId()), NewBeeMallOrderStatusEnum.ORDER_CLOSED_BY_MALLUSER.getOrderStatus()) > 0) {
return ServiceResultEnum.SUCCESS.getResult();
} else {
return ServiceResultEnum.DB_ERROR.getResult();
}
}
return ServiceResultEnum.ORDER_NOT_EXIST_ERROR.getResult();
}
@Override
public String finishOrder(String orderNo, Long userId) {
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderMapper.selectByOrderNo(orderNo);
if (newBee
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip本资源中的源码都是经过本地编译过可运行的,评审分达到95分以上。资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。 java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip 本资源中的源码都是经过本地编译过可运行的,评审分达到95分以上。资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。本资源中的源码都是经过本地编译过可运行的
资源推荐
资源详情
资源评论
收起资源包目录
java毕业设计基于Springboot+Vue前后端分离的在线购物商城管理系统+数据库脚本.zip (327个子文件)
index.css 1.28MB
date-picker.css 83KB
cascader.css 81KB
pagination.css 73KB
select.css 63KB
transfer.css 60KB
time-picker.css 58KB
table.css 51KB
message-box.css 50KB
time-select.css 42KB
slider.css 42KB
cascader-panel.css 41KB
col.css 38KB
dropdown.css 36KB
table-column.css 34KB
autocomplete.css 33KB
tree.css 30KB
calendar.css 27KB
upload.css 26KB
base.css 24KB
tabs.css 24KB
input-number.css 23KB
button.css 21KB
menu.css 19KB
icon.css 17KB
checkbox.css 16KB
color-picker.css 14KB
input.css 13KB
dialog.css 13KB
collapse.css 13KB
select-dropdown.css 13KB
popover.css 12KB
step.css 12KB
drawer.css 11KB
radio.css 11KB
tag.css 11KB
radio-button.css 10KB
image.css 9KB
form.css 8KB
carousel.css 8KB
tooltip.css 8KB
progress.css 8KB
link.css 8KB
alert.css 7KB
message.css 7KB
switch.css 7KB
loading.css 7KB
notification.css 7KB
popper.css 7KB
timeline-item.css 7KB
scrollbar.css 6KB
breadcrumb.css 6KB
carousel-item.css 6KB
display.css 6KB
row.css 6KB
badge.css 6KB
divider.css 6KB
page-header.css 6KB
rate.css 6KB
avatar.css 6KB
card.css 5KB
option-group.css 5KB
option.css 5KB
backtop.css 5KB
popconfirm.css 5KB
main.css 5KB
timeline.css 5KB
footer.css 5KB
header.css 5KB
radio-group.css 5KB
spinner.css 4KB
reset.css 3KB
container.css 3KB
steps.css 3KB
aside.css 3KB
element-variables.css 2KB
infinite-scroll.css 0B
menu-item.css 0B
breadcrumb-item.css 0B
infiniteScroll.css 0B
button-group.css 0B
submenu.css 0B
menu-item-group.css 0B
checkbox-button.css 0B
tab-pane.css 0B
checkbox-group.css 0B
dropdown-menu.css 0B
dropdown-item.css 0B
collapse-item.css 0B
form-item.css 0B
.gitattributes 85B
.gitattributes 85B
.gitattributes 29B
.gitignore 361B
.gitignore 361B
.gitignore 268B
index.html 663B
index.html 435B
favicon.ico 4KB
favicon.ico 4KB
共 327 条
- 1
- 2
- 3
- 4
资源评论
盈梓的博客
- 粉丝: 9559
- 资源: 2308
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (179941432)基于MATLAB车牌识别系统【GUI含界面】.zip
- (179941434)基于MATLAB车牌识别系统【含界面GUI】.zip
- (178021462)基于Javaweb+ssm的医院在线挂号系统的设计与实现.zip
- (178047214)基于springboot图书管理系统.zip
- 张郅奇 的Python学习过程
- (23775420)欧姆龙PLC CP1H-E CP1L-E CJ2M CP1E 以太网通讯.zip
- (174590622)计算机课程设计-IP数据包解析
- (175550824)泛海三江全系调试软件PCSet-All2.0.3 1
- (172742832)实验1 - LC并联谐振回路仿真实验报告1
- 网络搭建练习题.pkt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功