|
@@ -39,12 +39,14 @@ class OrderService implements OrderServiceInterface
|
|
|
$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) {
|
|
@@ -391,23 +393,26 @@ class OrderService implements OrderServiceInterface
|
|
|
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 (!isset($data['website_id'])) {
|
|
|
$website_id = [];
|
|
|
foreach ($placeids as $v) {
|
|
|
array_push($website_id, $v['website_id']);
|
|
|
}
|
|
|
$result = Website::whereIn('id', $website_id)->get();
|
|
|
+ //若不存在网站id参数直接返回符合条件的广告位相关联的网站名称
|
|
|
} else {
|
|
|
$place_id = [];
|
|
|
foreach ($placeids as $val) {
|
|
@@ -429,8 +434,10 @@ class OrderService implements OrderServiceInterface
|
|
|
'rows' => $rep->toArray(),
|
|
|
'count' => $count,
|
|
|
];
|
|
|
+ //若存在网站id,关联查询是需要添加website_id条件查询
|
|
|
}
|
|
|
} else {
|
|
|
+ //若不存在有时间冲突的广告位则所有符合图片尺寸的广告位皆可以使用,只需要判断是否存在网站id参数即可
|
|
|
if (isset($data['website_id'])) {
|
|
|
$rep = AdPlace::where($where)
|
|
|
->where('ad_place.website_id', $data['website_id'])
|