123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace app\common\model;
- use app\api\controller\Common;
- use think\Model;
- class Apply extends Model
- {
- // 表名
- protected $name = 'apply';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- ];
- /**
- * uid资料
- */
- public function uidinfo(){
- return $this->belongsTo('User','uid','id',[],'LEFT');
- }
- /**
- * 申请我的
- */
- public function applyme(){
- return $this->belongsTo('User','nid','id',[],"LEFT")/*->field('id,id_authentication,avatar,username,avatar')*/;
- }
- /**
- * 被申请信息
- */
- public function Nuser(){
- return $this->belongsTo('User','nid','id',[],"LEFT")->field('id,id_authentication,avatar,username,avatar,wx');
- }
- public static function n_read($arr){
- foreach ($arr as $v){
- Apply::update(['n_is_read'=>1],['id'=>$v['id']]);
- }
- }
- public static function u_read($arr){
- foreach ($arr as $v){
- Apply::update(['u_is_read'=>1],['id'=>$v['id']]);
- }
- }
- /**
- * 微信服务号通知
- */
- public static function wxMessage($id,$time){
- $user_name = User::get(['id'=>$id]);
- $data = [
- 'keyword1'=>[
- 'value'=>$user_name['username']
- ],
- 'keyword2'=>[
- 'value'=>$time
- ],
- ];
- (new \app\api\controller\Common())->sendWechatMessage($user_name['open_id'],'SDrPJvTOgm03PnQHibVlguD3lra3nK9pknojcMjSXq8',$data,'https://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/shenqing-me');
- }
- /**
- * 微信模板消息通知(访客到访)
- */
- public static function wxVisitorMessage($user_name,$nid,$time){
- $user_info = User::get(['id'=>$nid]);
- $data = [
- 'thing1'=>[
- 'value'=>$user_name
- ],
- 'time3'=>[
- 'value'=>$time
- ],
- ];
- (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'KOWDFd4MsuxROCPCLNZF5k5LHzM_-o-WoEI2NpfQYx0',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/look-me');
- }
- /**
- * 微信模板消息通知(喜欢我,解锁照片,解锁资料)$url_type(1:解锁照片/资料,2:喜欢)
- */
- public static function wxUnlockMessage($uid,$nid,$time,$appeal_type){
- $user_name = User::get(['id'=>$uid])['username'];
- $user_info = User::get(['id'=>$nid]);
- if($appeal_type == 1){ //喜欢我
- $appeal = '喜欢了你';
- }elseif ($appeal_type == 2){ //解锁照片
- $appeal = '解锁了你';
- }else{ //解锁资料
- $appeal = '解锁了你';
- }
- $data = [
- 'thing2'=>[
- 'value'=>$user_name
- ],
- 'time8'=>[
- 'value'=>$time
- ],
- 'phrase10'=>[
- 'value'=>$appeal
- ],
- ];
- $url = $appeal_type == 1?'/h5/#/pages/xiaoxi/like-me':'/h5/#/pages/xiaoxi/look-me';
- (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'VJNwruW2tQp4bG0K1gg_-HJ4vaougj6fELLED2OYcrI',$data,'http://'.$_SERVER['HTTP_HOST'].$url);
- }
- /**
- * 微信模板消息通知(申请通过、被拒、过期)
- */
- public static function wxApplyMessage($uid,$nid,$time,$appeal_type){
- $user_name = User::get(['id'=>$uid])['username'];
- $user_info = User::get(['id'=>$nid]);
- if($appeal_type == 1){ //通过
- $appeal = '已通过申请啦';
- }elseif ($appeal_type == 2){ //拒绝
- $appeal = '暂时不合适';
- }else{ //过期
- $appeal = '已经过期啦';
- }
- $data = [
- 'thing7'=>[
- 'value'=>$user_name
- ],
- 'time4'=>[
- 'value'=>$time
- ],
- 'thing3'=>[
- 'value'=>$appeal
- ],
- ];
- (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'bNR9STIj3_z7PwuXLNAEjGELj31DerERhXixAJqf3to',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/my-shenqing');
- }
- /**
- * 微信模板消息通知(申请认识)
- */
- public static function wxKnowMessage($uid,$nid,$time){
- $user_name = User::get(['id'=>$uid])['username'];
- $user_info = User::get(['id'=>$nid]);
- $data = [
- 'thing17'=>[
- 'value'=>$user_name
- ],
- 'time5'=>[
- 'value'=>$time
- ],
- 'thing9'=>[
- 'value'=>'想认识一下你'
- ],
- ];
- (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'rPRvrkJ7QYwGpANXf6sOU4YyrejhUh70ow7dSdCXxU8',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/look-me');
- }
- /**
- * 微信模板消息通知(头像,学历,工作审核通知)
- */
- public static function wxAuditMessage($uid,$type,$status){
- $open_id = User::get(['id'=>$uid])['open_id'];
- if($type == 1){ //头像
- $appeal = '头像';
- }elseif ($type == 2){ //拒绝
- $appeal = '学历';
- }else{ //过期
- $appeal = '工作';
- }
- $status_name = $status == 1?'审核通过':'审核驳回';
- $appeal .= '审核';
- $data = [
- 'thing2'=>[
- 'value'=>$appeal
- ],
- 'thing3'=>[
- 'value'=>$status_name
- ],
- ];
- (new \app\api\controller\Common())->sendWechatMessage($open_id,'Tfe62uA5N34evu_Z7jf-OE0NK6hJ6nFYTsZXG6yIqSY',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/system');
- }
- }
|