|
@@ -2,6 +2,9 @@
|
|
namespace App\JsonRpc;
|
|
namespace App\JsonRpc;
|
|
|
|
|
|
use App\Model\Ad;
|
|
use App\Model\Ad;
|
|
|
|
+use App\Model\AdPlace;
|
|
|
|
+use App\Model\Order;
|
|
|
|
+use App\Model\OrderAd;
|
|
use App\Tools\Result;
|
|
use App\Tools\Result;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
|
|
|
@@ -9,25 +12,68 @@ use Hyperf\RpcServer\Annotation\RpcService;
|
|
class OrderService implements OrderServiceInterface
|
|
class OrderService implements OrderServiceInterface
|
|
{
|
|
{
|
|
|
|
|
|
- /**
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询没有广告的广告位
|
|
|
|
+ * @param
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
public function getAD(array $data): array
|
|
public function getAD(array $data): array
|
|
{
|
|
{
|
|
- $where = [];
|
|
|
|
- $id = $data['id'];
|
|
|
|
- if ($id) {
|
|
|
|
- $where[] = ['id', '=', $id];
|
|
|
|
|
|
+ $where = [
|
|
|
|
+ 'width' => $data['width'],
|
|
|
|
+ 'height' => $data['height']
|
|
|
|
+ ];
|
|
|
|
+ $start = $data['starttime'];
|
|
|
|
+ $end = $data['endtime'];
|
|
|
|
+ $rep=Ad::where($where)
|
|
|
|
+ ->where('fromtime','<',$start)
|
|
|
|
+ ->where('totime','>',$end)
|
|
|
|
+ ->orderBy('id')
|
|
|
|
+ ->limit($data['pageSize'])
|
|
|
|
+ ->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
|
|
+ $count = Ad::where($where)->count();
|
|
|
|
+ $data = [
|
|
|
|
+ 'rows'=>$rep->toArray(),
|
|
|
|
+ 'count'=>$count
|
|
|
|
+ ];
|
|
|
|
+ $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("没有信息数据");
|
|
}
|
|
}
|
|
- $rep = AD::where($where)->limit(10)->orderBy("id", "asc")->get();
|
|
|
|
- $count = AD::where($where)->count();
|
|
|
|
|
|
+ return Result::success($data);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 添加订单
|
|
|
|
+ * @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 = [
|
|
$data = [
|
|
- 'rows' => $rep->toArray(),
|
|
|
|
- 'count' => $count,
|
|
|
|
|
|
+ 'rows'=>$ads->toArray(),
|
|
|
|
+ 'count'=>$count
|
|
];
|
|
];
|
|
- if (empty($rep->toArray())) {
|
|
|
|
- return Result::error("没有广告数据");
|
|
|
|
|
|
+ if(empty($rep)){
|
|
|
|
+ return Result::error("没有信息数据");
|
|
}
|
|
}
|
|
return Result::success($data);
|
|
return Result::success($data);
|
|
}
|
|
}
|