123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?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,$url_type){
- $user_name = User::get(['id'=>$uid])['username'];
- $user_info = User::get(['id'=>$nid]);
- $data = [
- 'thing2'=>[
- 'value'=>$user_name
- ],
- 'time8'=>[
- 'value'=>$time
- ],
- 'phrase10'=>[
- 'value'=>$appeal
- ],
- ];
- $url = $url_type == 1?'/h5/#/pages/xiaoxi/look-me':'/h5/#/pages/xiaoxi/like-me';
- (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'VJNwruW2tQp4bG0K1gg_-HJ4vaougj6fELLED2OYcrI',$data,'http://'.$_SERVER['HTTP_HOST'].$url);
- }
- }
|