From a6415f77536e2c28ca38b534295b2558db501223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AF=E4=B9=90=E5=8A=A0=E5=86=B0?= <11869599+addie66@user.noreply.gitee.com> Date: Sat, 12 Sep 2026 20:49:38 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(regional=5Fagent):=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=BB=A3=E7=90=86=E4=BD=A3=E9=87=91=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=92=8C=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shopro/regional_agent/Agent.php | 10 +++++++--- .../admin/model/shopro/regional_agent/Agent.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/shopro/regional_agent/Agent.php b/application/admin/controller/shopro/regional_agent/Agent.php index 0e05d2d..4604883 100644 --- a/application/admin/controller/shopro/regional_agent/Agent.php +++ b/application/admin/controller/shopro/regional_agent/Agent.php @@ -255,9 +255,13 @@ class Agent extends Base protected function buildCommissionData($data) { - $useCustom = isset($data['use_custom_commission']) - ? boolval($data['use_custom_commission']) - : !empty($data['commission_type']); + if (array_key_exists('use_custom_commission', $data)) { + $useCustom = filter_var($data['use_custom_commission'], FILTER_VALIDATE_BOOLEAN); + } else { + $hasRate = isset($data['commission_rate']) && $data['commission_rate'] !== '' && $data['commission_rate'] !== null; + $hasMoney = isset($data['commission_money']) && $data['commission_money'] !== '' && $data['commission_money'] !== null; + $useCustom = !empty($data['commission_type']) && ($hasRate || $hasMoney); + } if (!$useCustom) { return [ diff --git a/application/admin/model/shopro/regional_agent/Agent.php b/application/admin/model/shopro/regional_agent/Agent.php index 4fe9ac2..5ff8da9 100644 --- a/application/admin/model/shopro/regional_agent/Agent.php +++ b/application/admin/model/shopro/regional_agent/Agent.php @@ -11,6 +11,20 @@ class Agent extends Model protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; + const STATUS_NORMAL = 'normal'; + const STATUS_PENDING = 'pending'; + const STATUS_FORBIDDEN = 'forbidden'; + + public function scopeNormal($query) + { + return $query->where('status', self::STATUS_NORMAL); + } + + public function scopeAvailable($query) + { + return $query->where('status', 'in', [self::STATUS_NORMAL]); + } + public function user() { return $this->belongsTo(\app\admin\model\shopro\user\User::class, 'user_id', 'id');