1622 行
66 KiB
PHP
可执行文件
1622 行
66 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Super\Controller;
|
||
|
||
use Common\Business\Plug;
|
||
use Common\Model\AppweixinModel;
|
||
use Common\Model\MiniProgramUseModel;
|
||
use Think\Controller;
|
||
use Common\Validate\CustomValidate;//参数验证类
|
||
|
||
//[1.9.5]
|
||
|
||
/**
|
||
* 系统设置
|
||
* Class ConfigController
|
||
* @package Super\Controller
|
||
*/
|
||
class ConfigController extends SubBaseController
|
||
{
|
||
protected $operator_id;
|
||
protected $debug = 0;
|
||
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize();
|
||
$user = session('admin_userinfo');
|
||
if (empty($user)) {
|
||
echo '<script>top.window.location="' . $_SERVER ["SCRIPT_NAME"] . '/Retail/Login/index"</script>';
|
||
exit;
|
||
}
|
||
$this->operator_id = session('jurisdiction_user')['id'];
|
||
}
|
||
|
||
/**
|
||
* websocket把参数修改成本机的外网地址
|
||
*/
|
||
public function makefile()
|
||
{
|
||
$ip = I("post.ip");
|
||
$client = I("post.client");
|
||
$intranet_client = I('post.intranet_client');
|
||
$start_port = I('post.start_port');
|
||
|
||
$str = file_get_contents("./Public/tpl/worker.tpl");
|
||
$str = str_replace("[ip]", $ip, $str);
|
||
$str = str_replace("[intranet_client]", $intranet_client, $str);
|
||
$re = file_put_contents("./Worker/Applications/YourApp/start_text_gateway.php", $str);
|
||
|
||
$str1 = file_get_contents("./Public/tpl/start_gateway.tpl");
|
||
$str1 = str_replace("[client]", $client, $str1);
|
||
$str1 = str_replace("[startPort]", $start_port, $str1);
|
||
$re1 = file_put_contents("./Worker/Applications/YourApp/start_gateway.php", $str1);
|
||
if ($re || $re1) {
|
||
$data["status"] = 1;
|
||
$data["msg"] = "文件替换成功";
|
||
} else {
|
||
$data["status"] = 0;
|
||
$data["msg"] = "文件替换失败";
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
/**
|
||
* 保存websocket参数
|
||
*/
|
||
public function addWebsocket()
|
||
{
|
||
$ip = I("post.ip");
|
||
$intranet_client = I("post.intranet_client");
|
||
$client = I("post.client");
|
||
$status = I("post.status");
|
||
$start_port = I("post.start_port");
|
||
$original_ip = I("post.original_ip");
|
||
if (!empty($ip) && !empty($client) || !empty($intranet_client) || empty($start_port)) {
|
||
$webData["ip"] = $ip;
|
||
$webData["client"] = $client;
|
||
$webData["intranet_client"] = $intranet_client;
|
||
$webData["start_port"] = $start_port;
|
||
$webData["original_ip"] = $original_ip ? $original_ip : '';
|
||
$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()
|
||
{
|
||
$template_id = I("post.template_id");
|
||
$model = I("post.model");
|
||
$user_version = I("post.user_version");
|
||
$user_desc = I("post.user_desc");
|
||
$version_name = array(
|
||
'1' => 'default_version_id',
|
||
'2' => 'diy_version_id',
|
||
'3' => 'default_live_version_id',
|
||
'4' => 'diy_live_version_id',
|
||
);
|
||
$data = array(
|
||
$version_name[$model] => $template_id
|
||
);
|
||
$AppWeiXinModel = new AppweixinModel();
|
||
$cache = $AppWeiXinModel->updateOrder(array('id' => 1), $data);
|
||
if ($cache !== false) {
|
||
$ProgramUseModel = new MiniProgramUseModel();
|
||
$item = array(
|
||
'type' => $model, //'模板类型 1普通版(无直播) 2diy版(无直播) 3普通版(有直播) 4diy版(有直播)',
|
||
'user_version' => $user_version, //'版本号',
|
||
'user_desc' => $user_desc,//'版本描述',
|
||
'template_id' => $template_id,//'版本ID(微信官方)',
|
||
'use_time' => time(), //'使用时间',
|
||
'operator_id' => $this->operator_id,//'操作者id(角色表)',
|
||
);
|
||
$ProgramUseModel->addOrder($item);
|
||
$data["status"] = 1;
|
||
$data["msg"] = "切换成功";
|
||
} else {
|
||
$data["status"] = 0;
|
||
$data["msg"] = "切换失败";
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
/**
|
||
* 商城代码-删除草稿箱内容
|
||
*/
|
||
public function del_Drafts()
|
||
{
|
||
$id = I("post.template_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 = http_request($url);
|
||
$results = json_decode($responses, true);
|
||
if ($results['draft_list']) {
|
||
foreach ($results['draft_list'] as &$val) {
|
||
$val['create_time'] = date('Y-m-d H:i:s', $val['create_time']);
|
||
}
|
||
}
|
||
$this->ajaxReturn(array(
|
||
'status' => 1,
|
||
'msg' => $results['draft_list'] ? '获取成功' : '暂无数据',
|
||
'data' => $results['draft_list'] ? $results['draft_list'] : array(),
|
||
));
|
||
}
|
||
|
||
/**
|
||
* 商城代码-获取模板列表
|
||
*/
|
||
public function getTemplate()
|
||
{
|
||
$access_token = get_acc_token();
|
||
$url = "https://api.weixin.qq.com/wxa/gettemplatelist?access_token=" . $access_token;
|
||
$responses = http_request($url);
|
||
$results = json_decode($responses, true);
|
||
if ($results['template_list']) {
|
||
foreach ($results['template_list'] as &$val) {
|
||
$val['create_time'] = date('Y-m-d H:i:s', $val['create_time']);
|
||
}
|
||
}
|
||
$this->ajaxReturn(array(
|
||
'status' => 1,
|
||
'msg' => $results['template_list'] ? '获取成功' : '暂无数据',
|
||
'data' => $results['template_list'] ? $results['template_list'] : array(),
|
||
));
|
||
}
|
||
|
||
public function xcxtemplate()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 商城代码-获取模板基本设置
|
||
*/
|
||
public function getTemplateSet()
|
||
{
|
||
$AppWeiXinModel = new AppweixinModel();
|
||
$field = array(
|
||
'default_version_id',
|
||
'diy_version_id',
|
||
'default_live_version_id',
|
||
'diy_live_version_id',
|
||
);
|
||
$cache = $AppWeiXinModel->getFind(array('id' => 1), $field);
|
||
|
||
$MiniProgramUseModel = new MiniProgramUseModel();
|
||
$version_info = array(
|
||
array('title' => '普通版(无直播)'),
|
||
array('title' => 'DIY版(无直播)'),
|
||
array('title' => '普通版(有直播)'),
|
||
array('title' => 'DIY版(有直播)')
|
||
);
|
||
if ($cache['default_version_id']) {
|
||
//默认版 无直播
|
||
$map = array(
|
||
'template_id' => $cache['default_version_id'],
|
||
'type' => 1,
|
||
);
|
||
$default_version = $MiniProgramUseModel->getOrderFind($map, '*', 'id desc');
|
||
if ($default_version) {
|
||
$default_version['use_time'] = date('Y-m-d H:i:s', $default_version['use_time']);
|
||
}
|
||
$version_info[0]['info'] = $default_version ? $default_version : array();
|
||
}
|
||
if ($cache['diy_version_id']) {
|
||
//diy版 无直播
|
||
$map = array(
|
||
'template_id' => $cache['diy_version_id'],
|
||
'type' => 2,
|
||
);
|
||
$diy_version = $MiniProgramUseModel->getOrderFind($map, '*', 'id desc');
|
||
if ($diy_version) {
|
||
$diy_version['use_time'] = date('Y-m-d H:i:s', $diy_version['use_time']);
|
||
}
|
||
$version_info[1]['info'] = $diy_version ? $diy_version : array();
|
||
}
|
||
if ($cache['default_live_version_id']) {
|
||
//默认版 有直播
|
||
$map = array(
|
||
'template_id' => $cache['default_live_version_id'],
|
||
'type' => 3,
|
||
);
|
||
$default_version = $MiniProgramUseModel->getOrderFind($map, '*', 'id desc');
|
||
if ($default_version) {
|
||
$default_version['use_time'] = date('Y-m-d H:i:s', $default_version['use_time']);
|
||
}
|
||
$version_info[2]['info'] = $default_version ? $default_version : array();
|
||
}
|
||
if ($cache['diy_live_version_id']) {
|
||
//diy版 有直播
|
||
$map = array(
|
||
'template_id' => $cache['diy_live_version_id'],
|
||
'type' => 4,
|
||
);
|
||
$diy_version = $MiniProgramUseModel->getOrderFind($map, '*', 'id desc');
|
||
if ($diy_version) {
|
||
$diy_version['use_time'] = date('Y-m-d H:i:s', $diy_version['use_time']);
|
||
}
|
||
$version_info[3]['info'] = $diy_version ? $diy_version : array();
|
||
}
|
||
$this->ajaxReturn(array(
|
||
'status' => 1,
|
||
'msg' => '获取成功',
|
||
'data' => array(
|
||
'default_version_id' => $cache['default_version_id'] ? intval($cache['default_version_id']) : 0,
|
||
'diy_version_id' => $cache['diy_version_id'] ? intval($cache['diy_version_id']) : 0,
|
||
'default_live_version_id' => $cache['default_live_version_id'] ? intval($cache['default_live_version_id']) : 0,
|
||
'diy_live_version_id' => $cache['diy_live_version_id'] ? intval($cache['diy_live_version_id']) : 0,
|
||
'version_info' => $version_info,
|
||
),
|
||
));
|
||
}
|
||
|
||
public function index()
|
||
{
|
||
$host_name = exec("hostname");
|
||
$host_ip = gethostbyname($host_name); //获取本机的局域网IP
|
||
$this->assign("host_ip", $host_ip);
|
||
|
||
// 微信授权后
|
||
$AppWeiXinModel = new AppweixinModel();
|
||
$wxInfo = $AppWeiXinModel->getFind(array('id' => 1));
|
||
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);
|
||
|
||
$arr = array(
|
||
'setConfig' => '/index.php/Super/Config/setConfig',
|
||
'setProgram' => '/index.php/Super/Config/setProgram',
|
||
'xcxtemplate' => '/index.php/Super/Config/xcxtemplate',
|
||
'urgentAudit' => '/index.php/Super/Config/urgentAudit',
|
||
'getVersionInfo' => '/index.php/Super/Config/getVersionInfo',
|
||
'wx_agentconf' => '/index.php/Super/Config/wx_agentconf',
|
||
'ali_agentconf' => '/index.php/Super/Config/ali_agentconf',
|
||
'continent_conf' => '/index.php/Super/Config/continent_conf',
|
||
'setSms' => '/index.php/Super/Config/setSms',
|
||
'checkSms' => '/index.php/Super/Config/checkSms',
|
||
'setSmsone' => '/index.php/Super/Config/setSmsone',
|
||
'addWebsocket' => '/index.php/Super/Config/addWebsocket',
|
||
'makefile' => '/index.php/Super/Config/makefile',
|
||
'addStorageSet' => '/index.php/Super/Config/addStorageSet',
|
||
'adddeveloper' => '/index.php/Super/Developer/adddeveloper',
|
||
'editRedis' => '/index.php/Super/Config/editRedis',
|
||
'convenientSign' => true,
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$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');
|
||
$result = A('Api/Alidayu')->sendSmsCode($phone);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 百度地图API配置
|
||
*/
|
||
public function setSmsone()
|
||
{
|
||
$baidukeyid = I('post.baidukeyid');
|
||
$serverkeyid = I('post.serverkeyid');
|
||
$server_map_type = I('post.server_map_type');
|
||
$gould_key = I('post.gould_key');
|
||
$tencent_key = I('post.tencent_key');
|
||
if (empty($baidukeyid)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '百度浏览器端key为必填';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
if (empty($server_map_type)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请选择';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
if ($server_map_type == 1 && !$serverkeyid) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请填写百度浏服务器端key';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
if ($server_map_type == 2 && !$gould_key) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请填写高德地图key';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
if ($server_map_type == 3 && !$tencent_key) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请填写腾讯地图key';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$item = array(
|
||
'baidukeyid' => $baidukeyid,
|
||
'serverkeyid' => $serverkeyid,
|
||
'server_map_type' => $server_map_type,
|
||
'gould_key' => $gould_key,
|
||
'tencent_key' => $tencent_key,
|
||
);
|
||
$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);
|
||
}
|
||
|
||
/**
|
||
* 判断验证码是否正确
|
||
* @return bool
|
||
*/
|
||
protected function verifyCode()
|
||
{
|
||
$verifyCode = session('identifying_codes');
|
||
$code = I('post.code');
|
||
if ($verifyCode == $code) {
|
||
session('identifying_codes', null);
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 发送验证码
|
||
*/
|
||
public function sendCode()
|
||
{
|
||
$user = session('jurisdiction_user');
|
||
$phone = D('RetailAdmin')->getFindField(['id' => $user['partner_id']], 'phone');
|
||
$result = A('Api/Alidayu')->sendSmsCode($phone);
|
||
if ($result['status'] == 1) {
|
||
session('identifying_codes', $result['code'], 300); //把验证码存到session
|
||
unset($result['code']);
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 微信配置信息
|
||
*/
|
||
public function wx_agentconf()
|
||
{
|
||
//微信配置
|
||
// $userinfo = session('admin_userinfo');
|
||
// $uid = $userinfo['id'];
|
||
if (IS_POST) {
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断没有没这个配置
|
||
// $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['wx_serial_no'] = I('post.wx_serial_no');
|
||
$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['wx_serial_no'] = I('post.wx_serial_no');
|
||
$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) {
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断没有没这个配置
|
||
// $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 cloud_pay_conf()
|
||
{
|
||
if (IS_POST) {
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断是否存在
|
||
$data = I('post.');
|
||
if (!empty($data['union_pay_rate']) && !preg_match('/^[0-9]+(.[0-9]{1,6})?$/', $data['union_pay_rate'])) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "最多保留六位小数";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
$content = [
|
||
'serprovid' => $data['serprovid'],
|
||
'acqcode' => $data['acqcode'],
|
||
'prvkey' => $data['prvkey'],
|
||
'pubkey' => $data['pubkey'],
|
||
'prodkey' => $data['prodkey'],
|
||
'union_pay_rate' => $data['union_pay_rate'],
|
||
'addtime' => $_SERVER['REQUEST_TIME'],
|
||
'status' => 1,
|
||
];
|
||
$uid = 1;
|
||
$re = M('systemconfig')->where(array('partnerid' => $uid))->count();
|
||
if ($re == 0) {
|
||
//添加流程
|
||
$content['partnerid'] = $uid;
|
||
$res = M('systemconfig')->add($content);
|
||
if ($res) {
|
||
$data['status'] = 1;
|
||
$data['msg'] = "云闪付配置参数成功";
|
||
} else {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "云闪付配置参数失败";
|
||
}
|
||
} else {
|
||
$res = M('systemconfig')->where(array('partnerid' => $uid))->save($content);
|
||
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()
|
||
{
|
||
$AppWeiXinModel = new AppweixinModel();
|
||
$appid = $AppWeiXinModel->getFindField(array('id' => 1), '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'];
|
||
$AppWeiXinModel->updateOrder(array('id' => 1), $data);
|
||
//点击授权
|
||
$pre_auth_code = $resulty['pre_auth_code'];
|
||
// $redirect_uri = 'http://' . C("adminhttp") . '/index.php/Super/Config/index';
|
||
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/Super/Config/authSuccess';
|
||
$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 authSuccess()
|
||
{
|
||
$AppWeiXinModel = new AppweixinModel();
|
||
$wxInfo = $AppWeiXinModel->getFind(array('id' => 1));
|
||
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);
|
||
$this->assign('status', 1);
|
||
} else {
|
||
$this->assign('status', 0);
|
||
}
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 上传证书
|
||
*/
|
||
public function upload()
|
||
{
|
||
$type = I('post.type');
|
||
if (empty($type)) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请求有误,请刷新页面重试';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$upload = new \Think\Upload (); // 实例化上传类
|
||
$upload->maxSize = 5242880 / 2; // 设置附件上传大小5M/5
|
||
$upload->exts = array(
|
||
'pkcs12',
|
||
'pem',
|
||
'cer',
|
||
'pfx'
|
||
); // 设置附件上传类型
|
||
$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'];
|
||
$res['status'] = 1;
|
||
$res['type'] = $type;
|
||
$res['path'] = $_SERVER['DOCUMENT_ROOT'] . $path;
|
||
$res['cloud_path'] = $path;
|
||
$res['msg'] = '文件上传成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '文件上传失败';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 新大陆支付配置
|
||
*/
|
||
public function continent_conf()
|
||
{
|
||
//新大陆配置
|
||
$userinfo = session('admin_userinfo');
|
||
$uid = $userinfo['id'];
|
||
if (IS_POST) {
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断没有没这个配置
|
||
$map['uid'] = $uid;
|
||
$re = M('continent_config')->count();
|
||
$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['partner_rate'] = I('post.partner_rate');
|
||
if ($re == 0) {
|
||
//添加流程
|
||
$item['partnerid'] = $uid;
|
||
$res = M('continent_config')->add($item);
|
||
if ($res) {
|
||
if ($item['continent_number'] && $item['continent_pay_secret_key'] && $item['continent_credential']) {
|
||
M('retail_admin')->where(array('entry' => array('neq', 2)))->save(array('entry' => 2));
|
||
} else {
|
||
M('retail_admin')->where(array('entry' => array('neq', 1)))->save(array('entry' => 1));
|
||
}
|
||
$data['status'] = 1;
|
||
$data['msg'] = "新大陆参数配置成功";
|
||
} else {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "新大陆参数配置失败";
|
||
}
|
||
} else {
|
||
//修改流程
|
||
$res = M('continent_config')->where(array('id' => array('gt', 0)))->save($item);
|
||
if ($item['continent_number'] && $item['continent_pay_secret_key'] && $item['continent_credential']) {
|
||
M('retail_admin')->where(array('entry' => array('neq', 2)))->save(array('entry' => 2));
|
||
} else {
|
||
M('retail_admin')->where(array('entry' => array('neq', 1)))->save(array('entry' => 1));
|
||
}
|
||
$data['status'] = 1;
|
||
$data['msg'] = "新大陆参数配置成功";
|
||
}
|
||
} else {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "配置错误,暂无信息";
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
/**
|
||
* 保存图库设置
|
||
*/
|
||
public function addStorageSet()
|
||
{
|
||
$user = session('admin_userinfo');
|
||
if (!empty($user)) {
|
||
$storage_type = I('post.storage_type');
|
||
$qiniu_access_key = I('post.qiniu_access_key');
|
||
$qiniu_secret_key = I('post.qiniu_secret_key');
|
||
$qiniu_outer_chain_url = I('post.qiniu_outer_chain_url');
|
||
$qiniu_storage_space = I('post.qiniu_storage_space');
|
||
$tencent_secret_id = I('post.tencent_secret_id');
|
||
$tencent_secret_key = I('post.tencent_secret_key');
|
||
$tencent_outer_chain_url = I('post.tencent_outer_chain_url');
|
||
$tencent_storage_space = I('post.tencent_storage_space');
|
||
$tencent_region = I('post.tencent_region');
|
||
$oss_access_key_id = I('post.oss_access_key_id');
|
||
$oss_access_key_secret = I('post.oss_access_key_secret');
|
||
$oss_outer_chain_url = I('post.oss_outer_chain_url');
|
||
$oss_storage_space = I('post.oss_storage_space');
|
||
$oss_region = I('post.oss_region');
|
||
if ($storage_type == 2 && (empty($qiniu_access_key) || empty($qiniu_secret_key) || empty($qiniu_outer_chain_url) || empty($qiniu_storage_space))) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请完善七牛云对象储存配置信息';
|
||
} else if ($storage_type == 3 && (empty($tencent_secret_id) || empty($tencent_secret_key) || empty($tencent_outer_chain_url) || empty($tencent_storage_space) || empty($tencent_region))) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请完善腾讯云对象储存配置信息';
|
||
} else if ($storage_type == 4 && (empty($oss_access_key_id) || empty($oss_access_key_secret) || empty($oss_outer_chain_url) || empty($oss_storage_space) || empty($oss_region))) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请完善阿里云对象储存配置信息';
|
||
} else if ($storage_type != 1 && $storage_type != 2 && $storage_type != 3 && $storage_type != 4) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请选择存储类型';
|
||
} else {
|
||
$item = array(
|
||
'qiniu_access_key' => $qiniu_access_key,
|
||
'qiniu_secret_key' => $qiniu_secret_key,
|
||
'qiniu_outer_chain_url' => $qiniu_outer_chain_url,
|
||
'qiniu_storage_space' => $qiniu_storage_space,
|
||
'tencent_secret_id' => $tencent_secret_id,
|
||
'tencent_secret_key' => $tencent_secret_key,
|
||
'tencent_outer_chain_url' => $tencent_outer_chain_url,
|
||
'tencent_storage_space' => $tencent_storage_space,
|
||
'tencent_region' => $tencent_region,
|
||
'oss_access_key_id' => $oss_access_key_id,
|
||
'oss_access_key_secret' => $oss_access_key_secret,
|
||
'oss_outer_chain_url' => $oss_outer_chain_url,
|
||
'oss_storage_space' => $oss_storage_space,
|
||
'oss_region' => $oss_region
|
||
);
|
||
$update1 = M('retail_admin')->where(array('id' => $user['id']))->save(array('storage_type' => $storage_type));
|
||
$old = M('upload_config')->where(array('id' => 1))->find();
|
||
if ($old) {
|
||
$update2 = M('upload_config')->where(array('id' => 1))->save($item);
|
||
} else {
|
||
$update2 = M('upload_config')->add($item);
|
||
}
|
||
if ($update1 || $update2) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '设置成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '您未修改数据';
|
||
}
|
||
}
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '登录超时';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/*
|
||
* 便捷登录
|
||
*/
|
||
public function convenientSign()
|
||
{
|
||
$user = session("admin_userinfo");
|
||
$admin_id = $user['id'];
|
||
$convenient_sign_state = I('post.convenient_sign_state');
|
||
if ($convenient_sign_state == 1) {//开启
|
||
$data['convenient_sign_state'] = 1;
|
||
} else {
|
||
$data['convenient_sign_state'] = 2;
|
||
}
|
||
$save = M('retail_admin')->where(array('id' => $admin_id))->save($data);
|
||
if ($save) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '设置成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '暂无操作';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 配置Redis服务
|
||
*/
|
||
public function editRedis()
|
||
{
|
||
$is_set_redis = I('post.is_set_redis') ? 'true' : 'false';
|
||
$redis_local = I('post.redis_local');
|
||
$redis_port = I('post.redis_port');
|
||
$redis_pass = I('post.redis_pass');
|
||
$redis_pass = isset($redis_pass) ? $redis_pass : '';
|
||
$redis_number = is_numeric(I('post.redis_number')) ? intval(I('post.redis_number')) : 0;
|
||
|
||
$config = array(
|
||
'IS_SET_REDIS' => $is_set_redis,
|
||
'REDIS_LOCAL' => $redis_local,
|
||
'REDIS_PORT' => $redis_port,
|
||
'REDIS_PASS' => $redis_pass,
|
||
'REDIS_NUMBER' => $redis_number,
|
||
'HTTP' => $_SERVER["HTTP_HOST"],
|
||
);
|
||
$change = changeConfig($config);
|
||
if ($change) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '设置成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '修改失败';
|
||
}
|
||
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 检测redis是否配置成功
|
||
*/
|
||
public function checkRedis()
|
||
{
|
||
$ApiRedis = new \Addons\Api\RedisController();
|
||
if ($ApiRedis) {
|
||
$set_result = $ApiRedis::$redis->setex('test', 5, '123');
|
||
if ($set_result) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '配置成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '配置失败';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检测checkWebsocket是否配置成功
|
||
*/
|
||
public function checkWebsocket()
|
||
{
|
||
$ip = I('post.ip');
|
||
$intranet_client = I('post.intranet_client');
|
||
if (!$ip) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请填写IP';
|
||
} else if (!$intranet_client) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请填写内网端口';
|
||
} else {
|
||
$content['content'] = '检测配置';
|
||
$content['type'] = "say";
|
||
$content['type_id'] = -2;
|
||
$content['other_data'] = array();
|
||
$content['uid'] = -1;
|
||
$contents = json_encode($content);
|
||
//发送消息到内网
|
||
$client = stream_socket_client("tcp://{$ip}:{$intranet_client}");
|
||
$re = fwrite($client, $contents . "\n");
|
||
if ($re) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '发送成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '发送失败';
|
||
}
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
//获取基本设置的所有配置
|
||
public function getConfig()
|
||
{
|
||
// 微信开放平台配置
|
||
$wxConfig = D('Appweixin')->getFind(array('id' => 1));
|
||
// 微信平台接入项配置参数
|
||
$wxConfig['url_name'] = C('adminhttp');
|
||
$wxConfig['auth_name'] = "https://{$wxConfig['url_name']}/index.php/WxApi/Auth/index";
|
||
$wxConfig['notify_url'] = "https://{$wxConfig['url_name']}/index.php/WxApi/wx/auth/Appid/\$APPID\$";
|
||
$data['wxConfig'] = $wxConfig ? $wxConfig : array();
|
||
|
||
//服务商配置
|
||
$serverConfig = M('systemconfig')->find();
|
||
$serverConfig = $serverConfig ? $serverConfig : array(
|
||
'mch_id' => '',//'商户id',
|
||
'wx_appid' => '',//'微信appid',
|
||
'wx_key' => '',//'微信key',
|
||
'wx_apiclient_cert' => '',//'apiclient_cert证书',
|
||
'wx_apiclient_key' => '',//'apiclient_key证书',
|
||
'wx_serial_no' => '',//'微信服务商证书序列号',
|
||
'alipay_appid' => '',//'支付宝appid',
|
||
'alipay_pid' => '',//'支付宝pid',
|
||
'alipay_public_key' => '',//'支付宝公钥',
|
||
'alipay_private_key' => '',//'支付宝私钥',
|
||
'continent_orgno' => '',//'新大陆服务商机构号',
|
||
'continent_key' => '',//'新大陆服务商秘钥',
|
||
'serprovid' => '',//'云闪付服务商id',
|
||
'acqcode' => '',//'云闪付机构代码',
|
||
'prvkey' => '',//'云闪付私钥',
|
||
'pubkey' => '',//'云闪付公钥',
|
||
'prodkey' => '',//'云闪付私钥解密密码',
|
||
'happy_institution' => '',//'乐返支付机构号',
|
||
'happy_prvkey' => '',//'乐返支付私钥',
|
||
'happy_pubkey' => '',//'乐返支付公钥',
|
||
'happy_rate' => '',//'合伙人乐返服务商费率',
|
||
'lakala_appid' => '',//'拉卡拉应用标识',
|
||
'lakala_token' => '',//'拉卡拉授权码',
|
||
'lakala_termid' => '',//'拉卡拉终端号',
|
||
'lakala_secret_key' => '',//'拉卡拉secretKey',
|
||
'lakala_rate' => '',//'合伙人拉卡拉服务商费率',
|
||
'qian_ke_rate' => '',//'合伙人钱客云服务商费率',
|
||
);
|
||
$Plug = new Plug();
|
||
$systemPlug = $Plug->systemPlugState(['identification_arr' => ['moneyguestpay', 'lakalapay', 'happypay']]);
|
||
$serverConfig['happyPayState'] = $systemPlug['happypay'];
|
||
$serverConfig['laKaLaState'] = $systemPlug['lakalapay'];
|
||
$serverConfig['moneyGuestState'] = $systemPlug['moneyguestpay'];
|
||
$data['serverConfig'] = $serverConfig;
|
||
|
||
//新大陆配置
|
||
$continent = M('continent_config')->find();
|
||
$continent['partner_rate'] = round($continent['partner_rate'], 6);
|
||
$data['continent'] = $continent ? $continent : array();
|
||
|
||
//redis配置
|
||
$redis = array(
|
||
'is_set_redis' => C('IS_SET_REDIS'),//是否已经配置redis true开启 false关闭
|
||
'redis_local' => C('REDIS_LOCAL'),//redis地址
|
||
'redis_port' => C('REDIS_PORT'),//redis端口
|
||
'redis_pass' => C('REDIS_PASS'),//redis密码
|
||
'redis_number' => C('REDIS_NUMBER'),//链接的redis的第几个库
|
||
);
|
||
$data['redis'] = $redis;
|
||
|
||
//短信配置和地图配置
|
||
$mapConfig = M('sms_config')->where(array('id' => 1))->find();
|
||
$data['mapConfig'] = $mapConfig ? $mapConfig : array();
|
||
|
||
//获取系统设置的websocket配置
|
||
$websocket = D("Websocket")->getWebsocket();
|
||
$data['websocket'] = $websocket ? $websocket : array();
|
||
|
||
//图片存储设置
|
||
$uploadConfig = M('upload_config')->find();
|
||
$data['uploadConfig'] = $uploadConfig ? $uploadConfig : array();
|
||
|
||
//图片存储方式
|
||
$user = M('retail_admin')->order('id asc')->find();
|
||
$data['storage_type'] = $user['storage_type'];
|
||
//是否开启便捷登录
|
||
$data['convenient_sign_state'] = $user['convenient_sign_state'];
|
||
//条码查询
|
||
$data['app_code'] = $user['app_code'];
|
||
$data['app_status'] = $user['app_status'];
|
||
//配送设置
|
||
$developer = M('retail_da_developer')->find();
|
||
$data['developer'] = $developer ? $developer : array();
|
||
//快递设置
|
||
$express = M('system_express')->find();
|
||
$data['express'] = $express ? $express : array('cn_app_key' => '',
|
||
'cn_app_secret' => '',
|
||
'kd100_customer' => '',
|
||
'kd100_key' => ''
|
||
);
|
||
|
||
//新大陆多域名回调
|
||
$continentNotify = file_get_contents('./Public/continent/notifyUrl.json');
|
||
$data['continentNotify'] = $continentNotify ? json_decode($continentNotify, true) : array();
|
||
|
||
$res['data'] = $data;
|
||
$res['status'] = 1;
|
||
$res['msg'] = '获取成功';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 保存快递设置
|
||
*/
|
||
public function saveExpressConfig()
|
||
{
|
||
$item = array(
|
||
'cn_app_key' => I('post.cn_app_key'),
|
||
'cn_app_secret' => I('post.cn_app_secret'),
|
||
'kd100_customer' => I('post.kd100_customer'),
|
||
'kd100_key' => I('post.kd100_key'),
|
||
);
|
||
$express = M('system_express')->find();
|
||
if (!empty($express)) {
|
||
$update = M('system_express')->where(array('id' => $express['id']))->save($item);
|
||
} else {
|
||
$item['add_time'] = time();
|
||
$update = M('system_express')->add($item);
|
||
}
|
||
if ($update) {
|
||
$config = array(
|
||
'CN_APP_KEY' => $item['cn_app_key'],
|
||
'CN_APP_SECRET' => $item['cn_app_secret'],
|
||
'KD100_CUSTOMER' => $item['kd100_customer'],
|
||
'KD100_KEY' => $item['kd100_key'],
|
||
);
|
||
$change = changeConfig($config);
|
||
if ($change) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '设置成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '修改失败';
|
||
}
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '保存失败';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
//保存新大陆多域名回调设置
|
||
public function saveContinentNotify()
|
||
{
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['msg'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
$list = I('post.list');
|
||
try {
|
||
if (is_array($list)) {
|
||
if (count($list) > 10) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '最多只能添加10个回调域名';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$path = './Public/continent';
|
||
if (!is_dir($path)) {
|
||
mkdir($path, 0777);
|
||
}
|
||
$save = file_put_contents($path . '/notifyUrl.json', json_encode($list));
|
||
if ($save) {
|
||
$res['status'] = 1;
|
||
$res['msg'] = '保存成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '保存失败';
|
||
}
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '提交数据有误';
|
||
}
|
||
} catch (Exception $e) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '提交数据有误1';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 商城小程序加急审核
|
||
*/
|
||
public function urgentAudit()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取审核中的小程序列表
|
||
*/
|
||
public function getAuditing()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$MiniProgramExamineModel = D('MiniProgramExamine');
|
||
|
||
$list = $MiniProgramExamineModel->getMerchantExamineList($page, $limit, $merchant_id);
|
||
$count = $MiniProgramExamineModel->getMerchantExamineCount($merchant_id);
|
||
foreach ($list as &$value) {
|
||
$value['urgent_msg'] = $value['urgent_audit'] == 1 ? '是' : '否';
|
||
$value['status_msg'] = '审核中';
|
||
$value['add_time'] = date('Y-m-d H:i:s', $value['add_time']);
|
||
}
|
||
$res['data'] = $list;
|
||
$res['count'] = $count;
|
||
$res['status'] = 1;
|
||
$res['msg'] = empty($list) ? '暂无数据' : '获取成功';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 查询商户
|
||
*/
|
||
public function getMerchant()
|
||
{
|
||
$keyword = I('post.keyword');
|
||
$page = I('post.page');
|
||
$MerchantModel = D('RetailMerchant');
|
||
$map = array(
|
||
'status' => 1,
|
||
);
|
||
if (!empty($keyword)) {
|
||
$map['name'] = array('like', "%{$keyword}%");
|
||
}
|
||
$list = $MerchantModel->getSelect($map, 'id,name', 'id desc', $page . ',20');
|
||
$res['status'] = 1;
|
||
$res['msg'] = empty($list) ? '暂无数据' : '获取成功';
|
||
$res['data'] = $list;
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 提交加急审核请求
|
||
*/
|
||
public function sendUrgentAudit()
|
||
{
|
||
$id = I('post.id');
|
||
$MiniProgramExamineModel = D('MiniProgramExamine');
|
||
|
||
$map = array(
|
||
'id' => $id,
|
||
'state' => 1,
|
||
);
|
||
$examine = $MiniProgramExamineModel->getFind($map, 'status,audit_id');
|
||
if (empty($examine)) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '该审核单不存在或已过期';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
if ($examine['status'] != 2) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '该小程序已不在审核中,请检查';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
if ($examine['urgent_audit'] == 1) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '该小程序已提交过加急审核,请勿重复提交';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf($examine['merchant_id']);
|
||
$res = $MerXcxConf->sendUrgentAudit($examine['id'], $examine['audit_id']);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 查询当月剩余加急审核次数
|
||
*/
|
||
public function getUrgentAuditCount()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (empty($merchant_id)) {
|
||
$merchant_id = D('Wxappinfo')->getOrderFindField(array('authorizer_access_token' => array('neq', '')), 'merchant_id', 'access_token_time desc');
|
||
}
|
||
if (empty($merchant_id)) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '暂无商户授权开放平台,无法查询加急审核次数';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$access_token = get_authorizer_access_tokens($merchant_id);
|
||
$url = "https://api.weixin.qq.com/wxa/queryquota?access_token=" . $access_token;
|
||
$response = http_request($url, json_encode(array()));
|
||
$response = json_decode($response, true);
|
||
if ($response['errcode'] == '0') {
|
||
$res['quota'] = $response;
|
||
$res['status'] = 1;
|
||
$res['msg'] = '查询成功';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = $response['errmsg'] ? $response['errmsg'] : '请求发生错误';
|
||
$res['data'] = $response;
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
|
||
/**
|
||
* 条码查询设置
|
||
*/
|
||
public function appCodeSet()
|
||
{
|
||
$data = I('post.');
|
||
if ($data['app_status'] == 1 && empty($data['app_code'])) {
|
||
$result = ['status' => 0, 'message' => '请输入AppCode'];
|
||
} else {
|
||
$where = [
|
||
'id' => session("admin_userinfo")['id']
|
||
];
|
||
$update = M('retail_admin')->where($where)->save($data);
|
||
if ($update) {
|
||
$result = ['status' => 1, 'message' => '操作成功'];
|
||
} else {
|
||
$result = ['status' => 0, 'message' => '暂无修改'];
|
||
}
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 乐返参数信息配置
|
||
*/
|
||
public function happyPayConfig()
|
||
{
|
||
if (IS_POST) {
|
||
//验证码验证
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['message'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断参数是否正确
|
||
$post = I('post.');
|
||
$param = [
|
||
'happyInstitution',//乐返支付机构号
|
||
'happyPrvKey',//乐返支付私钥
|
||
'happyPubKey',//乐返支付公钥
|
||
'happyRate',//合伙人乐返服务商费率
|
||
];
|
||
$customValidate = new CustomValidate();
|
||
$dataOne = $customValidate->validationParameters($param, $post);
|
||
if ($dataOne !== true) {
|
||
$this->ajaxReturn($dataOne);
|
||
}
|
||
if ($post['happyInstitution'] == '' || $post['happyPrvKey'] == '' || $post['happyPubKey'] == '') {
|
||
$data = callBack(statusCode()['error'], "参数不能为空");
|
||
$this->ajaxReturn($data);
|
||
}
|
||
if (!empty($post['happyRate']) && !preg_match('/^[0-9]+(.[0-9]{1,6})?$/', $post['happyRate'])) {
|
||
$data = callBack(statusCode()['error'], "最多保留六位小数");
|
||
$this->ajaxReturn($data);
|
||
}
|
||
$content = [
|
||
'happy_institution' => $post['happyInstitution'],
|
||
'happy_prvkey' => $post['happyPrvKey'],
|
||
'happy_pubkey' => $post['happyPubKey'],
|
||
'happy_rate' => $post['happyRate'],
|
||
'addtime' => $_SERVER['REQUEST_TIME'],
|
||
'status' => 1,
|
||
];
|
||
$uid = 1;
|
||
$re = M('systemconfig')->where(array('partnerid' => $uid))->count();
|
||
if ($re == 0) {
|
||
//添加流程
|
||
$content['partnerid'] = $uid;
|
||
$res = M('systemconfig')->add($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "乐返配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "乐返配置参数失败");
|
||
}
|
||
} else {
|
||
$res = M('systemconfig')->where(array('partnerid' => $uid))->save($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "乐返配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "乐返配置参数失败");
|
||
}
|
||
}
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "配置错误,暂无信息");
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
/**
|
||
* 拉卡拉参数信息配置
|
||
*/
|
||
public function laKaLaPayConfig()
|
||
{
|
||
if (IS_POST) {
|
||
//验证码验证
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['message'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断参数是否正确
|
||
$post = I('post.');
|
||
$param = [
|
||
'laKaLaAppId',//拉卡拉应用标识
|
||
'laKaLaToken',//拉卡拉授权码
|
||
'laKaLaTermId',//拉卡拉终端号
|
||
'laKaLaSecretKey',//拉卡拉secretKey
|
||
'laKaLaRate',//合伙人拉卡拉服务商费率
|
||
];
|
||
$customValidate = new CustomValidate();
|
||
$dataOne = $customValidate->validationParameters($param, $post);
|
||
if ($dataOne !== true) {
|
||
$this->ajaxReturn($dataOne);
|
||
}
|
||
if ($post['laKaLaAppId'] == '' || $post['laKaLaToken'] == '' || $post['laKaLaTermId'] == '' || $post['laKaLaSecretKey'] == '') {
|
||
$data = callBack(statusCode()['error'], "参数不能为空");
|
||
$this->ajaxReturn($data);
|
||
}
|
||
if (!empty($post['laKaLaRate']) && !preg_match('/^[0-9]+(.[0-9]{1,6})?$/', $post['laKaLaRate'])) {
|
||
$data = callBack(statusCode()['error'], "最多保留六位小数");
|
||
$this->ajaxReturn($data);
|
||
}
|
||
$content = [
|
||
'lakala_appid' => $post['laKaLaAppId'],
|
||
'lakala_token' => $post['laKaLaToken'],
|
||
'lakala_termid' => $post['laKaLaTermId'],
|
||
'lakala_secret_key' => $post['laKaLaSecretKey'],
|
||
'lakala_rate' => $post['laKaLaRate'],
|
||
'addtime' => $_SERVER['REQUEST_TIME'],
|
||
'status' => 1,
|
||
];
|
||
$uid = 1;
|
||
$re = M('systemconfig')->where(array('partnerid' => $uid))->count();
|
||
if ($re == 0) {
|
||
//添加流程
|
||
$content['partnerid'] = $uid;
|
||
$res = M('systemconfig')->add($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "拉卡拉配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "拉卡拉配置参数失败");
|
||
}
|
||
} else {
|
||
$res = M('systemconfig')->where(array('partnerid' => $uid))->save($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "拉卡拉配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "拉卡拉配置参数失败");
|
||
}
|
||
}
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "配置错误,暂无信息");
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
/**
|
||
* 钱客云参数信息配置保存
|
||
*/
|
||
public function qianKePayConfig()
|
||
{
|
||
if (IS_POST) {
|
||
//验证码验证
|
||
if (!$this->verifyCode()) {
|
||
$data['status'] = 0;
|
||
$data['message'] = "验证码错误";
|
||
$this->ajaxReturn($data);
|
||
}
|
||
//判断参数是否正确
|
||
$post = I('post.');
|
||
$param = [
|
||
'qianKeRate',//合伙人钱客云服务商费率
|
||
];
|
||
$customValidate = new CustomValidate();
|
||
$dataOne = $customValidate->validationParameters($param, $post);
|
||
if ($dataOne !== true) {
|
||
$this->ajaxReturn($dataOne);
|
||
}
|
||
if (!empty($post['qianKeRate']) && !preg_match('/^[0-9]+(.[0-9]{1,6})?$/', $post['qianKeRate'])) {
|
||
$data = callBack(statusCode()['error'], "最多保留六位小数");
|
||
$this->ajaxReturn($data);
|
||
}
|
||
$content = [
|
||
'qian_ke_rate' => $post['qianKeRate'],
|
||
'addtime' => $_SERVER['REQUEST_TIME'],
|
||
'status' => 1,
|
||
];
|
||
$uid = 1;
|
||
$re = M('systemconfig')->where(array('partnerid' => $uid))->count();
|
||
if ($re == 0) {
|
||
//添加流程
|
||
$content['partnerid'] = $uid;
|
||
$res = M('systemconfig')->add($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "钱客云配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "钱客云配置参数失败");
|
||
}
|
||
} else {
|
||
$res = M('systemconfig')->where(array('partnerid' => $uid))->save($content);
|
||
if ($res) {
|
||
$data = callBack(statusCode()['success'], "钱客云配置参数成功");
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "钱客云配置参数失败");
|
||
}
|
||
}
|
||
} else {
|
||
$data = callBack(statusCode()['error'], "配置错误,暂无信息");
|
||
}
|
||
$this->ajaxReturn($data);
|
||
}
|
||
|
||
}
|