SmartPushMsgs.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Modules\OfficialAccount\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use DB;
  5. class SmartPushMsgs extends Model
  6. {
  7. protected $tables = 'smart_push_msgs';
  8. protected $fillable = ['appid', 'name','category_type', 'distribution_channel_id','content','sex','status','user_num','created_at','updated_at','description','book_name','chapter_name'];
  9. /**
  10. * 根据渠道获取自定义智能推送内容列表
  11. */
  12. static function smartPushMsgsBydistributionChannelId($distribtion_channel_id)
  13. {
  14. return self::where('distribution_channel_id', $distribtion_channel_id)->where('status', 1)->get();
  15. }
  16. /**
  17. * 根据渠道、分类获取自定义智能推送内容列表
  18. */
  19. static function smartPushByDistributionChannelIdAndCategorySex($distribtion_channel_id,$category_type,$sex)
  20. {
  21. return self::where('distribution_channel_id', $distribtion_channel_id)->where('category_type', $category_type)->where('sex', $sex)->first();
  22. }
  23. /**
  24. * 根据渠道、分类获取自定义智能推送内容列表
  25. */
  26. static function checkSexAllEdit($distribtion_channel_id,$category_type)
  27. {
  28. $man = self::smartPushByDistributionChannelIdAndCategorySex($distribtion_channel_id,$category_type,'a');
  29. $women = self::smartPushByDistributionChannelIdAndCategorySex($distribtion_channel_id,$category_type,'b');
  30. if(empty($man) || empty($women)){
  31. return false;
  32. }
  33. return true;
  34. }
  35. /**
  36. * 根据id获取自定义智能推送内容
  37. */
  38. static function smartPushMsgsById($id)
  39. {
  40. return self::where('id', $id)->first();
  41. }
  42. /**
  43. * 更新自定义智能推送内容状态
  44. */
  45. static function updateSmartPushMsgStatus($id,$status)
  46. {
  47. return self::where('id', $id)->update(['status'=>$status,'updated_at'=>date('Y-m-d H:i:s')]);
  48. }
  49. }