0
0

SmsLog.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Exception;
  5. class SmsLog extends Base
  6. {
  7. public function addLog($mobiles,$msg,$orgId=0,$fromId=0,$type=1){
  8. try{
  9. // 短信日志
  10. $mobiles = explode(',',$mobiles);
  11. $curTime = date('Y-m-d H:i:s');
  12. $arr = [];
  13. foreach ($mobiles as $k=>$v){
  14. $arr[] = [
  15. 'phone' => $v,
  16. 'org_id' => $orgId,
  17. 'from_id' => $fromId,
  18. 'type' => $type,
  19. 'content' => $msg,
  20. 'create_time' => $curTime
  21. ];
  22. if(count($arr) == 50){
  23. Db::name('sms_log')->insertAll($arr);
  24. $arr = [];
  25. }
  26. }
  27. if($arr){
  28. Db::name('sms_log')->insertAll($arr);
  29. }
  30. return true;
  31. }catch (Exception $e){
  32. trace($e->getMessage());
  33. return false;
  34. }
  35. }
  36. }