123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace App\JsonRpc;
- use App\Model\Ad;
- use App\Model\AdPlace;
- use App\Model\Order;
- use App\Model\OrderAd;
- use App\Tools\Result;
- use Hyperf\RpcServer\Annotation\RpcService;
- #[RpcService(name: "OrderService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
- class OrderService implements OrderServiceInterface
- {
- /**
- * 查询没有广告的广告位
- * @param
- * @return void
- */
- public function getAD(array $data): array
- {
- $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("没有信息数据");
- }
- 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 = [
- 'rows'=>$ads->toArray(),
- 'count'=>$count
- ];
- if(empty($rep)){
- return Result::error("没有信息数据");
- }
- return Result::success($data);
- }
- }
|