pull/1121/head
梁宇奇 2025-07-24 00:29:09 +08:00
parent 1aa40f8e58
commit 1c2bbe2727
11 changed files with 247 additions and 7 deletions

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.xkt;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -43,10 +45,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -179,6 +178,28 @@ public class StoreOrderController extends XktBaseController {
return success(PageVO.of(pageDTO, StoreOrderPageItemVO.class)); return success(PageVO.of(pageDTO, StoreOrderPageItemVO.class));
} }
@PreAuthorize("@ss.hasAnyRoles('store,seller')||@ss.hasSupplierSubRole()")
@ApiOperation(value = "订单物流信息")
@GetMapping(value = "/count/{srcPage}")
public R<StoreOrderCountVO> count(@PathVariable("srcPage") Long srcPage) {
StoreOrderCountQueryDTO queryDTO = new StoreOrderCountQueryDTO();
if (1 == srcPage) {
queryDTO.setOrderUserId(SecurityUtils.getUserId());
} else {
Long storeId = SecurityUtils.getStoreId();
if (storeId == null && !SecurityUtils.isAdmin()) {
//没有权限
return R.fail();
}
queryDTO.setStoreId(storeId);
}
//半年内
Date now = new Date();
queryDTO.setCreateTimeBegin(DateUtil.offset(now, DateField.MONTH, -6));
queryDTO.setCreateTimeEnd(now);
return success(BeanUtil.toBean(storeOrderService.count(queryDTO), StoreOrderCountVO.class));
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()") @PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
@Log(title = "订单", businessType = BusinessType.OTHER) @Log(title = "订单", businessType = BusinessType.OTHER)
@ApiOperation("发货-有单号(已打印快递单)") @ApiOperation("发货-有单号(已打印快递单)")
@ -229,7 +250,7 @@ public class StoreOrderController extends XktBaseController {
storeOrderService.checkOrderStore(vo.getStoreOrderDetailIds(), SecurityUtils.getStoreId()); storeOrderService.checkOrderStore(vo.getStoreOrderDetailIds(), SecurityUtils.getStoreId());
} }
ExpressShippingLabelDTO dto = storeOrderService.printOrder(vo.getStoreOrderId(), ExpressShippingLabelDTO dto = storeOrderService.printOrder(vo.getStoreOrderId(),
vo.getStoreOrderDetailIds(), vo.getExpressId(), SecurityUtils.getUserId()); vo.getStoreOrderDetailIds(), vo.getExpressId(), vo.getNeedShip(), SecurityUtils.getUserId());
return success(DesensitizationUtil.desensitize(BeanUtil.toBean(dto, ExpressShippingLabelVO.class))); return success(DesensitizationUtil.desensitize(BeanUtil.toBean(dto, ExpressShippingLabelVO.class)));
} }

View File

@ -0,0 +1,69 @@
package com.ruoyi.web.controller.xkt.vo.order;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author liangyq
* @date 2025-07-23
*/
@ApiModel
@Data
public class StoreOrderCountVO {
/**
*
*/
@ApiModelProperty(value = "全部订单")
private Integer all;
/**
* 退/
*/
@ApiModelProperty(value = "售后订单(退款/售后)")
private Integer afterSale;
/**
*
*/
@ApiModelProperty(value = "已取消")
private Integer cancelled;
/**
*
*/
@ApiModelProperty(value = "待付款")
private Integer pendingPayment;
/**
*
*/
@ApiModelProperty(value = "待发货")
private Integer pendingShipment;
/**
*
*/
@ApiModelProperty(value = "已发货")
private Integer shipped;
/**
*
*/
@ApiModelProperty(value = "已完成")
private Integer completed;
/**
*
*/
@ApiModelProperty(value = "售后中")
private Integer afterSaleInProgress;
/**
*
*/
@ApiModelProperty(value = "售后拒绝")
private Integer afterSaleRejected;
/**
*
*/
@ApiModelProperty(value = "平台介入")
private Integer platformIntervened;
/**
*
*/
@ApiModelProperty(value = "售后完成")
private Integer afterSaleCompleted;
}

View File

@ -27,4 +27,7 @@ public class StoreOrderPrintReqVO {
@NotNull(message = "物流ID不能为空") @NotNull(message = "物流ID不能为空")
@ApiModelProperty(value = "物流ID", required = true) @ApiModelProperty(value = "物流ID", required = true)
private Long expressId; private Long expressId;
@ApiModelProperty(value = "打印成功后立即发货", required = true)
private Boolean needShip;
} }

