订单财务状态,订单异议汇总完善

This commit is contained in:
朱昊天
2026-05-26 12:04:16 +08:00
parent 4408e80e1c
commit a44497f92c
23 changed files with 1543 additions and 86 deletions

View File

@@ -24,6 +24,7 @@ import com.gear.oa.domain.vo.GearReturnExchangeVo;
import com.gear.oa.domain.bo.GearReturnExchangeBo;
import com.gear.oa.service.IGearReturnExchangeService;
import com.gear.common.core.page.TableDataInfo;
import java.util.Map;
/**
* 退换货管理
@@ -47,6 +48,14 @@ public class GearReturnExchangeController extends BaseController {
return iGearReturnExchangeService.queryPageList(bo, pageQuery);
}
/**
* 汇总(总数/总金额/按状态/按类型)
*/
@GetMapping("/summary")
public R<Map<String, Object>> summary(GearReturnExchangeBo bo) {
return R.ok(iGearReturnExchangeService.summary(bo));
}
/**
* 导出退换货管理列表
*/

View File

@@ -46,6 +46,16 @@ public class GearJournal extends BaseEntity {
* 对方户名
*/
private String counterpart;
/**
* 客户ID用于按客户过滤收款记录
*/
@TableField("customer_id")
private Long customerId;
/**
* 销售员ID用于按销售员过滤收款记录
*/
@TableField("salesman_id")
private Long salesmanId;
/**
* 收入金额
*/

View File

@@ -36,6 +36,8 @@ public class GearStockIoOrder extends BaseEntity {
private String responsibleName;
private Date ioTime;
private Date planArrivalTime;
private Date actualArrivalTime;

View File

@@ -52,6 +52,16 @@ public class GearJournalBo extends BaseEntity {
*/
private String counterpart;
/**
* 客户ID用于按客户过滤收款记录
*/
private Long customerId;
/**
* 销售员ID用于按销售员过滤收款记录
*/
private Long salesmanId;
/**
* 收入金额
*/
@@ -72,5 +82,15 @@ public class GearJournalBo extends BaseEntity {
*/
private String remark;
/**
* 时间范围筛选(按 journalDate
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
}

View File

@@ -66,5 +66,16 @@ public class GearReturnExchangeBo extends BaseEntity {
//订单id
private Long orderId;
//时间范围筛选(按创建时间)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
* 汇总维度status,type逗号分隔为空则不返回分组汇总
*/
private String summaryDims;
}

View File

@@ -35,6 +35,8 @@ public class GearStockIoOrderBo extends BaseEntity {
private String responsibleName;
private Date ioTime;
private Date planArrivalTime;
private Date actualArrivalTime;

View File

@@ -32,8 +32,12 @@ public class GearStockIoOrderWithDetailBo {
private String responsibleName;
private Date ioTime;
private Date planArrivalTime;
private Date actualArrivalTime;
private Date planFinishTime;
private Long warehouseId;
@@ -48,4 +52,3 @@ public class GearStockIoOrderWithDetailBo {
private List<GearStockIoOrderDetailBo> details;
}

View File

@@ -58,6 +58,16 @@ public class GearJournalVo {
@ExcelProperty(value = "对方户名")
private String counterpart;
/**
* 客户ID用于按客户过滤收款记录
*/
private Long customerId;
/**
* 销售员ID用于按销售员过滤收款记录
*/
private Long salesmanId;
/**
* 收入金额
*/

View File

@@ -36,6 +36,9 @@ public class GearStockIoOrderVo extends BaseEntity {
private String responsibleName;
@ExcelProperty(value = "出入库时间")
private Date ioTime;
private Date planArrivalTime;
private Date actualArrivalTime;

View File

@@ -7,6 +7,9 @@ import com.gear.oa.domain.vo.GearReturnExchangeVo;
import com.gear.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 退换货管理Mapper接口
*
@@ -16,4 +19,10 @@ import org.apache.ibatis.annotations.Param;
public interface GearReturnExchangeMapper extends BaseMapperPlus<GearReturnExchangeMapper, GearReturnExchange, GearReturnExchangeVo> {
Page<GearReturnExchangeVo> selectVoPagePlus(Page<Object> build,@Param("ew") QueryWrapper<GearReturnExchange> lqw);
Map<String, Object> selectSummary(@Param("ew") QueryWrapper<GearReturnExchange> lqw);
List<Map<String, Object>> selectStatusStats(@Param("ew") QueryWrapper<GearReturnExchange> lqw);
List<Map<String, Object>> selectTypeStats(@Param("ew") QueryWrapper<GearReturnExchange> lqw);
}

View File

@@ -8,6 +8,7 @@ import com.gear.common.core.domain.PageQuery;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 退换货管理Service接口
@@ -46,4 +47,9 @@ public interface IGearReturnExchangeService {
* 校验并批量删除退换货管理信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 汇总(总数/总金额/按状态/按类型)
*/
Map<String, Object> summary(GearReturnExchangeBo bo);
}

View File

@@ -67,9 +67,12 @@ public class GearJournalServiceImpl implements IGearJournalService {
lqw.eq(StringUtils.isNotBlank(bo.getSummary()), GearJournal::getSummary, bo.getSummary());
lqw.eq(StringUtils.isNotBlank(bo.getTransType()), GearJournal::getTransType, bo.getTransType());
lqw.eq(StringUtils.isNotBlank(bo.getCounterpart()), GearJournal::getCounterpart, bo.getCounterpart());
lqw.eq(bo.getCustomerId() != null, GearJournal::getCustomerId, bo.getCustomerId());
lqw.eq(bo.getSalesmanId() != null, GearJournal::getSalesmanId, bo.getSalesmanId());
lqw.eq(bo.getIncomeAmount() != null, GearJournal::getIncomeAmount, bo.getIncomeAmount());
lqw.eq(bo.getExpenseAmount() != null, GearJournal::getExpenseAmount, bo.getExpenseAmount());
lqw.eq(bo.getBalanceAmount() != null, GearJournal::getBalanceAmount, bo.getBalanceAmount());
lqw.between(bo.getStartTime() != null && bo.getEndTime() != null, GearJournal::getJournalDate, bo.getStartTime(), bo.getEndTime());
//根据这个创建时间进行一个倒叙
lqw.orderByDesc(GearJournal::getCreateTime);
return lqw;

View File

@@ -198,6 +198,13 @@ public class GearReceivableServiceImpl implements IGearReceivableService {
journal.setSummary("客户付款");
journal.setTransType("收入");
journal.setCounterpart(customerMapper.selectById(receivable.getCustomerId()).getName());
journal.setCustomerId(receivable.getCustomerId());
if (receivable.getOrderId() != null) {
GearOrder order = orderMapper.selectById(receivable.getOrderId());
if (order != null) {
journal.setSalesmanId(order.getSalesmanId());
}
}
journal.setIncomeAmount(changePaidAmount);
journal.setExpenseAmount(BigDecimal.ZERO);
gearJournalService.computeBalance(journal);

View File

@@ -75,6 +75,10 @@ public class GearReturnExchangeServiceImpl implements IGearReturnExchangeService
queryWrapper.eq(StringUtils.isNotBlank(bo.getReason()), "gre.reason", bo.getReason());
queryWrapper.eq(StringUtils.isNotBlank(bo.getStatus()), "gre.status", bo.getStatus());
queryWrapper.eq(bo.getAmount() != null, "gre.amount", bo.getAmount());
queryWrapper.and(bo.getSalesmanId() != null,
w -> w.eq("o.salesman_id", bo.getSalesmanId()).or().eq("gre.salesman_id", bo.getSalesmanId()));
queryWrapper.between(bo.getStartTime() != null && bo.getEndTime() != null,
"gre.create_time", bo.getStartTime(), bo.getEndTime());
//逻辑删除
queryWrapper.eq("gre.del_flag", 0);
@@ -101,9 +105,30 @@ public class GearReturnExchangeServiceImpl implements IGearReturnExchangeService
lqw.eq(StringUtils.isNotBlank(bo.getReason()), GearReturnExchange::getReason, bo.getReason());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), GearReturnExchange::getStatus, bo.getStatus());
lqw.eq(bo.getAmount() != null, GearReturnExchange::getAmount, bo.getAmount());
lqw.eq(bo.getSalesmanId() != null, GearReturnExchange::getSalesmanId, bo.getSalesmanId());
lqw.between(bo.getStartTime() != null && bo.getEndTime() != null, GearReturnExchange::getCreateTime, bo.getStartTime(), bo.getEndTime());
return lqw;
}
@Override
public Map<String, Object> summary(GearReturnExchangeBo bo) {
QueryWrapper<GearReturnExchange> lqw = buildQueryWrapperPlus(bo);
Map<String, Object> summary = baseMapper.selectSummary(lqw);
String dims = bo.getSummaryDims() == null ? "" : bo.getSummaryDims().trim();
boolean needStatus = dims.contains("status");
boolean needType = dims.contains("type");
List<Map<String, Object>> statusStats = needStatus ? baseMapper.selectStatusStats(lqw) : java.util.Collections.emptyList();
List<Map<String, Object>> typeStats = needType ? baseMapper.selectTypeStats(lqw) : java.util.Collections.emptyList();
if (summary == null) {
summary = new java.util.HashMap<>();
summary.put("totalCount", 0);
summary.put("totalAmount", java.math.BigDecimal.ZERO);
}
summary.put("statusStats", statusStats);
summary.put("typeStats", typeStats);
return summary;
}
/**
* 新增退换货管理
*/

View File

@@ -143,6 +143,9 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
}
GearStockIoOrder order = BeanUtil.toBean(bo, GearStockIoOrder.class);
Date ioTime = bo.getIoTime() != null ? bo.getIoTime() : new Date();
ensureIoTimeNotAfterToday(ioTime);
order.setIoTime(ioTime);
if (StringUtils.isBlank(order.getOrderCode())) {
order.setOrderCode("SIOO_" + IdUtil.getSnowflakeNextIdStr());
}
@@ -197,6 +200,9 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
throw new ServiceException("单据明细不能为空");
}
if (bo.getIoTime() != null) {
ensureIoTimeNotAfterToday(bo.getIoTime());
}
GearStockIoOrder update = BeanUtil.toBean(bo, GearStockIoOrder.class);
update.setStatus(null);
update.setExecFlag(null);
@@ -268,6 +274,22 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
}
}
private void ensureIoTimeNotAfterToday(Date ioTime) {
if (ioTime == null) {
return;
}
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
Date endOfToday = cal.getTime();
if (ioTime.after(endOfToday)) {
throw new ServiceException("出入库时间不能晚于当天");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
@@ -326,7 +348,7 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
update.setConfirmInFlag("1");
update.setConfirmInBy(LoginHelper.getNickName());
update.setConfirmInTime(new Date());
update.setActualArrivalTime(new Date());
update.setActualArrivalTime(order.getActualArrivalTime() != null ? order.getActualArrivalTime() : new Date());
update.setExecFlag("1");
baseMapper.updateById(update);
}