$data['ad_size_id'], ]; $start = Carbon::parse($data['starttime']); $end = Carbon::parse($data['endtime']); $status = [ 0 => '1', 1 => '4', 2 => '6', ]; $ads = Ad::where('fromtime', '<=', $start)->where('totime', '>=', $end)->select('pid')->get()->all(); $orderads = OrderAd::where('fromtime', '<=', $start)->where('totime', '>=', $end)->whereIn('status', $status)->select('pid')->get()->all(); $pids = array_merge($ads, $orderads); $ad_pids = array_unique($pids); // $ad_pid = [1,2,3]; // 所有与用户有时间冲突的广告位 if (!empty($ad_pids)) { $pid = []; foreach ($ad_pids as $val) { array_push($pid, $val['pid']); } $placeids = AdPlace::whereNotIn('id', $pid)->where($where)->select('id')->get()->all(); //所有去掉与用户时间冲突的广告并且符合图片尺寸的广告位 // 符合用户条件的空广告位 $place_id = []; foreach ($placeids as $val) { array_push($place_id, $val['id']); } $rep = AdPlace::whereIn('ad_place.id', $place_id) ->leftJoin('website', 'ad_place.website_id', 'website.id') ->leftJoin('ad_size', 'ad_place.ad_size_id', 'ad_size.id') ->select('ad_place.*', 'website.website_name', 'website.id', 'ad_size.*') ->selectSub('website.id', 'webid') ->selectSub('ad_place.id', 'pid') ->selectSub('ad_size.width', 'size_width') ->selectSub('ad_size.height', 'size_height') ->orderBy("website.id", "asc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->get(); $count = AdPlace::whereIn('ad_place.id', $place_id)->count(); } else { $rep = AdPlace::where($where) ->leftJoin('website', 'ad_place.website_id', 'website.id') ->leftJoin('ad_size', 'ad_place.ad_size_id', 'ad_size.id') ->select('ad_place.*', 'website.website_name', 'website.id', 'ad_size.*') ->selectSub('website.id', 'webid') ->selectSub('ad_place.id', 'pid') ->selectSub('ad_size.width', 'size_width') ->selectSub('ad_size.height', 'size_height') ->orderBy("website.id", "asc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->get(); $count = AdPlace::where($where)->count(); } $startTime = strtotime($data['starttime']); $endTime = strtotime($data['endtime']); $time = ($endTime - $startTime) / (24 * 60 * 60); $roundedValue = round($time, 2); $days = number_format($roundedValue, 2, '.', ''); $result = [ 'rows' => $rep->toArray(), 'count' => $count, 'days' => $days, ]; if (empty($result['rows'])) { return Result::error("暂无符合您条件的广告位!"); } } else { $result = AdSize::get(); if (empty($result)) { return Result::error('暂无广告尺寸!'); } } return Result::success($result); } /** * 添加订单 * @param * @return void */ public function addOrder(array $data): array { $ads = Ad::whereIn($data['id']) ->leftJoin('ad_place', 'ad.pid', 'ad_place.id') ->leftJoin("article_data", "article.id", "article_data.article_id") ->select("ad_place.*", "ad.*") ->orderBy("ad.id", "desc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize'])->get(); $count = Ad::whereIn($data['id'])->count(); $data = [ 'rows' => $ads->toArray(), 'count' => $count, ]; if (empty($rep)) { return Result::error("没有信息数据"); } return Result::success($data); } /** * 获取订单列表 * @param * @return void */ public function getOrderListAdmin(array $data): array { // 获取分页参数,默认每页 10 条记录 $page = isset($data['page']) ? (int) $data['page'] : 1; $perPage = isset($data['pagesize']) ? (int) $data['pagesize'] : 10; var_dump($data, 'p---------------------'); // 构建查询条件 $where = []; if (!empty($data['status'])) { $where = [ 'order.status' => $data['status'], // 明确指定 order 表的 status 列 ]; } //广告订单状态 if (!empty($data['ad_status'])) { $where = [ 'order.ad_status' => $data['ad_status'], ]; } // 添加订单号查询条件 if (!empty($data['order_num'])) { $where['order.order_num'] = $data['order_num']; // 明确指定 order 表的 order_num 列 } // 处理时间范围查询 $start = $data['sttime'] ?? ''; $end = $data['edtime'] ?? ''; // 查询数据并分页 $query = Order::where($where) ->when(!empty($start) && !empty($end), function ($q) use ($start, $end) { $q->whereBetween('order.fromtime', [$start, $end]); // 明确指定 order 表的 fromtime 列 }) ->when(!empty($start), function ($q) use ($start) { $q->where('order.fromtime', '>=', $start); // 明确指定 order 表的 fromtime 列 }) ->when(!empty($end), function ($q) use ($end) { $q->where('order.totime', '<=', $end); // 明确指定 order 表的 totime 列 }) ->leftJoin('user as admin_user', 'order.admin_user_id', '=', 'admin_user.id') ->leftJoin('user as user', 'order.user_id', '=', 'user.id') ->select( 'order.*', 'admin_user.user_name as admin_user_name', 'user.user_name as user_name' ) ->orderBy('order.id', 'desc'); // 执行分页查询 $result = $query->paginate($perPage, ['*'], 'page', $page); // 返回分页结果 return Result::success([ 'count' => $result->total(), 'current_page' => $result->currentPage(), 'last_page' => $result->lastPage(), 'pagesize' => $result->perPage(), 'rows' => $result->items(), ]); } /** * 获取订单详情 * @param * @return void */ public function getOrderDetailAdmin(array $data): array { $order = Order::where('order.id', $data['id']) ->leftJoin('user as admin_user', 'order.admin_user_id', '=', 'admin_user.id') ->leftJoin('user as user', 'order.user_id', '=', 'user.id') ->select( 'order.*', 'admin_user.user_name as admin_user_name', 'user.user_name as user_name' )->first(); if (empty($order)) { return Result::error("没有信息数据"); } $pid = $order['id']; $ad = OrderAd::where('order_id', $pid) ->leftJoin('ad_place as ad', 'order_ad.pid', '=', 'ad.id') ->select('order_ad.*', 'ad.name as ad_name') ->get(); $order['ad'] = $ad; return Result::success($order); } /** * 修改订单价格 * @param * @return void */ public function editPriceOrderAdmin(array $data): array { $order = Order::where('id', $data['id'])->first(); if (empty($order)) { return Result::error("没有信息数据"); } $order->price = $data['price']; $order->save(); return Result::success($order); } /** *拒绝订单 * @param * @return void */ public function rejectOrderAdmin(array $data): array { $order = Order::where('id', $data['id'])->first(); if (empty($order)) { return Result::error("没有信息数据"); } Db::beginTransaction(); try { $order->status = 2; //订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束 $order->ad_status = 2; $order->reason = $data['reason']; $order->bhtime = date('Y-m-d H:i:s'); $order->save(); OrderAd::where('order_id', $data['id']) ->update(['status' => 2]); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error("操作失败"); } return Result::success($order); } /** * 结束订单 * @param * @return void */ public function endOrderAdmin(array $data): array { $order = Order::where('id', $data['id'])->first(); if (empty($order)) { return Result::error("没有信息数据"); } Db::beginTransaction(); try { $order->status = 7; $order->jstime = date('Y-m-d H:i:s'); $order->save(); // 获取 order_ad 表中的记录 $orderAds = OrderAd::where('order_id', $data['id']) ->update(['status' => 7]); // 在ad表中删除相同pid的数据 Ad::where('order_id', $data['id'])->delete(); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error("操作失败" . $e->getMessage()); } return Result::success($order); } /** * 删除订单 * @param * @return void */ public function delOrderAdmin(array $data): array { // 获取订单信息 $order = Order::where('id', $data['id'])->first(); if (empty($order)) { return Result::error("没有信息数据"); } Db::beginTransaction(); try { Order::where('id', $data['id'])->delete(); var_dump(11111111); // 获取 order_ad 表中的记录 OrderAd::where('order_id', $data['id'])->delete(); // 删除 ad 表中的记录 Ad::where('order_id', $data['id'])->delete(); // 提交事务 Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollBack(); // 返回错误信息 return Result::error($e->getMessage()); } // 返回成功信息 return Result::success("删除成功"); } /** * 审核订单 * @param * @return void */ public function applyOrderStatusAdmin(array $data): array { $order = Order::where('id', $data['id']) ->where('status', 6) ->first(); if (empty($order)) { return Result::error("没有信息数据"); } Db::beginTransaction(); try { $order->status = 1; //判断是否在周期范围内 $ad_status = 8; // 待生效 if ($order->starttime < date('Y-m-d H:i:s') && date('Y-m-d H:i:s') < $order->endtime) { // 条件满足时的逻辑 $ad_status = 1; } $order->ad_status = 1; $order->shtime = date('Y-m-d H:i:s'); $order->save(); // 批量更新 order_ad 表中的状态 OrderAd::where('order_id', $data['id']) ->where('status', 6) ->update(['status' => 1]); //判断的当前时间是否在订单的开始时间之后,并且小于等于订单的结束时间 if (time() >= strtotime($order->sttime) && time() < strtotime($order->edtime)) { $ad_status = 1; //审核生效 } else { $ad_status = 2; //审核 } $ads = []; $orderAds = OrderAd::where('order_id', $data['id'])->get(); foreach ($orderAds as $orderAd) { $ads[] = [ 'name' => $orderAd->name, 'pid' => $orderAd->pid, 'areaid' => $orderAd->areaid, 'amount' => $orderAd->amount, 'introduce' => $orderAd->introduce, 'hits' => $orderAd->hits, 'admin_user_id' => $orderAd->admin_user_id, 'fromtime' => $orderAd->fromtime, 'totime' => $orderAd->totime, 'text_name' => $orderAd->text_name, 'text_url' => $orderAd->text_url, 'text_title' => $orderAd->text_title, 'image_src' => $orderAd->image_src, 'image_url' => $orderAd->image_url, 'image_alt' => $orderAd->image_alt, 'video_src' => $orderAd->video_src, 'video_url' => $orderAd->video_url, 'video_auto' => $orderAd->video_auto, 'video_loop' => $orderAd->video_loop, 'status' => $ad_status, 'order_id' => $orderAd->order_id, ]; } Ad::insert($ads); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error($e->getMessage()); } return Result::success($order); } /*  * 根据用户条件及网站搜索没有广告的广告位  * @param  * @return void */ public function getWebsiteAd(array $data): array { $where = [ 'ad_place.ad_size_id' => $data['ad_size_id'], ]; $start = Carbon::parse($data['starttime']); $end = Carbon::parse($data['endtime']); $status = [ 0 => '1', 1 => '4', 2 => '6', ]; //订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束 $ads = Ad::where('fromtime', '<=', $start)->where('totime', '>=', $end)->select('pid')->get()->all(); $orderads = OrderAd::where('fromtime', '<=', $start)->where('totime', '>=', $end)->whereIn('status', $status)->select('pid')->get()->all(); $pids = array_merge($ads, $orderads); $ad_pids = array_unique($pids); //$ad_pids=所有与用户提交的时间有冲突的广告位pid if (!empty($ad_pids)) { $pid = []; foreach ($ad_pids as $val) { array_push($pid, $val['pid']); } //去掉时间冲突并且符合图片尺寸的广告位 $placeids = AdPlace::whereNotIn('id', $pid)->where($where)->select('id', 'website_id')->get()->all(); if (empty($placeids)) { return Result::error('暂无数据!'); } if (!isset($data['website_id'])) { $websiteIds = array_column($placeids, 'website_id'); $website_id = array_unique($websiteIds); $rep = Website::whereIn('id', $website_id)->get(); $count = Website::whereIn('id', $website_id)->count(); //若不存在网站id参数直接返回符合条件的广告位相关联的网站名称 } else { $place_id = []; foreach ($placeids as $val) { array_push($place_id, $val['id']); } $rep = AdPlace::where($where) ->whereIn('ad_place.id', $place_id) ->where('ad_place.website_id', $data['website_id']) ->leftJoin('website', 'ad_place.website_id', 'website.id') ->leftJoin('ad_size', 'ad_place.ad_size_id', 'ad_size.id') ->select('ad_place.*', 'website.website_name', 'website.id', 'ad_size.*') ->selectSub('website.id', 'webid') ->selectSub('ad_place.id', 'pid') ->selectSub('ad_size.width', 'size_width') ->selectSub('ad_size.height', 'size_height') ->orderBy("website.id", "asc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->get(); $count = AdPlace::where($where)->where('ad_place.website_id', $data['website_id'])->count(); //若存在网站id,关联查询是需要添加website_id条件查询 } } else { //若不存在有时间冲突的广告位则所有符合图片尺寸的广告位皆可以使用,只需要判断是否存在网站id参数即可 if (isset($data['website_id'])) { $rep = AdPlace::where($where) ->where('ad_place.website_id', $data['website_id']) ->leftJoin('website', 'ad_place.website_id', 'website.id') ->leftJoin('ad_size', 'ad_place.ad_size_id', 'ad_size.id') ->select('ad_place.*', 'website.website_name', 'website.id', 'ad_size.*') ->selectSub('website.id', 'webid') ->selectSub('ad_place.id', 'pid') ->selectSub('ad_size.width', 'size_width') ->selectSub('ad_size.height', 'size_height') ->orderBy("website.id", "asc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->get(); $count = AdPlace::where($where)->where('ad_place.website_id', $data['website_id'])->count(); } else { $place_all = AdPlace::where($where)->select('website_id')->get()->all(); $place_allads = []; foreach ($place_all as $v) { array_push($place_allads, $v['website_id']); } $rep = Website::whereIn('id', $place_allads)->get(); $count = Website::whereIn('id', $place_allads)->count(); } } if (empty($rep)) { return Result::error("暂无符合您条件的广告位!"); } $startTime = strtotime($data['starttime']); $endTime = strtotime($data['endtime']); $time = ($endTime - $startTime) / (24 * 60 * 60); $roundedValue = round($time, 2); $days = number_format($roundedValue, 2, '.', ''); $result = [ 'rows' => $rep->toArray(), 'count' => $count, 'days' => $days, ]; return Result::success($result); } /**  * 获取广告金额  * @param  * @return void */ public function getPrice(array $data): array { // $data['pid'] = [15,16]; $startTime = strtotime($data['starttime']); $endTime = strtotime($data['endtime']); $days = ($endTime - $startTime) / (24 * 60 * 60); //计算共计多少天 $price = 0; if (isset($data['pid'])) { $ad_price = AdPlace::whereIn('id', $data['pid'])->select('id', 'price')->get(); foreach ($ad_price as $v) { $price += number_format($v['price'] * $days, 2, '.', ''); } } else { $price = 0; } // 确保 $price带有两位小数位数 $price = number_format((float) $price, 2, '.', ''); return Result::success($price); } /**  * 添加广告订单  * @param  * @return void */ public function addAD(array $data): array { date_default_timezone_set('Asia/Shanghai'); $time = time(); $startTime = strtotime($data['starttime']); $endTime = strtotime($data['endtime']); $days = ($endTime - $startTime) / (24 * 60 * 60); //计算共计多少天 $timestamp = date('YmdHis', $time); $catetime = date('Y-m-d H:i:s', $time); $randomNumber = mt_rand(1000, 9999); $ordernum = $randomNumber . $timestamp; // 时间戳与随机数拼接 $order_size = AdSize::where('id', $data['ad_size_id'])->first(); // var_dump(($time)); Db::beginTransaction(); try { $order = [ 'order_num' => $ordernum, 'name' => $data['name'], 'sttime' => $data['starttime'], 'edtime' => $data['endtime'], 'user_id' => $data['user_id'], 'cttime' => $catetime, 'width' => $order_size['width'], 'height' => $order_size['height'], 'days' => $days, 'price' => $data['price'], 'created_at' => date('Y-m-d H:i:s', time()), 'updated_at' => date('Y-m-d H:i:s', time()), ]; //添加订单 $orderid = Order::insertGetId($order); $adplace = $data['pid']; if (is_array($data['pid'])) { $adplace = AdPlace::whereIn('id', $data['pid'])->select('website_id', 'id')->get(); $order_ad = []; foreach ($adplace as $key => $ads) { $order_ad[$key] = [ 'order_id' => $orderid, 'order_num' => $ordernum, 'name' => $data['name'], 'fromtime' => $data['starttime'], 'totime' => $data['endtime'], 'image_src' => $data['imgsrc'], 'image_url' => $data['imgurl'], 'pid' => $ads['id'], 'website_id' => $ads['website_id'], ]; } } $orderad_id = OrderAd::insert($order_ad); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error($e->getMessage()); } // $log = AdLog::insert($log); $result = [ 'order_id' => $orderid, 'orderad_id' => $orderad_id, 'name' => $data['name'], 'ordernum' => $ordernum, ]; return Result::success($result); } /**  * 获取订单列表  * @param  * @return void */ public function getOrderList(array $data): array { $where = [ 'user_id' => $data['user_id'], 'user_del' => 2, ]; if (isset($data['status'])) { $where['status'] = $data['status']; } $orders = Order::where($where) ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->orderBy("updated_at", "desc") ->get() ->all(); //订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束 $count['all'] = Order::where($where)->count(); $count['pass'] = Order::where($where)->where('status', 1)->count(); $count['return'] = Order::where($where)->where('status', 2)->count(); $count['recall'] = Order::where($where)->where('status', 3)->count(); $count['update'] = Order::where($where)->where('status', 4)->count(); $count['fail'] = Order::where($where)->where('status', 5)->count(); $count['waite'] = Order::where($where)->where('status', 6)->count(); $count['over'] = Order::where($where)->where('status', 7)->count(); foreach ($orders as $key => $val) { $adsnum = OrderAd::where('order_id', $val['id'])->count(); $rep[$key] = $val; $rep[$key]['num'] = $adsnum; } if (empty($rep)) { return Result::error("您暂时还没有下单"); } else { $data = [ 'rows' => $rep, 'count' => $count, ]; } return Result::success($data); } /**  * 获取订单详情  * @param  * @return void */ public function getOrderDetail(array $data): array { $order = Order::where('id', $data['order_id'])->first(); $orderads = OrderAd::where('order_ad.order_id', $data['order_id']) ->leftJoin('website', 'order_ad.website_id', 'website.id') ->leftJoin('ad_place', 'order_ad.pid', 'ad_place.id') ->select('order_ad.*', 'website.website_name', 'website.id', 'ad_place.name') ->selectSub('website.id', 'webid') ->selectSub('order_ad.id', 'oid') ->selectSub('order_ad.name', 'adname') ->selectSub('ad_place.name', 'apname') ->orderBy("website.id", "asc") ->limit($data['pageSize']) ->offset(($data['page'] - 1) * $data['pageSize']) ->get(); if (empty($order)) { return Result::error("订单id错误"); } $count = OrderAd::where('order_ad.order_id', $data['order_id'])->count(); $result = [ 'order' => $order, 'orderads' => $orderads, 'count' => $count, ]; return Result::success($result); } /**  * 撤回订单  * @param  * @return void */ public function cancelOrder(array $data): array { date_default_timezone_set('Asia/Shanghai'); $time = time(); $timestamp = date('YmdHis', $time); Db::beginTransaction(); try { $order = Order::where('id', $data['order_id'])->where('status', 6)->where('sttime', '>=', $timestamp)->update(['status' => 3, 'ad_status' => '3']); $ads = OrderAd::where('order_id', $data['order_id'])->where('status', 6)->where('fromtime', '>=', $timestamp)->update(['status' => 3]); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error($e->getMessage()); } $result = [ 'order' => $order, 'ads' => $ads, ]; if ($order == 0) { return Result::error("此订单不可撤回"); } return Result::success($result); } /**  * 删除订单  * @param  * @return void */ public function delOrderAD(array $data): array { $data['status'] = [ 0 => 2, 1 => 3, 2 => 5, 3 => 7, ]; //1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束; date_default_timezone_set('Asia/Shanghai'); $time = time(); $timestamp = date('YmdHis', $time); $where = [ ['id', '=', $data['id']], ]; $time = [['edtime', '<=', $timestamp]]; $order = Order::where($where)->where($time)->update(['user_del' => 1]); if (empty($order)) { $order = Order::where($where)->whereIn('status', $data['status'])->update(['user_del' => 1]); } if ($order == 0) { return Result::error("此订单不可删除"); } return Result::success($order); } /**  * 创建购物车  * @param  * @return void */ public function addShoppingCart(array $data): array { $shop = ShoppingCart::where('user_id', $data['user_id'])->get()->all(); $time = time(); $timestamp = date('YmdHis', $time); $randomNumber = mt_rand(100, 999); $shopping_id = $randomNumber . $timestamp; // 时间戳与随机数拼接 Db::beginTransaction(); try { if (!empty($shop)) { $del_shop = ShoppingCart::where('user_id', $data['user_id'])->delete(); if (empty($del_shop)) { return Result::error("删除失败"); } } $shop = [ 'user_id' => $data['user_id'], 'shopping_id' => $shopping_id, 'created_at' => date('Y-m-d H:i:s', time()), 'updated_at' => date('Y-m-d H:i:s', time()) ]; $result = ShoppingCart::insert($shop); Db::commit(); } catch (\Exception $e) { Db::rollBack(); return Result::error($e->getMessage()); } if(empty($result)){ return Result::error("创建失败"); }else{ return Result::success($shopping_id); } } /**  * 获取购物车中的广告位  * @param  * @return void */ public function getShoppingCartAD(array $data): array { $result = ShoppingCart::where('shopping_id', $data['shopping_id']) ->where('user_id',$data['user_id']) ->orderBy('pid') ->get() ->toArray(); if (empty($result)) { return Result::error("购物车id错误"); }else{ return Result::success($result); } } /**  * 添加购物车中的广告位  * @param  * @return void */ public function addShoppingCartAD(array $data): array { $shop = ShoppingCart::where('shopping_id', $data['shopping_id'])->where('user_id',$data['user_id'])->first(); if (empty($shop)) { return Result::error("购物车id错误"); }else{ $ad = AdPlace::when(is_array($data['pid']), function ($query) use ($data) { return $query->whereIn('ad_place.id', $data['pid']); }, function ($query) use ($data) { return $query->where('ad_place.id', $data['pid']); }) ->leftJoin('website','ad_place.website_id','website.id') ->select('ad_place.id as pid','website.id as website_id') ->first(); if(empty($ad)) { return Result::error("广告位id错误"); } if(empty($shop['pid']) && empty($shop['website_id'])){ $result = ShoppingCart::where('shopping_id', $shop['shopping_id'])->where('user_id',$data['user_id'])->update(['pid' => $ad['pid'],'website_id' => $ad['website_id']]); }else{ if($data['pid'] == $shop['pid']){ return Result::error("购物车中已存在该广告位"); } $shop_ad = [ 'pid' => $ad['pid'], 'website_id' => $ad['website_id'], 'shopping_id' => $shop['shopping_id'], 'user_id' => $data['user_id'] ]; $result = ShoppingCart::insertGetId($shop_ad); } } if(empty($result)){ return Result::error("添加失败"); }else{ return Result::success($result); } } /**  * 删除购物车中的广告位  * @param  * @return void */ public function delShoppingCartAD(array $data): array { $shop = ShoppingCart::where('shopping_id', $data['shopping_id'])->where('user_id',$data['user_id'])->where('pid',$data['pid'])->first(); if (empty($shop)) { return Result::error("不存在此条记录!(参数错误)"); }else{ $result = ShoppingCart::where('shopping_id', $shop['shopping_id'])->where('user_id',$data['user_id'])->where('pid',$data['pid'])->delete(); } if(empty($result)){ return Result::error("删除失败"); }else{ return Result::success($result); } } }