feat(merchant): 企业订单聚合列表与关联账号只读详情

- 新增 /merchant/orders,按主账号+关联账号聚合订单并支持状态筛选
- 新增企业订单页,展示订单归属账号(主账号/关联账号)
- 工作台企业订单入口改到聚合列表,近期订单可点击查看
- 订单详情允许同商家账号查看,非下单账号隐藏操作按钮
- 报价选择仅下单账号可操作,防止关联账号/主账号误操作
这个提交包含在:
linda
2026-10-28 19:27:51 +08:00
父节点 c6c2583dfc
当前提交 fbc6feee87
共有 7 个文件被更改,包括 213 次插入 和 7 次删除

查看文件

@@ -216,7 +216,20 @@ class Order extends Base
public function detail()
{
$orderId = (int)$this->request->param('id');
$order = $this->ownOrder($orderId, 'user');
if ($orderId <= 0) {
$this->error('订单参数错误');
}
$order = Db::name('order')->where('id', $orderId)->find();
if (!$order) {
$this->error('订单不存在');
}
// 本人订单,或同一商家(主账号 + 关联账号)的订单
if ((int)$order['user_id'] !== $this->uid()) {
$uids = $this->currentMerchantUserIds();
if (!in_array((int)$order['user_id'], $uids, true)) {
$this->error('无权操作该订单', null, 403);
}
}
$logs = Db::name('order_log')->where('order_id', $orderId)->order('id asc')->select();
foreach ($logs as &$log) {
@@ -531,9 +544,36 @@ class Order extends Base
'create_text' => date('Y-m-d H:i', (int)$row['createtime']),
'urgent' => (int)$row['urgent'],
'price_type_text' => $this->priceTypeText($row['price_type']),
'is_order_owner' => (int)$row['user_id'] === $this->uid(),
]);
}
/**
* 当前用户所属商家的全部账号(主账号 + 关联账号)
*/
protected function currentMerchantUserIds()
{
$merchant = Db::name('merchant')->where('user_id', $this->uid())->find();
if (!$merchant) {
$bind = Db::name('merchant_member')->where('user_id', $this->uid())->find();
if ($bind) {
$merchant = Db::name('merchant')->where('id', (int)$bind['merchant_id'])->find();
}
}
if (!$merchant) {
return [];
}
$ids = [(int)$merchant['user_id']];
$rows = Db::name('merchant_member')->where('merchant_id', (int)$merchant['id'])->column('user_id');
foreach ($rows as $id) {
$id = (int)$id;
if ($id > 0 && !in_array($id, $ids, true)) {
$ids[] = $id;
}
}
return $ids;
}
/**
* 计价方式文案(前后端与后台统一口径)
*/