|
@@ -423,6 +423,27 @@ class Ai extends MemberApi
|
423
|
423
|
//12.判断是否合法 同时存在触发词和并发词
|
424
|
424
|
[$is_bh1,$fc1] = $this->isInRule($data['cfc'],$line);
|
425
|
425
|
[$is_bh2,$fc2] = $this->isInRule($data['bfc'],$line);
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+ //13.替换指令的变量
|
|
429
|
+ //var_dump($data['zlj']);die;
|
|
430
|
+ if(!empty($data['zlj'])){
|
|
431
|
+ $zlj = json_decode($data['zlj'],true);
|
|
432
|
+ $zlj_new = [];
|
|
433
|
+ foreach ($zlj as $k => $v) {
|
|
434
|
+ $key = ''.(string)$k.'';
|
|
435
|
+ if (strpos($v,'K') !== false) {
|
|
436
|
+ $v_str = str_replace("K", $line, $v);
|
|
437
|
+ $zlj_new[$key] = $v_str;
|
|
438
|
+ }else{
|
|
439
|
+ $zlj_new[$key] = $v;
|
|
440
|
+ }
|
|
441
|
+ }
|
|
442
|
+ $zlj_new_json = json_encode($zlj_new,JSON_UNESCAPED_UNICODE);
|
|
443
|
+ $data['zlj'] = $zlj_new_json;
|
|
444
|
+ //var_dump($zlj_new_json);die;
|
|
445
|
+ }
|
|
446
|
+
|
426
|
447
|
if($is_bh1 > 0 && $is_bh2 > 0){
|
427
|
448
|
//同时存在
|
428
|
449
|
$desc .= '同时存在并发词['.$fc2.']和触发词['.$fc1.']合法';
|
|
@@ -540,7 +561,14 @@ class Ai extends MemberApi
|
540
|
561
|
->order('tb_time desc')
|
541
|
562
|
->limit(1)
|
542
|
563
|
->find();
|
543
|
|
- $lasttime = $row['tb_time'];
|
|
564
|
+
|
|
565
|
+ //var_dump($row);
|
|
566
|
+
|
|
567
|
+ if(isset($row['tb_time'])){
|
|
568
|
+ $lasttime = $row['tb_time'];
|
|
569
|
+ }else{
|
|
570
|
+ $lasttime = 0;
|
|
571
|
+ }
|
544
|
572
|
|
545
|
573
|
$list = Db::name('cms_zl')->where([
|
546
|
574
|
'catid'=>18,
|
|
@@ -570,6 +598,12 @@ class Ai extends MemberApi
|
570
|
598
|
|
571
|
599
|
//读取指令集
|
572
|
600
|
$zlj = $json['zlj'];
|
|
601
|
+ $zlj_arr = json_decode($zlj,true);
|
|
602
|
+ $zlj_end = end($zlj_arr);
|
|
603
|
+ $key = count($zlj_arr)-1;
|
|
604
|
+ unset($zlj_arr[$key]);
|
|
605
|
+ $zlj = json_encode($zlj_arr,JSON_UNESCAPED_UNICODE);
|
|
606
|
+
|
573
|
607
|
|
574
|
608
|
//获取创意
|
575
|
609
|
if((string)$json['is_sj'] === '-1'){
|
|
@@ -580,16 +614,23 @@ class Ai extends MemberApi
|
580
|
614
|
//既然指定 不管管是否为空
|
581
|
615
|
$cy = $json['cy'.$json['is_sj']];
|
582
|
616
|
}else{
|
|
617
|
+
|
583
|
618
|
//随机
|
|
619
|
+
|
|
620
|
+
|
584
|
621
|
$sj_num = [];
|
585
|
622
|
for($i=1;$i<=6;$i++){
|
586
|
623
|
if(!empty($json['cy'.$i])){
|
587
|
624
|
$sj_num[] = $i;
|
588
|
625
|
}
|
589
|
626
|
}
|
590
|
|
- $randomKey = array_rand($sj_num);
|
591
|
|
- $num = $sj_num[$randomKey];
|
592
|
|
- $cy = $json['cy'.$num];
|
|
627
|
+ if(!empty($sj_num)){
|
|
628
|
+ $randomKey = array_rand($sj_num);
|
|
629
|
+ $num = $sj_num[$randomKey];
|
|
630
|
+ $cy = $json['cy'.$num];
|
|
631
|
+ }else{
|
|
632
|
+ $cy = '0';
|
|
633
|
+ }
|
593
|
634
|
}
|
594
|
635
|
}
|
595
|
636
|
|
|
@@ -610,6 +651,7 @@ class Ai extends MemberApi
|
610
|
651
|
'status' => 0, //默认手动开启
|
611
|
652
|
'cy' => $cy, //创意
|
612
|
653
|
'zlj' => $zlj, //指令集 json字符串
|
|
654
|
+ 'tpzl' => $zlj_end,
|
613
|
655
|
'sjcy' => $json['is_sj'], //随机创意
|
614
|
656
|
'lyjlid' => $row['id'], //来源id
|
615
|
657
|
'sblx' => 3,//设别类型 电脑A
|