Commit 7cb64f71 authored by 刘小敏's avatar 刘小敏

fix(agent): 优化代理商详情查看与状态校验

parent 26035c5a
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace addons\shopro\controller\user; namespace addons\shopro\controller\user;
use addons\shopro\controller\Common; use addons\shopro\controller\Common;
use app\admin\model\shopro\commission\Agent as AgentModel; use app\admin\model\shopro\agent\Agent as AgentModel;
class Agent extends Common class Agent extends Common
{ {
...@@ -63,13 +63,21 @@ class Agent extends Common ...@@ -63,13 +63,21 @@ class Agent extends Common
$user = auth_user(); $user = auth_user();
$userId = $user->id ?? 0; $userId = $user->id ?? 0;
$agent = \app\admin\model\shopro\agent\Agent::where('user_id', $userId) $agentModel = new AgentModel();
->where('status', \app\admin\model\shopro\agent\Agent::STATUS_NORMAL) $agent = $agentModel
->where('user_id', $userId)
->field('id,user_id,province_name,real_name,id_card,id_card_images,commission_rate,total_commission,status,apply_id,createtime') ->field('id,user_id,province_name,real_name,id_card,id_card_images,commission_rate,total_commission,status,apply_id,createtime')
->find(); ->find();
if (!$agent) { if (!$agent) {
$this->error('数据不存在'); $this->error('您还不是代理商');
}
// 冻结或禁用状态不允许查看详情
$allowStatus = [AgentModel::STATUS_NORMAL];
if (!in_array($agent->status, $allowStatus)) {
$statusText = $agentModel->statusList()[$agent->status] ?? $agent->status;
$this->error("代理商状态{$statusText},不可查看详情");
} }
$this->success('成功', $agent); $this->success('成功', $agent);
......
...@@ -233,42 +233,12 @@ class Agent extends Backend ...@@ -233,42 +233,12 @@ class Agent extends Backend
*/ */
public function detail($ids = null) public function detail($ids = null)
{ {
// 容错:多层兜底获取代理商 ID
// Fast.api.open 以 iframe 方式打开,URL 格式可能是:
// ?ids=1&dialog=1 (新 JS,query 参数)
// /ids/1 (旧 JS,路径参数)
// /ids/1.html (旧 JS + url_html_suffix=html)
// 1) 方法参数(ThinkPHP 路由自动注入) // 1) 方法参数(ThinkPHP 路由自动注入)
if (empty($ids)) { if (empty($ids)) {
// 2) param() — 兼容 query string (?ids=1) 和 url_common_param // 2) param() — 兼容 query string (?ids=1) 和 url_common_param
$ids = $this->request->param('ids'); $ids = $this->request->param('ids');
} }
// if (empty($ids)) {
// // 3) get() — 直接读 GET 参数
// $ids = $this->request->get('ids');
// }
// if (empty($ids)) {
// // 4) pathinfo 正则解析 /ids/数字 或 /ids/数字.html
// $pathinfo = $this->request->pathinfo();
// if (preg_match('#/ids/(\d+)[.\b]#', $pathinfo, $m)) {
// $ids = $m[1];
// }
// }
// echo '[detail] row=' . var_export($row, true), 'notice'; '[detail] ids来源检测: method=' . var_export(func_get_arg(0), true) .
// ' param=' . var_export($this->request->param('ids'), true) .
// ' get=' . var_export($this->request->get('ids'), true) .
// ' pathinfo=' . $this->request->pathinfo() .
// ' 最终ids=' . var_export($ids, true), 'notice';
// 临时调试日志(问题定位后可删除)
// \think\Log::write('[detail] ids来源检测: method=' . var_export(func_get_arg(0), true) .
// ' param=' . var_export($this->request->param('ids'), true) .
// ' get=' . var_export($this->request->get('ids'), true) .
// ' pathinfo=' . $this->request->pathinfo() .
// ' 最终ids=' . var_export($ids, true), 'notice');
if (empty($ids)) { if (empty($ids)) {
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
return json(['code' => 0, 'msg' => '缺少代理商ID', 'total' => 0, 'rows' => []]); return json(['code' => 0, 'msg' => '缺少代理商ID', 'total' => 0, 'rows' => []]);
...@@ -285,6 +255,16 @@ class Agent extends Backend ...@@ -285,6 +255,16 @@ class Agent extends Backend
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
} }
// // 冻结或禁用状态不允许查看详情
// $allowStatus = [\app\admin\model\shopro\agent\Agent::STATUS_NORMAL];
// if (!in_array($row->status, $allowStatus)) {
// $statusText = $this->model->statusList()[$row->status] ?? $row->status;
// if ($this->request->isAjax()) {
// return json(['code' => 0, 'msg' => "该代理商{$statusText}状态不可查看详情", 'total' => 0, 'rows' => []]);
// }
// $this->error("该代理商{$statusText}状态不可查看详情");
// }
$commissionModel = new \app\admin\model\shopro\agent\AgentOrderCommission; $commissionModel = new \app\admin\model\shopro\agent\AgentOrderCommission;
// Ajax 分页获取佣金流水 // Ajax 分页获取佣金流水
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment