844 lines
32 KiB
PHP
844 lines
32 KiB
PHP
<?php
|
||
namespace app\controllers\admin;
|
||
use common\models\AuthItem;
|
||
use Illuminate\Support\Facades\DB;
|
||
use yii\db\Expression;
|
||
use Yii;
|
||
use yii\web\Controller;
|
||
use yii\web\UploadedFile;
|
||
use app\models\common\Config;
|
||
use app\models\common\Store;
|
||
use app\models\common\Good;
|
||
|
||
use Mrgoon\AliSms\AliSms;
|
||
class IndexController extends CommonController{
|
||
public $enableCsrfValidation = false;
|
||
public function actionSqlCeshi(){
|
||
//运行sql文件
|
||
if(file_exists('update.sql')){
|
||
$sqlData=file_get_contents('update.sql');
|
||
$sql_arr=explode(';',$sqlData);
|
||
foreach ($sql_arr as $v){
|
||
if(trim($v)){
|
||
Yii::$app->runAction('admin/update/sql-dump-load',['sql'=>trim($v)]);
|
||
}
|
||
}
|
||
// unlink('update.sql');
|
||
}
|
||
}
|
||
public function actionOrderSend(){
|
||
$redisArray=array(
|
||
'voiceName'=>'newOrder',
|
||
'uniacid'=>39,
|
||
'storeId'=>1,
|
||
'num'=>3
|
||
);
|
||
Yii::$app->redis->rpush("myqueue",json_encode($redisArray));
|
||
echo '订单推送成功';
|
||
}
|
||
public function actionDemoCeshi(){
|
||
$re=Good::categoryForGoods(1,39,11);
|
||
//$re=Good::getGoodS($uniacid,$storeId,$display='',$stock='',$page='',$limit='',$needCount='')
|
||
dd($re);
|
||
}
|
||
|
||
public function actionIndex(){
|
||
// dd(getSysInfo());die;
|
||
// //运行sql文件
|
||
// if(file_exists('update.sql')){
|
||
// $sqlData=file_get_contents('update.sql');
|
||
// $sql_arr=explode(';',$sqlData);
|
||
// foreach ($sql_arr as $v){
|
||
// if(trim($v)){
|
||
// Yii::$app->runAction('admin/update/sql-dump-load',['sql'=>trim($v)]);
|
||
// }
|
||
// }
|
||
// unlink('update.sql');
|
||
// }
|
||
return $this->renderPartial('index');
|
||
}
|
||
public function actionMycenter(){
|
||
$arr= Yii::$app->session->get('userInfo');
|
||
return $this->renderPartial('mycenter',$arr);
|
||
}
|
||
public function actionGetapplytop(){
|
||
$request = Yii::$app->request;
|
||
$sessionData=Yii::$app->session->get('adminInfo');
|
||
if ($request->isGet){
|
||
//返回新增前五名的平台
|
||
$re=(new \yii\db\Query())->from('{{%ybwm_apply}}')
|
||
->where(['status'=>1])->orderBy('dt_operdate desc')->limit(5)
|
||
->all();
|
||
if($sessionData['userLoginType']==2){
|
||
$uniacidData=(new \yii\db\Query())->from('{{%ybwm_users}}')->select('uniacid')
|
||
->where(['phone'=>$sessionData['phone']])->all();
|
||
$re=(new \yii\db\Query())
|
||
->from('{{%ybwm_apply}}')
|
||
->where(['status'=>1])->andWhere(['in','id',array_column($uniacidData,'uniacid')])
|
||
->orderBy('dt_operdate desc')->limit(5)
|
||
->all();
|
||
}
|
||
//返回平台排行
|
||
$result=axios_request();
|
||
switch ($result['timeType']){
|
||
case 1;
|
||
$startTime=mktime(0,0,0,date('m'),date('d'),date('Y'));
|
||
$endTime=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
|
||
break;
|
||
case 2;
|
||
$startTime=mktime(0,0,0,date('m'),date('d')-date('w')+1,date('Y'));
|
||
$endTime=mktime(23,59,59,date('m'),date('d')-date('w')+7,date('Y'));
|
||
break;
|
||
case 2;
|
||
$startTime=mktime(0,0,0,date('m'),1,date('Y'));
|
||
$endTime=mktime(23,59,59,date('m'),date('t'),date('Y'));
|
||
break;
|
||
default;
|
||
$startTime=mktime(0,0,0,date('m'),date('d'),date('Y'));
|
||
$endTime=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
|
||
break;
|
||
}
|
||
// dd($startTime); dd($endTime);die;
|
||
// $res= (new \yii\db\Query())
|
||
// ->select(['a.id','apply_name','IFNULL(sum(money),0)money','IFNULL(count(b.id),0)count','IFNULL(count(c.id),0)visitCount'])
|
||
// ->from('{{%ybwm_apply}} a')
|
||
// ->leftJoin('{{%ybwm_bill}} b','b.uniacid=a.id and b.createdAt>=:startTime AND b.createdAt<=:endTime',[':startTime'=>$startTime,':endTime'=>$endTime])
|
||
// ->leftJoin('{{%ybwm_visit_list}} c','c.uniacid=a.id and c.createdAt>=:startTime AND c.createdAt<=:endTime',[':startTime'=>$startTime,':endTime'=>$endTime])
|
||
// ->orderBy('money desc')
|
||
// ->limit(10)->all();
|
||
//var_dump(ddSql($res));die;
|
||
|
||
// if($sessionData['userLoginType']==2){
|
||
// $ratio=(new \yii\db\Query())->from('{{%ybwm_users}}')
|
||
// ->where(['id'=>$sessionData['userId']])
|
||
// ->one()['ratio'];
|
||
// foreach ($res as $k=>$v){
|
||
// $res[$k]['myMoney']=bcdiv(bcmul($v['money'],$ratio,2),100,2);
|
||
// $query= (new \yii\db\Query())
|
||
// ->from('{{%ybwm_users}} a')->select('b.id')
|
||
// ->Leftjoin('{{%ybwm_apply}} b','a.uniacid=b.id')
|
||
// ->where(['a.phone'=>$sessionData['phone']])->all();
|
||
// $ids=array_unique(array_column($query,'id'));
|
||
// if(!in_array($v['id'],$ids)){
|
||
// unset($res[$k]);
|
||
// }
|
||
// }
|
||
// }
|
||
$data=array(
|
||
'topArr'=>$re,
|
||
'billArr'=>$res
|
||
);
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
return $this->result(2,'请求异常');
|
||
}
|
||
//获取首页可创建数量 回收站 总账号数量 总浏览量
|
||
public function actionGetdescribe(){
|
||
$request = Yii::$app->request;
|
||
if ($request->isGet){
|
||
$sysInfo=getSysInfo();
|
||
//今日创建账号数量
|
||
$todayNum=(new \yii\db\Query())->from('{{%ybwm_apply}}')
|
||
->where(['>=','dt_operdate',date('Y-m-d 00:00:00',time())])
|
||
->andWhere(['<=','dt_operdate',date('Y-m-d 23:59:59',time())])
|
||
->andWhere(['!=','status',3])
|
||
->count();
|
||
//已创建账号数量
|
||
$totalNum=(new \yii\db\Query())->from('{{%ybwm_apply}}')->where(['!=','status',3])->count();
|
||
//已购买版本
|
||
$versionNum=count($sysInfo['authData']['channel']);
|
||
//已开通插件数
|
||
$plugCount=count($sysInfo['authData']['plug']);
|
||
$time=date('Y-m-d H:i:s',time());
|
||
//已到期平台数量
|
||
$expireCount=(new \yii\db\Query())->from('{{%ybwm_apply}}')
|
||
->where(['time_type'=>1])->andWhere(['!=','status',3])
|
||
->andWhere(['<','end_time',$time])->count()?:0;
|
||
//回收站平台数量
|
||
//回收站平台数量
|
||
$sql="select a.*,b.userName,b.phone from {{%ybwm_apply}} a left join {{%ybwm_users}} b on a.id=b.uniacid where a.status=2";
|
||
//dd($sql);die;
|
||
$recoveryCount=count(Yii::$app->db->createCommand($sql)->queryAll())?:0;
|
||
//有效期
|
||
if($sysInfo['time_type']==1){
|
||
$timeEnd='无限';
|
||
}else{
|
||
$timeEnd=substr($sysInfo['time_end'],0,10);
|
||
}
|
||
$isApp=2;$isPs=2;$isCashier=2;
|
||
//是否支持商家管理端App
|
||
if(in_array('app',$sysInfo['authData']['service'])){
|
||
$isApp=1;
|
||
}
|
||
//是否支持网页收银台
|
||
if(in_array('cashier',$sysInfo['authData']['plug'])){
|
||
$isCashier=1;
|
||
}
|
||
//是否支持配送端App
|
||
if(in_array('ps',$sysInfo['authData']['service'])){
|
||
$isPs=1;
|
||
}
|
||
$channelArr=$sysInfo['authData']['channel'];
|
||
$pludIds=$sysInfo['authData']['plug'];
|
||
if(in_array('zijie',$channelArr)){
|
||
$pludIds[]='zijie';
|
||
}
|
||
if(in_array('ali',$channelArr)){
|
||
$pludIds[]='ali';
|
||
}
|
||
if(in_array('wechat',$channelArr)){
|
||
$pludIds[]='wechat';
|
||
}
|
||
if($sysInfo['time_type']==1){
|
||
$time_end='永久';
|
||
}else{
|
||
$time_end=floor((strtotime($sysInfo['time_end'])-time())/86400).'天';
|
||
}
|
||
if($sysInfo['account_type']==1){
|
||
$account_number='无限';
|
||
}else{
|
||
$account_number=$sysInfo['account_number'];
|
||
}
|
||
$adminInfo = Yii::$app->session->get('adminInfo');
|
||
$siteInfo = YII::$app->db->createCommand("select * from {{%ybwm_site_set}}")->queryOne();
|
||
// $sysInfo['domain_name'] = $siteInfo['site_name'] ? $siteInfo['site_name'] : '';
|
||
$detail=array(
|
||
'portrait'=>$adminInfo['portrait'],
|
||
'domain_name'=>$siteInfo['site_name'],
|
||
'service_type'=>$sysInfo['service_type'],
|
||
'account_number'=>$account_number,
|
||
'status'=>$sysInfo['status'],
|
||
'time_end'=>$time_end,
|
||
'user_name'=>$adminInfo['userName'],
|
||
);
|
||
echo json_encode(['code'=>1,
|
||
'todayNum'=>$todayNum,
|
||
'totalNum'=>$totalNum,
|
||
'versionNum'=>$versionNum,
|
||
'plugCount'=>$plugCount,
|
||
'timeEnd'=>$timeEnd,
|
||
'isApp'=>$isApp,
|
||
'isCashier'=>$isCashier,
|
||
'isPs'=>$isPs,
|
||
'pludIds'=>$pludIds,
|
||
'recoveryCount'=>$recoveryCount,
|
||
'expireCount'=>$expireCount,
|
||
'detail'=>$detail
|
||
]
|
||
);
|
||
}
|
||
}
|
||
|
||
|
||
public function actionTosearch(){
|
||
$request = Yii::$app->request;
|
||
if ($request->isPost){
|
||
$result=axios_request();
|
||
$model=new Users();
|
||
$row=$model->getByName(trim($result['username']));
|
||
//var_dump($row);die;
|
||
if($row){
|
||
echo json_encode(array(
|
||
'code'=>'200',
|
||
'msg'=>$row
|
||
));
|
||
}else{
|
||
echo json_encode(array(
|
||
'code'=>'500',
|
||
'msg'=>'没有您查找的用户'
|
||
));
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
//升级项目版本
|
||
public function actionUpversion(){
|
||
$errorArr=[];
|
||
$install=dirname(dirname(dirname(__FILE__))).'/version.php';
|
||
//dd($install);die;
|
||
if(!is_writable($install)){
|
||
$str=$install.'不可写';
|
||
}
|
||
|
||
$errorArr['install'][]=$str;
|
||
//获取当前文件的目录
|
||
$controllerfile=dirname(__FILE__);
|
||
|
||
$errorArr['controller']=list_file($controllerfile);
|
||
|
||
$modelfile=dirname(dirname(dirname(__FILE__))).'/models';
|
||
$errorArr['model']=list_file($modelfile);
|
||
|
||
$viewfile=dirname(dirname(dirname(__FILE__))).'/views';
|
||
$errorArr['views']=list_file($viewfile);
|
||
|
||
dd($errorArr);die;
|
||
|
||
|
||
$zip=new \ZipArchive();
|
||
if($zip->open('test.zip', ZipArchive::OVERWRITE)=== TRUE){
|
||
addFileToZip($controllerfile, $zip); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||
$zip->close(); //关闭处理的zip文件
|
||
}else{
|
||
echo '无法打开文件';
|
||
}
|
||
die;
|
||
if($errorArr){
|
||
echo json_encode(array('code'=>500,'msg'=>$errorArr));die;
|
||
}else{
|
||
//需要更新的文件打包
|
||
|
||
}
|
||
|
||
|
||
|
||
}
|
||
//返回网站的版本信息
|
||
public function actionGetversion(){
|
||
//获取最新的版本号
|
||
$new_version='2.0.0';
|
||
$data=require('../Install/version.php');
|
||
$version=$data['version'];
|
||
if($version==$new_version){
|
||
echo json_encode(array('code'=>500,'msg'=>'暂无更新内容'));
|
||
}else{
|
||
$data['version']=$new_version;
|
||
echo json_encode(array('code'=>200,'msg'=>$data));
|
||
}
|
||
}
|
||
//授权码激活
|
||
public function actionGetauth() {
|
||
global $_W, $_GPC;
|
||
$url = 'https://cloud.y-bei.cn/cloud/we7_o2o_auth/authorization';
|
||
$data['code'] = $_GPC['__input']['code'];
|
||
$data['uniacid'] = $_W['uniacid'];
|
||
dd($_SESSION['we7_user']);die;
|
||
$name = $_SERVER["HTTP_HOST"];
|
||
$host = "https://" . $name;
|
||
$data['domain'] = $host;
|
||
print_R($data);die();
|
||
$res = curl_request($url, $data);
|
||
$res = json_decode($res, true);
|
||
print_R($res);die();
|
||
if ($res['code'] == 1) {
|
||
$this->result(0, '激活成功');
|
||
} else {
|
||
$this->result(1, $res['msg']);
|
||
}
|
||
|
||
}
|
||
//读取文件
|
||
public function doMobileRead() {
|
||
global $_W, $_GPC;
|
||
|
||
$file_path = __DIR__ . '/.lock';
|
||
if (file_exists($file_path)) {
|
||
$str = file_get_contents($file_path);
|
||
} else {
|
||
$this->result(1, '读取失败');
|
||
}
|
||
$this->result(0, '读取成功', $str);
|
||
|
||
}
|
||
|
||
public function actionCeshi(){
|
||
// 获取 redis 组件
|
||
$redis = Yii::$app->redis;
|
||
|
||
|
||
|
||
|
||
var_dump($redis);
|
||
}
|
||
|
||
public function actionQueuelist(){
|
||
dd(Yii::$app);die;
|
||
Yii::$app->queue->push(new \app\job\DownloadJob([
|
||
'url' => 'http://example.com/image.jpg',
|
||
'file' => '/tmp/image.jpg',
|
||
]));
|
||
}
|
||
public function actionTest2(){
|
||
$arr=[
|
||
'name'=>'云贝餐饮',
|
||
'domain'=>'www.baidu.com',
|
||
];
|
||
$a="r1nQxNKahXFWwqptbpqVlKtsmZbFkayabpfCldttZWyVk9eYmmnEWWCImaemx52mWHGG2dusZceazMWulJufpVa0";
|
||
print_R(json_decode(ybwmDecrypt($a,'aaaaa'),true));die;
|
||
}
|
||
public function actionTest(){
|
||
$request = Yii::$app->request;
|
||
if ($request->isPost){
|
||
$model = new UploadForm();
|
||
$model->imageFile = UploadedFile::getInstanceByName('file');
|
||
|
||
var_dump($model->imageFile);
|
||
}else{
|
||
return $this->renderPartial('test');
|
||
}
|
||
|
||
}
|
||
public function sectionTime($type){
|
||
$arr=[];
|
||
if($type==1){
|
||
for ($i=1;$i<=23;$i++){
|
||
$arr[$i]=0;
|
||
}
|
||
}else{
|
||
for ($i=14; $i>=0;$i--){
|
||
$day=date('Y-m-d', strtotime('-'.$i.' days'));
|
||
if(!is_string($day)){
|
||
$day=strval($day);
|
||
}
|
||
$arr[$day]=0;
|
||
}
|
||
}
|
||
return $arr;
|
||
}
|
||
|
||
//$type 1为单日查询 2最近15天内查询
|
||
public function TimeQuery($type,$re){
|
||
$arr=$this->sectionTime($type);
|
||
$newArr=[];
|
||
foreach ($re as $k=>$v){
|
||
$newArr[$v['data_time']]=$v['count'];
|
||
}
|
||
$new_arr=$newArr+$arr;
|
||
ksort($new_arr);
|
||
$a=[];
|
||
foreach ($new_arr as $key=>$v){
|
||
$a[]=array(
|
||
'data_time'=>$key,
|
||
'count'=>$v
|
||
);
|
||
|
||
}
|
||
return $a;
|
||
}
|
||
//获取时间段订单数按天统计
|
||
public function getCountByDay($table,$uniacid,$storeId,$startTime,$endTime){
|
||
$sql="SELECT FROM_UNIXTIME(createdAt,'%Y-%m-%d') AS hours,count(*) as money
|
||
FROM ".$table." WHERE createdAt >= '$startTime' and createdAt <= '$endTime' and uniacid=".$uniacid." and storeId=".$storeId."
|
||
GROUP BY FROM_UNIXTIME(createdAt,'%Y-%m-%d')
|
||
ORDER BY FROM_UNIXTIME(createdAt,'%Y-%m-%d')";
|
||
return $sql;
|
||
}
|
||
public function actionGetaccessdate(){
|
||
|
||
$request = Yii::$app->request;
|
||
if ($request->isGet){
|
||
$time=Yii::$app->request->get('start_time');
|
||
|
||
if($time){
|
||
$startTime=strtotime($time.' 00:00:00');
|
||
$endTime=strtotime($time.' 23:59:59');
|
||
}else{
|
||
$startTime=strtotime(date('Y-m-d 00:00:00',time()));
|
||
$endTime=strtotime(date('Y-m-d 23:59:59',time()));
|
||
}
|
||
|
||
$visitData=(new \yii\db\Query())
|
||
->from('{{%ybwm_visit_list}}')
|
||
->select(new Expression("from_unixtime(createdAt,'%H')hours,count(*) money"))
|
||
->where(['in','modelname',[1,2]])
|
||
->andWhere(['>=','createdAt',$startTime])
|
||
->andWhere(['<=','createdAt',$endTime])
|
||
->groupBy(new Expression("from_unixtime(createdAt,'%H')"))
|
||
->all();
|
||
|
||
//var_dump(ddSql($visitData));die;
|
||
$data=CreatQuery(1,$visitData);
|
||
//dd($data);die;
|
||
$arr=[];
|
||
foreach ($data as $v){
|
||
$arr[]=array(
|
||
'data_time'=>$v['hours'],
|
||
'count'=>$v['money'],
|
||
);
|
||
}
|
||
$count=count($arr);
|
||
return $this->result(1, '成功',$arr,$count);
|
||
|
||
}
|
||
return $this->result(2, '请求异常');
|
||
}
|
||
|
||
public function actionAnz(){
|
||
$db=1;
|
||
$username=2;
|
||
$password=3;
|
||
$dbprefix=4;
|
||
Yii::$app->cache->flush();
|
||
$content="<?php return [
|
||
'class' => 'yii\db\Connection',
|
||
'dsn' => 'mysql:host=localhost;dbname=$db',
|
||
'username' => '$username',
|
||
'password' => '$password',
|
||
'charset' => 'utf8',
|
||
'tablePrefix'=> '$dbprefix',
|
||
];";
|
||
$config_file=\Yii::$app->basePath.'/config/db.php';
|
||
|
||
if(!is_writable($config_file)){
|
||
chmod($config_file,0755);
|
||
}
|
||
$write_bool=file_put_contents($config_file,$content);
|
||
dd($write_bool);die;
|
||
}
|
||
|
||
public function actionGerUserInfo(){
|
||
$data=Yii::$app->session->get('adminInfo');
|
||
$arr=array(
|
||
'id'=>$data['id'],
|
||
'userName'=>$data['userName'],
|
||
'passWord'=>$data['passWord'],
|
||
'portrait'=>$data['portrait'],
|
||
'uniacid'=>$data['uniacid'],
|
||
'phone'=>$data['phone'],
|
||
);
|
||
return $this->result(1, '成功',$arr);
|
||
}
|
||
|
||
public function actionUserSave(){
|
||
$result=axios_request();
|
||
$salt=randoms(8);
|
||
$auth_key=Yii::$app->params['authkey'];
|
||
$data=array(
|
||
'userName'=>$result['userName'],
|
||
'portrait'=>$result['portrait'],
|
||
);
|
||
if(Yii::$app->session->get('adminInfo')['loginType']==3){
|
||
$row=(new \yii\db\Query())->from('{{%ybwm_admin}}')->where(['id'=>$result['id']])->one();
|
||
}else{
|
||
$row=(new \yii\db\Query())->from('{{%ybwm_users}}')->where(['id'=>$result['id']])->one();
|
||
}
|
||
if(trim($result['oldPassWord'])&&trim($result['passWord'])){
|
||
// if(!preg_match("/^[A-Za-z0-9]+$/",trim($result['passWord']))){
|
||
// return $this->result(2, '密码不能包含中文和特殊字符!');die;
|
||
// }
|
||
if(checkPassWord($row['salt'],$auth_key,trim($result['oldPassWord']))!==$row['passWord']){
|
||
return $this->result(2, '旧密码输入有误');die;
|
||
}
|
||
if(trim($result['passWord'])!==$row['passWord']){
|
||
$data['passWord']=checkPassWord($salt,$auth_key,$result['passWord']);
|
||
$data['salt']=$salt;
|
||
}
|
||
}
|
||
$data=filter_array($data);
|
||
//var_dump($data);die;
|
||
if(Yii::$app->session->get('adminInfo')['loginType']==3){
|
||
$res = YII::$app->db->createCommand()->update('{{%ybwm_admin}}', $data, 'id=:id', ['id' =>$result['id']])->execute();
|
||
$row=(new \yii\db\Query())->from('{{%ybwm_admin}}')->where(['id'=>$result['id']])->one();
|
||
}else{
|
||
$res = YII::$app->db->createCommand()->update('{{%ybwm_users}}', $data, 'id=:id', ['id' =>$result['id']])->execute();
|
||
$row=(new \yii\db\Query())->from('{{%ybwm_users}}')->where(['id'=>$result['id']])->one();
|
||
}
|
||
$row['loginType']=Yii::$app->session->get('adminInfo')['loginType'];
|
||
Yii::$app->session->set('adminInfo',$row);
|
||
//Yii::$app->session->remove('userInfo');
|
||
return $this->result(1, '用户信息已修改',$res);
|
||
}
|
||
|
||
|
||
//缓存设置
|
||
public function actionCacheset(){
|
||
return $this->renderPartial('cacheset');
|
||
}
|
||
public function actionCacheSetSave(){
|
||
$request = Yii::$app->request;
|
||
if($request->isGet){
|
||
if(!extension_loaded('swoole')){
|
||
return $this->result(2,'请安装php swoole扩展');
|
||
}
|
||
if(!extension_loaded('redis')){
|
||
return $this->result(2,'请安装php redis扩展');
|
||
}
|
||
$info=file_get_contents('./web/cacheSet.log');
|
||
if($info){
|
||
$data=array(
|
||
'redis'=>json_decode($info,true)['redis'],
|
||
'redispx'=>json_decode($info,true)['redispx']?:6379,
|
||
'swoole'=>json_decode($info,true)['swoole'],
|
||
'ssl_certificate'=>json_decode($info,true)['ssl_certificate'],
|
||
'ssl_certificate_key'=>json_decode($info,true)['ssl_certificate_key'],
|
||
|
||
);
|
||
}
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
if($request->isPost){
|
||
if(!extension_loaded('swoole')){
|
||
return $this->result(2,'请安装php swoole扩展');
|
||
}
|
||
if(!extension_loaded('redis')){
|
||
return $this->result(2,'请安装php redis扩展');
|
||
}
|
||
$result=axios_request();
|
||
if($result['type']==1){
|
||
$disabled = explode(',', ini_get('disable_functions'));
|
||
if(in_array('shell_exec',$disabled)){
|
||
return $this->result(2,'shell_exec函数被禁用');
|
||
}
|
||
Yii::$app->redis->set('swoole_test','666');
|
||
$source = Yii::$app->redis->get('swoole_test');
|
||
Yii::$app->redis->del('swoole_test');
|
||
if(!$source){
|
||
return $this->result(2,'redis配置参数有误');
|
||
}
|
||
$port=Yii::$app->params['swoolePort'];
|
||
$shell = "netstat -anp 2>/dev/null | grep " . $port . " | grep LISTEN | wc -l";
|
||
$result = shell_exec($shell);
|
||
if ($result <> 1) {
|
||
return $this->result(2,'请检查配置');die;
|
||
} else {
|
||
return $this->result(1,'服务端已启动');die;
|
||
}
|
||
}
|
||
$array=array(
|
||
'redis'=>trim($result['redis'])?:null,
|
||
'redispx'=>trim($result['redispx'])?:6379,
|
||
'swoole'=>9875,
|
||
'ssl_certificate'=>trim($result['ssl_certificate']),
|
||
'ssl_certificate_key'=>trim($result['ssl_certificate_key']),
|
||
);
|
||
file_put_contents('./web/cacheSet.log',json_encode($array));
|
||
return $this->result(1,'操作成功');
|
||
}
|
||
}
|
||
|
||
|
||
public function actionCheckRole(){
|
||
$role_id = Yii::$app->session->get('userInfo')['role_id']?:1;
|
||
$query= (new \yii\db\Query())
|
||
->select('role_str')
|
||
->from('{{%ybwm_users}} a')
|
||
->leftJoin('{{%ybwm_role_list}} b','a.role_id=b.id')
|
||
->where(['a.role_id'=>$role_id,'b.display'=>1]);
|
||
//echo $query->createCommand()->getRawSql();die;
|
||
$re=$query->one();
|
||
$navData=(new \yii\db\Query())
|
||
->select('id,c_name')
|
||
->from('{{%ybwm_nav}}')
|
||
->where(['in','id',explode(',',$re['role_str'])])
|
||
->all();
|
||
return json_encode(['code'=>1,'data'=>$navData]);
|
||
}
|
||
|
||
function getChild($array,$pid = 0){
|
||
$data = array();
|
||
foreach ($array as $k=>$v){ //PID符合条件的
|
||
if($v['pid'] == $pid){//寻找子集
|
||
if($v['pid']==0){
|
||
$v['name']=$v['route'];
|
||
unset($v['route']);
|
||
}
|
||
$child = $this->getChild($array,$v['id']); //加入数组
|
||
if($child){
|
||
$v['children'] = $child;
|
||
}
|
||
$data[] = $v;//加入数组中
|
||
}
|
||
} return $data;
|
||
}
|
||
public function actionOtherset(){
|
||
return $this->renderPartial('otherset');
|
||
}
|
||
|
||
public function actionGetMake(){
|
||
error_reporting("E_ALL");
|
||
ini_set("display_errors", 1);
|
||
$request = Yii::$app->request;
|
||
$result=axios_request();
|
||
if($request->isGet){
|
||
if($result['id']){
|
||
$data=Config::getSystemSet('sysTopImage',$result['id']);
|
||
return $this->result(1,'成功',$data);
|
||
}else{
|
||
$data=Config::getSystemSet('superPower',0);
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
|
||
}else{
|
||
if($request->isPost){
|
||
if($result['id']){
|
||
$re=Config::getSystemSet('sysTopImage',$result['id']);
|
||
$re['makeName']=$result['makeName'];
|
||
$re['makeIcon']=$result['makeIcon'];
|
||
$re['yunbeiName']=$result['yunbeiName'];
|
||
$re['yunbeiIcon']=$result['yunbeiIcon'];
|
||
$re['support']=$result['support'];
|
||
$re['icon']=$result['icon'];
|
||
$re['qq']=$result['qq'];
|
||
$re['cashierName']=$result['cashierName'];
|
||
$re['cashierIcon']=$result['cashierIcon'];
|
||
$re['cashierBg']=$result['cashierBg'];
|
||
Config::saveSystemSet($re,'sysTopImage',$result['id'],'网站头部LOGO');
|
||
return $this->result(1,'成功');
|
||
}else{
|
||
$re=Config::getSystemSet('superPower',0);
|
||
$re['makeName']=$result['makeName'];
|
||
$re['makeIcon']=$result['makeIcon'];
|
||
$re['support']=$result['support'];
|
||
$re['yunbeiIcon']=$result['yunbeiIcon'];
|
||
$re['yunbeiName']=$result['yunbeiName'];
|
||
$re['icon']=$result['icon'];
|
||
$re['qq']=$result['qq'];
|
||
$re['cashierName']=$result['cashierName'];
|
||
$re['cashierIcon']=$result['cashierIcon'];
|
||
$re['cashierBg']=$result['cashierBg'];
|
||
Config::saveSystemSet($re,'superPower',0,'超级权限');
|
||
return $this->result(1,'成功');
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
public function actionSmsset()
|
||
{
|
||
return $this->renderPartial('smsset');
|
||
}
|
||
|
||
public function actionSmsSave(){
|
||
$request = Yii::$app->request;
|
||
$result=axios_request();
|
||
if($request->isGet){
|
||
$data=Config::getSystemSet('smsConfigSet',0);
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
if($request->isPost){
|
||
$result=filter_array($result);
|
||
Config::saveSystemSet($result,'smsConfigSet',0,'管理后台短信设置');
|
||
return $this->result(1,'成功');
|
||
}
|
||
}
|
||
|
||
public function actionSendSms(){
|
||
$request = Yii::$app->request;
|
||
$result=axios_request();
|
||
if($request->isPost){
|
||
$code=generate_code(4);
|
||
$aliSms = new AliSms();
|
||
$phone=$result['phone'];
|
||
$smsCode=$result['smsCode']?:$result['forgetCode'];
|
||
if(!$phone){
|
||
return $this->result(2,'手机号码不能为空');
|
||
}
|
||
if(!$smsCode){
|
||
return $this->result(2,'模板code不能为空');
|
||
}
|
||
$smsConfig=Config::getSystemSet('smsConfigSet',0);
|
||
$response = object_array($aliSms->sendSms($phone,$smsCode, ['code'=>$code],$smsConfig));
|
||
if($response['Message']=='OK'&&$response['Code']=='OK'){
|
||
return $this->result(1,'成功');
|
||
}else{
|
||
return $this->result(2,$response['Message']);
|
||
}
|
||
}
|
||
}
|
||
|
||
//商家端小程序信息保存
|
||
public function actionMerchantConfig(){
|
||
$request = Yii::$app->request;
|
||
$result=axios_request();
|
||
if($request->isGet){
|
||
$uniacid=0;
|
||
$data=(new \yii\db\Query())
|
||
->from('{{%ybwm_core_system}}')
|
||
->where(['ident'=>'merchantConfig','uniacid'=>$uniacid])->one();
|
||
$data=json_decode($data['data'],'true');
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
if($request->isPost){
|
||
$re=Config::getSystemSet('merchantConfig',0);
|
||
$re['uniacid']=$result['uniacid']?:0;
|
||
$re['miniName']=$result['miniName'];
|
||
$re['miniAppId']=$result['miniAppId'];
|
||
$re['miniOriginal']=$result['miniOriginal'];
|
||
$re['miniSecret']=$result['miniSecret'];
|
||
Config::saveSystemSet($re,'merchantConfig',0,'商家端小程序信息');
|
||
return $this->result(1,'成功');
|
||
}
|
||
}
|
||
|
||
//压缩小程序文件夹打包并下载
|
||
public function actionMiniDown(){
|
||
$dir='miniApp/';
|
||
$res=miniScan($dir);
|
||
//file_put_contents(Yii::$app->basePath.'/web/oldSoft.lock.json', json_encode($res));
|
||
$datalist=array_keys($res);
|
||
//dd($datalist);die;
|
||
if(file_exists(Yii::$app->basePath.'/web/upgraded/mini.zip')){
|
||
unlink(Yii::$app->basePath.'/web/upgraded/mini.zip');
|
||
}
|
||
//dd($newData);die;
|
||
addFileToZip($datalist,Yii::$app->basePath.'/web/upgraded/','mini.zip');
|
||
header('Content-Type:text/html;charset=utf-8');
|
||
header('Content-disposition:attachment;filename=mini.zip');
|
||
$filesize = filesize(Yii::$app->basePath.'/web/upgraded/mini.zip');
|
||
readfile(Yii::$app->basePath.'/web/upgraded/mini.zip');
|
||
header('Content-length:'.$filesize);
|
||
}
|
||
//商家端用户列表
|
||
public function actionMerchantset(){
|
||
return $this->renderPartial('merchantset');
|
||
}
|
||
|
||
public function actionUserList(){
|
||
$result=axios_request();
|
||
$page=$result['page']?$result['page']:1;
|
||
$num=($page-1)*10;
|
||
$limit=10;
|
||
$query=(new \yii\db\Query())
|
||
->select(["FROM_UNIXTIME(a.createdAt,'%Y-%m-%d %H:%i:%s') createdAt",'a.id memberId','a.userName memberName','b.id userId','b.userName','a.portrait','apply_name','c.name','c.id storeId','d.id applyId'])
|
||
->from('{{%ybwm_merchant_member}} a')
|
||
->leftJoin('{{%ybwm_users}} b','a.id=b.userId')
|
||
->leftJoin('{{%ybwm_store}} c','b.storeId=c.id')
|
||
->leftJoin('{{%ybwm_apply}} d','b.uniacid=d.id')
|
||
->where(['>','a.portrait',''])
|
||
->orderBy('b.userId desc,a.id desc');
|
||
$count=$query->count();
|
||
$data=(clone $query)->offset($num)->limit($limit)->all();
|
||
return $this->result(1,'成功',$data,$count);
|
||
}
|
||
|
||
//商家端小程序
|
||
public function actionSaveTemplates(){
|
||
$request = Yii::$app->request;
|
||
$result=axios_request();
|
||
$ident=$result['ident'];
|
||
$identName=$result['identName'];
|
||
$bool=false;
|
||
if($request->isGet){
|
||
$bool=true;
|
||
}
|
||
Config::saveConfig($bool,$ident,$identName);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
public function actionCeslll(){
|
||
$startToday = strtotime(date('Y-m-d', time()));
|
||
$endToday = strtotime(date('Y-m-d', time())) + 3600 * 24;
|
||
$rst = (new \yii\db\Query())
|
||
->select('id,callNo')
|
||
->from('{{%ybwm_instore_order}}')
|
||
->where('createdAt>=:startTime AND createdAt<:endTime AND storeId=:storeId AND orderMode=2 AND state not in(1,5)',[':startTime'=>$startToday,':endTime'=>$endToday,':storeId'=>58])->orderBy('id desc')->one();
|
||
if ($rst) {
|
||
$callNo=substr($rst['callNo'],1);
|
||
settype($callNo, 'integer');
|
||
$callNo++;
|
||
if (count($callNo) < 3) {
|
||
$callNo = str_pad($callNo, 3, '0', STR_PAD_LEFT);
|
||
}
|
||
$data['callNo'] = 'A' . $callNo;
|
||
} else {
|
||
$data['callNo'] = "A001";
|
||
}
|
||
var_dump($data);
|
||
}
|
||
}
|