admin - 新增根据入会类型id获取权益接口

This commit is contained in:
2026-04-27 17:59:34 +08:00
parent 4537d070c8
commit 47cdd4c92d
2 changed files with 29 additions and 2 deletions

View File

@@ -107,6 +107,30 @@ class Level extends Backend
$this->error(__('No rows were deleted')); $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,
]);
}
/** /**
* 添加 * 添加
* *

View File

@@ -54,12 +54,15 @@ class MemberBenefits extends Model
return isset($list[$value]) ? $list[$value] : ''; 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) { if (null !== $disabled) {
$query->where('disabled', '=', $disabled); $query->where('disabled', '=', $disabled);
} }
if (null !== $join_config_id) {
$query->where('join_config_id', '=', $join_config_id);
}
})->order('sort', 'asc')->select(); })->order('sort', 'asc')->select();
} }
} }