|
@@ -2,8 +2,10 @@
|
|
|
namespace App\JsonRpc;
|
|
|
use App\Model\Ad;
|
|
|
use App\Model\AdPlace;
|
|
|
+use App\Model\AdSize;
|
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
use App\Tools\Result;
|
|
|
+use Hyperf\DbConnection\Db;
|
|
|
#[RpcService(name: "AdService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class AdService implements AdServiceInterface
|
|
|
{
|
|
@@ -243,4 +245,36 @@ class AdService implements AdServiceInterface
|
|
|
return Result::success($adInfo->toArray());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addTwinAdPlace(array $data): array
|
|
|
+ {
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $adSizeInfo = AdSize::firstOrCreate(['width'=>$data['width'],'height'=>$data['height']]);
|
|
|
+ $adPlaceInfo = AdPlace::insertGetId(
|
|
|
+ [
|
|
|
+ 'website_id'=>$data['website_id'],
|
|
|
+ 'typeid'=>$data['typeid'],
|
|
|
+ 'status'=>2,
|
|
|
+ 'name'=>$data['name']??'',
|
|
|
+ 'thumb'=>$data['thumb']??'',
|
|
|
+ 'introduce'=>$data['introduce']??'',
|
|
|
+ 'code'=>$data['code']??'',
|
|
|
+ 'price'=>0,
|
|
|
+ 'ad_size_id'=>$adSizeInfo->id,
|
|
|
+ 'ad_tag'=>$data['ad_tag']??'',
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ Db::commit();
|
|
|
+ return Result::success(['id'=>$adPlaceInfo]);
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error("创建广告位失败".$e->getMessage(),0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|