feat(merchant): 企业订单聚合列表与关联账号只读详情
- 新增 /merchant/orders,按主账号+关联账号聚合订单并支持状态筛选 - 新增企业订单页,展示订单归属账号(主账号/关联账号) - 工作台企业订单入口改到聚合列表,近期订单可点击查看 - 订单详情允许同商家账号查看,非下单账号隐藏操作按钮 - 报价选择仅下单账号可操作,防止关联账号/主账号误操作
这个提交包含在:
@@ -171,6 +171,58 @@ class Merchant extends Base
|
||||
$this->success('', ['months' => $months, 'orders' => $orders]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业订单:主账号 + 关联账号的全部订单
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
$merchant = $this->requireMerchant();
|
||||
$uids = $this->merchantUserIds($merchant);
|
||||
$status = $this->request->param('status', 'all');
|
||||
$page = max(1, (int)$this->request->param('page', 1));
|
||||
$limit = min(50, max(1, (int)$this->request->param('limit', 20)));
|
||||
|
||||
$build = function () use ($uids, $status) {
|
||||
$q = Db::name('order')->where('user_id', 'in', $uids);
|
||||
if ($status === 'active') {
|
||||
$q->where('status', 'in', \app\common\library\OrderStatus::activeValues());
|
||||
} elseif ($status === 'completed') {
|
||||
$q->where('status', \app\common\library\OrderStatus::COMPLETED);
|
||||
} elseif ($status === 'cancelled') {
|
||||
$q->where('status', \app\common\library\OrderStatus::CANCELLED);
|
||||
} elseif ($status !== 'all' && $status !== '') {
|
||||
$q->where('status', (int)$status);
|
||||
}
|
||||
return $q;
|
||||
};
|
||||
|
||||
$total = $build()->count();
|
||||
$rows = $build()->order('id desc')->page($page, $limit)->select();
|
||||
$userMap = Db::name('user')->where('id', 'in', $uids)->column('id,nickname,mobile', 'id');
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$ownerUser = (int)$row['user_id'] === (int)$merchant['user_id'];
|
||||
$u = isset($userMap[(int)$row['user_id']]) ? $userMap[(int)$row['user_id']] : null;
|
||||
$mobile = $u ? (string)$u['mobile'] : '';
|
||||
$row['pay_amount'] = (float)$row['pay_amount'];
|
||||
$row['urgent'] = (int)$row['urgent'];
|
||||
$row['status_text'] = \app\common\library\OrderStatus::label((int)$row['status']);
|
||||
$row['appoint_text'] = $row['appoint_time'] ? date('m-d H:i', (int)$row['appoint_time']) : '尽快上门';
|
||||
$row['create_text'] = date('Y-m-d H:i', (int)$row['createtime']);
|
||||
$row['address_text'] = $row['province'] . $row['city'] . $row['district'] . $row['address'];
|
||||
$row['account_name'] = $u && $u['nickname'] ? $u['nickname'] : ('用户' . substr($mobile, -4));
|
||||
$row['account_role'] = $ownerUser ? 'owner' : 'member';
|
||||
$row['account_role_text'] = $ownerUser ? '主账号' : '关联账号';
|
||||
}
|
||||
unset($row);
|
||||
|
||||
$this->success('', [
|
||||
'list' => $rows,
|
||||
'total' => (int)$total,
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开票记录
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户