|
@@ -534,16 +534,22 @@ class Ai extends MemberApi
|
534
|
534
|
public function dsTitlelist()
|
535
|
535
|
{
|
536
|
536
|
//得到最后时间
|
537
|
|
- $row = Db::name('cms_ai')->where(['catid' => 13])->order('tb_time desc')->limit(1)->find();
|
|
537
|
+ $row = Db::name('cms_ai')->where([
|
|
538
|
+ 'catid' => 13
|
|
539
|
+ ])
|
|
540
|
+ ->order('tb_time desc')
|
|
541
|
+ ->limit(1)
|
|
542
|
+ ->find();
|
538
|
543
|
$lasttime = $row['tb_time'];
|
539
|
544
|
|
540
|
545
|
$list = Db::name('cms_zl')->where([
|
541
|
546
|
'catid'=>18,
|
542
|
|
- 'is_use' => 1,
|
|
547
|
+ 'is_use' => 1, //合法
|
543
|
548
|
'status' => 1,
|
544
|
|
- 'is_cf' => 0
|
|
549
|
+ 'is_cf' => 0, //是否重复
|
|
550
|
+ //'id'=>1199
|
545
|
551
|
])
|
546
|
|
- ->field('id,title,create_time')
|
|
552
|
+ ->field('id,title,create_time,is_use_id')
|
547
|
553
|
->where('create_time','>',$lasttime)
|
548
|
554
|
//->limit(10) //不能限制数量 不然时间查询 下次会漏掉某些时间相同的剩余数量 //要么使用状态字段 //要么使用自增id判断
|
549
|
555
|
->order('create_time asc') //必须asc排序 先入库
|
|
@@ -553,7 +559,40 @@ class Ai extends MemberApi
|
553
|
559
|
|
554
|
560
|
foreach ($list as $index=>$row) {
|
555
|
561
|
$one = Db::name('cms_ai')->field('id,title')->where(['catid' => 13])->where('title','=',$row['title'])->find();
|
|
562
|
+
|
556
|
563
|
if(empty($one)){
|
|
564
|
+
|
|
565
|
+ //$json = strip_tags(htmlspecialchars_decode($row['is_use_id']));
|
|
566
|
+ //echo $json;
|
|
567
|
+ $json = $row['is_use_id'];
|
|
568
|
+ $json = json_decode($json,true);
|
|
569
|
+ //dump($json);die;
|
|
570
|
+
|
|
571
|
+ //读取指令集
|
|
572
|
+ $zlj = $json['zlj'];
|
|
573
|
+
|
|
574
|
+ //获取创意
|
|
575
|
+ if((string)$json['is_sj'] === '-1'){
|
|
576
|
+ //不需要加创意
|
|
577
|
+ $cy = '0';
|
|
578
|
+ }else{
|
|
579
|
+ if((int)$json['is_sj'] > 0){
|
|
580
|
+ //既然指定 不管管是否为空
|
|
581
|
+ $cy = $json['cy'.$json['is_sj']];
|
|
582
|
+ }else{
|
|
583
|
+ //随机
|
|
584
|
+ $sj_num = [];
|
|
585
|
+ for($i=1;$i<=6;$i++){
|
|
586
|
+ if(!empty($json['cy'.$i])){
|
|
587
|
+ $sj_num[] = $i;
|
|
588
|
+ }
|
|
589
|
+ }
|
|
590
|
+ $randomKey = array_rand($sj_num);
|
|
591
|
+ $num = $sj_num[$randomKey];
|
|
592
|
+ $cy = $json['cy'.$num];
|
|
593
|
+ }
|
|
594
|
+ }
|
|
595
|
+
|
557
|
596
|
//不存在于ai中
|
558
|
597
|
$data = [
|
559
|
598
|
'catid' => 13,
|
|
@@ -569,6 +608,12 @@ class Ai extends MemberApi
|
569
|
608
|
'create_time' => time(),
|
570
|
609
|
'update_time' => time(),
|
571
|
610
|
'status' => 0, //默认手动开启
|
|
611
|
+ 'cy' => $cy, //创意
|
|
612
|
+ 'zlj' => $zlj, //指令集 json字符串
|
|
613
|
+ 'sjcy' => $json['is_sj'], //随机创意
|
|
614
|
+ 'lyjlid' => $row['id'], //来源id
|
|
615
|
+ 'sblx' => 3,//设别类型 电脑A
|
|
616
|
+ 'is_sc' => 0, //是否生成文章
|
572
|
617
|
];
|
573
|
618
|
$run = Db::name('cms_ai')->insert($data);
|
574
|
619
|
Db::name('cms_zl')->where('id',$row['id'])->update(['is_cf'=>2]); //已检测 同步
|