Apply.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\common\model;
  3. use app\api\controller\Common;
  4. use think\Model;
  5. class Apply extends Model
  6. {
  7. // 表名
  8. protected $name = 'apply';
  9. // 自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'integer';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. protected $updateTime = false;
  14. protected $deleteTime = false;
  15. // 追加属性
  16. protected $append = [
  17. ];
  18. /**
  19. * uid资料
  20. */
  21. public function uidinfo(){
  22. return $this->belongsTo('User','uid','id',[],'LEFT');
  23. }
  24. /**
  25. * 申请我的
  26. */
  27. public function applyme(){
  28. return $this->belongsTo('User','nid','id',[],"LEFT")/*->field('id,id_authentication,avatar,username,avatar')*/;
  29. }
  30. /**
  31. * 被申请信息
  32. */
  33. public function Nuser(){
  34. return $this->belongsTo('User','nid','id',[],"LEFT")->field('id,id_authentication,avatar,username,avatar,wx');
  35. }
  36. public static function n_read($arr){
  37. foreach ($arr as $v){
  38. Apply::update(['n_is_read'=>1],['id'=>$v['id']]);
  39. }
  40. }
  41. public static function u_read($arr){
  42. foreach ($arr as $v){
  43. Apply::update(['u_is_read'=>1],['id'=>$v['id']]);
  44. }
  45. }
  46. /**
  47. * 微信服务号通知
  48. */
  49. public static function wxMessage($id,$time){
  50. $user_name = User::get(['id'=>$id]);
  51. $data = [
  52. 'keyword1'=>[
  53. 'value'=>$user_name['username']
  54. ],
  55. 'keyword2'=>[
  56. 'value'=>$time
  57. ],
  58. ];
  59. (new \app\api\controller\Common())->sendWechatMessage($user_name['open_id'],'SDrPJvTOgm03PnQHibVlguD3lra3nK9pknojcMjSXq8',$data,'https://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/shenqing-me');
  60. }
  61. /**
  62. * 微信模板消息通知(访客到访)
  63. */
  64. public static function wxVisitorMessage($user_name,$nid,$time){
  65. $user_info = User::get(['id'=>$nid]);
  66. $data = [
  67. 'thing1'=>[
  68. 'value'=>$user_name
  69. ],
  70. 'time3'=>[
  71. 'value'=>$time
  72. ],
  73. ];
  74. (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'KOWDFd4MsuxROCPCLNZF5k5LHzM_-o-WoEI2NpfQYx0',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/look-me');
  75. }
  76. /**
  77. * 微信模板消息通知(喜欢我,解锁照片,解锁资料)$url_type(1:解锁照片/资料,2:喜欢)
  78. */
  79. public static function wxUnlockMessage($uid,$nid,$time,$appeal,$url_type){
  80. $user_name = User::get(['id'=>$uid])['username'];
  81. $user_info = User::get(['id'=>$nid]);
  82. $data = [
  83. 'thing2'=>[
  84. 'value'=>$user_name
  85. ],
  86. 'time8'=>[
  87. 'value'=>$time
  88. ],
  89. 'phrase10'=>[
  90. 'value'=>$appeal
  91. ],
  92. ];
  93. $url = $url_type == 1?'/h5/#/pages/xiaoxi/look-me':'/h5/#/pages/xiaoxi/like-me';
  94. (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'VJNwruW2tQp4bG0K1gg_-HJ4vaougj6fELLED2OYcrI',$data,'http://'.$_SERVER['HTTP_HOST'].$url);
  95. }
  96. }