```
feat(shopro_wechat_trade): 微信同步页面优化及数据格式化功能 - 新增formatListItem方法对同步记录数据进行格式化处理, 包括同步类型、状态、发货模式和错误信息的中文映射 - 实现统计项点击筛选功能,添加高亮状态指示器 - 重构前端JavaScript代码,使用预格式化数据字段提升显示性能 - 添加详情弹窗功能,支持查看完整的同步请求响应内容 - 优化重试按钮交互,增加确认提示防止误操作 - 更新页面布局样式,改善用户界面体验 ```
这个提交包含在:
@@ -40,6 +40,49 @@ class Sync extends Backend
|
||||
return $stats;
|
||||
}
|
||||
|
||||
protected function formatListItem(array $row)
|
||||
{
|
||||
$typeMap = [
|
||||
'shipping' => '发货同步',
|
||||
'confirm' => '确认收货同步',
|
||||
];
|
||||
$row['sync_type_text'] = $typeMap[$row['sync_type'] ?? ''] ?? ($row['sync_type'] ?? '-');
|
||||
|
||||
$status = $row['status'] ?? '';
|
||||
$retryCount = intval($row['retry_count'] ?? 0);
|
||||
if ($status === 'success') {
|
||||
$row['status_text'] = '成功';
|
||||
} elseif ($status === 'failed') {
|
||||
$row['status_text'] = '失败';
|
||||
} elseif ($status === 'pending') {
|
||||
$row['status_text'] = $retryCount > 0 ? '待重试' : '处理中';
|
||||
} else {
|
||||
$row['status_text'] = $status ?: '-';
|
||||
}
|
||||
|
||||
if (($row['sync_type'] ?? '') !== 'shipping') {
|
||||
$row['delivery_mode_text'] = '-';
|
||||
} else {
|
||||
$modeMap = [1 => '统一发货', 2 => '分拆发货'];
|
||||
$row['delivery_mode_text'] = $modeMap[intval($row['delivery_mode'] ?? 0)] ?? ('模式' . $row['delivery_mode']);
|
||||
}
|
||||
|
||||
if ($status === 'success') {
|
||||
$row['error_text'] = '-';
|
||||
} else {
|
||||
$parts = [];
|
||||
if ($row['errcode'] !== null && $row['errcode'] !== '') {
|
||||
$parts[] = '[' . $row['errcode'] . ']';
|
||||
}
|
||||
if (!empty($row['errmsg'])) {
|
||||
$parts[] = $row['errmsg'];
|
||||
}
|
||||
$row['error_text'] = $parts ? implode(' ', $parts) : '-';
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
@@ -52,6 +95,9 @@ class Sync extends Backend
|
||||
$query = $this->buildQuery($status, $syncType, $orderSn)->order('id', 'desc');
|
||||
$total = (clone $query)->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
foreach ($list as $key => $row) {
|
||||
$list[$key] = $this->formatListItem($row);
|
||||
}
|
||||
|
||||
return json(['total' => $total, 'rows' => $list]);
|
||||
}
|
||||
@@ -67,7 +113,7 @@ class Sync extends Backend
|
||||
if (!$row) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
$this->success('', null, $row);
|
||||
$this->success('', null, $this->formatListItem($row));
|
||||
}
|
||||
|
||||
public function retry()
|
||||
|
||||
@@ -24,7 +24,11 @@
|
||||
font-size: 13px;
|
||||
background: #f5f7fa;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
user-select: none;
|
||||
}
|
||||
.wx-sync-page .stat-item:hover { opacity: 0.85; }
|
||||
.wx-sync-page .stat-item .num {
|
||||
font-weight: 600;
|
||||
margin-left: 4px;
|
||||
@@ -32,15 +36,19 @@
|
||||
.wx-sync-page .stat-success { background: #f0f9eb; color: #67c23a; }
|
||||
.wx-sync-page .stat-pending { background: #fdf6ec; color: #e6a23c; }
|
||||
.wx-sync-page .stat-failed { background: #fef0f0; color: #f56c6c; }
|
||||
.wx-sync-page .toolbar-row {
|
||||
.wx-sync-page .stat-item-active {
|
||||
border-color: currentColor;
|
||||
box-shadow: 0 0 0 1px currentColor inset;
|
||||
}
|
||||
.wx-sync-page .filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.wx-sync-page .toolbar-row .form-control { width: auto; min-width: 140px; }
|
||||
.wx-sync-page .toolbar-row .order-sn-input { min-width: 220px; }
|
||||
.wx-sync-page .filter-bar .form-control { width: auto; min-width: 140px; }
|
||||
.wx-sync-page .filter-bar .order-sn-input { min-width: 220px; }
|
||||
.wx-sync-detail pre {
|
||||
max-height: 280px;
|
||||
overflow: auto;
|
||||
@@ -70,34 +78,34 @@
|
||||
<div class="panel-body">
|
||||
<div class="page-tip">
|
||||
<strong>说明:</strong>本页展示商城向微信「发货信息管理服务」同步的记录,包括
|
||||
<strong>发货同步</strong>(upload_shipping_info)与<strong>确认收货同步</strong>(notify_confirm_receive)。
|
||||
<strong>发货同步</strong>与<strong>确认收货同步</strong>。
|
||||
「同步成功」仅表示微信接口返回成功,<strong>不代表</strong>商城订单状态;订单实际状态请到「订单管理」查看。
|
||||
失败记录会按配置自动重试,也可在此手动重试。
|
||||
</div>
|
||||
|
||||
<div class="stats-bar">
|
||||
<span class="stat-item">全部<span class="num">{$stats.total|default=0}</span></span>
|
||||
<span class="stat-item stat-success">成功<span class="num">{$stats.success|default=0}</span></span>
|
||||
<span class="stat-item stat-pending">待重试/处理中<span class="num">{$stats.pending|default=0}</span></span>
|
||||
<span class="stat-item stat-failed">失败<span class="num">{$stats.failed|default=0}</span></span>
|
||||
<span class="stat-item stat-all stat-item-active" data-status="">全部<span class="num">{$stats.total|default=0}</span></span>
|
||||
<span class="stat-item stat-success" data-status="success">成功<span class="num">{$stats.success|default=0}</span></span>
|
||||
<span class="stat-item stat-pending" data-status="pending">待重试/处理中<span class="num">{$stats.pending|default=0}</span></span>
|
||||
<span class="stat-item stat-failed" data-status="failed">失败<span class="num">{$stats.failed|default=0}</span></span>
|
||||
</div>
|
||||
|
||||
<div id="toolbar" class="toolbar toolbar-row">
|
||||
<select id="status-filter" class="form-control">
|
||||
<div id="wx-sync-filter-bar" class="filter-bar">
|
||||
<select id="wx-sync-status-filter" class="form-control">
|
||||
<option value="">全部状态</option>
|
||||
<option value="success">成功</option>
|
||||
<option value="pending">待重试/处理中</option>
|
||||
<option value="failed">失败</option>
|
||||
</select>
|
||||
<select id="type-filter" class="form-control">
|
||||
<select id="wx-sync-type-filter" class="form-control">
|
||||
<option value="">全部类型</option>
|
||||
<option value="shipping">发货同步</option>
|
||||
<option value="confirm">确认收货同步</option>
|
||||
</select>
|
||||
<input type="text" id="order-sn-filter" class="form-control order-sn-input" placeholder="搜索订单号">
|
||||
<button type="button" class="btn btn-primary btn-search"><i class="fa fa-search"></i> 搜索</button>
|
||||
<button type="button" class="btn btn-default btn-reset">重置</button>
|
||||
<button type="button" class="btn btn-warning btn-filter-failed">仅看失败</button>
|
||||
<input type="text" id="wx-sync-order-sn-filter" class="form-control order-sn-input" placeholder="搜索订单号">
|
||||
<button type="button" id="wx-sync-btn-search" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
|
||||
<button type="button" id="wx-sync-btn-reset" class="btn btn-default">重置</button>
|
||||
<button type="button" id="wx-sync-btn-failed" class="btn btn-warning">仅看失败</button>
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover" width="100%"></table>
|
||||
</div>
|
||||
|
||||
在新工单中引用
屏蔽一个用户