package ltd.newbee.mall.controller.mall;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import ltd.newbee.mall.config.AlipayConfig;
import ltd.newbee.mall.constant.Constants;
import ltd.newbee.mall.controller.base.BaseController;
import ltd.newbee.mall.core.entity.Coupon;
import ltd.newbee.mall.core.entity.Order;
import ltd.newbee.mall.core.entity.OrderItem;
import ltd.newbee.mall.core.entity.vo.*;
import ltd.newbee.mall.core.service.CouponUserService;
import ltd.newbee.mall.core.service.OrderItemService;
import ltd.newbee.mall.core.service.OrderService;
import ltd.newbee.mall.core.service.ShopCatService;
import ltd.newbee.mall.enums.OrderStatusEnum;
import ltd.newbee.mall.enums.PayStatusEnum;
import ltd.newbee.mall.enums.PayTypeEnum;
import ltd.newbee.mall.exception.BusinessException;
import ltd.newbee.mall.task.OrderUnPaidTask;
import ltd.newbee.mall.task.TaskService;
import ltd.newbee.mall.util.MyBeanUtil;
import ltd.newbee.mall.util.R;
import ltd.newbee.mall.util.security.Md5Utils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
@Slf4j
@Controller
public class MallOrderController extends BaseController {
@Autowired
private ShopCatService shopCatService;
@Autowired
private OrderService orderService;
@Autowired
private OrderItemService orderItemService;
@Autowired
private CouponUserService couponUserService;
@Autowired
private AlipayConfig alipayConfig;
@Autowired
private TaskService taskService;
@Value("${wayn.serverUrl}")
private String serverUrl;
@GetMapping("saveOrder")
public String saveOrder(Long couponUserId, HttpSession session) {
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
List<ShopCatVO> shopcatVOList = shopCatService.getShopCatVOList(mallUserVO.getUserId());
// 购物车中无数据则跳转至错误页
if (CollectionUtils.isEmpty(shopcatVOList)) {
throw new BusinessException("购物车中无数据");
}
String orderNo = orderService.saveOrder(mallUserVO, couponUserId, shopcatVOList);
return redirectTo("orders/" + orderNo);
}
@GetMapping("saveOrder/{seckillSuccessId}/{seckillSecretKey}")
public String seckillSaveOrder(@PathVariable Long seckillSuccessId,
@PathVariable String seckillSecretKey,
HttpSession session) {
if (seckillSecretKey == null || !seckillSecretKey.equals(Md5Utils.hash(seckillSuccessId + Constants.SECKILL_ORDER_SALT))) {
throw new BusinessException("秒杀商品下单不合法");
}
MallUserVO userVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
String orderNo = orderService.seckillSaveOrder(seckillSuccessId, userVO);
return redirectTo("/orders/" + orderNo);
}
@GetMapping("/orders/{orderNo}")
public String orderDetailPage(HttpServletRequest request, @PathVariable("orderNo") String orderNo, HttpSession session) {
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
Order order = orderService.getOne(new QueryWrapper<Order>().eq("order_no", orderNo));
if (order == null || !order.getUserId().equals(mallUserVO.getUserId())) {
throw new BusinessException("订单项异常");
}
return renderOrderDetail(request, order);
}
@GetMapping("/orders")
public String orderListPage(HttpServletRequest request, HttpSession session) {
Page<OrderListVO> page = getPage(request, Constants.ORDER_SEARCH_PAGE_LIMIT);
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
Order order = new Order();
order.setUserId(mallUserVO.getUserId());
IPage<OrderListVO> iPage = orderService.selectMyOrderPage(page, order);
List<OrderListVO> orderListVOS = iPage.getRecords();
for (OrderListVO orderListVO : orderListVOS) {
orderListVO.setOrderStatusString(OrderStatusEnum.getOrderStatusEnumByStatus(orderListVO.getOrderStatus()).getName());
}
List<Long> longs = orderListVOS.stream().map(OrderListVO::getOrderId).collect(Collectors.toList());
List<OrderItem> orderItems = orderItemService.list(new QueryWrapper<OrderItem>().in(CollectionUtils.isNotEmpty(longs), "order_id", longs));
Map<Long, List<OrderItem>> longListMap = orderItems.stream().collect(Collectors.groupingBy(OrderItem::getOrderId));
for (OrderListVO orderListVO : orderListVOS) {
if (longListMap.containsKey(orderListVO.getOrderId())) {
List<OrderItem> orderItemList = longListMap.get(orderListVO.getOrderId());
List<OrderItemVO> itemVOList = MyBeanUtil.copyList(orderItemList, OrderItemVO.class);
orderListVO.setNewBeeMallOrderItemVOS(itemVOList);
}
}
request.setAttribute("orderPageResult", iPage);
request.setAttribute("path", "orders");
return "mall/my-orders";
}
@PutMapping("/orders/{orderNo}/cancel")
@ResponseBody
public R cancelOrder(@PathVariable("orderNo") String orderNo, HttpSession session) {
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
Order order = judgeOrderUserId(orderNo, mallUserVO.getUserId());
// 判断订单状态
if (order.getOrderStatus() != OrderStatusEnum.OREDER_PAID.getOrderStatus()
|| order.getPayStatus() != PayStatusEnum.PAY_SUCCESS.getPayStatus()) {
throw new BusinessException("订单无法关闭");
}
order.setOrderStatus((byte) OrderStatusEnum.ORDER_CLOSED_BY_MALLUSER.getOrderStatus());
return R.result(orderService.updateById(order), "订单状态修改异常");
}
@PutMapping("/orders/{orderNo}/finish")
@ResponseBody
public R finishOrder(@PathVariable("orderNo") String orderNo, HttpSession session) {
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
Order order = judgeOrderUserId(orderNo, mallUserVO.getUserId());
// 判断订单状态
if (order.getOrderStatus() != OrderStatusEnum.OREDER_EXPRESS.getOrderStatus()
|| order.getPayStatus() != PayStatusEnum.PAY_SUCCESS.getPayStatus()) {
throw new BusinessException("订单结算异常");
}
order.setOrderStatus((byte) OrderStatusEnum.ORDER_SUCCESS.getOrderStatus());
return R.result(orderService.updateById(order), "订单状态更新异常");
}
@GetMapping("/selectPayType")
public String selectPayType(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession session) {
MallUserVO mallUserVO = (MallUserVO) session.getAttribute(Constants.MALL_USER_SESSION_KEY);
Order order = judgeOrderUserId(orderNo, mallUserVO.getUserId());
// 判断订单状态
if (order.getOrderStatus() != OrderStatusEnum.ORDER_PRE_PAY.getOrderStatus()
没有合适的资源?快使用搜索试试~ 我知道了~
基于Mybatis Plus的newbee-mall商城前端JavaScript版本源码,集成优惠券领取与支付宝沙箱支付功能
共907个文件
js:219个
html:194个
java:132个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 90 浏览量
2024-10-04
11:51:05
上传
评论
收藏 55.18MB ZIP 举报
温馨提示
本项目为基于Mybatis Plus的newbee-mall商城前端JavaScript版本源码,综合运用JavaScript、HTML、Java和CSS等语言开发。项目包含802个文件,具体包括198个JavaScript文件、150个HTML文件、132个Java文件、117个CSS文件,并附有丰富的图片、XML、JSON等资源。项目特色在于集成了优惠券领取和支付宝沙箱支付功能,后台管理支持搜索操作,旨在为用户提供便捷的购物体验和高效的管理工具。
资源推荐
资源详情
资源评论
收起资源包目录
基于Mybatis Plus的newbee-mall商城前端JavaScript版本源码,集成优惠券领取与支付宝沙箱支付功能 (907个子文件)
adminlte.css 247KB
adminlte.min.css 201KB
bootstrap.css 183KB
bootstrap.css 143KB
bootstrap.min.css 137KB
froala_editor.pkgd.css 131KB
bootstrap3.4.1.min.css 119KB
bootstrap.min.css 118KB
bootstrap-modal.css 106KB
froala_editor.pkgd.min.css 104KB
royal.css 83KB
gray.css 83KB
dark.css 82KB
plugins.pkgd.css 73KB
royal.min.css 70KB
gray.min.css 69KB
dark.min.css 69KB
plugins.pkgd.min.css 57KB
style.css 51KB
ionicons.min.css 50KB
froala_editor.css 48KB
froala_editor.min.css 39KB
bootstrap-grid.css 37KB
jquery-ui.css 32KB
website.css 31KB
files_manager.css 30KB
bootstrap-grid.min.css 28KB
font-awesome.min.css 26KB
files_manager.min.css 23KB
sweetalert.css 21KB
swiper.min.css 19KB
ui.jqgrid-bootstrap4.css 19KB
ui.jqgrid-bootstrap.css 19KB
ui.jqgrid.css 18KB
select2.css 17KB
layer.css 15KB
select2.min.css 15KB
jquery-ui-1.10.4.custom.min.css 14KB
index.css 11KB
layer.css 11KB
layim.css 11KB
froala_style.css 10KB
image_manager.css 9KB
order-detail.css 9KB
website.css 8KB
header.css 8KB
my-orders.css 8KB
froala_style.min.css 8KB
daterangepicker.css 7KB
image_manager.min.css 7KB
order-settle.css 6KB
laydate.css 6KB
cart.css 6KB
video.css 5KB
image.css 5KB
flatpickr.material_blue.min.css 5KB
pay.css 5KB
layer.css 5KB
flatpickr.dark.min.css 5KB
flatpickr.min.css 5KB
search.css 5KB
trim_video.css 5KB
bootstrap-reboot.css 5KB
video.min.css 4KB
image.min.css 4KB
addresses.css 4KB
coupon.css 4KB
trim_video.min.css 4KB
bootstrap-reboot.min.css 4KB
style.css 4KB
style.css 4KB
detail.css 3KB
laydate.css 3KB
pay-select.css 3KB
file.css 3KB
table.css 3KB
layer.ext.css 3KB
ebook.css 3KB
colors.css 3KB
iconfont.css 3KB
file.min.css 2KB
table.min.css 2KB
code_view.css 2KB
login.css 2KB
colors.min.css 2KB
personal.css 2KB
fullscreen.css 2KB
code_view.min.css 2KB
main.css 2KB
quick_insert.css 2KB
fullscreen.min.css 2KB
spell_checker.css 2KB
quick_insert.min.css 1KB
help.css 1KB
embedly.css 1KB
spell_checker.min.css 1KB
help.min.css 1KB
search.css 1KB
char_counter.css 1KB
common.css 1KB
共 907 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
wjs2024
- 粉丝: 2369
- 资源: 5533
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MPU9250 九轴 EKF扩展卡尔曼滤波数据融合算法 短时间内我们相信陀螺仪,长时间内我们可以相信加速度计 使用扩展卡尔曼滤波(EKF)将数据融合 选取状态量为四元数和三轴陀螺仪的漂移
- MFC如何修改多文档视图的标签
- PFT100资料(1).zip
- 土地出让数据集(2000-2022.12)(104.8W+ 记录,48特征)CSV
- 国特程序,有单部六层,3部十层,两款6部十层程序 跑分如图,wincc组态完全按照今年要求
- 2_代码合集(3)(1).zip
- 排序算法中插入排序C++实现及其特性
- logd/logcat源码
- linux常用命令大全.txt
- linux常用命令大全.txt
- linux常用命令大全.txt
- mysql和sqlserver语法有什么区别.txt
- C++小游戏超大合集!!
- 生理响应受背包负载影响的实验室协议研究综述
- 一个基于递归下降解析算法的C++程序
- 【紫金天风期货-2024研报】苯乙烯周报:近端矛盾不大.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功