diff --git a/application/admin/controller/wdsxh/member/Level.php b/application/admin/controller/wdsxh/member/Level.php index 236efce..46b2da0 100644 --- a/application/admin/controller/wdsxh/member/Level.php +++ b/application/admin/controller/wdsxh/member/Level.php @@ -107,6 +107,30 @@ class Level extends Backend $this->error(__('No rows were deleted')); } + /** + * 根据入会类型筛选权益 + * + * @param type $param + * @return type + */ + public function benefits() + { + $join_config_id = $this->request->get('join_config_id'); + $benefits = $this->benefit_model->getSimpleByStatus(0, $join_config_id); + if (empty($benefits)) { + return json([ + 'code' => 1, + 'msg' => __('No benefits found'), + 'data' => [] + ]); + } + return json([ + 'code' => 0, + 'msg' => 'success', + 'data' => $benefits, + ]); + } + /** * 添加 * diff --git a/application/admin/model/wdsxh/member/MemberBenefits.php b/application/admin/model/wdsxh/member/MemberBenefits.php index 4d07ace..7d22b66 100644 --- a/application/admin/model/wdsxh/member/MemberBenefits.php +++ b/application/admin/model/wdsxh/member/MemberBenefits.php @@ -54,12 +54,15 @@ class MemberBenefits extends Model return isset($list[$value]) ? $list[$value] : ''; } - public function getSimpleByStatus($disabled = 0) + public function getSimpleByStatus($disabled = 0, $join_config_id = null) { - return Self::field(['id', 'title'])->where(function($query) use ($disabled) { + return Self::field(['id', 'title'])->where(function($query) use ($disabled, $join_config_id) { if (null !== $disabled) { $query->where('disabled', '=', $disabled); } + if (null !== $join_config_id) { + $query->where('join_config_id', '=', $join_config_id); + } })->order('sort', 'asc')->select(); } }