|
@@ -484,122 +484,122 @@ class OrderService implements OrderServiceInterface
|
|
];
|
|
];
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+
|
|
- if (isset($data['ad_size_id']) && is_string($data['ad_size_id'])) {
|
|
+
|
|
- $where = [
|
|
+
|
|
- 'ad_place.ad_size_id' => $data['ad_size_id'],
|
|
+
|
|
- ];
|
|
+
|
|
- }
|
|
+
|
|
-
|
|
+
|
|
- if (!isset($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);
|
|
+
|
|
-
|
|
+
|
|
- 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();
|
|
+
|
|
-
|
|
+
|
|
- } 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();
|
|
+
|
|
-
|
|
+
|
|
- }
|
|
+
|
|
- } else {
|
|
+
|
|
-
|
|
+
|
|
- 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);
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
* 获取广告金额
|
|
* 获取广告金额
|