订单管理完成

This commit is contained in:
hans 2025-08-31 16:13:34 +08:00
parent 21d1518aa1
commit 9eb8bdd41c
8 changed files with 226 additions and 14 deletions

View File

@ -1,6 +1,9 @@
package org.dromara.system.controller.system;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
@ -41,8 +44,12 @@ public class OrderController extends BaseController {
*/
@SaCheckPermission("system:order:list")
@GetMapping("/list")
public TableDataInfo<OrderVo> list(OrderBo bo, PageQuery pageQuery) {
return orderService.queryPageList(bo, pageQuery);
public R<Map<String,Object>> list(OrderBo bo, PageQuery pageQuery) {
Map<String,Object> map = new HashMap<>();
map.put("page",orderService.queryPageList(bo, pageQuery));
Map<String,Double> totalData=orderService.queryPageListTotelData(bo);
map.put("totalData",totalData);
return R.ok(map);
}
/**
@ -53,6 +60,25 @@ public class OrderController extends BaseController {
@PostMapping("/export")
public void export(OrderBo bo, HttpServletResponse response) {
List<OrderVo> list = orderService.queryList(bo);
OrderVo totalData = new OrderVo();
totalData.setSellingPrice(new BigDecimal(0));
totalData.setMailPrice(new BigDecimal(0));
totalData.setActualPrice(new BigDecimal(0));
totalData.setRevenueMoney(new BigDecimal(0));
totalData.setSettlementAmount(new BigDecimal(0));
totalData.setTotalPrice(new BigDecimal(0));
totalData.setRefundMoney(new BigDecimal(0));
for (OrderVo vo : list) {
totalData.setSellingPrice(totalData.getSellingPrice().add(vo.getSellingPrice()));
totalData.setMailPrice(totalData.getMailPrice().add(vo.getMailPrice()));
totalData.setActualPrice(totalData.getActualPrice().add(vo.getActualPrice()));
totalData.setRevenueMoney(totalData.getRevenueMoney().add(vo.getRevenueMoney()));
totalData.setSettlementAmount(totalData.getSettlementAmount().add(vo.getSettlementAmount()));
totalData.setTotalPrice(totalData.getTotalPrice().add(vo.getTotalPrice()));
totalData.setRefundMoney(totalData.getRefundMoney().add(vo.getRefundMoney()));
}
list.add(totalData);
ExcelUtil.exportExcel(list, "订单明细", OrderVo.class, response);
}
@ -92,7 +118,6 @@ public class OrderController extends BaseController {
/**
* 删除订单明细
*
* @param ids 主键串
*/
@SaCheckPermission("system:order:remove")

View File

@ -1,5 +1,6 @@
package org.dromara.system.domain;
import cn.idev.excel.annotation.ExcelProperty;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
@ -32,7 +33,10 @@ public class Order extends TenantEntity {
*/
@TableId(value = "id")
private Long id;
/**
* 订单编号
*/
private String orderNo;
/**
* 顾客姓名
*/
@ -63,6 +67,23 @@ public class Order extends TenantEntity {
*/
private BigDecimal sellingPrice;
/**
* 邮费实收
*/
private BigDecimal actualMailPrice;
/**
* 邮费收益
*/
private BigDecimal mailRevenueMoney;
/**
* 总收益
*/
private BigDecimal totalRevenueMoney;
/**
* 收益额
*/
private BigDecimal revenueMoney;
/**
* 邮费
*/
@ -77,7 +98,10 @@ public class Order extends TenantEntity {
* 订单总额
*/
private BigDecimal totalPrice;
/**
* 结账金额
*/
private BigDecimal settlementAmount;
/**
* 退款金额
*/
@ -123,6 +147,14 @@ public class Order extends TenantEntity {
* 备注
*/
private String remark;
/**
* 宝主名称
*/
private String baozhuName;
/**
* 宝主id
*/
private String baozhuId;
}

View File

@ -36,7 +36,10 @@ public class OrderBo extends BaseEntity {
*/
@NotBlank(message = "顾客姓名不能为空", groups = { AddGroup.class, EditGroup.class })
private String customerName;
/**
* 订单编号
*/
private String orderNo;
/**
* 顾客电话
*/
@ -57,7 +60,10 @@ public class OrderBo extends BaseEntity {
*/
@NotBlank(message = "产品图片不能为空", groups = { AddGroup.class, EditGroup.class })
private String productImage;
/**
* 结账金额
*/
private BigDecimal settlementAmount;
/**
* 销售价格
*/
@ -74,6 +80,19 @@ public class OrderBo extends BaseEntity {
*/
private BigDecimal actualPrice;
/**
* 邮费实收
*/
private BigDecimal actualMailPrice;
/**
* 邮费收益
*/
private BigDecimal mailRevenueMoney;
/**
* 总收益
*/
private BigDecimal totalRevenueMoney;
/**
* 订单总额
*/
@ -104,7 +123,10 @@ public class OrderBo extends BaseEntity {
* 发货时间
*/
private Date shipmentTime;
/**
* 收益额
*/
private BigDecimal revenueMoney;
/**
* 发货图片
*/
@ -114,6 +136,15 @@ public class OrderBo extends BaseEntity {
* 快递单号
*/
private String trackingNumber;
/**
* 宝主名称
*/
private String baozhuName;
/**
* 宝主id
*/
private String baozhuId;
/**
* 备注

View File

@ -1,5 +1,6 @@
package org.dromara.system.domain.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import org.dromara.common.translation.annotation.Translation;
import java.math.BigDecimal;
@ -37,9 +38,19 @@ public class OrderVo implements Serializable {
/**
*
*/
@ExcelIgnore
@ExcelProperty(value = "")
private Long id;
/**
* 订单编号
*/
@ExcelProperty(value = "订单编号")
private String orderNo;
/**
* 宝主名称
*/
@ExcelProperty(value = "宝主名称")
private String baozhuName;
/**
* 顾客姓名
*/
@ -55,6 +66,7 @@ public class OrderVo implements Serializable {
/**
* 顾客id
*/
@ExcelIgnore
@ExcelProperty(value = "顾客id")
private Long customerId;
@ -67,6 +79,7 @@ public class OrderVo implements Serializable {
/**
* 产品图片
*/
@ExcelIgnore
@ExcelProperty(value = "产品图片")
private String productImage;
@ -86,13 +99,36 @@ public class OrderVo implements Serializable {
*/
@ExcelProperty(value = "邮费")
private BigDecimal mailPrice;
/**
* 结账金额
*/
@ExcelProperty(value = "结账金额")
private BigDecimal settlementAmount;
/**
* 收益额
*/
@ExcelProperty(value = "收益额")
private BigDecimal revenueMoney;
/**
* 实收价格
*/
@ExcelProperty(value = "实收价格")
private BigDecimal actualPrice;
/**
* 邮费实收
*/
@ExcelProperty(value = "邮费实收")
private BigDecimal actualMailPrice;
/**
* 邮费收益
*/
@ExcelProperty(value = "邮费收益")
private BigDecimal mailRevenueMoney;
/**
* 总收益
*/
@ExcelProperty(value = "总收益")
private BigDecimal totalRevenueMoney;
/**
* 订单总额
*/
@ -108,7 +144,7 @@ public class OrderVo implements Serializable {
/**
* 订单状态0未收款1已收款2已发货3已签收4已完成,5已取消6申请退款7申请退货8退货已发货9退货已签收10退货成功
*/
@ExcelProperty(value = "订单状态", converter = ExcelDictConvert.class)
@ExcelProperty(value = "订单状态", converter = ExcelDictConvert.class )
@ExcelDictFormat(dictType = "order_status")
private String orderStatus;
@ -153,5 +189,9 @@ public class OrderVo implements Serializable {
@ExcelProperty(value = "备注")
private String remark;
/**
* 宝主id
*/
private String baozhuId;
}

View File

@ -1,9 +1,16 @@
package org.dromara.system.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.dromara.system.domain.Order;
import org.dromara.system.domain.SysRole;
import org.dromara.system.domain.bo.OrderBo;
import org.dromara.system.domain.vo.OrderVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.Map;
/**
* 订单明细Mapper接口
*
@ -11,5 +18,5 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
* @date 2025-08-30
*/
public interface OrderMapper extends BaseMapperPlus<Order, OrderVo> {
Map<String, Double> queryPageListTotelData(@Param(Constants.WRAPPER) Wrapper<Order> queryWrapper);
}

View File

@ -7,6 +7,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 订单明细Service接口
@ -23,6 +24,13 @@ public interface IOrderService {
* @return 订单明细
*/
OrderVo queryById(Long id);
/**
* 查询订单明细
*
* @param bo 主键
* @return 订单明细
*/
Map<String,Double> queryPageListTotelData(OrderBo bo);
/**
* 分页查询订单明细列表

View File

@ -1,5 +1,6 @@
package org.dromara.system.service.impl;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -9,6 +10,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.redis.utils.RedisUtils;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.dromara.system.domain.bo.OrderBo;
import org.dromara.system.domain.vo.OrderVo;
@ -16,6 +19,11 @@ import org.dromara.system.domain.Order;
import org.dromara.system.mapper.OrderMapper;
import org.dromara.system.service.IOrderService;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@ -44,6 +52,13 @@ public class OrderServiceImpl implements IOrderService {
return baseMapper.selectVoById(id);
}
@Override
public Map<String, Double> queryPageListTotelData(OrderBo bo) {
LambdaQueryWrapper<Order> lqw = buildQueryWrapper(bo);
lqw.eq( Order::getDelFlag, "0");
return baseMapper.queryPageListTotelData(lqw);
}
/**
* 分页查询订单明细列表
*
@ -75,6 +90,8 @@ public class OrderServiceImpl implements IOrderService {
LambdaQueryWrapper<Order> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(Order::getId);
lqw.like(StringUtils.isNotBlank(bo.getCustomerName()), Order::getCustomerName, bo.getCustomerName());
lqw.like(StringUtils.isNotBlank(bo.getBaozhuName()), Order::getBaozhuName, bo.getBaozhuName());
lqw.like(StringUtils.isNotBlank(bo.getOrderNo()), Order::getOrderNo, bo.getOrderNo());
lqw.eq(StringUtils.isNotBlank(bo.getCustomerPhone()), Order::getCustomerPhone, bo.getCustomerPhone());
lqw.eq(bo.getCustomerId() != null, Order::getCustomerId, bo.getCustomerId());
lqw.like(StringUtils.isNotBlank(bo.getProductName()), Order::getProductName, bo.getProductName());
@ -103,6 +120,16 @@ public class OrderServiceImpl implements IOrderService {
public Boolean insertByBo(OrderBo bo) {
Order add = MapstructUtils.convert(bo, Order.class);
validEntityBeforeSave(add);
if (add != null) {
add.setActualPrice(add.getSellingPrice().add(add.getActualMailPrice()));
add.setOrderNo(getOrderNo());
add.setSettlementAmount(add.getSellingPrice().multiply(new BigDecimal("0.9")));
add.setRevenueMoney(add.getSellingPrice().subtract(add.getSettlementAmount()));
add.setTotalPrice(add.getSellingPrice().add(add.getActualMailPrice()));
add.setMailRevenueMoney(add.getActualMailPrice().subtract(add.getMailPrice()));
add.setTotalRevenueMoney(add.getRevenueMoney().add(add.getMailRevenueMoney()));
add.setRefundMoney(new BigDecimal("0.00"));
}
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
@ -120,6 +147,14 @@ public class OrderServiceImpl implements IOrderService {
public Boolean updateByBo(OrderBo bo) {
Order update = MapstructUtils.convert(bo, Order.class);
validEntityBeforeSave(update);
if (update != null) {
update.setActualPrice(update.getSellingPrice().add(update.getActualMailPrice()));
update.setSettlementAmount(update.getSellingPrice().multiply(new BigDecimal("0.9")));
update.setRevenueMoney(update.getSellingPrice().subtract(update.getSettlementAmount()));
update.setTotalPrice(update.getSellingPrice().add(update.getActualMailPrice()));
update.setMailRevenueMoney(update.getActualMailPrice().subtract(update.getMailPrice()));
update.setTotalRevenueMoney(update.getRevenueMoney().add(update.getMailRevenueMoney()));
}
return baseMapper.updateById(update) > 0;
}
@ -144,4 +179,24 @@ public class OrderServiceImpl implements IOrderService {
}
return baseMapper.deleteByIds(ids) > 0;
}
public String getOrderNo() {
long orderNoDes=0;
if(!RedisUtils.hasKey("orderNo")){
RedisUtils.setAtomicValue("orderNo",0);
orderNoDes= RedisUtils.incrAtomicValue("orderNo");
// 获取当前日期和时间
LocalDateTime now = LocalDateTime.now();
// 获取当天的结束时间23:59:59
LocalDateTime endOfDay = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
// 计算剩余时间
Duration remainingDuration = Duration.between(now, endOfDay);
long remainingMillis = remainingDuration.toMillis();
RedisUtils.expire("orderNo",Duration.ofMillis(remainingMillis));
}else{
orderNoDes=RedisUtils.incrAtomicValue("orderNo");
}
return "DJ"+DateUtils.getCurrentDate()+String.format("%04d",orderNoDes);
}
}

View File

@ -3,5 +3,19 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.OrderMapper">
<select id="queryPageListTotelData" resultType="java.util.Map">
SELECT
sum(revenue_money) as totalShouYi,
sum(actual_price) as totalShiShou,
sum(actual_mail_price) as totalYouFeiShiShou,
sum(mail_revenue_money) as totalYouFeiShouYi,
sum(selling_price) as totalXiaoShou,
sum(total_price) as totalLiuShui,
sum(mail_price) as totalYouFei,
sum(settlement_amount+mail_price) as totalFuKuan,
sum(total_revenue_money) as totalRevenueMoney,
sum(settlement_amount) as totalYingFu
FROM `b_order`
${ew.getCustomSqlSegment}
</select>
</mapper>