View File

@ -34,6 +34,9 @@ public class StoreOrderQueryVO extends BasePageVO {
*/ */
@ApiModelProperty(value = "订单号(模糊)") @ApiModelProperty(value = "订单号(模糊)")
private String orderNo; private String orderNo;
@ApiModelProperty(value = "售后订单原订单号")
private String originOrderNo;
/** /**
* [1: 2:退] * [1: 2:退]
*/ */

View File

@ -0,0 +1,55 @@
package com.ruoyi.xkt.dto.order;
import lombok.Data;
/**
* @author liangyq
* @date 2025-07-23
*/
@Data
public class StoreOrderCountDTO {
/**
*
*/
private Integer all;
/**
* 退/
*/
private Integer afterSale;
/**
*
*/
private Integer cancelled;
/**
*
*/
private Integer pendingPayment;
/**
*
*/
private Integer pendingShipment;
/**
*
*/
private Integer shipped;
/**
*
*/
private Integer completed;
/**
*
*/
private Integer afterSaleInProgress;
/**
*
*/
private Integer afterSaleRejected;
/**
*
*/
private Integer platformIntervened;
/**
*
*/
private Integer afterSaleCompleted;
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.xkt.dto.order;
import lombok.Data;
import java.util.Date;
/**
* @author liangyq
* @date 2025-07-23
*/
@Data
public class StoreOrderCountQueryDTO {
/**
* ID
*/
private Long storeId;
/**
* ID
*/
private Long orderUserId;
/**
*
*/
private Date createTimeBegin;
/**
*
*/
private Date createTimeEnd;
}

View File

@ -27,6 +27,10 @@ public class StoreOrderQueryDTO extends BasePageDTO {
* *
*/ */
private String orderNo; private String orderNo;
/**
*
*/
private String originOrderNo;
/** /**
* [1: 2:退] * [1: 2:退]
*/ */

View File

@ -2,6 +2,8 @@ package com.ruoyi.xkt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.xkt.domain.StoreOrder; import com.ruoyi.xkt.domain.StoreOrder;
import com.ruoyi.xkt.dto.order.StoreOrderCountDTO;
import com.ruoyi.xkt.dto.order.StoreOrderCountQueryDTO;
import com.ruoyi.xkt.dto.order.StoreOrderPageItemDTO; import com.ruoyi.xkt.dto.order.StoreOrderPageItemDTO;
import com.ruoyi.xkt.dto.order.StoreOrderQueryDTO; import com.ruoyi.xkt.dto.order.StoreOrderQueryDTO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -18,4 +20,6 @@ public interface StoreOrderMapper extends BaseMapper<StoreOrder> {
List<StoreOrderPageItemDTO> listStoreOrderPageItem(StoreOrderQueryDTO queryDTO); List<StoreOrderPageItemDTO> listStoreOrderPageItem(StoreOrderQueryDTO queryDTO);
List<StoreOrder> listNeedContinueRefundOrder(); List<StoreOrder> listNeedContinueRefundOrder();
StoreOrderCountDTO countOrder(StoreOrderCountQueryDTO queryDTO);
} }

View File

@ -94,6 +94,14 @@ public interface IStoreOrderService {
*/ */
Page<StoreOrderPageItemDTO> page(StoreOrderQueryDTO queryDTO); Page<StoreOrderPageItemDTO> page(StoreOrderQueryDTO queryDTO);
/**
*
*
* @param queryDTO
* @return
*/
StoreOrderCountDTO count(StoreOrderCountQueryDTO queryDTO);
/** /**
* *
* *
@ -150,11 +158,12 @@ public interface IStoreOrderService {
* @param storeOrderId * @param storeOrderId
* @param storeOrderDetailIds * @param storeOrderDetailIds
* @param expressId * @param expressId
* @param needShip
* @param operatorId * @param operatorId
* @return * @return
*/ */
ExpressShippingLabelDTO printOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId, ExpressShippingLabelDTO printOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
Long operatorId); Boolean needShip, Long operatorId);
/** /**
* *

View File

@ -20,6 +20,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.xkt.domain.*; import com.ruoyi.xkt.domain.*;
import com.ruoyi.xkt.dto.express.*; import com.ruoyi.xkt.dto.express.*;
@ -594,6 +595,11 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
return page; return page;
} }
@Override
public StoreOrderCountDTO count(StoreOrderCountQueryDTO queryDTO) {
return storeOrderMapper.countOrder(queryDTO);
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public StoreOrderExt preparePayOrder(Long storeOrderId, EPayChannel payChannel) { public StoreOrderExt preparePayOrder(Long storeOrderId, EPayChannel payChannel) {
@ -898,9 +904,10 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
return new StoreOrderExt(order, orderDetails); return new StoreOrderExt(order, orderDetails);
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
public ExpressShippingLabelDTO printOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId, public ExpressShippingLabelDTO printOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
Long operatorId) { Boolean needShip, Long operatorId) {
Assert.notEmpty(storeOrderDetailIds); Assert.notEmpty(storeOrderDetailIds);
ExpressManager expressManager = expressService.getExpressManager(expressId); ExpressManager expressManager = expressService.getExpressManager(expressId);
Express express = expressService.getById(expressId); Express express = expressService.getById(expressId);
@ -982,6 +989,10 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
//操作记录 //操作记录
addOperationRecords(order.getId(), EOrderAction.EXPRESS_SHIP, orderDetailIdList, EOrderAction.EXPRESS_SHIP, addOperationRecords(order.getId(), EOrderAction.EXPRESS_SHIP, orderDetailIdList, EOrderAction.EXPRESS_SHIP,
"打印快递单", operatorId, new Date()); "打印快递单", operatorId, new Date());
if (Boolean.TRUE.equals(needShip)) {
//立即发货
SpringUtils.getAopProxy(this).shipOrderByPlatform(storeOrderId, storeOrderDetailIds, operatorId);
}
return shippingLabelDTO; return shippingLabelDTO;
} }

View File

@ -24,6 +24,9 @@
<if test="orderNo != null and orderNo !=''"> <if test="orderNo != null and orderNo !=''">
AND so.order_no LIKE CONCAT('%', #{orderNo}, '%') AND so.order_no LIKE CONCAT('%', #{orderNo}, '%')
</if> </if>
<if test="originOrderNo != null and originOrderNo !=''">
AND EXISTS (SELECT 1 FROM store_order so1 WHERE so1.id = so.origin_order_id AND so1.order_no = #{originOrderNo} AND so1.del_flag = '0')
</if>
<if test="orderType != null"> <if test="orderType != null">
AND so.order_type = #{orderType} AND so.order_type = #{orderType}
</if> </if>
@ -70,4 +73,33 @@
AND sod.pay_status = 2 AND sod.pay_status = 2
) )
</select> </select>
<select id="countOrder" parameterType="com.ruoyi.xkt.dto.order.StoreOrderCountQueryDTO"
resultType="com.ruoyi.xkt.dto.order.StoreOrderCountDTO">
SELECT
SUM(1) AS `all`,
SUM(CASE WHEN `order_type` = 2 THEN 1 ELSE 0 END) AS `after_sale`,
SUM(CASE WHEN `order_status` = 10 THEN 1 ELSE 0 END) AS `cancelled`,
SUM(CASE WHEN `order_status` = 11 THEN 1 ELSE 0 END) AS `pending_payment`,
SUM(CASE WHEN `order_status` = 12 THEN 1 ELSE 0 END) AS `pending_shipment`,
SUM(CASE WHEN `order_status` = 13 THEN 1 ELSE 0 END) AS `shipped`,
SUM(CASE WHEN `order_status` = 14 THEN 1 ELSE 0 END) AS `completed`,
SUM(CASE WHEN `order_status` = 21 THEN 1 ELSE 0 END) AS `after_sale_in_progress`,
SUM(CASE WHEN `order_status` = 22 THEN 1 ELSE 0 END) AS `after_sale_rejected`,
SUM(CASE WHEN `order_status` = 23 THEN 1 ELSE 0 END) AS `platform_intervened`,
SUM(CASE WHEN `order_status` = 24 THEN 1 ELSE 0 END) AS `after_sale_completed`
FROM
store_order
<where>
del_flag = '0'
<if test="storeId != null">
AND store_id = #{storeId}
</if>
<if test="orderUserId != null">
AND order_user_id = #{orderUserId}
</if>
<if test="createTimeBegin != null and createTimeEnd != null">
AND create_time BETWEEN #{createTimeBegin}' AND #{createTimeEnd}
</if>
</where>
</select>
</mapper> </mapper>