12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\admin\controller\client;
- use app\controller\Curd;
- use app\model\ClientFavorite;
- use app\model\ClientPoints;
- use support\Request;
- use support\Response;
- class PointsController extends Curd
- {
- public function __construct()
- {
- $this->model = new ClientPoints();
- }
- public function select(Request $request): Response
- {
- [$where, $format, $limit, $field, $order] = $this->selectInput($request);
- $order = $request->get('order', 'desc');
- $field = $field ?? 'client_points_addtimes';
- if (!empty($request->get('member_mobile'))) {
- $where['member.member_mobile'] = ['like', $request->get('member_mobile')];
- }
- if (!empty($request->get('order_id'))) {
- $where['order.order_id'] = ['like', $request->get('order_id')];
- }
- $query = $this->doSelect($where, $field, $order);
- return $this->doFormat($query, $format, $limit);
- }
- protected function doSelect(array $where, string $field = null, string $order = 'desc')
- {
- $model = $this->model->leftJoin('member', 'member.member_id', '=', 'client_points.join_client_points_member_id')
- ->leftJoin('member_info', 'member_info.join_info_member_id', '=', 'client_points.join_client_points_member_id')
- ->leftJoin('member_cert', 'member_cert.join_cert_member_id', '=', 'client_points.join_client_points_member_id')
- ->leftJoin('order', 'order.order_id', '=', 'client_points.join_client_points_order_id')
- ->select('member.member_id', 'member.member_mobile','member_info.member_info_nickname','member_cert.member_cert_name', 'order.order_id', 'order.order_name', 'client_points.*');
- foreach ($where as $column => $value) {
- if (is_array($value)) {
- if ($value[0] === 'like' || $value[0] === 'not like') {
- $model = $model->where($column, $value[0], "%$value[1]%");
- } elseif (in_array($value[0], ['>', '=', '<', '<>'])) {
- $model = $model->where($column, $value[0], $value[1]);
- } elseif ($value[0] == 'in' && !empty($value[1])) {
- $valArr = $value[1];
- if (is_string($value[1])) {
- $valArr = explode(",", trim($value[1]));
- }
- $model = $model->whereIn($column, $valArr);
- } elseif ($value[0] == 'not in' && !empty($value[1])) {
- $valArr = $value[1];
- if (is_string($value[1])) {
- $valArr = explode(",", trim($value[1]));
- }
- $model = $model->whereNotIn($column, $valArr);
- } elseif ($value[0] == 'null') {
- $model = $model->whereNull($column);
- } elseif ($value[0] == 'not null') {
- $model = $model->whereNotNull($column);
- } elseif ($value[0] !== '' || $value[1] !== '') {
- $model = $model->whereBetween($column, $value);
- }
- } else {
- $model = $model->where($column, $value);
- }
- }
- if ($field) {
- $model = $model->orderBy($field, $order);
- }
- return $model;
- }
- /**
- * @Desc 积分详情
- * @Author Gorden
- * @Date 2024/9/19 18:16
- *
- * @param Request $request
- * @return Response
- */
- public function info(Request $request): Response
- {
- $pointsId = $request->get('points_id');
- if (!$pointsId){
- return json_fail('参数异常');
- }
- }
- }
|