order('id', 'desc'); if($username = $request->get('username')) { $query->where('username', $username); } if($status = $request->get('status')) { $query->where('status', $status); } if($is_order = $request->get('is_order')) { $query->where('is_order', $is_order); } $list = $query->paginate($request->get('limit',1000)); return $this->success($list,null,['oss' => array_values(array_map(function ($os, $k) { return ['id' => $k, 'os' => $os]; }, Orders::OSS, array_keys(Orders::OSS)))]); } public function add(Request $request) { if (!$request->post('os')) { return $this->error(2001, '请选择平台.'); } if (!$request->post('product_name')) { return $this->error(2001, '线路名称必填'); } if (!$request->post('third_product_id')) { return $this->error(2001, '线路id必填'); } $where = ['os' => $request->post('os'), 'third_product_id' => $request->post('third_product_id')]; $product = (new Products())->where($where)->find(); if (!empty($product)) { return $this->error(2002, '线路已存在'); } $product = new Products(); $product->os = $request->post('os'); $product->third_product_id = $request->post('third_product_id'); $product->product_name = $request->post('product_name'); $product->status = 1; $product->save(); Log::info('product:' . json_encode($product)); return $this->success([]); } }