WechatMaterialSendMsg.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Modules\WechatMaterial\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class WechatMaterialSendMsg extends Model
  5. {
  6. protected $table = 'wechat_material_send_msgs';
  7. protected $connection = 'api_mysql';
  8. protected $fillable = ['batch_id', 'distribution_channel_id', 'appid', 'name', 'wechat_material_id', 'wechat_media_id',
  9. 'status', 'send_user_num', 'receive_user_num', 'first_day_material_uv', 'first_day_url_uv', 'del_flag', 'upload_result',
  10. 'created_at', 'updated_at'];
  11. public static function get_zs_wechat_batch_distribution_infos($batch_id)
  12. {
  13. return self::where('batch_id', $batch_id)->select('batch_id', 'distribution_channel_id', 'appid')->get();
  14. }
  15. public static function get_infos_by_batch_id($batch_id,$columns=[])
  16. {
  17. if(!isset($columns))
  18. {
  19. $columns ='*';
  20. }
  21. return self::where('batch_id', $batch_id)->select($columns)->get();
  22. }
  23. /**
  24. * 根据状态获取客服消息
  25. */
  26. public static function wechatCustomMsgsByStatus($status)
  27. {
  28. return self::where(['status' => $status, 'del_flag' => 0])->get();
  29. }
  30. public static function getMsgByAppBatchChannelId($appId, $batchId, $channelId)
  31. {
  32. $where = ['appid' => $appId, 'batch_id' => $batchId, 'distribution_channel_id' => $channelId];
  33. $result = self::where($where)->first();
  34. return $result ? $result->toArray() : [];
  35. }
  36. /**
  37. *
  38. * @return mixed
  39. */
  40. public static function getUnCollectedList()
  41. {
  42. $result = self::whereNull('first_day_material_uv')->get();
  43. return $result;
  44. }
  45. }