797 行
31 KiB
PHP
可执行文件
797 行
31 KiB
PHP
可执行文件
<?php
|
|
namespace Super\Controller;
|
|
//[1.0.63]
|
|
use Think\Controller;
|
|
|
|
class ConfigController extends BaseController{
|
|
public function _initialize(){
|
|
$sign = M("retail_admin")->getField("sign");
|
|
if(empty($sign)){
|
|
$request = getSign();
|
|
if(!$request["status"]){
|
|
$this->error($request["errmsg"]);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
//检测是否上传
|
|
public function checkUp(){
|
|
$url = "http://console.mobzhifu.com/index.php/OpenApi/Xcxapi/checkUp";
|
|
$item = $this->getCommonData();
|
|
$token = I("post.token");
|
|
$item["token"] = $token;
|
|
$item["sign"] = sign($item);
|
|
$re = curl_get($url,$item);
|
|
$infoData = json_decode($re,true);
|
|
if(!$infoData["errno"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "上传成功";
|
|
$data["data"] = $infoData;
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "上传失败,错误原因:".$infoData["errmsg"];
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
//上传零售小程序
|
|
public function uploadTemplate(){
|
|
$url = "http://console.mobzhifu.com/index.php/OpenApi/Xcxapi/xcxUpload";
|
|
$item = $this->getCommonData();
|
|
//上传小程序
|
|
$item["appid"] = I("post.appid");
|
|
$item["token"] = I("post.token");
|
|
$item["version"] = I("post.version");
|
|
$item["desc"] = I("post.desc");
|
|
$item["xcxid"] = I("post.xcxid");
|
|
$item["sign"] = sign($item);
|
|
$re = curl_get($url,$item);
|
|
$infoData = json_decode($re,true);
|
|
if(!$infoData["errno"]){
|
|
$this->sendUpdate();
|
|
$data["status"] = 1;
|
|
$data["msg"] = "上传成功";
|
|
$data["data"] = $infoData;
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "上传失败,错误原因:".$infoData["errmsg"];
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
public function sendUpdate($versionid,$runtime){
|
|
$data = $this->getCommonData();
|
|
$url = "http://console.mobzhifu.com/index.php/VersionApi/Version/Versionlog";
|
|
$data["appid"] = 4;
|
|
$data["type"] = 2;
|
|
$data["versionid"] = $versionid;
|
|
$data["time"] = $runtime;
|
|
curl_get($url,$data);
|
|
}
|
|
//创建上传小程序页面上传
|
|
public function xcxUpload(){
|
|
$this->assign("xcxid",I('get.xcxid'));
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* 获取公共函数
|
|
*/
|
|
private function getCommonData(){
|
|
$cache = M("retail_admin")->find();
|
|
$phone = $cache["phone"];
|
|
$domain = C("adminhttp");
|
|
$item["phone"] = $phone;
|
|
$item["site"] = $domain;
|
|
return $item;
|
|
}
|
|
//创建检测是否登录成功的方法
|
|
public function checkLogin(){
|
|
$url = "http://console.mobzhifu.com/index.php/OpenApi/Xcxapi/checkLogin";
|
|
$item = $this->getCommonData();
|
|
$token = I("post.token");
|
|
$item["token"] = $token;
|
|
$item["sign"] = sign($item);
|
|
$re = curl_get($url,$item);
|
|
$infoData = json_decode($re,true);
|
|
if(!$infoData["errno"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "登录成功";
|
|
$data["data"] = $infoData;
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "登录失败,错误原因:".$infoData["errmsg"];
|
|
}
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
//获取服务器开发工具的上传二维码
|
|
public function qrcode(){
|
|
//请求接口生成二维码
|
|
$url = "http://console.mobzhifu.com/index.php/OpenApi/Xcxapi/loginCode";
|
|
$item = $this->getCommonData();
|
|
$token = substr($item["phone"],2).time();
|
|
$item["token"] = $token;
|
|
$item["sign"] = sign($item);
|
|
$re = curl_get($url,$item);
|
|
$infoData = json_decode($re,true);
|
|
if(!$infoData["errno"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "获取成功";
|
|
$data["data"] = $infoData;
|
|
$data["token"] = $token;
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "获取失败,错误原因:".$infoData["errmsg"];
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
public function getVersionInfo(){
|
|
if(IS_POST){
|
|
$cache = M("retail_admin")->find();
|
|
$phone = $cache["phone"];
|
|
$domain = C("adminhttp");
|
|
$xcxid = I("post.xcxid");
|
|
$item["phone"] = $phone;
|
|
$url = "http://console.mobzhifu.com/index.php/OpenApi/Xcxapi/getxcxInfo";
|
|
$item["xcxid"] = $xcxid;
|
|
$item["site"] = $domain;
|
|
$item["sign"] = sign($item);
|
|
$re = curl_get($url,$item);
|
|
$infoData = json_decode($re,true);
|
|
if(!$infoData["errno"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "获取成功";
|
|
$data["data"] = $infoData;
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "获取失败,错误原因:".$infoData["errmsg"];
|
|
}
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "参数不全,请检查";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
//把参数修改成本机的外网地址
|
|
public function makefile(){
|
|
$ip = I("post.ip");
|
|
$str = file_get_contents("./Public/tpl/worker.tpl");
|
|
$str = str_replace("[ip]",$ip,$str);
|
|
$re = file_put_contents("./Worker/Applications/YourApp/start_text_gateway.php",$str);
|
|
if($re){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "文件替换成功";
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "文件替换失败";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
/**
|
|
* 保存websocket参数
|
|
*/
|
|
public function addWebsocket(){
|
|
$ip = I("post.ip");
|
|
$client = I("post.client");
|
|
$status = I("post.status");
|
|
if(!empty($ip)&&!empty($client)){
|
|
$webData["ip"] = $ip;
|
|
$webData["client"] = $client;
|
|
$webData["status"] = $status;
|
|
$re = D("Websocket")->SaveWebsocket($webData);
|
|
if($re){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "配置成功";
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "添加失败";
|
|
}
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "缺少参数";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
/**
|
|
* @desc 选择模板信息
|
|
*/
|
|
public function chooseTemplate(){
|
|
$id = I("post.templateid");
|
|
$data['version'] = $id;
|
|
$cache = M('Appweixin')->where("id = 1")->save($data);
|
|
if($cache!==false){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "切换成功";
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "切换失败";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
//删除草稿箱内容
|
|
public function del_Drafts(){
|
|
$id = I("post.id");
|
|
$access_token = get_acc_token();
|
|
$url = "https://api.weixin.qq.com/wxa/deletetemplate?access_token=".$access_token;
|
|
$data["template_id"] = $id;
|
|
$dataJson = json_encode($data);
|
|
$responses = curl_get($url,$dataJson);
|
|
$results = json_decode($responses, true);
|
|
if(!$results["errcode"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "模板删除成功";
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "模板删除失败";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
//添加代码到模板库
|
|
public function addTemplate(){
|
|
$id = I("post.id");
|
|
$access_token = get_acc_token();
|
|
$url = "https://api.weixin.qq.com/wxa/addtotemplate?access_token=".$access_token;
|
|
$data["draft_id"] = $id;
|
|
$dataJson = json_encode($data);
|
|
$responses = curl_get($url,$dataJson);
|
|
$results = json_decode($responses, true);
|
|
if(!$results["errcode"]){
|
|
$data["status"] = 1;
|
|
$data["msg"] = "添加模板库添加成功";
|
|
}else{
|
|
$data["status"] = 0;
|
|
$data["msg"] = "添加模板库添加失败,失败原因".$results["errmsg"];
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
public function getDrafts(){
|
|
$access_token = get_acc_token();
|
|
$url = "https://api.weixin.qq.com/wxa/gettemplatedraftlist?access_token=".$access_token;
|
|
$responses = curl_get($url);
|
|
$results = json_decode($responses, true);
|
|
// print_r($results);
|
|
$this->assign("DraftsList",$results['draft_list']);
|
|
}
|
|
public function getTemplate(){
|
|
//获取当前的模板id信息,映射到页面上
|
|
$cache = M("appweixin")->find();
|
|
$this->assign("version",$cache["version"]);
|
|
$access_token = get_acc_token();
|
|
$url = "https://api.weixin.qq.com/wxa/gettemplatelist?access_token=".$access_token;
|
|
$responses = curl_get($url);
|
|
$results = json_decode($responses, true);
|
|
$this->assign("TemplateList",$results['template_list']);
|
|
$count = 50-count($results['template_list']);
|
|
$this->assign("count",$count);
|
|
}
|
|
public function xcxtemplate(){
|
|
//获取所有草稿箱信息
|
|
$this->getDrafts();
|
|
//获取所有的模板库信息
|
|
$this->getTemplate();
|
|
$this->display();
|
|
}
|
|
public function index(){
|
|
$host_name = exec("hostname");
|
|
$host_ip = gethostbyname($host_name); //获取本机的局域网IP
|
|
$this->assign("host_ip",$host_ip);
|
|
//获取系统设置的websocket配置
|
|
$cache = D("Websocket")->getWebsocket();
|
|
$this->assign("Webcache",$cache);
|
|
// 微信授权后
|
|
$wxinfo = M('appweixin')->where('id=1')->find();
|
|
if($_GET['auth_code']) {
|
|
$appid = $wxinfo['appid'];
|
|
$access = get_acc_token();
|
|
//获取第三方接口调用凭据
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=' . $access;
|
|
$data = array(
|
|
'component_appid' => $appid,
|
|
'authorization_code' => $_GET['auth_code']
|
|
);
|
|
$data = json_encode($data);
|
|
$response = curl_get($url, $data);
|
|
$result = json_decode($response, true);
|
|
$da['authorizer_access_token'] = $result['authorization_info']['authorizer_access_token'];
|
|
$da['authorizer_refresh_token'] = $result['authorization_info']['authorizer_refresh_token'];
|
|
$access = get_acc_token();
|
|
// 获取授权方的账号基本信息
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=' . $access;
|
|
$data = array(
|
|
'component_appid' => $appid,
|
|
'authorizer_appid' => $result['authorization_info']['authorizer_appid']
|
|
);
|
|
$data = json_encode($data);
|
|
$response = curl_get($url,$data);
|
|
$result = json_decode( $response, true );
|
|
// dump($result);
|
|
|
|
}
|
|
$nickname = $result['authorizer_info']['nick_name'];
|
|
$username = $result['authorizer_info']['user_name'];
|
|
$signature = $result['authorizer_info']['signature'];
|
|
$authorizerappid = $result['authorization_info']['authorizer_appid'];
|
|
$this -> assign('nickname',$nickname);
|
|
$this -> assign('username',$username);
|
|
$this -> assign('signature',$signature);
|
|
$this -> assign('authorizerappid',$authorizerappid);
|
|
|
|
// 微信开放平台配置
|
|
$info = D('Appweixin')->getFind(array('id'=>1));
|
|
|
|
// 短信配置和百度地图配置
|
|
$data = M('sms_config')->where(array('id' => 1))->find();
|
|
//获取微信和支付宝的基本服务商配置
|
|
$map['partnerid'] = 1;
|
|
// $entrys = M('retail_admin')->where(array('id'=>$map['partnerid']))->getField('entry');
|
|
|
|
$cache = M('systemconfig')->where($map)->find();
|
|
$pays = M('pay_api')->where(array('id'=>2))->find();
|
|
$this->assign('pays',$pays);
|
|
$this->assign('cache',$cache);
|
|
// $this->assign('entrys',$entrys); //判断合伙人是否有添加新大陆商户权限
|
|
$this->assign('data', $data);
|
|
$this->assign('info',$info);
|
|
|
|
// 微信平台接入项配置参数
|
|
$wx = array();
|
|
$wx['name'] = C('adminhttp');
|
|
$wx['authname'] = "http://{$wx['name']}/index.php/WxApi/Auth/index";
|
|
$this -> assign('wx',$wx);
|
|
|
|
$continent = M('continent_config')->where($map)->find();
|
|
$this->assign('continent',$continent);
|
|
|
|
$this->display();
|
|
}
|
|
|
|
// 微信开放平台
|
|
public function setConfig(){
|
|
$post = I('post.');
|
|
if( empty($post['appid']) || empty($post['token']) || empty($post['key']) || empty($post['appsecret']) ){
|
|
$result['status'] = 0;
|
|
$result['msg'] = '缺少参数';
|
|
}else{
|
|
$item['appid'] = $post['appid'];
|
|
$item['token'] = $post['token'];
|
|
$item['encodingaeskey'] = $post['key'];
|
|
$item['appsecret'] = $post['appsecret'];
|
|
$AppweixinModel = D('Appweixin');
|
|
// $user = session('admin_userinfo');
|
|
$map['id'] = 1;
|
|
$info = $AppweixinModel->getFind($map);
|
|
if(!empty($info)){
|
|
$res = $AppweixinModel->updateConfig($map,$item);
|
|
}else{
|
|
// $item['partnerid'] = $user['pid'];
|
|
$res = $AppweixinModel->addConfig($item);
|
|
}
|
|
if($res){
|
|
$result['status'] = 1;
|
|
$result['msg'] = '编辑成功';
|
|
}else{
|
|
$result['status'] = 0;
|
|
$result['msg'] = '编辑失败请重试';
|
|
}
|
|
}
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
// 小程序配置
|
|
public function setProgram(){
|
|
$post = I('post.');
|
|
if( empty($post['server']) || empty($post['business']) || empty($post['information']) || empty($post['tag'])){
|
|
$result['status'] = 0;
|
|
$result['msg'] = '缺少参数';
|
|
}else{
|
|
$item['server'] = $post['server'];
|
|
$item['business'] = $post['business'];
|
|
$item['version'] = $post['version'];
|
|
$item['information'] = $post['information'];
|
|
$item['tag'] = $post['tag'];
|
|
$ProgramModel = M('Appweixin');
|
|
$map['id'] = 1;
|
|
$info = $ProgramModel->where($map)->find();
|
|
if(!empty($info)){
|
|
$res = $ProgramModel->where($map)->save($item);
|
|
}else{
|
|
$res = $ProgramModel->add($item);
|
|
}
|
|
if($res){
|
|
$result['status'] = 1;
|
|
$result['msg'] = '编辑成功';
|
|
}else{
|
|
$result['status'] = 0;
|
|
$result['msg'] = '编辑失败请重试';
|
|
}
|
|
}
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
// 短信配置
|
|
public function setSms(){
|
|
$post = I('post.');
|
|
if(empty($post['accesskeyid']) || empty($post['accesskeysecret']) || empty($post['accessname']) || empty($post['accesscode'])){
|
|
$result['status'] = 0;
|
|
$result['msg'] = '缺少参数';
|
|
}else{
|
|
$item['accesskeyid'] = $post['accesskeyid'];
|
|
$item['accesskeysecret'] = $post['accesskeysecret'];
|
|
$item['accessname'] = $post['accessname'];
|
|
$item['accesscode'] = $post['accesscode'];
|
|
$SmsModel = M('sms_config');
|
|
$map['id'] = 1;
|
|
$info = $SmsModel->where($map)->find();
|
|
if(!empty($info)){
|
|
$res = $SmsModel->where($map)->save($item);
|
|
}else{
|
|
$res = $SmsModel->add($item);
|
|
}
|
|
if($res){
|
|
$result['status'] = 1;
|
|
$result['msg'] = '编辑成功';
|
|
}else{
|
|
$result['status'] = 0;
|
|
$result['msg'] = '编辑失败请重试';
|
|
}
|
|
}
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
// 检测短信配置
|
|
public function checkSms(){
|
|
$phone = I('post.phone');
|
|
$newsms = $this -> Send($phone);
|
|
$newcode = $newsms['Code'];
|
|
|
|
switch ($newcode) {
|
|
case "OK":
|
|
$result['status'] = 1;
|
|
$result['msg'] = '短信发送成功';
|
|
break;
|
|
case "isv.BUSINESS_LIMIT_CONTROL":
|
|
$result['status'] = 0;
|
|
$result['msg'] = '业务限流';
|
|
break;
|
|
case "isv.SMS_SIGNATURE_ILLEGAL":
|
|
$result['status'] = 0;
|
|
$result['msg'] = '短信签名不合法';
|
|
break;
|
|
case "SignatureDoesNotMatch":
|
|
$result['status'] = 0;
|
|
$result['msg'] = 'Signature加密错误(秘钥)';
|
|
break;
|
|
case "InvalidAccessKeyId.NotFound":
|
|
$result['status'] = 0;
|
|
$result['msg'] = 'Access Key ID不存在';
|
|
break;
|
|
case "isv.MOBILE_NUMBER_ILLEGAL":
|
|
$result['status'] = 0;
|
|
$result['msg'] = '非法手机号';
|
|
break;
|
|
default:
|
|
$result['status'] = 0;
|
|
$result['msg'] = $newcode;
|
|
break;
|
|
}
|
|
|
|
$this->ajaxReturn($result);
|
|
}
|
|
// 发送短信
|
|
public function Send($phone)
|
|
{
|
|
$smsconfig = M("sms_config")->find();
|
|
$msl = $smsconfig["accesscode"];
|
|
$code = rand(100000, 999999); //定义验证码
|
|
session('identifying_codes', $code, 300); //把验证码存到session
|
|
$res = $this->sendSms($phone, $code, $msl);
|
|
return json_decode(json_encode($res), true);
|
|
|
|
}
|
|
|
|
function sendSms($phone, $code, $Msl)
|
|
{
|
|
require_once "./SignatureHelper.php";
|
|
$params = array();
|
|
|
|
// *** 需用户填写部分 ***
|
|
|
|
// fixme 必填: 请参阅 https://ak-console.aliyun.com/ 取得您的AK信息
|
|
//$accessKeyId = C('accessKeyId');
|
|
//$accessKeySecret = C('accessKeySecret');
|
|
$smsconfig = M("sms_config")->find();
|
|
$accessKeyId = $smsconfig["accesskeyid"];
|
|
$accessKeySecret = $smsconfig["accesskeysecret"];
|
|
// fixme 必填: 短信接收号码
|
|
$params["PhoneNumbers"] = $phone;
|
|
|
|
// fixme 必填: 短信签名,应严格按"签名名称"填写,请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/sign
|
|
$params["SignName"] = $smsconfig["accessname"];
|
|
|
|
// fixme 必填: 短信模板Code,应严格按"模板CODE"填写, 请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/template
|
|
$params["TemplateCode"] = $Msl ? $Msl : "SMS_128635518";
|
|
|
|
// fixme 可选: 设置模板参数, 假如模板中存在变量需要替换则为必填项
|
|
$params['TemplateParam'] = Array(
|
|
"code" => $code
|
|
);
|
|
|
|
// fixme 可选: 设置发送短信流水号
|
|
$params['OutId'] = "12345";
|
|
|
|
// fixme 可选: 上行短信扩展码, 扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段
|
|
$params['SmsUpExtendCode'] = "1234567";
|
|
|
|
|
|
// *** 需用户填写部分结束, 以下代码若无必要无需更改 ***
|
|
if (!empty($params["TemplateParam"]) && is_array($params["TemplateParam"])) {
|
|
$params["TemplateParam"] = json_encode($params["TemplateParam"], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
// 初始化SignatureHelper实例用于设置参数,签名以及发送请求
|
|
$helper = new \SignatureHelper();
|
|
|
|
// 此处可能会抛出异常,注意catch
|
|
$content = $helper->request(
|
|
$accessKeyId,
|
|
$accessKeySecret,
|
|
"dysmsapi.aliyuncs.com",
|
|
array_merge($params, array(
|
|
"RegionId" => "cn-hangzhou",
|
|
"Action" => "SendSms",
|
|
"Version" => "2017-05-25",
|
|
))
|
|
// fixme 选填: 启用https
|
|
// ,true
|
|
);
|
|
|
|
return $content;
|
|
}
|
|
|
|
// 百度地图API配置
|
|
public function setSmsone(){
|
|
$post = I('post.');
|
|
if( empty($post['baidukeyid']) || empty($post['serverkeyid'])){
|
|
$result['status'] = 0;
|
|
$result['msg'] = '缺少参数';
|
|
}else{
|
|
$item['baidukeyid'] = $post['baidukeyid'];
|
|
$item['serverkeyid'] = $post['serverkeyid'];
|
|
$SmsModel = M('sms_config');
|
|
$map['id'] = 1;
|
|
$info = $SmsModel->where($map)->find();
|
|
if(!empty($info)){
|
|
$res = $SmsModel->where($map)->save($item);
|
|
}else{
|
|
$res = $SmsModel->add($item);
|
|
}
|
|
if($res){
|
|
$result['status'] = 1;
|
|
$result['msg'] = '编辑成功';
|
|
}else{
|
|
$result['status'] = 0;
|
|
$result['msg'] = '编辑失败请重试';
|
|
}
|
|
}
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
/**
|
|
* 微信配置信息
|
|
*/
|
|
public function wx_agentconf(){
|
|
//微信配置
|
|
// $userinfo = session('admin_userinfo');
|
|
// $uid = $userinfo['id'];
|
|
if(IS_POST){
|
|
//判断没有没这个配置
|
|
// $map['uid'] = $uid;
|
|
$uid = 1;
|
|
$re = M('systemconfig')->where(array('partnerid'=>$uid))->count();
|
|
if($re==0){
|
|
//添加流程
|
|
$item['wx_appid'] = I('post.wx_appid');
|
|
$item['wx_key'] = I('post.wx_key');
|
|
$item['wx_apiclient_cert'] = I('post.wx_apiclient_cert');
|
|
$item['wx_apiclient_key'] = I('post.wx_apiclient_key');
|
|
$item['mch_id'] = I('post.mch_id');
|
|
$item['partnerid'] = $uid;
|
|
$item['addtime'] = time();
|
|
$item['status'] = 1;
|
|
$res = M('systemconfig')->add($item);
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "微信服务商配置参数成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "微信服务商配置参数失败";
|
|
}
|
|
}else{
|
|
//修改流程
|
|
$item['wx_appid'] = I('post.wx_appid');
|
|
$item['wx_key'] = I('post.wx_key');
|
|
$item['wx_apiclient_cert'] = I('post.wx_apiclient_cert');
|
|
$item['wx_apiclient_key'] = I('post.wx_apiclient_key');
|
|
$item['mch_id'] = I('post.mch_id');
|
|
$item['addtime'] = time();
|
|
$item['status'] = 1;
|
|
$res = M('systemconfig')->where(array('partnerid'=>$uid))->save($item);
|
|
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "微信服务商配置参数成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "微信服务商配置参数失败";
|
|
}
|
|
}
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "配置错误,暂无信息";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
/**
|
|
* 支付宝参数信息配置
|
|
*/
|
|
public function ali_agentconf(){
|
|
//支付宝配置
|
|
// $userinfo = session('admin_userinfo');
|
|
// $uid = $userinfo['id'];
|
|
if(IS_POST){
|
|
//判断没有没这个配置
|
|
// $map['uid'] = $uid;
|
|
$uid = 1;
|
|
$re = M('systemconfig')->where(array('partnerid'=>$uid))->count();
|
|
if($re==0){
|
|
//添加流程
|
|
$item['alipay_appid'] = I('post.alipay_appid');
|
|
$item['alipay_pid'] = I('post.alipay_pid');
|
|
$item['alipay_public_key'] = I('post.alipay_public_key');
|
|
$item['alipay_private_key'] = I('post.alipay_private_key');
|
|
$item['partnerid'] = $uid;
|
|
$item['addtime'] = time();
|
|
$item['status'] = 1;
|
|
$res = M('systemconfig')->add($item);
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "支付宝服务商配置参数成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "支付宝服务商配置参数失败";
|
|
}
|
|
}else{
|
|
$item['alipay_appid'] = I('post.alipay_appid');
|
|
$item['alipay_pid'] = I('post.alipay_pid');
|
|
$item['alipay_public_key'] = I('post.alipay_public_key');
|
|
$item['alipay_private_key'] = I('post.alipay_private_key');
|
|
$item['addtime'] = time();
|
|
$item['status'] = 1;
|
|
$res = M('systemconfig')->where(array('partnerid'=>$uid))->save($item);
|
|
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "支付宝服务商配置参数成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "支付宝服务商配置参数失败";
|
|
}
|
|
}
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "配置错误,暂无信息";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
|
|
/*
|
|
* 小程序的授权功能
|
|
*/
|
|
public function authindex(){
|
|
$appid = M('appweixin')->where('id=1')->getField('appid');
|
|
$access = get_acc_token();
|
|
$urly = 'https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=' . $access;
|
|
$dat = array(
|
|
'component_appid' => $appid
|
|
);
|
|
$postdata = json_encode( $dat );
|
|
$responsey = curl_get($urly,$postdata);
|
|
$resulty = json_decode( $responsey, true );
|
|
//插入数据库
|
|
$data['component_access_token'] = $access;
|
|
$data['pre_auth_code'] = $resulty['pre_auth_code'];
|
|
M('appweixin')->where('id=1')->save($data);
|
|
//点击授权
|
|
$pre_auth_code = $resulty['pre_auth_code'];
|
|
$redirect_uri = 'http://'.C("adminhttp").'/index.php/Super/Config/index';
|
|
$urls = 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=' . $appid . '&auth_type=2&pre_auth_code=' . $pre_auth_code . '&redirect_uri=' . $redirect_uri;
|
|
header('location:'.$urls);
|
|
}
|
|
public function upload()
|
|
{
|
|
$upload = new \Think\Upload (); // 实例化上传类
|
|
$upload->maxSize = 5242880 / 2; // 设置附件上传大小5M/5
|
|
$upload->exts = array(
|
|
'pkcs12',
|
|
'pem'
|
|
); // 设置附件上传类型
|
|
$upload->rootPath = 'Uploads'; // 设置附件上传根目录
|
|
$upload->savePath = '/cache/'; // 设置附件上传(子)目录
|
|
$upload->saveName = array(
|
|
'uniqid',
|
|
array('', true)
|
|
);
|
|
// 上传文件
|
|
$info = $upload->upload();
|
|
if (!empty($info['file']['savename'])) {
|
|
$path = "/" . $upload->rootPath . $info['file']['savepath'] . $info['file']['savename'];
|
|
$rt['status'] = 1;
|
|
$rt['path'] = $_SERVER['DOCUMENT_ROOT'].$path;
|
|
$rt['msg'] = '文件上传成功';
|
|
}else{
|
|
$rt['status'] = 0;
|
|
$rt['msg'] = '文件上传失败';
|
|
}
|
|
$this->ajaxReturn($rt);
|
|
}
|
|
|
|
//新大陆支付配置
|
|
public function continent_conf(){
|
|
//新大陆配置
|
|
$userinfo = session('admin_userinfo');
|
|
$uid = $userinfo['id'];
|
|
if(IS_POST){
|
|
//判断没有没这个配置
|
|
$map['uid'] = $uid;
|
|
$re = M('continent_config')->where(array('partnerid'=>$uid))->count();
|
|
if($re==0){
|
|
//添加流程
|
|
$item['continent_number'] = I('post.continent_number');
|
|
$item['continent_pay_secret_key'] = I('post.continent_pay_secret_key');
|
|
$item['continent_callback_secret_key'] = I('post.continent_callback_secret_key');
|
|
$item['continent_credential'] = I('post.continent_credential');
|
|
$item['continent_domain_secret'] = I('post.continent_domain_secret');
|
|
$arr = I('post.continent_domain');
|
|
$arr = $arr?$arr:array();
|
|
|
|
$item['partnerid'] = $uid;
|
|
$item['continent_domain'] = json_encode($arr);
|
|
$res = M('continent_config')->add($item);
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "新大陆配置参数成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "新大陆配置参数失败";
|
|
}
|
|
}else{
|
|
//修改流程
|
|
$item['continent_number'] = I('post.continent_number');
|
|
$item['continent_pay_secret_key'] = I('post.continent_pay_secret_key');
|
|
$item['continent_callback_secret_key'] = I('post.continent_callback_secret_key');
|
|
$item['continent_credential'] = I('post.continent_credential');
|
|
$item['continent_domain_secret'] = I('post.continent_domain_secret');
|
|
$arr = I('post.continent_domain');
|
|
if($arr){
|
|
foreach ($arr as $k=>$v){
|
|
if(!$v){
|
|
unset($arr[$k]);
|
|
}
|
|
}
|
|
}
|
|
$arr = $arr?$arr:array();
|
|
$item['continent_domain'] = json_encode($arr);
|
|
$res = M('continent_config')->where(array('partnerid'=>$uid))->save($item);
|
|
if($res){
|
|
$data['status'] = 1;
|
|
$data['msg'] = "新大陆配置参数修改成功";
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "新大陆配置参数修改失败";
|
|
}
|
|
}
|
|
}else{
|
|
$data['status'] = 0;
|
|
$data['msg'] = "配置错误,暂无信息";
|
|
}
|
|
$this->ajaxReturn($data);
|
|
}
|
|
} |