更新了写真预约特殊产品处理
This commit is contained in:
parent
d30d4776ab
commit
8bd52067ae
|
@ -172,7 +172,7 @@ public class FileController {
|
|||
String fileSuffix = FileUtil.getSuffix(multipartFile.getOriginalFilename());
|
||||
final long LIMIT = 30 * 1024 * 1024L;
|
||||
if (fileSize > LIMIT) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件大小不能超过512K");
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件大小不能超过30MB");
|
||||
}
|
||||
if (!Arrays.asList("jpeg", "jpg", "svg", "png", "webp", "JPG").contains(fileSuffix)) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件类型错误");
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
package com.cultural.heritage.controller.global;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cultural.heritage.annotation.AuthCheck;
|
||||
import com.cultural.heritage.common.BaseResponse;
|
||||
import com.cultural.heritage.common.ResultUtils;
|
||||
import com.cultural.heritage.constant.OrderStatusConstant;
|
||||
import com.cultural.heritage.constant.UserConstant;
|
||||
import com.cultural.heritage.model.entity.AdvanceOrder;
|
||||
import com.cultural.heritage.model.entity.Good;
|
||||
import com.cultural.heritage.model.entity.Order;
|
||||
import com.cultural.heritage.service.book.AdvanceOrderService;
|
||||
import com.cultural.heritage.service.good.GoodService;
|
||||
import com.cultural.heritage.service.order.OrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/global")
|
||||
@Slf4j
|
||||
@Tag(name = "获取全局数据接口")
|
||||
public class GlobalController {
|
||||
|
||||
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
@Resource
|
||||
private AdvanceOrderService advanceOrderService;
|
||||
|
||||
|
||||
@Resource
|
||||
private GoodService goodService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Web端管理员查看全局数据
|
||||
* @return Map集合
|
||||
*/
|
||||
@PostMapping("/queryAll")
|
||||
@Operation(summary = "Web端管理员查看全局数据", description = "参数:无,权限:管理员(admin, boss),方法名:delAppointmentDateById")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Map<String, Object>> getDashboardData() {
|
||||
|
||||
List<String> orderStatusList = List.of(OrderStatusConstant.PENDING_SHIPMENT, OrderStatusConstant.PENDING_DELIVERY, OrderStatusConstant.TRANSACTION_SUCCESSFUL);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 获取今天的开始时间和结束时间
|
||||
Date startOfDay = DateUtil.beginOfDay(new Date()); // 今天的开始时间(00:00:00)
|
||||
Date endOfDay = DateUtil.endOfDay(new Date()); // 今天的结束时间(23:59:59)
|
||||
|
||||
QueryWrapper<Order> orderQueryWrapper = new QueryWrapper<>();
|
||||
orderQueryWrapper.between("updateTime", startOfDay, endOfDay)
|
||||
.and(wrapper -> wrapper.in("orderStatus", orderStatusList));
|
||||
|
||||
List<Order> orderList = orderService.list(orderQueryWrapper);
|
||||
|
||||
List<Order> productOrderList = orderList.stream().filter(order -> order.getOrderType().equals("product")).toList();
|
||||
BigDecimal productTotalAmount = new BigDecimal("0.00");
|
||||
for (Order order : productOrderList) {
|
||||
BigDecimal orderAmount = order.getTotalAmount();
|
||||
productTotalAmount = productTotalAmount.add(orderAmount);
|
||||
}
|
||||
map.put("今日实体类商品订单数", productOrderList.size());
|
||||
map.put("今日实体类商品订单营业额", productTotalAmount);
|
||||
|
||||
|
||||
List<Order> serviceOrderList = orderList.stream().filter(order -> order.getOrderType().equals("service")).toList();
|
||||
BigDecimal serviceTotalAmount = new BigDecimal("0.00");
|
||||
for (Order order : serviceOrderList) {
|
||||
BigDecimal orderAmount = order.getTotalAmount();
|
||||
serviceTotalAmount = serviceTotalAmount.add(orderAmount);
|
||||
}
|
||||
map.put("今日服务类商品订单数", serviceOrderList.size());
|
||||
map.put("今日实体类商品订单营业额", serviceTotalAmount);
|
||||
|
||||
|
||||
QueryWrapper<AdvanceOrder> advanceOrderQueryWrapper = new QueryWrapper<>();
|
||||
orderQueryWrapper.between("updateTime", startOfDay, endOfDay)
|
||||
.and(wrapper -> wrapper.eq("orderStatus", OrderStatusConstant.PENDING_SHIPMENT)
|
||||
.or().eq("orderStatus", OrderStatusConstant.TRANSACTION_SUCCESSFUL));
|
||||
|
||||
List<AdvanceOrder> advanceOrderList = advanceOrderService.list(advanceOrderQueryWrapper);
|
||||
BigDecimal advanceTotalAmount = new BigDecimal("0.00");
|
||||
for (AdvanceOrder advanceOrder : advanceOrderList) {
|
||||
BigDecimal orderAmount = advanceOrder.getTotalAmount();
|
||||
advanceTotalAmount = advanceTotalAmount.add(orderAmount);
|
||||
}
|
||||
map.put("今日写真预约订单数", advanceOrderList.size());
|
||||
map.put("今日写真预约类订单营业额", advanceTotalAmount);
|
||||
|
||||
// 获取所有待支付订单
|
||||
List<Order> pendingPaymentOrderList = orderList.stream().filter(order -> order.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT)).toList();
|
||||
// 获取待发货实体类订单
|
||||
List<Order> productPendingShipmentOrderList = orderList.stream().filter(order ->
|
||||
order.getOrderStatus().equals(OrderStatusConstant.PENDING_SHIPMENT)
|
||||
&& order.getOrderType().equals("product")).toList();
|
||||
// 获取待消费服务类订单
|
||||
List<Order> servicePendingShipmentOrderList = orderList.stream().filter(order ->
|
||||
order.getOrderStatus().equals(OrderStatusConstant.PENDING_SHIPMENT)
|
||||
&& order.getOrderType().equals("service")).toList();
|
||||
|
||||
map.put("所有待支付订单数量", pendingPaymentOrderList.size());
|
||||
map.put("实体类待发货订单", productPendingShipmentOrderList.size());
|
||||
map.put("服务类待消费订单", servicePendingShipmentOrderList.size());
|
||||
|
||||
// 获取待拍摄写真预约订单
|
||||
List<AdvanceOrder> pendingShipmentAdvanceOrderList = advanceOrderList.stream().filter(advanceOrder -> advanceOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_SHIPMENT)).toList();
|
||||
map.put("写真预约类待拍摄订单", pendingShipmentAdvanceOrderList.size());
|
||||
|
||||
List<Good> goodList = goodService.list();
|
||||
List<Good> isShelvesGoodList = goodList.stream().filter(good -> good.getIsShelves() == 1).toList();
|
||||
List<Good> isNoShelvesGoodList = goodList.stream().filter(good -> good.getIsShelves() == 0).toList();
|
||||
|
||||
map.put("全部商品数量", goodList.size());
|
||||
map.put("全部已上架商品数量", isShelvesGoodList.size());
|
||||
map.put("全部已下架商品数量", isNoShelvesGoodList.size());
|
||||
|
||||
return ResultUtils.success(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -53,7 +53,7 @@ spring:
|
|||
password: yuanteng
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 50MB
|
||||
max-file-size: 20MB
|
||||
|
||||
|
||||
springdoc:
|
||||
|
|
Loading…
Reference in New Issue
Block a user