订单信息处理修改
This commit is contained in:
@ -119,6 +119,12 @@ public class OrderDTO {
|
|||||||
@ApiModelProperty("租电套餐id")
|
@ApiModelProperty("租电套餐id")
|
||||||
private Long rentBatteyRuleId;
|
private Long rentBatteyRuleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单结束时间")
|
||||||
|
private LocalDateTime endOrderTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单总金额")
|
||||||
|
private BigDecimal orderAmount;
|
||||||
|
|
||||||
@ApiModelProperty("租电套餐信息")
|
@ApiModelProperty("租电套餐信息")
|
||||||
private RentBatteyRuleDTO rentBatteyRule;
|
private RentBatteyRuleDTO rentBatteyRule;
|
||||||
|
|
||||||
|
|||||||
@ -126,6 +126,12 @@ public class OrderMainPO implements Serializable {
|
|||||||
@ApiModelProperty("租电套餐id")
|
@ApiModelProperty("租电套餐id")
|
||||||
private Long rentBatteyRuleId;
|
private Long rentBatteyRuleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单结束时间")
|
||||||
|
private LocalDateTime endOrderTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单总金额")
|
||||||
|
private BigDecimal orderAmount;
|
||||||
|
|
||||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -62,6 +64,14 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
public RentCarOrderResultDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq) {
|
public RentCarOrderResultDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq) {
|
||||||
|
|
||||||
SimpleUserInfoDTO userInfoDTO = jwtUtil.getUserInfoFromToken();
|
SimpleUserInfoDTO userInfoDTO = jwtUtil.getUserInfoFromToken();
|
||||||
|
LambdaQueryWrapper<OrderMainPO> currentOrderWrapper = new LambdaQueryWrapper<>();
|
||||||
|
currentOrderWrapper.eq(OrderMainPO::getCustomerId, userInfoDTO.getUserId())
|
||||||
|
.notIn(OrderMainPO::getOrderStatus, Arrays.asList(OrderStatusEnum.AUTO_END.getCode(), OrderStatusEnum.MANUAL_END.getCode()))
|
||||||
|
.eq(OrderMainPO::getDelFlag, "0");
|
||||||
|
List<OrderMainPO> currentOrderList = orderMainRepo.list(currentOrderWrapper);
|
||||||
|
if(currentOrderList.size()>0){
|
||||||
|
throw new BizException("您有未完成的订单,请先完成订单");
|
||||||
|
}
|
||||||
|
|
||||||
//获取门店信息
|
//获取门店信息
|
||||||
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(rentCarOrderReq.getStoreId().toString()));
|
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(rentCarOrderReq.getStoreId().toString()));
|
||||||
@ -87,7 +97,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
//TODO 默认应该是待支付状态,这里先默认支付完成待取车
|
//TODO 默认应该是待支付状态,这里先默认支付完成待取车
|
||||||
// orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PAY.getCode());
|
// orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PAY.getCode());
|
||||||
orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PICK.getCode());
|
orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PICK.getCode());
|
||||||
orderMainRepo.save(orderMainPO);
|
|
||||||
|
|
||||||
//生成子表订单
|
//生成子表订单
|
||||||
String paymentType;
|
String paymentType;
|
||||||
@ -110,7 +120,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
if(!rentCarOrderReq.getIsDepositFree()){
|
if(!rentCarOrderReq.getIsDepositFree()){
|
||||||
OrderSubPO depositOrder = new OrderSubPO();
|
OrderSubPO depositOrder = new OrderSubPO();
|
||||||
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.YJ_PREFIX));
|
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.YJ_PREFIX));
|
||||||
depositOrder.setOrderId(orderMainPO.getOrderId());
|
|
||||||
depositOrder.setSuborderType(SubOrderTypeEnum.DEPOSIT.getCode());
|
depositOrder.setSuborderType(SubOrderTypeEnum.DEPOSIT.getCode());
|
||||||
depositOrder.setAmount(orderMainPO.getDepositPrice());
|
depositOrder.setAmount(orderMainPO.getDepositPrice());
|
||||||
depositOrder.setCreatedAt(LocalDateTime.now());
|
depositOrder.setCreatedAt(LocalDateTime.now());
|
||||||
@ -122,7 +131,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
rentBatteyRuleDTO = carInteg.getRentBatteyRuleByBatteyRuleId(rentCarOrderReq.getRentBatteyRuleId());
|
rentBatteyRuleDTO = carInteg.getRentBatteyRuleByBatteyRuleId(rentCarOrderReq.getRentBatteyRuleId());
|
||||||
OrderSubPO depositOrder = new OrderSubPO();
|
OrderSubPO depositOrder = new OrderSubPO();
|
||||||
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZD_PREFIX));
|
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZD_PREFIX));
|
||||||
depositOrder.setOrderId(orderMainPO.getOrderId());
|
|
||||||
depositOrder.setSuborderType(SubOrderTypeEnum.RENTBATTEY.getCode());
|
depositOrder.setSuborderType(SubOrderTypeEnum.RENTBATTEY.getCode());
|
||||||
depositOrder.setAmount(rentBatteyRuleDTO.getRentPrice());
|
depositOrder.setAmount(rentBatteyRuleDTO.getRentPrice());
|
||||||
depositOrder.setCreatedAt(LocalDateTime.now());
|
depositOrder.setCreatedAt(LocalDateTime.now());
|
||||||
@ -132,12 +140,19 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
//生成租车订单
|
//生成租车订单
|
||||||
OrderSubPO rentOrder = new OrderSubPO();
|
OrderSubPO rentOrder = new OrderSubPO();
|
||||||
rentOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZC_PREFIX));
|
rentOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZC_PREFIX));
|
||||||
rentOrder.setOrderId(orderMainPO.getOrderId());
|
|
||||||
rentOrder.setSuborderType(SubOrderTypeEnum.RENTCAR.getCode());
|
rentOrder.setSuborderType(SubOrderTypeEnum.RENTCAR.getCode());
|
||||||
rentOrder.setAmount(orderMainPO.getRentalPrice());
|
rentOrder.setAmount(orderMainPO.getRentalPrice());
|
||||||
rentOrder.setCreatedAt(LocalDateTime.now());
|
rentOrder.setCreatedAt(LocalDateTime.now());
|
||||||
rentOrder.setPaymentMethod(paymentType);
|
rentOrder.setPaymentMethod(paymentType);
|
||||||
orderSubPOList.add(rentOrder);
|
orderSubPOList.add(rentOrder);
|
||||||
|
|
||||||
|
BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
orderMainPO.setOrderAmount(orderAmount);
|
||||||
|
orderMainRepo.save(orderMainPO);
|
||||||
|
|
||||||
|
orderSubPOList.forEach(orderSubPO -> {
|
||||||
|
orderSubPO.setOrderId(orderMainPO.getOrderId());
|
||||||
|
});
|
||||||
orderSubRepo.saveBatch(orderSubPOList);
|
orderSubRepo.saveBatch(orderSubPOList);
|
||||||
// TODO 发起支付返回预支付信息
|
// TODO 发起支付返回预支付信息
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
SELECT
|
SELECT
|
||||||
store_id,
|
store_id,
|
||||||
COUNT(*) as total_orders,
|
COUNT(*) as total_orders,
|
||||||
SUM(CASE WHEN (status = 'AUTO_END' OR status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN 1 ELSE 0 END) as monthly_completed_orders,
|
SUM(CASE WHEN (order_status = 'AUTO_END' OR order_status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN 1 ELSE 0 END) as monthly_completed_orders,
|
||||||
SUM(CASE WHEN (status = 'AUTO_END' OR status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN order_amount ELSE 0 END) as monthly_order_amount,
|
SUM(CASE WHEN (order_status = 'AUTO_END' OR order_status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN order_amount ELSE 0 END) as monthly_order_amount,
|
||||||
COUNT(CASE WHEN status = 'WAIT_RETURN' THEN 1 END) as pending_pickup_count,
|
COUNT(CASE WHEN order_status = 'WAIT_RETURN' THEN 1 END) as pending_pickup_count,
|
||||||
COUNT(CASE WHEN status = 'WAIT_RETURN' THEN 1 END) as pending_return_count,
|
COUNT(CASE WHEN order_status = 'WAIT_RETURN' THEN 1 END) as pending_return_count,
|
||||||
COUNT(CASE WHEN status = 'RENT_OVERDUE' THEN 1 END) as overdue_count
|
COUNT(CASE WHEN order_status = 'RENT_OVERDUE' THEN 1 END) as overdue_count
|
||||||
FROM zc_order_main
|
FROM zc_order_main
|
||||||
WHERE store_id = #{storeId}
|
WHERE store_id = #{storeId}
|
||||||
GROUP BY store_id
|
GROUP BY store_id
|
||||||
|
|||||||
Reference in New Issue
Block a user