mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
feat(订单中台): 拆分用户删除与后台删除标记
eb_order_center 新增 is_system_del(后台删除,隐藏后台列表), is_del 语义收敛为用户删除(用户端隐藏)。后台列表与统计改按 is_system_del 过滤,用户删除的订单后台仍可见;后台删除以用户 已删为前提,写 is_system_del 并清统计缓存,不再动 is_del。 同步 crmeb_table.sql,新增 public/install/update.sql 增量脚本 (已安装环境升级执行,全新安装无需)。
This commit is contained in:
parent
76146a9483
commit
2a79dc7bb2
@ -20,6 +20,7 @@ use crmeb\trade\order\type\OrderCenterSyncInterface;
|
||||
use crmeb\trade\mode\TradeModeRegistry;
|
||||
use crmeb\trade\product\ProductTypeRegistry;
|
||||
use crmeb\utils\SnowflakeIdGenerator;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use app\dao\driver\pay\PayChannelDao;
|
||||
use app\dao\user\UserBillDao;
|
||||
use think\facade\Log;
|
||||
@ -2247,9 +2248,9 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
|
||||
{
|
||||
$searchWhere = [];
|
||||
|
||||
// 通用:是否删除筛选,默认不查已删除
|
||||
// 通用:是否后台删除筛选,默认不查已删除;用户删除(is_del)不影响后台可见性
|
||||
$isDeleted = $where['is_deleted'] ?? false;
|
||||
$searchWhere[] = ['is_del', '=', $isDeleted ? 1 : 0];
|
||||
$searchWhere[] = ['is_system_del', '=', $isDeleted ? 1 : 0];
|
||||
|
||||
// 订单大类筛选
|
||||
if (!empty($where['order_category'])) {
|
||||
@ -2303,7 +2304,7 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
|
||||
total_num, title, image, subtitle, shipping_type,
|
||||
extra_info,
|
||||
remark, detail_route,
|
||||
add_time, pay_time, delivery_time, take_time, refund_time, cancel_time, is_del';
|
||||
add_time, pay_time, delivery_time, take_time, refund_time, cancel_time, is_del, is_system_del';
|
||||
|
||||
// 售后状态筛选:需要先按其他条件筛选出候选订单号,再按售后状态过滤,保证分页准确
|
||||
$afterSaleOrderNos = [];
|
||||
@ -2506,7 +2507,7 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
|
||||
$ttl = empty($where['date_range']) ? 300 : 60;
|
||||
|
||||
return app()->cache->remember($cacheKey, function () use ($where) {
|
||||
$baseWhere = [['is_del', '=', 0]];
|
||||
$baseWhere = [['is_system_del', '=', 0]];
|
||||
// 按订单大类筛选
|
||||
if (!empty($where['order_category'])) {
|
||||
$baseWhere[] = ['order_category', '=', $where['order_category']];
|
||||
@ -2610,13 +2611,24 @@ class OrderCenterServices extends BaseService implements OrderCenterSyncInterfac
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除订单
|
||||
* 软删除订单(管理端)
|
||||
* 写 is_system_del 仅隐藏后台列表,不影响用户端;仅允许后台删除用户端已删除的订单
|
||||
* @param int $id 订单中台记录ID
|
||||
* @return bool 返回是否删除成功
|
||||
* @throws ApiException 订单不存在或用户未删除时抛出
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
return $this->dao->update(['id' => $id], ['is_del' => 1]) !== false;
|
||||
$orderInfo = $this->dao->get(['id' => $id]);
|
||||
if (!$orderInfo) {
|
||||
throw new ApiException('订单不存在');
|
||||
}
|
||||
if (!(int)($orderInfo['is_del'] ?? 0)) {
|
||||
throw new ApiException('订单未被用户删除,不能删除');
|
||||
}
|
||||
$res = $this->dao->update(['id' => $id], ['is_system_del' => 1]) !== false;
|
||||
app()->cache->delete('order_center:stat:*');
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -786,7 +786,8 @@ CREATE TABLE IF NOT EXISTS `eb_order_center` (
|
||||
`take_time` int NOT NULL DEFAULT '0' COMMENT '收货/完成时间',
|
||||
`refund_time` int NOT NULL DEFAULT '0' COMMENT '退款时间',
|
||||
`cancel_time` int NOT NULL DEFAULT '0' COMMENT '取消时间',
|
||||
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除(软删除)',
|
||||
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '用户删除标记(用户端隐藏)',
|
||||
`is_system_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '后台删除标记(后台列表隐藏)',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
||||
UNIQUE KEY `uk_source_order` (`source_type`,`source_id`),
|
||||
|
||||
13
backend/public/install/update.sql
Normal file
13
backend/public/install/update.sql
Normal file
@ -0,0 +1,13 @@
|
||||
-- ============================================================
|
||||
-- CRMEB 数据库增量更新脚本
|
||||
-- 用途:已安装环境升级到当前版本时执行;全新安装直接导入
|
||||
-- crmeb_table.sql,无需本文件。
|
||||
-- 注意:MySQL 8 不支持 ADD COLUMN IF NOT EXISTS,请勿重复执行。
|
||||
-- ============================================================
|
||||
|
||||
-- 2026-10-09 订单中台删除标记拆分:is_del=用户删除(用户端隐藏),
|
||||
-- is_system_del=后台删除(后台列表隐藏);后台列表与统计改按
|
||||
-- is_system_del 过滤,用户删除的订单后台仍可见,后台删除以用户已删为前提。
|
||||
ALTER TABLE `eb_order_center`
|
||||
ADD COLUMN `is_system_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '后台删除标记(后台列表隐藏)' AFTER `is_del`,
|
||||
MODIFY COLUMN `is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '用户删除标记(用户端隐藏)';
|
||||
Loading…
x
Reference in New Issue
Block a user