后台管理 -> 订单管理完成;nginx配置文件限制ip并发数
This commit is contained in:
parent
152ff7d8e5
commit
83f424b80f
@ -424,6 +424,13 @@ server
|
||||
listen 80;
|
||||
listen 443 ssl http2;
|
||||
|
||||
# 并发限制 限制当前站点最大并发数
|
||||
limit_conn perserver 50;
|
||||
# 单IP限制 限制单个IP访问最大并发数
|
||||
limit_conn perip 10;
|
||||
# 流量限制 限制每个请求的流量上限(单位:KB)
|
||||
limit_rate 8192k;
|
||||
|
||||
# 核心配置
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5203; # ⚠ Gateway 微服务项目本地运行的端口
|
||||
|
@ -4,7 +4,7 @@ import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum OrderStatus {
|
||||
PENDING("Pending", "等待确认"),
|
||||
PENDING("Pending", "等待支付"),
|
||||
PROCESSING("Processing", "已支付,等待发货中"),
|
||||
SHIPPED("Shipped", "已发货,等待确认收货"),
|
||||
DELIVERED("Delivered", "已送达"),
|
||||
|
@ -4,10 +4,12 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true) // 链式写法
|
||||
public class Good {
|
||||
public class Good implements Serializable {
|
||||
Long id;
|
||||
String goodsName;
|
||||
Integer categoryId;
|
||||
|
@ -4,10 +4,12 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true) // 链式写法
|
||||
public class GoodCategory {
|
||||
public class GoodCategory implements Serializable {
|
||||
Long id;
|
||||
String categoryName;
|
||||
Integer order;
|
||||
|
@ -4,13 +4,14 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true) // 链式写法
|
||||
public class Order {
|
||||
public class Order implements Serializable {
|
||||
private Long id;
|
||||
private Integer userId;
|
||||
private LocalDateTime orderDate;
|
||||
|
@ -4,10 +4,12 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true) // 链式写法
|
||||
public class OrderDetail {
|
||||
public class OrderDetail implements Serializable {
|
||||
private Long id;
|
||||
private Long orderId;
|
||||
private Long goodId;
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.cxyxiaomo.epp.common.query;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true) // 链式写法
|
||||
// 微服务必须要实现Serializable
|
||||
public class OrderQuery implements Serializable {
|
||||
private Long id;
|
||||
private Integer userId;
|
||||
private String orderStatusCode;
|
||||
private String expressId;
|
||||
}
|
@ -9,7 +9,6 @@ import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -22,10 +21,10 @@ import java.util.stream.Collectors;
|
||||
public class OrderVO implements Serializable {
|
||||
private String id;
|
||||
private Integer userId;
|
||||
private LocalDateTime orderDate;
|
||||
private String orderStatus;
|
||||
private String orderStatusCode;
|
||||
private String orderPrice;
|
||||
private String orderDate;
|
||||
private String payDate;
|
||||
private String cancelDate;
|
||||
private String shipDate;
|
||||
@ -47,6 +46,9 @@ public class OrderVO implements Serializable {
|
||||
String price = order.getOrderPrice().setScale(2, RoundingMode.FLOOR).toPlainString();
|
||||
orderVO.setOrderPrice(price);
|
||||
|
||||
if (order.getOrderDate() != null) {
|
||||
orderVO.setOrderDate(order.getOrderDate().toString().replace("T", " "));
|
||||
}
|
||||
if (order.getPayDate() != null) {
|
||||
orderVO.setPayDate(order.getPayDate().toString().replace("T", " "));
|
||||
}
|
||||
|
@ -2,18 +2,31 @@ package com.cxyxiaomo.epp.shop.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.AddType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.EditType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.FieldType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.SearchType;
|
||||
import com.cxyxiaomo.epp.PageTable.query.PageQuery;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldBuilder;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldMapperBuilder;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldRuleBuilder;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldRuleListBuilder;
|
||||
import com.cxyxiaomo.epp.common.enums.OrderStatus;
|
||||
import com.cxyxiaomo.epp.common.pojo.Order;
|
||||
import com.cxyxiaomo.epp.common.pojo.OrderDetail;
|
||||
import com.cxyxiaomo.epp.common.query.OrderQuery;
|
||||
import com.cxyxiaomo.epp.common.response.Res;
|
||||
import com.cxyxiaomo.epp.common.vo.GoodVO;
|
||||
import com.cxyxiaomo.epp.common.vo.OrderDetailVO;
|
||||
import com.cxyxiaomo.epp.common.vo.OrderVO;
|
||||
import com.cxyxiaomo.epp.shop.service.GoodService;
|
||||
import com.cxyxiaomo.epp.shop.service.OrderService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -30,8 +43,8 @@ public class OrderController {
|
||||
/**
|
||||
* 小程序端创建订单
|
||||
*
|
||||
* @param userId 下单用户
|
||||
* @param orderList 下单商品 [ { goodId, count }, ... ]
|
||||
* @param params userId 下单用户
|
||||
* @param params orderList 下单商品 [ { goodId, count }, ... ]
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/miniprogram/createOrder")
|
||||
@ -184,6 +197,12 @@ public class OrderController {
|
||||
return Res.success(success ? "支付成功" : "支付失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户取消订单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/miniprogram/cancelOrder")
|
||||
@ResponseBody
|
||||
public Res cancelOrder(@RequestBody JSONObject params) {
|
||||
@ -224,6 +243,107 @@ public class OrderController {
|
||||
return Res.success(success ? "取消成功" : "取消失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
*
|
||||
* @param orderId
|
||||
* @param expressId
|
||||
* @param comment
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/manage/deliverOrder")
|
||||
@ResponseBody
|
||||
public Res deliverOrder(Long orderId, String expressId, String comment) {
|
||||
if (orderId == null || expressId == null || comment == null) {
|
||||
return Res.error("参数错误");
|
||||
}
|
||||
|
||||
if (expressId.equals("") && comment.equals("")) {
|
||||
return Res.error("运单号 和 发货备注 不可同时为空");
|
||||
}
|
||||
|
||||
// 查询订单详情
|
||||
Order order = orderService.getOrderById(orderId);
|
||||
if (order == null) {
|
||||
return Res.error("订单不存在");
|
||||
}
|
||||
|
||||
//判断是否可以发货
|
||||
OrderStatus orderStatus = OrderStatus.get(order.getOrderStatus());
|
||||
switch (orderStatus) {
|
||||
case PENDING:
|
||||
return Res.error("订单尚未支付,不可发货");
|
||||
case PROCESSING: // 订单未发货
|
||||
// 更新订单发货信息
|
||||
orderService.updateOrderShipInfo(orderId, expressId, comment);
|
||||
// 更新支付信息
|
||||
orderService.updateOrderStatus(orderId, OrderStatus.SHIPPED);
|
||||
return Res.success("发货成功");
|
||||
case SHIPPED: // 订单已发货,修改发货信息
|
||||
// 更新订单发货信息
|
||||
orderService.updateOrderShipInfo(orderId, expressId, comment);
|
||||
return Res.success("发货信息修改成功");
|
||||
case DELIVERED:
|
||||
return Res.error("订单已完成,无法再次发货");
|
||||
case CANCELLED:
|
||||
return Res.error("订单已取消,不可发货");
|
||||
default:
|
||||
return Res.error("当前订单状态不可发货");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员取消订单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/manage/cancelOrder")
|
||||
@ResponseBody
|
||||
public Res cancelOrderByManager(@RequestBody JSONObject params) {
|
||||
Long orderId = params.getLong("orderId");
|
||||
if (orderId == null) {
|
||||
return Res.error("参数错误");
|
||||
}
|
||||
|
||||
// 查询订单详情
|
||||
Order order = orderService.getOrderById(orderId);
|
||||
if (order == null) {
|
||||
return Res.error("订单不存在");
|
||||
}
|
||||
|
||||
//判断是否可以取消
|
||||
OrderStatus orderStatus = OrderStatus.get(order.getOrderStatus());
|
||||
switch (orderStatus) {
|
||||
case PENDING:
|
||||
// 更新订单发货信息
|
||||
orderService.updateOrderShipInfo(orderId, "", "管理员取消了您的订单,如有疑问请联系管理员");
|
||||
// 更新支付信息
|
||||
orderService.updateOrderStatus(orderId, OrderStatus.CANCELLED);
|
||||
return Res.success("操作成功");
|
||||
case PROCESSING:
|
||||
// 更新订单发货信息
|
||||
orderService.updateOrderShipInfo(orderId, "", "管理员取消了您的订单,费用已退回至您的帐户,如有疑问请联系管理员");
|
||||
// 更新支付信息
|
||||
orderService.updateOrderStatus(orderId, OrderStatus.CANCELLED);
|
||||
return Res.success("操作成功");
|
||||
case SHIPPED:
|
||||
return Res.error("订单已发货,不可取消");
|
||||
case DELIVERED:
|
||||
return Res.error("订单已送达,不可取消");
|
||||
case CANCELLED:
|
||||
return Res.error("订单已取消");
|
||||
default:
|
||||
return Res.error("当前订单状态无法取消");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/miniprogram/confirmOrder")
|
||||
@ResponseBody
|
||||
public Res confirmOrder(@RequestBody JSONObject params) {
|
||||
@ -261,4 +381,189 @@ public class OrderController {
|
||||
|
||||
return Res.success(success ? "确认收货成功" : "确认收货失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/manage/getOrderList")
|
||||
@ResponseBody
|
||||
public Res getOrderList(PageQuery pageQuery, OrderQuery orderQuery) {
|
||||
// 查询分页数据
|
||||
PageHelper.startPage(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
||||
List<Order> orderList = orderService.getOrderList(orderQuery);
|
||||
PageInfo<Order> orderPageInfo = new PageInfo<>(orderList);
|
||||
List<Order> list = orderPageInfo.getList();
|
||||
List<OrderVO> voList = OrderVO.convertFrom(list);
|
||||
|
||||
// id列 字段名(区分大小写;以VO中的变量名为准)
|
||||
// 新增、修改弹窗时,使用该列作为主键列进行操作
|
||||
String idFieldName = "id";
|
||||
|
||||
// 当前管理页面
|
||||
String pageName = "订单管理";
|
||||
|
||||
// 指定前端表格显示列
|
||||
JSONArray columns = FieldBuilder.create()
|
||||
.add("userId", "userId", "用户ID", "",
|
||||
FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("orderStatusCode", "orderStatusName", "订单状态", true,
|
||||
FieldType.TEXT, SearchType.SELECT, AddType.CAN_NOT_ADD, EditType.SELECT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, "订单状态",
|
||||
FieldRuleListBuilder.create()
|
||||
.add(FieldRuleBuilder.create("订单状态").required()),
|
||||
null
|
||||
)
|
||||
.add("orderPrice", "orderPrice", "订单价格", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("orderDate", "orderDate", "下单时间", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("payDate", "payDate", "支付时间", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("cancelDate", "cancelDate", "取消时间", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("shipDate", "shipDate", "发货时间", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("deliverDate", "deliverDate", "送达时间", "",
|
||||
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("expressId", "expressId", "运单号", "",
|
||||
FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("comment", "comment", "发货备注", "",
|
||||
FieldType.LONG_TEXT, SearchType.CAN_NOT_SEARCH, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.build();
|
||||
|
||||
// 指定需要翻译的字段
|
||||
OrderStatus[] orderStatusList = OrderStatus.values();
|
||||
HashMap<String, String> orderStatusMap = new HashMap<>(orderStatusList.length);
|
||||
for (OrderStatus orderStatus : orderStatusList) {
|
||||
orderStatusMap.put(orderStatus.getValue(), orderStatus.toString());
|
||||
}
|
||||
// build
|
||||
JSONArray fieldMapper = FieldMapperBuilder.create()
|
||||
.add("orderStatusCode", "orderStatusName", orderStatusMap)
|
||||
.build();
|
||||
|
||||
// 拼装返回结果
|
||||
JSONObject map = new JSONObject(6);
|
||||
map.put("total", orderPageInfo.getTotal());
|
||||
map.put("list", voList);
|
||||
map.put("columns", columns);
|
||||
map.put("fieldMapper", fieldMapper);
|
||||
map.put("idFieldName", idFieldName);
|
||||
map.put("pageName", pageName);
|
||||
|
||||
// 返回结果
|
||||
return Res.success(map);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 编辑订单
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping("/manage/editOrder")
|
||||
// @ResponseBody
|
||||
// public Res editOrder(@ModelAttribute OrderVO OrderVO) {
|
||||
// Order Order = OrderVO.convertTo(OrderVO);
|
||||
//
|
||||
// // 先查询订单是否存在
|
||||
// Order existOrder = orderService.getOrderById(Order.getId());
|
||||
//
|
||||
// if (Order.getId() == null || Order.getId() < 1) {
|
||||
// // 新增订单
|
||||
// if (existOrder != null) {
|
||||
// return Res.error("订单已存在,操作失败");
|
||||
// }
|
||||
//
|
||||
// if (Order.getOrdersName() == null || "".equals(Order.getOrdersName())) {
|
||||
// return Res.error("订单名称不能为空");
|
||||
// }
|
||||
// Order.setId(null);
|
||||
// orderService.addOrder(Order);
|
||||
// } else {
|
||||
// // 修改订单
|
||||
// if (existOrder == null) {
|
||||
// return Res.error("订单不存在,操作失败");
|
||||
// }
|
||||
//
|
||||
// orderService.updateOrder(Order);
|
||||
// }
|
||||
// return Res.success(true);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 关闭订单
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping("/manage/deleteOrder")
|
||||
// @ResponseBody
|
||||
// public Res deleteOrder(Long id) {
|
||||
// if (id == null || id <= 0) {
|
||||
// return Res.error("订单不存在,删除失败");
|
||||
// }
|
||||
// // 先查询订单是否存在
|
||||
// Order existOrder = orderService.getOrderById(id);
|
||||
// if (existOrder == null) {
|
||||
// return Res.error("订单不存在,删除失败");
|
||||
// }
|
||||
// boolean b = orderService.deleteOrder(existOrder.getId());
|
||||
// return Res.success(b);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导出订单列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/manage/exportOrderList")
|
||||
@ResponseBody
|
||||
public Res exportOrderList(OrderQuery orderQuery) {
|
||||
List<Order> orderList = orderService.getOrderList(orderQuery);
|
||||
List<OrderVO> orderVOList = OrderVO.convertFrom(orderList);
|
||||
|
||||
// 当前时间
|
||||
Date now = Calendar.getInstance().getTime();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
String dateTime = format.format(now);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("list", orderVOList);
|
||||
map.put("sheetName", "订单表-" + System.currentTimeMillis());
|
||||
map.put("fileName", "订单表_导出时间_" + dateTime);
|
||||
|
||||
return Res.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,13 +27,7 @@ public interface GoodDao {
|
||||
Integer deleteById(Integer id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Manage
|
||||
public boolean addGood(Good good);
|
||||
|
||||
public boolean updateGood(Good good);
|
||||
|
@ -2,6 +2,7 @@ package com.cxyxiaomo.epp.shop.dao;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.Order;
|
||||
import com.cxyxiaomo.epp.common.pojo.OrderDetail;
|
||||
import com.cxyxiaomo.epp.common.query.OrderQuery;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@ -62,6 +63,19 @@ public interface OrderDao {
|
||||
*/
|
||||
int updateOrderStatus(@Param("orderId") Long orderId, @Param("orderStatus") String orderStatus);
|
||||
|
||||
/**
|
||||
* 更新订单发货信息
|
||||
*
|
||||
* @param orderId
|
||||
* @param expressId
|
||||
* @param comment
|
||||
* @return
|
||||
*/
|
||||
int updateOrderShipInfo(@Param("orderId") Long orderId, @Param("expressId") String expressId, @Param("comment") String comment);
|
||||
|
||||
// 根据订单 ID 删除订单信息及订单详情信息
|
||||
int deleteOrderById(Long orderId);
|
||||
boolean deleteOrderById(Long orderId);
|
||||
|
||||
|
||||
public List<Order> getOrderList(OrderQuery orderQuery);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.cxyxiaomo.epp.common.enums.OrderStatus;
|
||||
import com.cxyxiaomo.epp.common.pojo.Good;
|
||||
import com.cxyxiaomo.epp.common.pojo.Order;
|
||||
import com.cxyxiaomo.epp.common.pojo.OrderDetail;
|
||||
import com.cxyxiaomo.epp.common.query.OrderQuery;
|
||||
import com.cxyxiaomo.epp.common.utils.SnowflakeManager;
|
||||
import com.cxyxiaomo.epp.common.vo.OrderDetailVO;
|
||||
import com.cxyxiaomo.epp.shop.dao.GoodDao;
|
||||
@ -132,4 +133,15 @@ public class OrderService {
|
||||
int affectRows = orderDao.updateOrderStatus(orderId, orderStatus.getValue());
|
||||
return affectRows > 0;
|
||||
}
|
||||
|
||||
public Boolean updateOrderShipInfo(Long orderId, String expressId, String comment) {
|
||||
int affectRows = orderDao.updateOrderShipInfo(orderId, expressId, comment);
|
||||
return affectRows > 0;
|
||||
}
|
||||
|
||||
|
||||
public List<Order> getOrderList(OrderQuery orderQuery) {
|
||||
return orderDao.getOrderList(orderQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,7 +95,7 @@
|
||||
</update>
|
||||
|
||||
<!-- 根据订单 ID 删除订单信息及订单详情信息 -->
|
||||
<delete id="deleteOrderById" parameterType="java.lang.Integer">
|
||||
<delete id="deleteOrderById" parameterType="java.lang.Long">
|
||||
DELETE
|
||||
FROM `order`
|
||||
WHERE id = #{orderId};
|
||||
@ -104,4 +104,39 @@
|
||||
-- FROM goods_order_details
|
||||
-- WHERE order_id = #{orderId};
|
||||
</delete>
|
||||
|
||||
|
||||
<!-- manage 相关的 SQL -->
|
||||
<select id="getOrderList" resultType="com.cxyxiaomo.epp.common.pojo.Order"
|
||||
parameterType="com.cxyxiaomo.epp.common.query.OrderQuery">
|
||||
SELECT * FROM `order`
|
||||
<where>
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="orderStatusCode != null and orderStatusCode != ''">
|
||||
AND order_status = #{orderStatusCode}
|
||||
</if>
|
||||
<if test="expressId != null and expressId != ''">
|
||||
AND express_id = #{expressId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 更新发货信息 -->
|
||||
<update id="updateOrderShipInfo" parameterType="com.cxyxiaomo.epp.common.pojo.Order">
|
||||
UPDATE `order`
|
||||
<set>
|
||||
<if test="expressId != null">
|
||||
express_id = #{expressId},
|
||||
</if>
|
||||
<if test="comment != null">
|
||||
`comment` = #{comment},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{orderId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
1
frontend/components.d.ts
vendored
1
frontend/components.d.ts
vendored
@ -35,6 +35,7 @@ declare module '@vue/runtime-core' {
|
||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||
Header: typeof import('./src/components/header.vue')['default']
|
||||
|
64
frontend/src/api/shop-order.js
Normal file
64
frontend/src/api/shop-order.js
Normal file
@ -0,0 +1,64 @@
|
||||
import send_request from '../utils/send_request';
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* @returns
|
||||
*/
|
||||
export function getOrderList(params) {
|
||||
return send_request({
|
||||
url: '/shop/order/manage/getOrderList',
|
||||
method: 'GET',
|
||||
params: params,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* @returns
|
||||
*/
|
||||
export function getOrderDetail(params) {
|
||||
return send_request({
|
||||
url: '/shop/order/miniprogram/orderDetail',
|
||||
method: 'GET',
|
||||
params: params,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
* @returns
|
||||
*/
|
||||
export function deliverOrder(params) {
|
||||
console.log("params", params)
|
||||
return send_request({
|
||||
url: '/shop/order/manage/deliverOrder',
|
||||
method: 'POST',
|
||||
useQS: true,
|
||||
params: params,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
* @returns
|
||||
*/
|
||||
export function cancelOrder(params) {
|
||||
return send_request({
|
||||
url: '/shop/order/manage/cancelOrder',
|
||||
method: 'POST',
|
||||
useQS: true,
|
||||
params: params,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出订单列表
|
||||
* @returns
|
||||
*/
|
||||
export function exportOrderList(params) {
|
||||
return send_request({
|
||||
url: '/shop/order/manage/exportOrderList',
|
||||
method: 'GET',
|
||||
params: params,
|
||||
});
|
||||
};
|
@ -56,16 +56,27 @@
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220" align="center" v-if="props.editFunc || props.deleteFunc">
|
||||
<el-table-column label="操作" width="220" align="center"
|
||||
v-if="props.editFunc || props.deleteFunc || props.customEditHandle">
|
||||
<template #default="scope">
|
||||
<el-button text :icon="Edit" @click="handleEdit(scope.$index, scope.row)"
|
||||
v-permiss="props.editPermiss" v-if="props.editFunc">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button text :icon="Delete" class="red" @click="handleDelete(scope.$index, scope.row)"
|
||||
v-permiss="props.editPermiss" v-if="props.deleteFunc">
|
||||
删除
|
||||
</el-button>
|
||||
<template v-if="props.customEditHandle">
|
||||
<el-button text :icon="List"
|
||||
@click="props.customEditHandle((scope as any).$index, (scope as any).row, getData)"
|
||||
v-permiss="props.editPermiss">
|
||||
管理
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button text :icon="Edit" @click="handleEdit((scope as any).$index, (scope as any).row)"
|
||||
v-permiss="props.editPermiss" v-if="props.editFunc">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button text :icon="Delete" class="red"
|
||||
@click="handleDelete((scope as any).$index, (scope as any).row)"
|
||||
v-permiss="props.editPermiss" v-if="props.deleteFunc">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -141,7 +152,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { FormInstance, FormRules, ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Delete, Edit, Search, Plus, Filter, Download } from '@element-plus/icons-vue';
|
||||
import { Delete, Edit, Search, Plus, Filter, Download, List } from '@element-plus/icons-vue';
|
||||
import * as xlsx from 'xlsx';
|
||||
import Mock from 'mockjs';
|
||||
import ImageUpload from './image-upload.vue';
|
||||
@ -176,6 +187,12 @@ const props = defineProps({
|
||||
'editPermiss': {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
|
||||
// 自定义修改按钮点击事件
|
||||
'customEditHandle': {
|
||||
type: Function,
|
||||
required: false,
|
||||
}
|
||||
})
|
||||
|
||||
@ -540,7 +557,7 @@ const handleExport = async () => {
|
||||
// 数据部分
|
||||
let excelList = dataList.map((row: any) => {
|
||||
// 通过翻译前的 key 拿数据
|
||||
return fieldNameList.map((field: any) => String(row[field]))
|
||||
return fieldNameList.map((field: any) => String(row[field] || ""))
|
||||
})
|
||||
excelList.unshift(firstRow) // 插入表头
|
||||
|
||||
|
@ -91,6 +91,11 @@ const items = [
|
||||
title: '商品管理',
|
||||
permiss: 'shop-good-setting',
|
||||
},
|
||||
{
|
||||
index: '/shop-order-setting',
|
||||
title: '订单管理',
|
||||
permiss: 'shop-order-setting',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -84,6 +84,15 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
component: () => import('../views/shop-good-setting.vue'),
|
||||
},
|
||||
{
|
||||
path: '/shop-order-setting',
|
||||
name: 'shop-order-setting',
|
||||
meta: {
|
||||
title: '订单管理',
|
||||
permiss: 'shop-order-setting',
|
||||
},
|
||||
component: () => import('../views/shop-order-setting.vue'),
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ export const usePermissStore = defineStore('permiss', {
|
||||
"shop",
|
||||
"shop-cate-setting",
|
||||
"shop-good-setting",
|
||||
"shop-order-setting",
|
||||
|
||||
"privilege",
|
||||
"privilege-user-setting",
|
||||
@ -46,6 +47,7 @@ export const usePermissStore = defineStore('permiss', {
|
||||
"shop",
|
||||
"shop-cate-setting",
|
||||
"shop-good-setting",
|
||||
"shop-order-setting",
|
||||
|
||||
"privilege",
|
||||
"privilege-user-setting",
|
||||
|
165
frontend/src/views/shop-order-setting.vue
Normal file
165
frontend/src/views/shop-order-setting.vue
Normal file
@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<manageList :list-func="shopOrderApi.getOrderList" :custom-edit-handle="editHandle"
|
||||
:export-func="shopOrderApi.exportOrderList" edit-permiss="shop-order-setting" />
|
||||
|
||||
<!-- 新增 / 编辑弹出框 -->
|
||||
<el-dialog title="管理订单" v-model="visible" style="width: 60%; min-width: 280px;">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单ID</span>
|
||||
{{ orderDetail.id || "" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单状态</span>
|
||||
<el-tag effect="plain" round>{{ orderDetail.orderStatus || "" }}</el-tag>
|
||||
{{ orderDetail.orderStatusCode || "" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">下单用户ID</span>
|
||||
{{ orderDetail.userId || "" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单价格</span>
|
||||
{{ orderDetail.orderPrice ? ('¥' + orderDetail.orderPrice) : "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">下单时间</span>
|
||||
{{ orderDetail.orderDate || "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单取消时间</span>
|
||||
{{ orderDetail.cancelDate || "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单支付时间</span>
|
||||
{{ orderDetail.payDate || "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单发货时间</span>
|
||||
{{ orderDetail.shipDate || "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">订单送达时间</span>
|
||||
{{ orderDetail.deliverDate || "-" }}
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">运单号</span>
|
||||
<template
|
||||
v-if="orderDetail.orderStatusCode != 'Processing' && orderDetail.orderStatusCode != 'Shipped'">
|
||||
{{ orderDetail.expressId || "-" }}
|
||||
</template>
|
||||
<el-input v-else v-model="shippingInfo.expressId" placeholder="Please input" />
|
||||
</p>
|
||||
<p class="line-height">
|
||||
<span class="row-index">发货备注</span>
|
||||
<template
|
||||
v-if="orderDetail.orderStatusCode != 'Processing' && orderDetail.orderStatusCode != 'Shipped'">
|
||||
{{ orderDetail.comment || "-" }}
|
||||
</template>
|
||||
<el-input v-else v-model="shippingInfo.comment" placeholder="Please input" />
|
||||
</p>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<p style="margin-bottom: 20px;">该订单中包含如下商品</p>
|
||||
<div style="max-height:50vh; overflow-y: scroll;">
|
||||
<el-card class="box-card" v-for="i in orderItem" :key="i.goodId"
|
||||
style="--el-card-padding: 10px; margin-bottom: 8px;">
|
||||
<div style="display: grid; grid-template-columns: 50px 1fr 60px; gap: 15px;">
|
||||
<img :src="i.good.picUrl" style="width: 60px; height: 60px;" />
|
||||
<div style="place-self: center left;">
|
||||
<p>{{ i.good.goodsName }}</p>
|
||||
<p style="color: grey; font-size: 12px;">商品ID: {{ i.goodId }}</p>
|
||||
</div>
|
||||
<div style="place-self: center; font-size: 16px;">{{ i.goodCount }} {{ i.good.unit }}</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 订单状态:PENDING("Pending", "等待确认"), -->
|
||||
<!-- 订单状态:PROCESSING("Processing", "已支付,等待发货中"), -->
|
||||
<!-- 订单状态:SHIPPED("Shipped", "已发货,等待确认收货"), -->
|
||||
<!-- 订单状态:DELIVERED("Delivered", "已送达"), -->
|
||||
<!-- 订单状态:CANCELLED("Cancelled", "已取消"); -->
|
||||
<!-- 该订单已被取消 -->
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button
|
||||
v-if="orderDetail.orderStatusCode == 'Processing' || orderDetail.orderStatusCode == 'Shipped'"
|
||||
type="primary" @click="saveEdit">保存发货信息</el-button>
|
||||
<el-button @click="visible = false">关 闭</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import manageList from '../components/manage-list.vue';
|
||||
import * as shopOrderApi from '../api/shop-order';
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { FormInstance, FormRules, ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Delete, Edit, Search, Plus, Filter, Download } from '@element-plus/icons-vue';
|
||||
|
||||
const visible: any = ref(false);
|
||||
|
||||
const orderDetail = ref({} as any);
|
||||
const orderItem = ref([] as any);
|
||||
|
||||
const shippingInfo = ref({} as any); // 发货信息
|
||||
|
||||
let completeCallback: Function = () => { };
|
||||
|
||||
const editHandle = async function (tabIndex: number, row: any, refreshFunc: Function) {
|
||||
console.log("tabIndex", tabIndex)
|
||||
console.log("orderDetail", row)
|
||||
orderDetail.value = row // 订单详情
|
||||
|
||||
shippingInfo.value.expressId = row.expressId
|
||||
shippingInfo.value.comment = row.comment
|
||||
|
||||
completeCallback = refreshFunc
|
||||
visible.value = true
|
||||
|
||||
shopOrderApi.getOrderDetail({
|
||||
orderId: row.id
|
||||
}).then(function (data) {
|
||||
let orderGoods = {}
|
||||
data.goods.forEach((good: any) => {
|
||||
orderGoods[good.id] = good
|
||||
});
|
||||
|
||||
orderItem.value = data.orderItem.map((item: any) => {
|
||||
item.good = orderGoods[item.goodId]
|
||||
return item
|
||||
})
|
||||
|
||||
console.log("orderItem", orderItem.value)
|
||||
})
|
||||
}
|
||||
|
||||
const saveEdit = function () {
|
||||
// 保存发货信息
|
||||
shopOrderApi.deliverOrder({
|
||||
orderId: orderDetail.value.id,
|
||||
...shippingInfo.value
|
||||
}).then(function (data) {
|
||||
ElMessage.success({ message: data })
|
||||
visible.value = false
|
||||
completeCallback()
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.line-height {
|
||||
line-height: 2.7em;
|
||||
}
|
||||
|
||||
.row-index {
|
||||
width: 110px;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
@ -4,6 +4,13 @@ server
|
||||
listen 80;
|
||||
listen 443 ssl http2;
|
||||
|
||||
# 并发限制 限制当前站点最大并发数
|
||||
limit_conn perserver 50;
|
||||
# 单IP限制 限制单个IP访问最大并发数
|
||||
limit_conn perip 10;
|
||||
# 流量限制 限制每个请求的流量上限(单位:KB)
|
||||
limit_rate 8192k;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5203;
|
||||
|
||||
|
@ -137,7 +137,7 @@ Page({
|
||||
filterList: filterList,
|
||||
filterActiveName: "全部",
|
||||
orderList: userOrder.orders.map(order => {
|
||||
order.displayDate = order.orderDate.replace("T", " ")
|
||||
order.displayDate = order.orderDate
|
||||
return order
|
||||
})
|
||||
})
|
||||
@ -153,7 +153,7 @@ Page({
|
||||
console.log("userOrder", userOrder)
|
||||
this.setData({
|
||||
orderList: userOrder.orders.map(order => {
|
||||
order.displayDate = order.orderDate.replace("T", " ")
|
||||
order.displayDate = order.orderDate
|
||||
return order
|
||||
})
|
||||
})
|
||||
|
@ -259,7 +259,7 @@ Page({
|
||||
this.setData({
|
||||
order: orderDetail.order,
|
||||
orderGoodList: orderGoodList,
|
||||
orderTime: orderDetail.order.orderDate.replace("T", " "),
|
||||
orderTime: orderDetail.order.orderDate,
|
||||
orderStatusCode: orderStatusCode,
|
||||
orderPrice: orderPrice,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user