91 lines
3.0 KiB
PHP
91 lines
3.0 KiB
PHP
<?php
|
|
namespace app\admin\controller;
|
|
use app\common\controller\Admin;
|
|
use think\Request;
|
|
use think\Loader;
|
|
use think\Db;
|
|
//配置推送新注册用户
|
|
class Wxregpush extends Admin{
|
|
|
|
public function index(){
|
|
$pay = db('pay_setting')->field('id,price')->where('status',0)->select();
|
|
$pushinfo = db('wxregpush')->where('id',1)->find();
|
|
$pushinfotwo = db('wxregpush')->where('id',2)->find();
|
|
|
|
$this->setMeta('推送新用户配置');
|
|
$this->assign('pushinfotwo',$pushinfotwo);
|
|
$this->assign('pushinfo',$pushinfo);
|
|
$this->assign('pay',$pay);
|
|
return $this->fetch();
|
|
}
|
|
// 生成支付链接
|
|
public function getlink(){
|
|
$id = input('id');
|
|
$type = input('type');
|
|
$price = db('pay_setting')->where('id',$id)->value('price');
|
|
$payurl = config('web_site_url')."/pay/index/?type=".$price."&Regpush=".$id;
|
|
exit(json_encode(array('type'=>$type,'link'=>$payurl)));
|
|
|
|
}
|
|
|
|
public function savepush(){
|
|
$data = input('post.');
|
|
if($data){
|
|
$imgurl = request()->file('imgurl');
|
|
if($imgurl){
|
|
$img = $imgurl->move(ROOT_PATH . 'public' . DS . 'uploads');
|
|
if($img){
|
|
$imageurl = config('web_site_url').'/public'.'/'.'uploads'.'/'.$img->getSaveName();
|
|
compressedImage(ROOT_PATH.'/public'.'/'.'uploads'.'/'.$img->getSaveName(), ROOT_PATH.'/public'.'/'.'uploads'.'/'.$img->getSaveName(), 40);
|
|
@unlink(parseurl($data['gurl']));
|
|
}else{
|
|
echo $file->getError();
|
|
}
|
|
}else{
|
|
$imageurl = $data['gurl'];
|
|
}
|
|
|
|
$arr=array(
|
|
'open'=>$data['open'],
|
|
'title'=>$data['title'],
|
|
'pushtime'=>$data['pushtime'],
|
|
'url'=>$data['url'],
|
|
'd'=>$data['d'],
|
|
'imgurl'=>$imageurl
|
|
);
|
|
$res = db('wxregpush')->where('id',$data['id'])->update($arr);
|
|
if($res){
|
|
exit(json_encode(array('status'=>1,'reg'=>'成功')));
|
|
}else{
|
|
exit(json_encode(array('status'=>1,'reg'=>'保存失败')));
|
|
}
|
|
}
|
|
}
|
|
|
|
// 测试推送
|
|
public function ceshipush(){
|
|
$id = input('id');
|
|
$type = input('type');
|
|
if($id){
|
|
import("Wechatpush.Wechatpush", EXTEND_PATH,'.php');
|
|
$wxid = db('member')->where('uid',$id)->value('wxid');
|
|
if($wxid!=0){
|
|
$wx_config = db('wxopen_account')->field('appid,appsecret')->where('id',$wxid)->find();
|
|
$appid = $wx_config['appid'];
|
|
$secret= $wx_config['appsecret'];
|
|
$wx = new \Wechatpush($appid,$secret);
|
|
$data = db('wxregpush')->where('id',$type)->find();
|
|
$openid[] = db('member_userapi')->where('uid',$id)->value('wxmpid');
|
|
$wx->kefuImg($openid,$data['title'],$data['d'],$data['url'],$data['imgurl']);
|
|
exit(json_encode(array('status'=>1,'reg'=>'推送成功')));
|
|
}else{
|
|
exit(json_encode(array('status'=>2,'reg'=>'未绑定公众号')));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |