|
@@ -12,6 +12,7 @@ package com.yami.shop.platform.controller;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.yami.shop.bean.enums.DvyType;
|
|
import com.yami.shop.bean.enums.DvyType;
|
|
@@ -21,12 +22,20 @@ import com.yami.shop.bean.model.OrderItem;
|
|
|
import com.yami.shop.bean.model.User;
|
|
import com.yami.shop.bean.model.User;
|
|
|
import com.yami.shop.bean.model.UserAddrOrder;
|
|
import com.yami.shop.bean.model.UserAddrOrder;
|
|
|
import com.yami.shop.bean.param.*;
|
|
import com.yami.shop.bean.param.*;
|
|
|
|
|
+import com.yami.shop.bean.model.*;
|
|
|
|
|
+import com.yami.shop.bean.param.BackendOrderParam;
|
|
|
|
|
+import com.yami.shop.bean.param.DeliveryOrderParam;
|
|
|
|
|
+import com.yami.shop.bean.param.OrderParam;
|
|
|
|
|
+import com.yami.shop.bean.param.OrderPayParam;
|
|
|
import com.yami.shop.common.exception.GlobalException;
|
|
import com.yami.shop.common.exception.GlobalException;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
import com.yami.shop.common.util.R;
|
|
import com.yami.shop.common.util.R;
|
|
|
import com.yami.shop.coupon.comment.model.Coupon;
|
|
import com.yami.shop.coupon.comment.model.Coupon;
|
|
|
|
|
+import com.yami.shop.security.comment.dao.AppConnectMapper;
|
|
|
|
|
+import com.yami.shop.security.comment.model.AppConnect;
|
|
|
import com.yami.shop.service.*;
|
|
import com.yami.shop.service.*;
|
|
|
import com.yami.shop.utils.CullenUtils;
|
|
import com.yami.shop.utils.CullenUtils;
|
|
|
|
|
+import com.yami.shop.wx.service.impl.WxProviderServiceImpl;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
@@ -39,6 +48,7 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 订单信息管理实现
|
|
* 订单信息管理实现
|
|
@@ -59,6 +69,8 @@ public class OrderController {
|
|
|
private final SkuService skuService;
|
|
private final SkuService skuService;
|
|
|
private final UserService userService;
|
|
private final UserService userService;
|
|
|
private final DeliveryService deliveryService;
|
|
private final DeliveryService deliveryService;
|
|
|
|
|
+ private final OrderSettlementService orderSettlementService;
|
|
|
|
|
+ private final AppConnectMapper appConnectMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -80,7 +92,7 @@ public class OrderController {
|
|
|
|
|
|
|
|
@GetMapping("/deliverListStatusNum")
|
|
@GetMapping("/deliverListStatusNum")
|
|
|
@ApiOperation("后管端-快递订单列表-订单状态数量")
|
|
@ApiOperation("后管端-快递订单列表-订单状态数量")
|
|
|
- public R<Map<String,Integer>> deliverListStatusNum() {
|
|
|
|
|
|
|
+ public R<Map<String, Integer>> deliverListStatusNum() {
|
|
|
return R.SUCCESS(orderService.deliverListStatusNum());
|
|
return R.SUCCESS(orderService.deliverListStatusNum());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -89,9 +101,9 @@ public class OrderController {
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/orderPayByShopId")
|
|
@GetMapping("/orderPayByShopId")
|
|
|
@ApiOperation(value = "根据商家id获取支付信息")
|
|
@ApiOperation(value = "根据商家id获取支付信息")
|
|
|
- public R<OrderPayParam> orderPayByShopId(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam("startTime") Date startTime,
|
|
|
|
|
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam("endTime") Date endTime) {
|
|
|
|
|
- OrderPayParam actualTotal = orderService.getPayUserCountByshopId(null,startTime,endTime);
|
|
|
|
|
|
|
+ public R<OrderPayParam> orderPayByShopId(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam("startTime") Date startTime,
|
|
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam("endTime") Date endTime) {
|
|
|
|
|
+ OrderPayParam actualTotal = orderService.getPayUserCountByshopId(null, startTime, endTime);
|
|
|
return R.SUCCESS(actualTotal);
|
|
return R.SUCCESS(actualTotal);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -108,15 +120,15 @@ public class OrderController {
|
|
|
UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId());
|
|
UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId());
|
|
|
order.setUserAddrOrder(userAddrOrder);
|
|
order.setUserAddrOrder(userAddrOrder);
|
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber);
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber);
|
|
|
- if (!orderItems.isEmpty()){
|
|
|
|
|
- orderItems.forEach(c->{
|
|
|
|
|
|
|
+ if (!orderItems.isEmpty()) {
|
|
|
|
|
+ orderItems.forEach(c -> {
|
|
|
c.setRefundIngCount(orderItemService.refundIngCount(c.getOrderItemId()));
|
|
c.setRefundIngCount(orderItemService.refundIngCount(c.getOrderItemId()));
|
|
|
c.setRefundSuccessCount(orderItemService.refundSuccessCount(c.getOrderItemId()));
|
|
c.setRefundSuccessCount(orderItemService.refundSuccessCount(c.getOrderItemId()));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
order.setOrderItems(orderItems);
|
|
order.setOrderItems(orderItems);
|
|
|
User user = userService.getById(order.getUserId());
|
|
User user = userService.getById(order.getUserId());
|
|
|
- if (user!=null) {
|
|
|
|
|
|
|
+ if (user != null) {
|
|
|
order.setNickName(user.getNickName());
|
|
order.setNickName(user.getNickName());
|
|
|
order.setUserMobile(user.getUserMobile());
|
|
order.setUserMobile(user.getUserMobile());
|
|
|
}
|
|
}
|
|
@@ -133,7 +145,7 @@ public class OrderController {
|
|
|
@PreAuthorize("@pms.hasPermission('platform:order:exportExcel')")
|
|
@PreAuthorize("@pms.hasPermission('platform:order:exportExcel')")
|
|
|
public void soldExcel(OrderParam orderParam, HttpServletResponse response) {
|
|
public void soldExcel(OrderParam orderParam, HttpServletResponse response) {
|
|
|
// orderParam.setIsPayed(1);
|
|
// orderParam.setIsPayed(1);
|
|
|
- orderService.soldExcel(orderParam,response);
|
|
|
|
|
|
|
+ orderService.soldExcel(orderParam, response);
|
|
|
//
|
|
//
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -142,21 +154,20 @@ public class OrderController {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R<Void> delivery(@RequestBody DeliveryOrderParam deliveryOrderParam) {
|
|
public R<Void> delivery(@RequestBody DeliveryOrderParam deliveryOrderParam) {
|
|
|
Order order = orderService.getOne(new LambdaUpdateWrapper<Order>().eq(Order::getOrderNumber, deliveryOrderParam.getOrderNumber()));
|
|
Order order = orderService.getOne(new LambdaUpdateWrapper<Order>().eq(Order::getOrderNumber, deliveryOrderParam.getOrderNumber()));
|
|
|
- if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.PADYED.value()) && Objects.equals(order.getDvyType(), DvyType.FETCH.value())){
|
|
|
|
|
|
|
+ if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.PADYED.value()) && Objects.equals(order.getDvyType(), DvyType.FETCH.value())) {
|
|
|
throw new GlobalException("订单不处于待入库状态,无法进行入库");
|
|
throw new GlobalException("订单不处于待入库状态,无法进行入库");
|
|
|
- }else if (!Objects.equals(order.getHbOrderStatus(), 1)){
|
|
|
|
|
|
|
+ } else if (!Objects.equals(order.getHbOrderStatus(), 1)) {
|
|
|
throw new GlobalException("订单不处于待发货状态,无法进行发货");
|
|
throw new GlobalException("订单不处于待发货状态,无法进行发货");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
|
|
|
if (!orderItems.isEmpty()) {
|
|
if (!orderItems.isEmpty()) {
|
|
|
- orderItems.forEach(orderItem->
|
|
|
|
|
- CullenUtils.validateDataThrowException(orderItemService.refundIngCount(orderItem.getOrderItemId())!=0,"该订单存在售后中商品,请处理后发货..."));
|
|
|
|
|
|
|
+ orderItems.forEach(orderItem ->
|
|
|
|
|
+ CullenUtils.validateDataThrowException(orderItemService.refundIngCount(orderItem.getOrderItemId()) != 0, "该订单存在售后中商品,请处理后发货..."));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //Delivery delivery = deliveryService.getById(deliveryOrderParam.getDvyId());
|
|
|
|
|
Order orderParam = new Order();
|
|
Order orderParam = new Order();
|
|
|
- if (deliveryOrderParam.getDvyType().equals(2)){
|
|
|
|
|
|
|
+ if (deliveryOrderParam.getDvyType().equals(2)) {
|
|
|
orderParam.setOrderId(order.getOrderId());
|
|
orderParam.setOrderId(order.getOrderId());
|
|
|
orderParam.setDvyType(2);
|
|
orderParam.setDvyType(2);
|
|
|
orderService.updateById(orderParam);
|
|
orderService.updateById(orderParam);
|
|
@@ -164,7 +175,7 @@ public class OrderController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
orderParam.setOrderId(order.getOrderId());
|
|
orderParam.setOrderId(order.getOrderId());
|
|
|
- if (!Objects.equals(order.getDvyType(), DvyType.FETCH.value()) || !Objects.equals(order.getDvyType(), DvyType.NOT_DELIVERY.value())){
|
|
|
|
|
|
|
+ if (!Objects.equals(order.getDvyType(), DvyType.FETCH.value()) || !Objects.equals(order.getDvyType(), DvyType.NOT_DELIVERY.value())) {
|
|
|
orderParam.setDvyId(deliveryOrderParam.getDvyId());
|
|
orderParam.setDvyId(deliveryOrderParam.getDvyId());
|
|
|
orderParam.setDvyFlowId(deliveryOrderParam.getDvyFlowId());
|
|
orderParam.setDvyFlowId(deliveryOrderParam.getDvyFlowId());
|
|
|
}
|
|
}
|
|
@@ -177,8 +188,21 @@ public class OrderController {
|
|
|
|
|
|
|
|
for (OrderItem orderItem : orderItems) {
|
|
for (OrderItem orderItem : orderItems) {
|
|
|
productService.removeProductCacheByProdId(orderItem.getProdId());
|
|
productService.removeProductCacheByProdId(orderItem.getProdId());
|
|
|
- skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId());
|
|
|
|
|
|
|
+ skuService.removeSkuCacheBySkuId(orderItem.getSkuId(), orderItem.getProdId());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ OrderSettlement settlement = orderSettlementService.getOne(new LambdaQueryWrapper<OrderSettlement>().eq(OrderSettlement::getOrderNumber, deliveryOrderParam.getOrderNumber()));
|
|
|
|
|
+ UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId());
|
|
|
|
|
+ AppConnect connect = appConnectMapper.getByUserId(order.getUserId(), 1);
|
|
|
|
|
+ Delivery delivery = deliveryService.getById(deliveryOrderParam.getDvyId());
|
|
|
|
|
+ WxProviderServiceImpl.uploadShippingInfo(
|
|
|
|
|
+ deliveryOrderParam.getDvyFlowId(),
|
|
|
|
|
+ settlement.getBizPayNo(),
|
|
|
|
|
+ toOrderStr(orderItems),
|
|
|
|
|
+ userAddrOrder.getMobile(),
|
|
|
|
|
+ connect.getBizUserId(),
|
|
|
|
|
+ delivery.getDvyNo(), 1
|
|
|
|
|
+ );
|
|
|
return R.SUCCESS();
|
|
return R.SUCCESS();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -202,4 +226,13 @@ public class OrderController {
|
|
|
return R.SUCCESS(orderCount);
|
|
return R.SUCCESS(orderCount);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static String toOrderStr(List<OrderItem> items) {
|
|
|
|
|
+ if (items == null || items.isEmpty()) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ return items.stream()
|
|
|
|
|
+ .map(item -> item.getProdName() + "*" + item.getProdCount())
|
|
|
|
|
+ .collect(Collectors.joining(" "));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|