Browse Source
feat(admin): 新增媒体圈资源变更与稿件进度通知接口
feat(admin): 新增媒体圈资源变更与稿件进度通知接口
- 添加无需登录的资源批量变更通知接口 - 添加无需登录的稿件安排进度通知接口 - 实现资源变更数据解密与存储逻辑 - 实现稿件进度更新逻辑 - 新增投稿记录模型及DAO层 - 添加投稿接口服务实现 - 注册相关路由并配置权限控制master
8 changed files with 273 additions and 6 deletions
-
1app/controller/admin/ApiController.php
-
32app/controller/admin/OnlineMediasController.php
-
15app/dao/user/CreationArticleReceiveRecordsDao.php
-
33app/model/user/CreationArticleReceiveRecords.php
-
9app/route/admin.php
-
1app/route/route.php
-
99app/service/admin/ApiService.php
-
89app/service/user/ApiService.php
@ -0,0 +1,15 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\dao\user; |
||||
|
|
||||
|
use app\model\user\CreationArticleReceiveRecords; |
||||
|
use plugin\piadmin\app\base\UserBaseDao; |
||||
|
|
||||
|
class CreationArticleReceiveRecordsDao extends UserBaseDao |
||||
|
{ |
||||
|
protected function setModel(): string |
||||
|
{ |
||||
|
return CreationArticleReceiveRecords::class; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\model\user; |
||||
|
|
||||
|
use plugin\piadmin\app\base\BaseModel; |
||||
|
|
||||
|
/** |
||||
|
* 投稿记录模型 |
||||
|
*/ |
||||
|
class CreationArticleReceiveRecords extends BaseModel |
||||
|
{ |
||||
|
/** |
||||
|
* The table associated with the model. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $table = 'geo_creation_article_receive_records'; |
||||
|
|
||||
|
/** |
||||
|
* The primary key associated with the table. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $primaryKey = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* Indicates if the model should be timestamped. |
||||
|
* |
||||
|
* @var bool |
||||
|
*/ |
||||
|
public $timestamps = true; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\service\user; |
||||
|
|
||||
|
use app\dao\admin\OnlineMediasDao; |
||||
|
use app\dao\user\CreationArticleDao; |
||||
|
use app\dao\user\CreationArticleReceiveRecordsDao; |
||||
|
use plugin\piadmin\app\base\BaseService; |
||||
|
use plugin\piadmin\app\exception\ApiException; |
||||
|
|
||||
|
class ApiService extends BaseService |
||||
|
{ |
||||
|
//投稿接口
|
||||
|
protected $url = "http://www.meijiequan.cn/api/companyOrder/receive"; |
||||
|
protected $appkey = 'de06270f3515bad109aa1fd2c023dd41'; |
||||
|
|
||||
|
protected $onlineMediasDao; |
||||
|
protected $creationArticleDao; |
||||
|
protected $creationArticleReceiveRecordsDao; |
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
$this->onlineMediasDao = app()->make(OnlineMediasDao::class); |
||||
|
$this->creationArticleDao = app()->make(CreationArticleDao::class); |
||||
|
$this->creationArticleReceiveRecordsDao = app()->make(CreationArticleReceiveRecordsDao::class); |
||||
|
} |
||||
|
|
||||
|
public function receive($params) |
||||
|
{ |
||||
|
$article = $this->creationArticleDao->get($params['article_id']); |
||||
|
$media = $this->onlineMediasDao->get($params['media_id']); |
||||
|
$time_out = 60; |
||||
|
$url = $this->url; |
||||
|
//保存投稿记录
|
||||
|
$record = $this->creationArticleReceiveRecordsDao->save([ |
||||
|
'model_id' => $media['model_id'], |
||||
|
'article_id' => $article['id'], |
||||
|
'title' => $article['title'], |
||||
|
'content' => $article['content'], |
||||
|
'price_assign' => $media['price_assign'] |
||||
|
]); |
||||
|
if (!$record) { |
||||
|
throw new ApiException('投稿失败'); |
||||
|
} |
||||
|
//查文章,封装数据
|
||||
|
$prop = [ |
||||
|
'biaoti' => $article['title'], |
||||
|
'neirong' => $article['content'], |
||||
|
'laiyuan' => '', |
||||
|
'miaoshu' => '', |
||||
|
'leixing' => 1 |
||||
|
]; |
||||
|
//查媒体,封装数据
|
||||
|
$data = array ( |
||||
|
"model_id" => $media['model_id'], |
||||
|
"resource_id" => $media['id'], |
||||
|
"customer_order_id" => $record['id'], |
||||
|
"customer_batch_id" => $record['id'], |
||||
|
"out_model_id" => $media['model_id'], |
||||
|
"out_resource_id" => $media['id'], |
||||
|
"sale_id" => "0", |
||||
|
"sale_name" => "", |
||||
|
"prop"=> json_encode($prop, JSON_UNESCAPED_UNICODE) |
||||
|
); |
||||
|
//加密
|
||||
|
$app_key = $this->appkey; |
||||
|
$data_info = serialize($data); |
||||
|
$iv = random_bytes(16); |
||||
|
$info['iv'] = base64_encode($iv); |
||||
|
$info['value'] = openssl_encrypt($data_info, 'AES-256-CBC', $app_key, 0, |
||||
|
base64_decode($info['iv'])); |
||||
|
$encrypt = base64_encode(json_encode($info)); |
||||
|
$sign = md5($encrypt); |
||||
|
$result = ['response' => $encrypt, 'sign' => $sign, 'app_key' => $app_key]; |
||||
|
//curl
|
||||
|
$ch = curl_init(); |
||||
|
curl_setopt($ch, CURLOPT_URL, $url); |
||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); |
||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out); |
||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
||||
|
curl_setopt($ch, CURLOPT_POST, 1); |
||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $result); |
||||
|
$output = curl_exec($ch); |
||||
|
curl_close($ch); |
||||
|
return json_decode($output, true); |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue