作者 邓超

预热 逻辑

@@ -86,7 +86,8 @@ class HotMail { @@ -86,7 +86,8 @@ class HotMail {
86 private function findList(Data $data, int $p = 1){ 86 private function findList(Data $data, int $p = 1){
87 $lists = db()->all( 87 $lists = db()->all(
88 sprintf( 88 sprintf(
89 - "select `id`,`folder_id`,`email_id`,`from` from `lists` where `id` > %d and `email_id` = %d and `folder_id` = %d and (select count(*) from `fob_hot_mail` where `lists`.`id` = `fob_hot_mail`.`lists_id`) = 0 order by `id` asc limit 1000 offset ".(($p-1)*1000), 89 + "select `id`,`folder_id`,`email_id`,`%s` from `lists` where `id` > %d and `email_id` = %d and `folder_id` = %d and (select count(*) from `fob_hot_mail` where `lists`.`id` = `fob_hot_mail`.`lists_id`) = 0 order by `id` asc limit 1000 offset ".(($p-1)*1000),
  90 + $data->type=='s' ? 'from':'to_name', // 收件箱查询 from字段 发件箱 查询 to_name字段
90 $data->last_id, 91 $data->last_id,
91 $data->email_id, 92 $data->email_id,
92 $data->folder_id 93 $data->folder_id
@@ -113,8 +114,26 @@ class HotMail { @@ -113,8 +114,26 @@ class HotMail {
113 * @time 2024/7/18 15:25 114 * @time 2024/7/18 15:25
114 */ 115 */
115 private function insertData(array $data){ 116 private function insertData(array $data){
  117 + $isInsert = false;
  118 + if($data['folder'] == 's'){
  119 + // 收件箱 匹配 from 字段
  120 + $isInsert = in_array($data['from'],$this->shopkHotEmail);
  121 + }else{
  122 + // 发件箱 匹配 to_name字段
  123 + $to_name = is_array($data['to_name']) ? $data['to_name'] : @json_decode($data['to_name'],1);
  124 + if($to_name){
  125 + foreach ($to_name as $item){
  126 + // 找到了就退出去
  127 + if(in_array($item['email'],$this->shopkHotEmail)){
  128 + $isInsert = true;
  129 + break;
  130 + }
  131 + }
  132 + }
  133 + }
  134 +
116 // 是预热 邮箱发来的邮件 135 // 是预热 邮箱发来的邮件
117 - if(in_array($data['from'],$this->shopkHotEmail)){ 136 + if($isInsert){
118 // 不存在 数据 137 // 不存在 数据
119 if(db()->count("select count(*) from `fob_hot_mail` where `lists_id` = ".$data['id']) == 0){ 138 if(db()->count("select count(*) from `fob_hot_mail` where `lists_id` = ".$data['id']) == 0){
120 db()->insert('fob_hot_mail',[ 139 db()->insert('fob_hot_mail',[