online状态和publish状态下的文章查询是否推送到微信公众号
This commit is contained in:
@@ -4,7 +4,7 @@ namespace app\api\controller;
|
||||
|
||||
use app\api\controller\Base;
|
||||
use think\Validate;
|
||||
|
||||
use think\Db;
|
||||
/**
|
||||
* @title 公共管理相关
|
||||
* @description 公共管理相关
|
||||
@@ -37,6 +37,17 @@ class Publish extends Base
|
||||
|
||||
$stages = $res['data']['stages'];
|
||||
foreach ($stages as $k =>$v){
|
||||
|
||||
//获取微信公众号文章状态 chengxiaoling 20250522 start
|
||||
if(empty($v['articles'])){
|
||||
continue;
|
||||
}
|
||||
$aArticleId = array_column($v['articles'], 'article_id');
|
||||
$aWechatArticle = $this->getWechatInfo($aArticleId);
|
||||
$aAiArticle = empty($aWechatArticle['ai_article']) ? [] : $aWechatArticle['ai_article'];
|
||||
$aAiWechatArticle = empty($aWechatArticle['ai_wechat_article']) ? [] : $aWechatArticle['ai_wechat_article'];
|
||||
//获取微信公众号文章状态 chengxiaoling 20250522 end
|
||||
|
||||
foreach ($v['articles'] as $key =>$val){
|
||||
$a = explode('/',$val['doi']);
|
||||
if(!isset($a[1])){
|
||||
@@ -49,6 +60,25 @@ class Publish extends Base
|
||||
}
|
||||
$stages[$k]['articles'][$key]['tg_article_id'] = $pro_info['article_id'];
|
||||
$stages[$k]['articles'][$key]['p_article_id'] = $pro_info['p_article_id'];
|
||||
|
||||
//获取微信公众号文章状态 chengxiaoling 20250522 start
|
||||
$stages[$k]['articles'][$key]['ai_wechat_status'] = 2; //1 Ai内容已生成 2ai内容未生成
|
||||
if(in_array($val['article_id'],$aAiArticle)){
|
||||
$stages[$k]['articles'][$key]['ai_wechat_status'] = 1;
|
||||
//是否推送到微信
|
||||
$aDraft = empty($aAiWechatArticle[$val['article_id']]) ? [] : $aAiWechatArticle[$val['article_id']];
|
||||
$stages[$k]['articles'][$key]['ai_wechat_status'] = empty($aDraft) ? 3 : 4; //3 未生成草稿 4 已生成草稿未发布 10 发布成功 11 发布中 >11发布失败
|
||||
if(!empty($aDraft)){
|
||||
foreach ($aDraft as $key => $value) {
|
||||
if($key == '-1'){
|
||||
$stages[$k]['articles'][$key]['ai_wechat_status'] = 4;
|
||||
}else{
|
||||
$stages[$k]['articles'][$key]['ai_wechat_status'] = '1'.$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//获取微信公众号文章状态 chengxiaoling 20250522 end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +296,12 @@ class Publish extends Base
|
||||
$res = object_to_array(json_decode(myPost($url, $pra)));
|
||||
|
||||
$articles = $res['data']["articleList"];
|
||||
|
||||
if(!empty($articles)){
|
||||
$aArticleId = array_column($articles, 'article_id');
|
||||
$aWechatArticle = $this->getWechatInfo($aArticleId);
|
||||
$aAiArticle = empty($aWechatArticle['ai_article']) ? [] : $aWechatArticle['ai_article'];
|
||||
$aAiWechatArticle = empty($aWechatArticle['ai_wechat_article']) ? [] : $aWechatArticle['ai_wechat_article'];
|
||||
}
|
||||
foreach ($articles as $k => $v){
|
||||
$a = explode('/',$v['doi']);
|
||||
if(!isset($a[1])){
|
||||
@@ -284,6 +319,25 @@ class Publish extends Base
|
||||
$articles[$k]['p_article_id'] = $pro_info['p_article_id'];
|
||||
$articles[$k]['tg_article_id'] = $pro_info['article_id'];
|
||||
$articles[$k]['refers'] = [];//$this->production_article_refer_obj->where("p_article_id",$pro_info['p_article_id'])->where('state',0)->order("index")->select();
|
||||
|
||||
//AI内容是否生成 chengxiaoling 20250522 start
|
||||
$articles[$k]['ai_wechat_status'] = 2;
|
||||
if(in_array($v['article_id'],$aAiArticle)){
|
||||
$articles[$k]['ai_wechat_status'] = 1;
|
||||
//是否推送到微信
|
||||
$aDraft = empty($aAiWechatArticle[$v['article_id']]) ? [] : $aAiWechatArticle[$v['article_id']];
|
||||
$articles[$k]['ai_wechat_status'] = empty($aDraft) ? 3 : 4; //3 未生成草稿 4 已生成草稿
|
||||
if(!empty($aDraft)){
|
||||
foreach ($aDraft as $key => $value) {
|
||||
if($key == '-1'){
|
||||
$articles[$k]['ai_wechat_status'] = 4;
|
||||
}else{
|
||||
$articles[$k]['ai_wechat_status'] = '1'.$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//AI内容是否生成 chengxiaoling 20250522 end
|
||||
}
|
||||
|
||||
$re['count'] = $res['data']["count"];
|
||||
@@ -663,5 +717,31 @@ class Publish extends Base
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信公众号相关数量
|
||||
*/
|
||||
public function getWechatInfo($aArticleId){
|
||||
|
||||
if(empty($aArticleId)){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取文章生成记录
|
||||
$aWhere = ['article_id' => ['in',$aArticleId],'is_delete' => 2];
|
||||
$aAiArticle = Db::name('ai_article')->where($aWhere)->column('article_id');
|
||||
if(!empty($aAiArticle)){
|
||||
//获取推送到草稿箱否
|
||||
$aWhere['article_id'] = ['in',$aAiArticle];
|
||||
$ai_wechat_article = Db::name('ai_wechat_article')->field('article_id,template_id,wechat_id,is_publish,publish_status')->where($aWhere)->select();
|
||||
if(!empty($ai_wechat_article)){
|
||||
foreach ($ai_wechat_article as $key => $value) {
|
||||
$aWechatArticle[$value['article_id']][$value['publish_status']][] = $value['template_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($ai_wechat_article);
|
||||
//返回数据
|
||||
return ['ai_article' => $aAiArticle,'ai_wechat_article' => empty($aWechatArticle) ? [] : $aWechatArticle];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user