<?php namespace app\common\model; use think\Db; use think\Exception; class SmsLog extends Base { public function addLog($mobiles,$msg,$orgId=0,$fromId=0,$type=1){ try{ // 短信日志 $mobiles = explode(',',$mobiles); $curTime = date('Y-m-d H:i:s'); $arr = []; foreach ($mobiles as $k=>$v){ $arr[] = [ 'phone' => $v, 'org_id' => $orgId, 'from_id' => $fromId, 'type' => $type, 'content' => $msg, 'create_time' => $curTime ]; if(count($arr) == 50){ Db::name('sms_log')->insertAll($arr); $arr = []; } } if($arr){ Db::name('sms_log')->insertAll($arr); } return true; }catch (Exception $e){ trace($e->getMessage()); return false; } } }