PushLog.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. use app\common\model\PushSmsMon;
  5. class PushLog extends BaseModel {
  6. const SEND_SMS = 1;
  7. const SEND_SYSTEM = 2;
  8. const SEND_PUSH = 3;
  9. const SEND_TMP_PUSH = 4;
  10. const SEND_SMS_MON = 5;
  11. const SEND_SMS_ZP_ACTIVITY = 6;
  12. // public static $tableName = 'push_logs';
  13. protected $name = 'push_logs';
  14. //content,mobiles,pub_name 必选参数--梦网群发短信
  15. public static function addSmsMon($content,$mobiles,$pubName,$isAll=0,$paramArray = [],$tmp_id = 0) {
  16. if(empty($isAll)&&empty($mobiles)){
  17. return false;
  18. }
  19. if(empty($content)){
  20. return false;
  21. }
  22. if(strlen($mobiles)>0&&$isAll==1){
  23. return false;
  24. }
  25. $remark = count(explode(',',$mobiles)).'人';
  26. $data = [
  27. 'ftype' => PushLog::SEND_SMS_MON,
  28. 'description' => $mobiles,
  29. 'pub_name' => $pubName,
  30. 'is_all'=>$isAll,
  31. 'content'=>$content,
  32. 'remark'=>$remark,
  33. 'sms_param'=>json_encode($paramArray),
  34. 'target_id'=>$tmp_id,
  35. 'total_receivers'=>0,//
  36. ];
  37. $id = Db::name("push_logs")->insertGetId($data);
  38. $pushLog = PushLog::where("id",$id)->find();
  39. $mon = new PushSmsMon;
  40. $mon->send($pushLog);
  41. return $id;
  42. }
  43. }