// +---------------------------------------------------------------------- namespace App\Http\Controllers\Admin; use App\Http\Validator\MemberValidator; use App\Services\Common\MemberService; use Illuminate\Http\Request; /** * 会员管理-控制器 * @author laravel开发员 * @since 2020/11/11 * Class MemberController * @package App\Http\Controllers */ class MemberController extends Backend { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 * MemberController constructor. */ public function __construct() { parent::__construct(); $this->service = new MemberService(); } /** * 列表 * @return array */ public function index() { $pageSize = request()->get('limit', 10); $list = $this->service->getDataList(request()->all(), $pageSize); $message = array( "msg" => '操作成功', "code" => 0, "data" => isset($list['list']) ? $list['list'] : [], "count" => isset($list['total']) ? $list['total'] : 0, ); return $message; } /** * 审核 * @return array */ public function confirm(MemberValidator $validator) { $params = request()->post(); $params = $validator->check($params, 'confirm'); if (!is_array($params)) { return message($params, false); } if (MemberService::make()->confirm($this->userId, $params)) { return message(MemberService::make()->getError(), true); } else { return message(MemberService::make()->getError(), false); } } /** * 选项列表 * @return mixed */ public function options() { $result = $this->service->options(); return message(1002, true, $result); } /** * 批量设置VIP * @return array */ public function batchVip() { $params = request()->post(); if (empty($params['ids']) || !is_array($params['ids'])) { return message("请选择要操作的会员", false); } // 判断是否设置各个VIP类型 if (isset($params['is_zg_vip'])) { $updateData['is_zg_vip'] = intval($params['is_zg_vip']); } if (isset($params['is_zsb_vip'])) { $updateData['is_zsb_vip'] = intval($params['is_zsb_vip']); } if (isset($params['is_video_vip'])) { $updateData['is_video_vip'] = intval($params['is_video_vip']); } if (empty($updateData)) { return message("未指定要修改的VIP类型", false); } return $this->service->batchVip($params); } /** * 会员注册统计接口(分页) */ public function stat(Request $request) { $params = $request->only(['dateType', 'start_time', 'end_time', 'page', 'limit']); $data = $this->service->getMemberStats($params); return response()->json([ 'code' => 0, 'data' => $data ]); } }