优化ctms-api语法、修复已知BUG;
主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
版本记录说明
|
||||
|
||||
2.1.20210909
|
||||
添加版本记录号;
|
||||
修复管理员表、会员表、粉丝表、API用户表的归属及统一
|
||||
修复后台管理员资料编辑错误,微调昵称等细节部分
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\assets;
|
||||
|
||||
namespace backend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* Main frontend application asset bundle.
|
||||
* Main backend application asset bundle.
|
||||
*/
|
||||
class AppAsset extends AssetBundle
|
||||
{
|
||||
@@ -13,8 +13,10 @@ class AppAsset extends AssetBundle
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
'css/site.css',
|
||||
'css/login.min.css',
|
||||
];
|
||||
public $js = [
|
||||
'js/hplus.min.js',
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '17';
|
||||
$cert['siteId'] = '1534755679';
|
||||
$cert['suIp'] = array('60.166.78.33');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('http:');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = '1098765230@qq.com';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = '936cb496df78da7794f8d866ab4f9e0c';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2018-08-20 17:01:19';
|
||||
$cert['updatetime'] = '更新时间:2018-08-20 17:01:19';
|
||||
return $cert;
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '14';
|
||||
$cert['siteId'] = '27086';
|
||||
$cert['suIp'] = array('120.79.11.71');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'anchengjieshun';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = '9c20c06c513bcf9d8580a773d1a24124';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2018-05-02 09:56:11';
|
||||
$cert['updatetime'] = '更新时间:2019-01-20 11:40:48';
|
||||
return $cert;
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '6';
|
||||
$cert['siteId'] = '27086';
|
||||
$cert['suIp'] = array('127.0.0.1');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'dongjiabing';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = '5ff8745bffe82e58547d5ae4dd157250';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2017-08-15 20:57:21';
|
||||
$cert['updatetime'] = '更新时间:2017-09-22 13:14:12';
|
||||
return $cert;
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => '1', //证书ID
|
||||
'siteId' => '1', //站点ID
|
||||
'suIp' => ['::1','127.0.0.1'], //允许访问的IP
|
||||
'siteName' => '本地测试站',
|
||||
'suDomain' => ['localhost'], //绑定域名
|
||||
'siteUrl' => '', //站点链接
|
||||
'api' => 'fm453_shopping', //授权API
|
||||
'sceret' => 'temp@te##453.com', //授权密钥
|
||||
'code' => 'Hiluker', //授权码
|
||||
'token' => '', //赋有有效期的Token(动态生成,此处暂不使用)
|
||||
'status' => '0', //站点状态,-1禁止0只读1可用
|
||||
'remark' => '本地测试时使用', //备注
|
||||
];
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '22';
|
||||
$cert['siteId'] = '1540174304';
|
||||
$cert['suIp'] = array('110.52.216.185');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('http:');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'howsou';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = 'ece82bff3ae54afa750872b01218df6d';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2018-10-22 10:11:44';
|
||||
$cert['updatetime'] = '更新时间:2018-10-22 10:13:56';
|
||||
return $cert;
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => '1', //证书ID
|
||||
'siteId' => '0', //站点ID
|
||||
'suIp' => ['::1','127.0.0.1'], //允许访问的IP
|
||||
'siteName' => '本地测试站',
|
||||
'suDomain' => ['localhost'], //绑定域名
|
||||
'siteUrl' => '', //站点链接
|
||||
'api' => 'fm453_shopping', //授权API
|
||||
'sceret' => 'temp@te##453.com', //授权密钥
|
||||
'code' => 'Hiluker', //授权码
|
||||
'token' => '', //赋有有效期的Token(动态生成,此处暂不使用)
|
||||
'status' => '0', //站点状态,-1禁止0只读1可用
|
||||
'remark' => '本地测试时使用', //备注
|
||||
];
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '4';
|
||||
$cert['siteId'] = '0';
|
||||
$cert['suIp'] = array('0.0.0.0/0');
|
||||
$cert['siteName'] = '公共接口站';
|
||||
$cert['suDomain'] = array('*');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'publicapi';
|
||||
$cert['code'] = 'Hiluker';
|
||||
$cert['token'] = '68da4cda191d1668834095f1209fb573';
|
||||
$cert['status'] = '1';
|
||||
$cert['remark'] = '公用接口账号';
|
||||
$cert['updatetime'] = '更新时间:2021-09-15 10:51:53';
|
||||
$cert['uniacid'] = '1';
|
||||
$cert['platid'] = '1';
|
||||
return $cert;
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '12';
|
||||
$cert['siteId'] = '1548742316';
|
||||
$cert['suIp'] = array('116.62.209.203');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'ukl';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = 'fa919dafaed937db58047791efe413f7';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2019-01-29 14:11:56';
|
||||
return $cert;
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => '2', //证书ID
|
||||
'siteId' => '27086', //站点ID
|
||||
'suIp' => ['::1','127.0.0.1','61.147.125.206'], //允许访问的IP
|
||||
'siteName' => 'VCMS微信管理系统',
|
||||
'suDomain' => ['vcms.hiluker.com'], //绑定域名
|
||||
'siteUrl' => '', //站点链接
|
||||
'api' => 'fm453_shopping', //授权API
|
||||
'sceret' => 'temp@te##453.com', //授权密钥
|
||||
'code' => 'Hiluker', //授权码
|
||||
'token' => '', //赋有有效期的Token(动态生成,此处暂不使用)
|
||||
'status' => '1', //站点状态,-1禁止0只读1可用
|
||||
'remark' => 'VCMS微信管理系统使用', //备注
|
||||
//'platid' => '1', //直接固定platid值
|
||||
];
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '2';
|
||||
$cert['siteId'] = '27086';
|
||||
$cert['suIp'] = array('61.147.111.178','127.0.0.1','::1');
|
||||
$cert['siteName'] = 'VCMS微信管理系统';
|
||||
$cert['suDomain'] = array('vcms.localhost');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'fm453_shopping';
|
||||
$cert['sceret'] = 'temp@te##453.com';
|
||||
$cert['code'] = 'Hiluker';
|
||||
$cert['token'] = 'bca3402b510ecd8e3603ebf746f4fbfa';
|
||||
$cert['status'] = '1';
|
||||
$cert['remark'] = 'VCMS微信管理本地开发测试系统';
|
||||
$cert['updatetime'] = '更新时间:2018-04-23 15:52:33';
|
||||
return $cert;
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '15';
|
||||
$cert['siteId'] = '27086';
|
||||
$cert['suIp'] = array('120.79.11.71');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'www.haijumeng.com';
|
||||
$cert['code'] = '';
|
||||
$cert['token'] = '0da3957934b098592c557c6281ca4922';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2018-05-02 08:52:09';
|
||||
$cert['updatetime'] = '更新时间:2018-06-08 23:19:50';
|
||||
$cert['platid'] = '1';
|
||||
$cert['uniacid'] = '111';
|
||||
return $cert;
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 通讯证书文件
|
||||
@status 站点状态,-1禁止 0只读 1可用
|
||||
@siteId 站点ID
|
||||
@suIp 允许访问的IP
|
||||
@suDomain 允许访问的域名
|
||||
@api 接口用户名(站点用户名)
|
||||
@code 用户授权码
|
||||
@token 接口通讯的accesstoken文件
|
||||
*/
|
||||
$cert = array();
|
||||
$cert['id'] = '21';
|
||||
$cert['siteId'] = '1528471799';
|
||||
$cert['suIp'] = array('36.57.163.170');
|
||||
$cert['siteName'] = '';
|
||||
$cert['suDomain'] = array('');
|
||||
$cert['siteUrl'] = '';
|
||||
$cert['api'] = 'xcx.hiluker.com';
|
||||
$cert['code'] = 'Hiluker.com';
|
||||
$cert['token'] = 'fda11ae350f6b1a231ce62766fd09dd6';
|
||||
$cert['status'] = '0';
|
||||
$cert['remark'] = '新创建待审核,创建时间:2018-06-08 23:29:59';
|
||||
$cert['updatetime'] = '更新时间:2018-06-08 23:29:59';
|
||||
return $cert;
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace: frontend\tests
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
data: tests/_data
|
||||
helpers: tests/_support
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
modules:
|
||||
config:
|
||||
Yii2:
|
||||
configFile: 'config/test-local.php'
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* User: Administrator
|
||||
* Date: 2016-7-5
|
||||
* Time: 16:10
|
||||
* Description:
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
|
||||
use Yii;
|
||||
use yii\rbac\Rule;
|
||||
|
||||
|
||||
class ArticleRule extends Rule
|
||||
{
|
||||
public $name = 'article';
|
||||
|
||||
public function execute($user, $item, $params)
|
||||
{
|
||||
// 这里先设置为false,逻辑上后面再完善
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-08 00:25:51
|
||||
* # @Last modified by: fm453
|
||||
* # @Last modified time: 2022-02-08T09:46:43+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
use Yii;
|
||||
use common\models\CLog;
|
||||
use common\models\User;
|
||||
use common\models\Member;
|
||||
use common\models\Fans;
|
||||
use common\models\CAttachment;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcPlat;
|
||||
use addons\models\AcContact;
|
||||
|
||||
class Helper
|
||||
{
|
||||
|
||||
//历史访客数
|
||||
public static function getHistoryVisNum()
|
||||
{
|
||||
$res = CLog::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//最近一个月访问量
|
||||
public static function getMonthHistoryVisNum()
|
||||
{
|
||||
$LastMonth = strtotime("-1 month");
|
||||
$res = CLog::find()->where(['>', 'create_time', $LastMonth])->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//API接口站用户总数
|
||||
public static function getApierCount()
|
||||
{
|
||||
$res = User::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//会员数据总数
|
||||
public static function getMemberCount()
|
||||
{
|
||||
$res = Member::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//粉丝数据总数
|
||||
public static function getFansCount()
|
||||
{
|
||||
$res = Fans::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//短信统计
|
||||
public static function getSmsStat()
|
||||
{
|
||||
$sms = CSms::find()->count();
|
||||
$mobile = CSms::find()->groupBy('mobile')->count();
|
||||
return ['sms' => $sms, 'mobile' => $mobile];
|
||||
}
|
||||
|
||||
//附件统计
|
||||
public static function getAttachStat()
|
||||
{
|
||||
$num = CAttachment::find()->count();
|
||||
$size = CAttachment::find()->sum('filesize');
|
||||
return ['num' => $num, 'size' => $size];
|
||||
}
|
||||
|
||||
//今日运单
|
||||
public static function getOrderToday()
|
||||
{
|
||||
$num = CAttachment::find()->count();
|
||||
$size = CAttachment::find()->sum('filesize');
|
||||
return ['num' => $num, 'size' => $size];
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,10 @@
|
||||
<?php
|
||||
Yii::setAlias('@frontend', dirname(__DIR__));
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2021-03-25T10:36:00+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:09:28+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
Yii::setAlias('@api', dirname(__DIR__));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_HI;
|
||||
$_HI['apiCertPath'] = Yii::getAlias('@frontend/cert/');
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
$config = [
|
||||
'components' => [
|
||||
'db' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
|
||||
'username' => 'dacms_dev',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
'attributes' => [
|
||||
// use a smaller connection timeout
|
||||
PDO::ATTR_TIMEOUT => 10,
|
||||
//使用长链接
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
],
|
||||
],
|
||||
//添加CHAT数据库配置(聊天室模块)
|
||||
'chatdb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
|
||||
'username' => 'dacms_dev',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
//添加REALTY数据库配置(房地产模块)
|
||||
'realtydb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
|
||||
'username' => 'dacms_dev',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
//添加PAGE数据库配置(页面模块)
|
||||
'pagedb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
|
||||
'username' => 'dacms_dev',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $config;
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-09 10:37:17
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-09 10:42:24
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
$config = [
|
||||
'components' => [
|
||||
'db' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
|
||||
'username' => 'dacms',
|
||||
'password' => 'eydnsidc',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
'attributes' => [
|
||||
// use a smaller connection timeout
|
||||
PDO::ATTR_TIMEOUT => 10,
|
||||
//使用长链接
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
],
|
||||
],
|
||||
//添加CHAT数据库配置(聊天室模块)
|
||||
'chatdb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
|
||||
'username' => 'dacms',
|
||||
'password' => 'eydnsidc',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
//添加REALTY数据库配置(房地产模块)
|
||||
'realtydb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
|
||||
'username' => 'dacms',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
//添加PAGE数据库配置(页面模块)
|
||||
'pagedb' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
|
||||
'username' => 'dacms',
|
||||
'password' => 'eydnsidc',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $config;
|
||||
+46
-26
@@ -1,43 +1,64 @@
|
||||
<?php
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
|
||||
# @Author: fm453
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: Fm453
|
||||
# @Last modified time: 2021-09-15T00:13:16+08:00
|
||||
# @Email: fm43@hiluker.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:21:21+08:00
|
||||
|
||||
$params = array_merge(
|
||||
require(__DIR__ . '/../../common/config/params-api.php'),
|
||||
require(__DIR__ . '/../../common/config/params.php'),
|
||||
require(__DIR__ . '/../../addons-' . HI_APP . '/config/citys.php'),
|
||||
require(__DIR__ . '/../../addons-' . HI_APP . '/config/params-car.php'),
|
||||
require(__DIR__ . '/../../addons-' . HI_APP . '/config/params-letter.php'),
|
||||
require(__DIR__ . '/../../addons-' . HI_APP . '/config/params-area.php'),
|
||||
require(__DIR__ . '/../../addons-' . HI_APP . '/config/params.php'),
|
||||
// require(__DIR__ . '/../../addons-'.HI_APP.'/config/version.php'),
|
||||
require(__DIR__ . '/params.php')
|
||||
);
|
||||
|
||||
$config = [
|
||||
'id' => 'app-frontend',
|
||||
'id' => 'api-ctms-backend',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'controllerNamespace' => 'api\controllers',
|
||||
'defaultRoute' => 'index', //默认路由
|
||||
'bootstrap' => ['log'],
|
||||
'controllerNamespace' => 'frontend\controllers',
|
||||
'modules' => [
|
||||
'data' => [
|
||||
'class' => 'vendor\fmsoft\modules\data\Module', //自动加载我的数据处理模型
|
||||
],
|
||||
// "admin" => [
|
||||
// "class" => 'mdm\admin\Module',
|
||||
// ],
|
||||
],
|
||||
'language'=>'zh-CN',
|
||||
'aliases' => [
|
||||
"@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
|
||||
],
|
||||
// 'as access' => [
|
||||
// //加了才会自动验证是否有权限
|
||||
// 'class' => 'mdm\admin\components\AccessControl',
|
||||
// 'allowActions' => [
|
||||
// //允许访问的action
|
||||
// //controller/action
|
||||
// '*'
|
||||
// ]
|
||||
// ],
|
||||
'language' => 'zh-CN', //目标语言
|
||||
//组件
|
||||
'components' => [
|
||||
'request' => [
|
||||
'csrfParam' => '_csrf-frontend',
|
||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
|
||||
'cookieValidationKey' => 'o_Rv6TiAxMkGII4dkFBKathreA5IEohp',
|
||||
'parsers' => [
|
||||
'application/json' => 'yii\web\JsonParser',
|
||||
]
|
||||
'csrfParam' => '_csrf-backend',
|
||||
'cookieValidationKey' => 'CU5iSYmIp6kbjKKuh541KsA_oaYvTuNh',
|
||||
],
|
||||
// //身份认证类
|
||||
'user' => [
|
||||
'identityClass' => 'common\models\User',
|
||||
'identityClass' => 'common\models\Adminer',
|
||||
'enableAutoLogin' => true,
|
||||
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
|
||||
'identityCookie' => ['name' => '_identity-api', 'httpOnly' => TRUE],
|
||||
],
|
||||
'session' => [
|
||||
'name' => 'advanced-frontend-api',
|
||||
'name' => 'advanced-ctms-api',
|
||||
],
|
||||
//Rbac权限控制
|
||||
'authManager' => [
|
||||
'class' => 'yii\rbac\DbManager',
|
||||
],
|
||||
'log' => [
|
||||
'traceLevel' => YII_DEBUG ? 3 : 0,
|
||||
@@ -51,17 +72,16 @@ $config = [
|
||||
'errorHandler' => [
|
||||
'errorAction' => 'site/error',
|
||||
],
|
||||
|
||||
'urlManager' => [
|
||||
'enablePrettyUrl' => false,
|
||||
'enableStrictParsing' => true,
|
||||
'enablePrettyUrl' => TRUE,
|
||||
'showScriptName' => true,
|
||||
'suffix' => '.hi',
|
||||
'suffix' => '.453', //后缀
|
||||
'rules' => [
|
||||
['class' => 'yii\rest\UrlRule', 'controller' => 'realty'], //为***控制器增加一个 URL 规则。这样, 用户的数据就能通过美化的 URL 和有意义的 http 动词进行访问和操作
|
||||
['class' => 'yii\rest\UrlRule', 'controller' => 'setting']
|
||||
],
|
||||
],
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
||||
return $config;
|
||||
|
||||
return $config;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: Fm453
|
||||
# @Last modified time: 2021-09-15T00:09:07+08:00
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-09T17:30:39+08:00
|
||||
|
||||
return [
|
||||
'adminEmail' => 'fm453@lukegzs.com',
|
||||
'redis' => ['IP'=>'127.0.0.1','PORT'=>'6379']
|
||||
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'app-frontend-tests',
|
||||
'id' => 'app-backend-tests',
|
||||
'components' => [
|
||||
'assetManager' => [
|
||||
'basePath' => __DIR__ . '/../web/assets',
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-06-04 11:06:07
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-11-11 13:11:55
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
class AlimsgController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
/*自定义常量*/
|
||||
|
||||
/*默认配置*/
|
||||
$_HI['accessKeyId'] = 'LTAIQrJFtHfqsyOt'; // AccessKeyId
|
||||
$_HI['accessKeySecret'] = 'tvGieI3vNI7Si3imauCB4rJ3OX4AR8'; // AccessKeySecret
|
||||
$_HI['sign'] = '嗨路客';
|
||||
$_HI['tmpl'] = 'SMS_116695055';
|
||||
|
||||
$_HI['reportQueueName'] = 'Alicom-Queue-31737903-SmsReport'; //状态报告接收
|
||||
$_HI['UpQueueName'] = 'Alicom-Queue-31737903-SmsUp'; //上行消息接收
|
||||
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSend()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
|
||||
$_HI['action'] = 'post';
|
||||
//数据取出方法
|
||||
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
|
||||
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : '';
|
||||
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : '';
|
||||
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : '';
|
||||
|
||||
$option = array();
|
||||
|
||||
$_content = isset($dataPost['content']) ? $dataPost['content'] : '';
|
||||
$_content = explode("\r\n",$_content);
|
||||
$content = array();
|
||||
foreach($_content as $c){
|
||||
$_c = explode(',', $c);
|
||||
$k = trim($_c[0]);
|
||||
$v = trim($_c[1]);
|
||||
$content[$k] = $v;
|
||||
}
|
||||
unset($_c);unset($k);unset($v);
|
||||
|
||||
$phone = isset($dataPost['phone']) ? $dataPost['phone'] : '';
|
||||
if($phone){
|
||||
$phone = explode(',', $phone);
|
||||
$phone = array_unique($phone); //去重
|
||||
$phone = array_filter($phone); //去空
|
||||
}
|
||||
|
||||
|
||||
$tmpl = isset($dataPost['tmpl']) ? $dataPost['tmpl'] : '';
|
||||
|
||||
if(isset($_GET['post']) && $_GET['post']==1){
|
||||
$_POST = array('config'=>$config,'option'=>$option,'phone'=>$phone,'content'=>$content,'tmpl'=>$tmpl);
|
||||
Yii::$app->request->setBodyParams($_POST); //重写模拟POST数据
|
||||
// Yii::$app->request->setQueryParams($_POST); //重写模拟GET数据
|
||||
return $this->actionPost($_POST);
|
||||
}
|
||||
|
||||
$sms = new Sms($option,$config);
|
||||
|
||||
$results = array();
|
||||
$msg = "";
|
||||
foreach($phone as $p){
|
||||
$result = $sms->send($p,$tmpl,$content);
|
||||
$results[$p] = $result;
|
||||
if(!$result){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$sms->errors."\r\n";
|
||||
}elseif(is_array($result) && $result['Code'] !='OK'){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$result['Message']."\r\n";
|
||||
}else{
|
||||
$msg .= "【".$p."】发送成功"."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$message = array();
|
||||
$message['title'] = "阿里云短信发送测试";
|
||||
$message['class'] = "success";
|
||||
$message['button'] = array();
|
||||
$message['content'] = "短信发送完毕;接口返回:".$msg;
|
||||
$message['button'][] = array("class"=>"btn btn-success","title"=>"首页","link"=>Url::toRoute('site/index'));
|
||||
$message['button'][] = array("class"=>"btn btn-info","title"=>"接口","link"=>Url::toRoute(['api/index', 'appid' => Yii::$app->user->identity->username]));
|
||||
return $this->render('//layouts/message.php',[
|
||||
'message'=>$message
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionPost()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
|
||||
$_HI['action'] = 'post';
|
||||
//数据取出方法
|
||||
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
|
||||
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
|
||||
$params = Yii::$app->params;
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],strlen(json_encode($dataPost))); //增加一次接口入站数据量累计
|
||||
|
||||
$return = array();
|
||||
$results = array();
|
||||
$msg = "";
|
||||
$errorCode = 0;
|
||||
|
||||
if(!isset($dataPost['config']) || !is_array($dataPost['config'])){
|
||||
$errorCode = '45300403';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$config = $dataPost['config'];
|
||||
|
||||
if(isset($dataPost['option'])){
|
||||
if(!is_array($dataPost['option'])){
|
||||
$errorCode = '45300404';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$option = $dataPost['option'];
|
||||
}else{
|
||||
$option = array();
|
||||
}
|
||||
|
||||
if(!isset($dataPost['tmpl']) || !is_string($dataPost['tmpl'])){
|
||||
$errorCode = '45300405';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$tmpl = $dataPost['tmpl'];
|
||||
|
||||
if(!isset($dataPost['phone']) || !is_array($dataPost['phone'])){
|
||||
$errorCode = '45300406';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$phone = $dataPost['phone'];
|
||||
|
||||
if(isset($dataPost['content'])){
|
||||
if(!is_array($dataPost['content'])){
|
||||
$errorCode = '45300407';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$content = $dataPost['content'];
|
||||
}else{
|
||||
$content = array();
|
||||
}
|
||||
|
||||
$sms = new Sms($option,$config);
|
||||
$error = $sms->errors;
|
||||
if($error){
|
||||
$errorCode = '45300402';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode).";接口提示:".$sms->errors.";";;
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
$msg = "";
|
||||
$errors = 0;
|
||||
$pn = count($phone);
|
||||
foreach($phone as $p){
|
||||
$result = $sms->send($p,$tmpl,$content);
|
||||
var_dump($result);die();
|
||||
$results[$p] = $result;
|
||||
if(!$result){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$sms->errors.";";
|
||||
$errors += 1;
|
||||
}elseif(is_array($result) && $result['Code'] !='OK'){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$result['Message'].";";
|
||||
$errors += 1;
|
||||
}else{
|
||||
$msg .= "【".$p."】发送成功".";";
|
||||
}
|
||||
}
|
||||
|
||||
if($errors>0){
|
||||
if($errors == $pn){
|
||||
$errorcode = 45300402;
|
||||
}else{
|
||||
$errorcode = 45300401;
|
||||
}
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode).";".$msg;
|
||||
$return['data'] = $dataPost;
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
$return['sms_left'] = fmFunc_stat_sms_send($username=$_FM['user']['name'],$times=$pn-$errors); //统计短信发送并返回剩余条数
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use common\models\User;
|
||||
use common\models\CAccess;
|
||||
|
||||
require dirname(__FILE__).'/_public/public_demo.php';
|
||||
|
||||
class ApiController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
$identity = Yii::$app->user->identity;
|
||||
if(!$identity){
|
||||
return $this->goHome();
|
||||
}
|
||||
$_FM['user']['name'] = $identity->username;
|
||||
$_FM['user']['uid'] = $identity->id;
|
||||
|
||||
fmFunc_cert_afterLogin();
|
||||
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'test';
|
||||
|
||||
$request = Yii::$app->request;
|
||||
$request->enableCsrfValidation = false;
|
||||
|
||||
// 返回所有参数
|
||||
$params = $request->get();
|
||||
$_FM['params'] = $params;
|
||||
$accesstoken = isset($_FM['params']['accesstoken']) ? $_FM['params']['accesstoken'] : '';
|
||||
//查询用户信息(根据username)
|
||||
$user = CAccess::findOne(['accesstoken' => $accesstoken]);
|
||||
if($user){
|
||||
$user = $user->toArray();
|
||||
}else{
|
||||
$errorCode = 45300001; //未找到用户
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
$_FM['user'] = $user;
|
||||
$_FM['user']['name'] = $_FM['user']['username'];
|
||||
$cert = fmFunc_cert_exist($_FM['user']['name']);
|
||||
$_FM['apiCert'] = $cert;
|
||||
if ($request->isAjax) {
|
||||
/* 该请求是一个 AJAX 请求 */
|
||||
$result = json_encode(1);
|
||||
}
|
||||
if ($request->isGet) {
|
||||
/* 请求方法是 GET */
|
||||
|
||||
}
|
||||
if ($request->isPost) {
|
||||
/* 请求方法是 POST */
|
||||
}
|
||||
if ($request->isPut) {
|
||||
/* 请求方法是 PUT */
|
||||
|
||||
}
|
||||
|
||||
###定义内容类型###
|
||||
//header('Content-Type: text/html; charset=utf-8'); //网页编码
|
||||
//header('Content-Type: text/plain'); //纯文本格式
|
||||
//header('Content-Type: image/jpeg'); //JPG、JPEG
|
||||
//header('Content-Type: application/zip'); // ZIP文件
|
||||
//header('Content-Type: application/pdf'); // PDF文件
|
||||
//header('Content-Type: audio/mpeg'); // 音频文件
|
||||
//header('Content-type: text/css'); //css文件
|
||||
//header('Content-type: text/javascript'); //js文件
|
||||
//header('Content-Type: application/x-shockw**e-flash'); //Flash动画
|
||||
//header('Content-type: application/pdf'); //pdf
|
||||
//header('Content-type: text/xml'); //xml
|
||||
header('Content-type: application/json'); //json
|
||||
$_FM['apiCert']['timeused'] = getMillisecond() - $START_TIME;
|
||||
$_FM['apiCert']['stat'] = fmFunc_stat_get($username=$_FM['user']['username']);
|
||||
$result = json_encode($_FM['apiCert']);
|
||||
die($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
use Yii;
|
||||
use yii\web\IdentityInterface;
|
||||
use yii\helpers\Url;
|
||||
// use yii\imagine\Image;
|
||||
|
||||
class ImageController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
|
||||
//本方法采用GD库支持
|
||||
|
||||
//创建图片
|
||||
$height = isset($_HI['post']['h']) ? abs($_HI['post']['h']) :(isset($_HI['get']['h']) ? abs($_HI['get']['h']) :0);
|
||||
$height = !$height ? 300 : $height;
|
||||
$width = isset($_HI['post']['w']) ? abs($_HI['post']['w']) :(isset($_HI['get']['w']) ? abs($_HI['get']['w']) :0);
|
||||
$width = !$width ? 300 : $width;
|
||||
|
||||
$im = imagecreatetruecolor($width,$height) or die("Cannot Initialize new GD image stream"); //参数为宽度和高度
|
||||
// $im=ImageCreateFromJpg("https://public.hiluker.com/vcms/nopic.jpg"); //使用背景图片创建
|
||||
|
||||
$bc = isset($_HI['post']['bc']) ? ltrim($_HI['post']['bc']) :(isset($_HI['get']['bc']) ? ltrim($_HI['get']['bc']) :'');
|
||||
$bc = !$bc ? 'AFAFAF' : $bc;
|
||||
$fc = isset($_HI['post']['fc']) ? ltrim($_HI['post']['fc']) :(isset($_HI['get']['fc']) ? ltrim($_HI['get']['fc']) :'');
|
||||
$fc = !$fc ? '333333' : $fc;
|
||||
//添加颜色
|
||||
$bc = $this->Hex2RGB('#'.$bc);
|
||||
$fc = $this->Hex2RGB('#'.$fc);
|
||||
|
||||
|
||||
$text_color = imagecolorallocate($im,$fc['r'],$fc['g'],$fc['b']);
|
||||
$background_color = imagecolorallocate($im,$bc['r'],$bc['g'],$bc['b']);
|
||||
$default_color = imagecolorallocate($im,5,5,5);
|
||||
|
||||
//绘制矩形图片
|
||||
imagefilledrectangle($im , 0, 0, $width-1 , $height-1 , $background_color); //填充
|
||||
// imagefilledrectangle($im , 0, 0, $width-1 , $height-1 , $default_color); //填充
|
||||
// imagerectangle($im , 0, 0, $width-1 , $height-1, $text_color); //边框
|
||||
|
||||
//添加文字
|
||||
$text = isset($_HI['post']['text']) ? trim($_HI['post']['text']) :(isset($_HI['get']['text']) ? trim($_HI['get']['text']) :'');
|
||||
$text = !($text) ? '' : html_entity_decode($text);
|
||||
// imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text );
|
||||
// 图片源;字体尺寸,文字方向,0从左至右,90从一至下;x、y,首字符起点位置,左下角坐标;color颜色索引。使用负的颜色索引值具有关闭防锯齿的效果;fontfile字体文件
|
||||
// imagettftext($im,10,0,$width/2,$height/2,$text_color,"/fonts/STHeiti Medium.ttc","☆"); //中心位置标记
|
||||
|
||||
$strlen = mb_strlen($text); //字符数(中文算1个字符)
|
||||
//BUG 180430 只输入一个字时,部分情况报错(中,0,1,`);无字符输入时报错
|
||||
if($strlen==0){
|
||||
imagettftext($im,10,0,$width/2-1,$height/2-1,$default_color,"/fonts/STHeiti Medium.ttc","☆"); //中心位置标记
|
||||
}else{
|
||||
//文字方向
|
||||
$fd = isset($_HI['post']['fd']) ? intval($_HI['post']['fd']) :(isset($_HI['get']['fd']) ? intval($_HI['get']['fd']) : -1);
|
||||
if($fd==-1){
|
||||
if($width<$height){
|
||||
$fd = 270;
|
||||
}else{
|
||||
$fd = 0;
|
||||
}
|
||||
}
|
||||
$dstyle=1; //文本框长度以矩形长为限
|
||||
// $dstyle=2; //文本框长度以矩形宽为限
|
||||
if($dstyle==1){
|
||||
$long = max($width,$height); //长
|
||||
$short = min($width,$height); //短
|
||||
$fd = ($width<$height) ? 270 : $fd;
|
||||
}else{
|
||||
$long = $width;
|
||||
$short = $height; //短
|
||||
}
|
||||
|
||||
//设置文字大小及位置、方向等
|
||||
$size_l = round($long/$strlen,2)-0.01;
|
||||
$size_l = intval($long/$strlen);
|
||||
$size_s = round($short/3,2)-0.01;
|
||||
$size_s = intval($short/3);
|
||||
$size = min($size_l,$size_s); //每个字的框宽限制
|
||||
|
||||
$f_w = imagefontwidth(6);
|
||||
$f_h = imagefontheight(6);
|
||||
|
||||
$fontsize = intval(($size-$f_w)/1.2); //字体大小
|
||||
|
||||
$text_w = $f_w;
|
||||
if($strlen>1){
|
||||
for($i=0;$i<$strlen;$i++){
|
||||
$t = mb_substr($text, $i, 1, 'utf-8');
|
||||
$len = strlen($t);
|
||||
if($len==3){
|
||||
$text_w += $fontsize+$f_w;
|
||||
}elseif($len==2){
|
||||
$text_w += $fontsize*2/3;
|
||||
}elseif($len==1){
|
||||
$text_w += $fontsize*2/3;
|
||||
}
|
||||
}
|
||||
$text_w = $text_w-$f_w;
|
||||
}else{
|
||||
$text_w = $fontsize;
|
||||
}
|
||||
|
||||
$p_l = $long/2 -$text_w/2;
|
||||
$p_l = intval($p_l);
|
||||
$p_s = $short/2+$fontsize/2; //字符串底部-y轴高度
|
||||
$p_s = intval($p_s);
|
||||
|
||||
if($fd==90){
|
||||
//90度时,右下角位置
|
||||
$x = $p_s-$f_h;
|
||||
$y = $p_l+$text_w;
|
||||
}elseif($fd==270){
|
||||
//270度时,左上角位置
|
||||
$x = $short/2-$fontsize/2;
|
||||
$y = $p_l+$f_w;
|
||||
}else{
|
||||
//0度时,左下角位置
|
||||
$x = ($strlen==1) ? $p_l-$f_w : $p_l-$fontsize/2+2*$f_w;
|
||||
$y = $p_s-$f_h;
|
||||
}
|
||||
|
||||
// var_dump('文本:'.$text);var_dump('字数:'.$strlen);var_dump('字框宽度:'.$size);var_dump('字体大小:'.$fontsize);var_dump('字体宽度:'.$f_w);var_dump('字体高度:'.$f_h);var_dump('文本框总宽度:'.$text_w);var_dump('字符X轴位置:'.$x);var_dump('字符Y轴位置:'.$y);var_dump('文字方向:'.$fd);die();
|
||||
imagettftext($im,$fontsize,$fd,$x+1,$y+1,$default_color,"/fonts/Arial Unicode.ttf",$text);
|
||||
imagettftext($im,$fontsize,$fd,$x,$y,$text_color,"/fonts/Arial Unicode.ttf",$text);
|
||||
}
|
||||
|
||||
//生成图片
|
||||
ob_clean();
|
||||
// header("Content-type:image/jpeg;");
|
||||
// imagejpeg($im,null,100);
|
||||
header("Content-type:image/png;");
|
||||
imagepng($im);
|
||||
//在根目录下生成图片文件
|
||||
// imagejpeg($im,"temp2.jpg",100);
|
||||
// imagepng($im,"temp2.png");
|
||||
//释放内存
|
||||
imagedestroy($im);
|
||||
}
|
||||
|
||||
/**
|
||||
* RGB转 十六进制
|
||||
* @param $rgb RGB颜色的字符串 如:rgb(255,255,255);
|
||||
* @return string 十六进制颜色值 如:#FFFFFF
|
||||
*/
|
||||
function RGB2Hex($rgb){
|
||||
$regexp = "/^rgb\(([0-9]{0,3})\,\s*([0-9]{0,3})\,\s*([0-9]{0,3})\)/";
|
||||
$re = preg_match($regexp, $rgb, $match);
|
||||
$re = array_shift($match);
|
||||
$hexColor = "#";
|
||||
$hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$r = null;
|
||||
$c = $match[$i];
|
||||
$hexAr = array();
|
||||
while ($c > 16) {
|
||||
$r = $c % 16;
|
||||
$c = ($c / 16) >> 0;
|
||||
array_push($hexAr, $hex[$r]);
|
||||
}
|
||||
array_push($hexAr, $hex[$c]);
|
||||
$ret = array_reverse($hexAr);
|
||||
$item = implode('', $ret);
|
||||
$item = str_pad($item, 2, '0', STR_PAD_LEFT);
|
||||
$hexColor .= $item;
|
||||
}
|
||||
return $hexColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制 转 RGB
|
||||
*/
|
||||
function Hex2RGB($hexColor) {
|
||||
$color = str_replace('#', '', $hexColor);
|
||||
if (strlen($color) > 3) {
|
||||
$rgb = array(
|
||||
'r' => hexdec(substr($color, 0, 2)),
|
||||
'g' => hexdec(substr($color, 2, 2)),
|
||||
'b' => hexdec(substr($color, 4, 2))
|
||||
);
|
||||
} else {
|
||||
$color = $hexColor;
|
||||
$r = substr($color, 0, 1) . substr($color, 0, 1);
|
||||
$g = substr($color, 1, 1) . substr($color, 1, 1);
|
||||
$b = substr($color, 2, 1) . substr($color, 2, 1);
|
||||
$rgb = array(
|
||||
'r' => hexdec($r),
|
||||
'g' => hexdec($g),
|
||||
'b' => hexdec($b)
|
||||
);
|
||||
}
|
||||
return $rgb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成图片
|
||||
* @param array 参数,包括图片和文字
|
||||
* @param string $filename 生成海报文件名,不传此参数则不生成文件,直接输出图片
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function createPoster($config=array(),$filename=""){
|
||||
//如果要看报什么错,可以先注释调这个header
|
||||
if(empty($filename)) header("content-type: image/png");
|
||||
$imageDefault = array(
|
||||
'left'=>0,
|
||||
'top'=>0,
|
||||
'right'=>0,
|
||||
'bottom'=>0,
|
||||
'width'=>100,
|
||||
'height'=>100,
|
||||
'opacity'=>100
|
||||
);
|
||||
$textDefault = array(
|
||||
'text'=>'',
|
||||
'left'=>0,
|
||||
'top'=>0,
|
||||
'fontSize'=>32, //字号
|
||||
'fontColor'=>'255,255,255', //字体颜色
|
||||
'angle'=>0,
|
||||
);
|
||||
$background = $config['background'];//海报最底层得背景
|
||||
//背景方法
|
||||
$backgroundInfo = getimagesize($background);
|
||||
$backgroundFun = 'imagecreatefrom'.image_type_to_extension($backgroundInfo[2], false);
|
||||
$background = $backgroundFun($background);
|
||||
$backgroundWidth = imagesx($background); //背景宽度
|
||||
$backgroundHeight = imagesy($background); //背景高度
|
||||
$imageRes = imageCreatetruecolor($backgroundWidth,$backgroundHeight);
|
||||
$color = imagecolorallocate($imageRes, 0, 0, 0);
|
||||
imagefill($imageRes, 0, 0, $color);
|
||||
// imageColorTransparent($imageRes, $color); //颜色透明
|
||||
imagecopyresampled($imageRes,$background,0,0,0,0,imagesx($background),imagesy($background),imagesx($background),imagesy($background));
|
||||
//处理了图片
|
||||
if(!empty($config['image'])){
|
||||
foreach ($config['image'] as $key => $val) {
|
||||
$val = array_merge($imageDefault,$val);
|
||||
$info = getimagesize($val['url']);
|
||||
$function = 'imagecreatefrom'.image_type_to_extension($info[2], false);
|
||||
if($val['stream']){ //如果传的是字符串图像流
|
||||
$info = getimagesizefromstring($val['url']);
|
||||
$function = 'imagecreatefromstring';
|
||||
}
|
||||
$res = $function($val['url']);
|
||||
$resWidth = $info[0];
|
||||
$resHeight = $info[1];
|
||||
//建立画板 ,缩放图片至指定尺寸
|
||||
$canvas=imagecreatetruecolor($val['width'], $val['height']);
|
||||
imagefill($canvas, 0, 0, $color);
|
||||
//关键函数,参数(目标资源,源,目标资源的开始坐标x,y, 源资源的开始坐标x,y,目标资源的宽高w,h,源资源的宽高w,h)
|
||||
imagecopyresampled($canvas, $res, 0, 0, 0, 0, $val['width'], $val['height'],$resWidth,$resHeight);
|
||||
$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']) - $val['width']:$val['left'];
|
||||
$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']) - $val['height']:$val['top'];
|
||||
//放置图像
|
||||
imagecopymerge($imageRes,$canvas, $val['left'],$val['top'],$val['right'],$val['bottom'],$val['width'],$val['height'],$val['opacity']);//左,上,右,下,宽度,高度,透明度
|
||||
}
|
||||
}
|
||||
//处理文字
|
||||
if(!empty($config['text'])){
|
||||
foreach ($config['text'] as $key => $val) {
|
||||
$val = array_merge($textDefault,$val);
|
||||
list($R,$G,$B) = explode(',', $val['fontColor']);
|
||||
$fontColor = imagecolorallocate($imageRes, $R, $G, $B);
|
||||
$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']):$val['left'];
|
||||
$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']):$val['top'];
|
||||
imagettftext($imageRes,$val['fontSize'],$val['angle'],$val['left'],$val['top'],$fontColor,$val['fontPath'],$val['text']);
|
||||
}
|
||||
}
|
||||
//生成图片
|
||||
if(!empty($filename)){
|
||||
$res = imagejpeg ($imageRes,$filename,90); //保存到本地
|
||||
imagedestroy($imageRes);
|
||||
if(!$res) return false;
|
||||
return $filename;
|
||||
}else{
|
||||
imagejpeg ($imageRes); //在浏览器上显示
|
||||
imagedestroy($imageRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionGet()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'get';
|
||||
//设置数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$data = array();
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataGet);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/get_data.php';
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
//return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'save';
|
||||
//设置数据保存方法
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/save_data.php';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,482 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class MetadataController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
use Yii;
|
||||
use yii\web\IdentityInterface;
|
||||
use common\models\User;
|
||||
use common\models\LoginForm;
|
||||
//use yii\helpers\Url;
|
||||
|
||||
//use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
class OssController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
}
|
||||
|
||||
/**
|
||||
* Login.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$post = $request->post();
|
||||
|
||||
if(isset($_GET['api']) && $_GET['api']){
|
||||
//API接口请求,模拟登陆
|
||||
|
||||
//查询用户信息(根据username)
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT * FROM c_user WHERE username = :username";
|
||||
$params[':username'] = urldecode($_GET['LoginForm']['username']);
|
||||
$_user = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if(!$_user){
|
||||
$errorCode = 45300001; //未找到用户
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//如果cert证书文件文件存在,则判断;域名、IP不合规时,不允许访问
|
||||
$username = $_GET['LoginForm']['username'];
|
||||
$cert = fmFunc_cert_exist($username);
|
||||
$viaDomain = fmFunc_server_via_domain();
|
||||
$viaIP = fmFunc_server_via_ip();
|
||||
$_FM['viaDomain'] = $viaDomain;
|
||||
$_FM['viaIp'] = $viaIP;
|
||||
$isAvailable = $cert ? fmFunc_cert_beforeLogin($cert,$viaIP,$viaDomain) : true;
|
||||
if(!$isAvailable) {
|
||||
$errorCode = 45300101; //非法访问1(来路IP或域名不在白名单中)
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//安全校验,登陆密码、授权码auth_key
|
||||
$auth_key = $_user['auth_key'];
|
||||
$hash = $_user['password_hash'];
|
||||
$password = urldecode($_GET['LoginForm']['password']);
|
||||
|
||||
$isPwdRight = Yii::$app->getSecurity()->validatePassword($password, $hash);
|
||||
if (!$isPwdRight) {
|
||||
$errorCode = 45300002; //密码错误
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
if($_user['status'] < 10){
|
||||
$errorCode = 45300003; //账号被冻结
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//校验结束
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$identity = User::findOne(['username' => $_GET['LoginForm']['username']]);
|
||||
|
||||
// 登录用户,有效期30d
|
||||
$duration = 3600 * 24 * 30;
|
||||
$_login = Yii::$app->user->login($identity, $duration);
|
||||
if ($_login) {
|
||||
//将用户信息写入全局变量
|
||||
$_FM['user']['name'] = $identity->username;
|
||||
$_FM['user']['uid'] = $identity->id;
|
||||
$result = 0;
|
||||
$result = json_encode($result);
|
||||
|
||||
//执行登陆后的证书创建/更新等工作
|
||||
fmFunc_cert_afterLogin();
|
||||
|
||||
//将token以data结果返回到客户侧
|
||||
$result = array();
|
||||
$result['errorcode'] = 0;
|
||||
$result['data'] = $_FM['token'];
|
||||
$result = json_encode($result);
|
||||
echo $result; //输出结果到前端视图渲染一次,否则客户侧的模拟登陆无法取cookie
|
||||
return; //返回,否则会继续执行最下面的未知报错
|
||||
} else {
|
||||
$errorCode = 45300004; //登陆失败
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$errorCode = 4530009999; //未知错误
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,481 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class PageController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionGet()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'get';
|
||||
//设置数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$data = array();
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataGet);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/get_data.php';
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
//return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'save';
|
||||
//设置数据保存方法
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/save_data.php';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-27 22:28:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(演示版,默认针对vcms的fm453_*系列应用)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定客户id\分组id
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 'undefined';
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
|
||||
//继续根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : 'undefined';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : 'undefined';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : 'undefined';
|
||||
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.$group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
}else{
|
||||
$type = 'app';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台用户组
|
||||
|
||||
if($isAppWeb) {
|
||||
$type = 'appweb';
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台核销用户组
|
||||
}
|
||||
}
|
||||
|
||||
//发送反馈消息
|
||||
$message = array();
|
||||
$message = '棒,客户端绑定成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'tips';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
//根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : '';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : '';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : '';
|
||||
|
||||
if($client_type) {
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
}elseif($isAppWeb){
|
||||
$type = 'appweb';
|
||||
}else{
|
||||
$type = 'app';
|
||||
}
|
||||
if($do){
|
||||
if($ac){
|
||||
if($op){
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}else{
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
|
||||
// 以下是调用示例,接口与GatewayWorker环境的接口一致
|
||||
// 接口具体使用方法见《Lib\Gateway类提供的接口》一章
|
||||
// 注意除了不支持sendToCurrentClient和closeCurrentClient方法
|
||||
// 其它方法都支持
|
||||
//Gateway::sendToAll($data);
|
||||
//Gateway::sendToClient($client_id, $data);
|
||||
//Gateway::closeClient($client_id);
|
||||
//Gateway::isOnline($client_id);
|
||||
//Gateway::bindUid($client_id, $uid);
|
||||
//Gateway::isUidOnline($uid);
|
||||
//Gateway::getClientIdByUid($uid);
|
||||
//Gateway::unbindUid($client_id, $uid);
|
||||
//Gateway::sendToUid($uid, $data);
|
||||
//Gateway::joinGroup($client_id, $group);
|
||||
//Gateway::sendToGroup($group, $data);
|
||||
//Gateway::leaveGroup($client_id, $group);
|
||||
//Gateway::getClientCountByGroup($group);
|
||||
//Gateway::getClientSessionsByGroup($group);
|
||||
//Gateway::getAllClientCount();
|
||||
//Gateway::getAllClientSessions();
|
||||
//Gateway::setSession($client_id, $session);
|
||||
//Gateway::updateSession($client_id, $session);
|
||||
//Gateway::getSession($client_id);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,562 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-30 10:11:22
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(针对嗨噜应用系统的HOFC嗨骑定向小程序)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushhofcController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定项
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
//常规绑定(绑定到UID,未传入用户详情)
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC-USER';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
if(!$uid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定用户';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$uid = $group_pre.fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户('.$uid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBinduser()
|
||||
{
|
||||
//绑定用户及详情、APPID,同时向数据关联组发送用户信息
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
//绑定到当前用户组,供服务侧同步绑定校验
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip();
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
if(!$uid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定用户';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$uid = $group_pre.'-USER-'.fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户('.$uid.')成功!';
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
|
||||
$group_ids = array();
|
||||
$group_id = '';
|
||||
//绑定小程序ID
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
if(!$appid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定小程序';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
}else{
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定小程序('.$appid.')成功!';
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
}
|
||||
|
||||
//向数据展板推送用户信息
|
||||
$user = isset($dataPost['user']) ? $dataPost['user'] : [];
|
||||
$time = time();
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'content'; //消息反馈类型:alert,confirm,toast,content,reg
|
||||
if(isset($dataPost['new']) && $dataPost['new']==1){
|
||||
$data['type'] = 'reg';
|
||||
}
|
||||
$data['msg'] = '由['.$viaIP.']进入了寻宝应用('.date('H:i').')';
|
||||
$data['status']=1; //消息状态
|
||||
$data['avatar'] = isset($user['face']) ? $user['face'] : '';
|
||||
$data['username'] = $user['nick_name']; //昵称
|
||||
$data['title'] = '系统提示'; //消息标题
|
||||
$data['mid'] = isset($user['user_id']) ? $user['user_id'] : -1; //消息来源会员, -1为公众号本身
|
||||
$data['id'] = md5($time.'_'.$user['user_id']);
|
||||
$data['ctype'] = 0; //消息内容类型(-1,系统消息;-2表情;-3快捷表态;-4 红包;0,默认,文本消息;1图片;3音频; 4视频;)
|
||||
$data['createtime'] = $time;
|
||||
$data = json_encode($data);
|
||||
//推送数据
|
||||
Gateway::sendToGroup($group_ids[$group_id], $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindgroup()
|
||||
{
|
||||
//绑定用户组
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
//绑定到当前用户组,供服务侧同步绑定校验
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
if($group_id){
|
||||
$group_ids[0] = $group_pre.fmFunc_server_hash_id(0);;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[0]); //将用户加入0会员组
|
||||
}
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户组成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindteam()
|
||||
{
|
||||
//绑定团队ID,方便同步接收
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$teamid = isset($dataPost['teamid']) ? $dataPost['teamid'] : 0;
|
||||
if(!$teamid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定队伍';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$group_id = 'team_'.$teamid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定队伍('.$teamid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindwxapp()
|
||||
{
|
||||
//绑定小程序ID
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
if(!$appid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定小程序';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定小程序('.$appid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'XCX-HOFC';
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
if($client_type) {
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据并向全部客户端群发
|
||||
*/
|
||||
public function actionSend2all()
|
||||
{
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
global $_FM;
|
||||
global $_HI;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : ' ';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type; //消息反馈类型:alert,confirm,toast,content
|
||||
$data['msg'] = $msg;
|
||||
$data['status']=1; //消息状态
|
||||
$data['avatar'] = isset($dataPost['avatar']) ? $dataPost['avatar'] : '';
|
||||
$data['username'] = '管理员'; //昵称
|
||||
$data['title'] = '系统提示'; //消息标题
|
||||
$data['mid'] = isset($dataPost['mid']) ? $dataPost['mid'] : 1; //消息来源会员, -1为公众号本身
|
||||
$time = time();
|
||||
$data['id'] = isset($dataPost['id']) ? $dataPost['id'] :md5($time.'_'.$data['mid']);
|
||||
$data['ctype'] = isset($dataPost['type']) ? $dataPost['type'] : 0; //消息内容类型(-1,系统消息;-2表情;-3快捷表态;-4 红包;0,默认,文本消息;1图片;3音频; 4视频;)
|
||||
$data['createtime'] = $time;
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
$data = json_encode($data);
|
||||
//向全体推送数据
|
||||
//设定群发群组
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$count++;
|
||||
Gateway::sendToGroup($group_ids[$group_id], $data);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '消息已发送';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,513 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-29 17:08:02
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(针对vcms的fm453_*系列应用)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushimmsController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定客户id\分组id
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 'undefined';
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
if($group_id){
|
||||
$group_ids[0] = $group_pre.fmFunc_server_hash_id(0);;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
}
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
|
||||
|
||||
//继续根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : 'undefined';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : 'undefined';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : 'undefined';
|
||||
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.$group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
}else{
|
||||
$type = 'app';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台用户组
|
||||
|
||||
if($isAppWeb) {
|
||||
$type = 'appweb';
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台核销用户组
|
||||
}
|
||||
}
|
||||
|
||||
//发送反馈消息
|
||||
$message = array();
|
||||
$message = '棒,客户端绑定成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'tips';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
// header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
//根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : '';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : '';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : '';
|
||||
|
||||
if($client_type) {
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
}elseif($isAppWeb){
|
||||
$type = 'appweb';
|
||||
}else{
|
||||
$type = 'app';
|
||||
}
|
||||
if($do){
|
||||
if($ac){
|
||||
if($op){
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}else{
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据并向全部客户端群发
|
||||
*/
|
||||
public function actionSend2all()
|
||||
{
|
||||
// header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
global $_FM;
|
||||
global $_HI;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : ' ';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : '';
|
||||
if(!$accessToken){
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'log';
|
||||
$data['msg'] = '未指定accessToken';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
// $params[':domain'] = $viaDomain;
|
||||
// $params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}else{
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'log';
|
||||
$data['msg'] = '无效的accessToken';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//设定群发群组
|
||||
$group_id = $group_pre.fmFunc_server_hash_id(0);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
// $data['type'] = 'alert';
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
return;
|
||||
}
|
||||
$data = json_encode($data);
|
||||
//向全体推送数据
|
||||
$count++;
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '消息已发送';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,481 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class RealtyController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'house'; //楼盘数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'room'; //房型数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_FM;
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'house'; //数据,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'room'; //数据,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'house'; //楼盘数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'room'; //户型数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,475 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SearchController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回param列表
|
||||
$sn = $s_sn;
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list=array();
|
||||
$list[]=$record;
|
||||
$record = $list;
|
||||
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
|
||||
$v = $record;
|
||||
}
|
||||
unset($v);
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = $s_sn;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
$_goods = array(
|
||||
"title" => '产品查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的产品关键词。
|
||||
提示:您可使用 产品名称中的词语作为条件(如,××酒店,芒果等),进行模糊查询匹配;我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '产品'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询产品,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关产品,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_goods',
|
||||
)
|
||||
);
|
||||
|
||||
$_member = array(
|
||||
"title" => '会员查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的会员关键词。
|
||||
提示:您可使用 姓名、籍贯、行业等条件,进行模糊查询匹配;我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '产品'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询会员资料,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关资料,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_member',
|
||||
)
|
||||
);
|
||||
|
||||
$_article = array(
|
||||
"title" => '文章查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的文章内容关键词。
|
||||
提示:我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '文章'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询文章内容,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关资料,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_article',
|
||||
)
|
||||
);
|
||||
@@ -1,481 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Setting s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Setting f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Setting o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
die(json_encode($_FM));
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
global $_FM;
|
||||
var_dump($_FM);
|
||||
return;
|
||||
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-09 23:05:45
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-09 23:06:05
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidParamException;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\filters\AccessControl;
|
||||
use frontend\models\LoginForm;
|
||||
use frontend\models\PasswordResetRequestForm;
|
||||
use frontend\models\ResetPasswordForm;
|
||||
use frontend\models\SignupForm;
|
||||
use frontend\models\ContactForm;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
*/
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'only' => ['logout', 'signup'],
|
||||
'rules' => [
|
||||
[
|
||||
'actions' => ['signup'],
|
||||
'allow' => true,
|
||||
'roles' => ['?'],
|
||||
],
|
||||
[
|
||||
'actions' => ['logout'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'logout' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'class' => 'yii\web\ErrorAction',
|
||||
],
|
||||
'captcha' => [
|
||||
'class' => 'yii\captcha\CaptchaAction',
|
||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays homepage.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||
return $this->goBack();
|
||||
} else {
|
||||
return $this->render('login', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the current user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::$app->user->logout();
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays contact page.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionContact()
|
||||
{
|
||||
$model = new ContactForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
|
||||
Yii::$app->session->setFlash('success', '已收到您的反馈,我们将尽快响应并联系您。');
|
||||
} else {
|
||||
Yii::$app->session->setFlash('error', '消息发送时系统遇到错误.');
|
||||
}
|
||||
|
||||
return $this->refresh();
|
||||
} else {
|
||||
return $this->render('contact', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays about page.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionAbout()
|
||||
{
|
||||
return $this->render('about');
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs user up.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionSignup()
|
||||
{
|
||||
$model = new SignupForm();
|
||||
if ($model->load(Yii::$app->request->post())) {
|
||||
if ($user = $model->signup()) {
|
||||
if (Yii::$app->getUser()->login($user)) {
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('signup', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests password reset.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionRequestPasswordReset()
|
||||
{
|
||||
$model = new PasswordResetRequestForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
if ($model->sendEmail()) {
|
||||
Yii::$app->session->setFlash('success', '发送完毕,请登陆您的邮箱查阅并进行接下来的操作.');
|
||||
|
||||
return $this->goHome();
|
||||
} else {
|
||||
Yii::$app->session->setFlash('error', '抱歉,系统无法向您填写的邮箱发送重置邮件,请检查邮箱地址.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('requestPasswordResetToken', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets password.
|
||||
*
|
||||
* @param string $token
|
||||
* @return mixed
|
||||
* @throws BadRequestHttpException
|
||||
*/
|
||||
public function actionResetPassword($token)
|
||||
{
|
||||
try {
|
||||
$model = new ResetPasswordForm($token);
|
||||
} catch (InvalidParamException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage());
|
||||
}
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
|
||||
Yii::$app->session->setFlash('success', '新密码已保存.');
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
return $this->render('resetPassword', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
//取form表sn
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$f_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$f_sn) {
|
||||
$initdata = $dbmodel->data_format($data,$suffix);
|
||||
$initdata['title'] = $f_sn_title;
|
||||
$initdata['value'] = '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$f_sn = $initdata['sn'];
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取addon表数据
|
||||
$suffix = 'addon';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor]=[];
|
||||
$record[$setfor][$title]=[];
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300307;
|
||||
}
|
||||
$result = $record;
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
//取data表数据
|
||||
$suffix = 'data';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300302;
|
||||
}
|
||||
$result = $record;
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取form表数据
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','s_sn','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300305;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取order表数据
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','s_sn','f_sn','sn','partnerid','mid','fid','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300306;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取param表数据
|
||||
$suffix = 'param';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300303;
|
||||
}
|
||||
|
||||
$result = $record;
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self表某站点、sn对应数据
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','sn','title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300304;
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取form数据列表
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('s_sn','platid','uniacid','shopid','partnerid','uid','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
//跨平台搜索条件
|
||||
if(isset($data['searching']['plat']) && $data['searching']['plat']==$platid){
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
}else{
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
//增加搜索条件,取多s_sn查询
|
||||
$issearching = isset($data['searching']) ? true : false;
|
||||
$searching = array();
|
||||
if($issearching){
|
||||
$condition_searching = $condition;
|
||||
$params_searching = $params;
|
||||
//系统自带搜索条件约定(精确匹配)
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`status` = :status";
|
||||
$params_searching[':status'] = intval($data['searching']['status']);
|
||||
}
|
||||
|
||||
if(isset($data['searching']['deleted'])){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`deleted` = :deleted";
|
||||
$params_searching[':deleted'] = intval($data['searching']['deleted']);
|
||||
}
|
||||
//搜索条件filter参数过滤
|
||||
if(isset($data['searching']['filter'])){
|
||||
foreach($data['searching']['filter'] as $_k =>$_v){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`key` = :key";
|
||||
$params_searching[':key'] = $_k;
|
||||
$condition_searching .=" AND ";
|
||||
if(is_array($_v)){
|
||||
$x_condition = "(";
|
||||
$x_i = count($_v);
|
||||
foreach($_v as $xk=>$xv){
|
||||
$x_i--;
|
||||
$x_condition .= "'".serialize($xv)."'";
|
||||
if($x_i>0){
|
||||
$x_condition .= ",";
|
||||
}
|
||||
}
|
||||
$x_condition .=")";
|
||||
$condition_searching .="`value` IN ".$x_condition;
|
||||
}else{
|
||||
$condition_searching .="`value` LIKE :value";
|
||||
$params_searching[':value'] = '%'.serialize($_v).'%';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//客户侧传入的额外搜索条件(模糊可选匹配)
|
||||
if(isset($data['searching']['addons'])){
|
||||
foreach($data['searching']['addons'] as $_k =>$_v){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`key` = :key";
|
||||
$params_searching[':key'] = $_k;
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`value` LIKE :value";
|
||||
$params_searching[':value'] = '%'.serialize($_v).'%';
|
||||
|
||||
$temp_tableName = $tablePre.'_'.$table.'_param';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('s_sn'), $condition_searching, $params_searching, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
if($_vv['s_sn'] != $s_sn){
|
||||
$searching[] = $_vv['s_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$temp_tableName = $tablePre.'_'.$table.'_param';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('s_sn'), $condition_searching, $params_searching, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
if($_vv['s_sn'] != $s_sn && !in_array($_vv['s_sn'],$searching)){
|
||||
$searching[] = $_vv['s_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$searching = array_unique($searching);
|
||||
$issearching = (count($searching) == 0) ? false : true;
|
||||
|
||||
//传入了s_sn时,也作为搜索条件
|
||||
if($s_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
}elseif($issearching){
|
||||
$s_sns = '';
|
||||
foreach($searching as $temp_s_sn){
|
||||
$s_sns .= $temp_s_sn.",";
|
||||
}
|
||||
$s_sns .= $s_sns;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` IN (".$s_sns.")";
|
||||
}
|
||||
|
||||
if($issearching){
|
||||
$op = '';
|
||||
}
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = $data['searching']['status'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
//补充搜索条件
|
||||
if(isset($data['searching']['keyword'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` LIKE :keyword";
|
||||
$params[':keyword'] = '%'.$data['searching']['keyword'].'%';
|
||||
}
|
||||
|
||||
//数据分页
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
//数据排序
|
||||
$orders = !empty($data['sqls']['orders']) ? $data['sqls']['orders'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300305;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取order数据列表
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('s_sn','f_sn','platid','uniacid','shopid','partnerid','mid','fid','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
//传入了s_sn时,也作为搜索条件
|
||||
if($s_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
}
|
||||
|
||||
//增加搜索条件,取多f_sn查询
|
||||
$issearching = false;
|
||||
$searching = array();
|
||||
if($issearching){
|
||||
if(isset($data['searching']['addons'])){
|
||||
foreach($data['searching']['addons'] as $_k =>$_v){
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $_k;
|
||||
$condition .=" AND ";
|
||||
$condition .="`value` LIKE :value";
|
||||
$params[':value'] = '%'.$_v.'%';
|
||||
|
||||
$temp_tableName = $tablePre.'_'.$table.'_addon';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('f_sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
$searching[] = $_vv['f_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$searching = array_unique($searching);
|
||||
$issearching = (count($searching) == 0) ? false : true;
|
||||
|
||||
//传入了f_sn时,也作为搜索条件
|
||||
if($f_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
}elseif($issearching){
|
||||
$f_sns = '';
|
||||
foreach($searching as $temp_f_sn){
|
||||
$f_sns .= $temp_f_sn.",";
|
||||
}
|
||||
$f_sns .= $f_sns;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` IN (".$f_sns.")";
|
||||
}
|
||||
|
||||
if($issearching){
|
||||
$op = '';
|
||||
}
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = $data['searching']['status'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
//补充搜索条件
|
||||
if(isset($data['searching']['keyword'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` LIKE :keyword";
|
||||
$params[':keyword'] = '%'.$data['searching']['keyword'].'%';
|
||||
}
|
||||
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300306;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self数据列表,只对应到站点即可
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','sn','title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300304;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$uid = isset($data['uid']) ? $data['uid'] : 0;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['value'] = isset($initdata['value']) ? $initdata['value'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$f_sn = $initdata['sn'];
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['value'] = isset($initdata['value']) ? $initdata['value'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
$initdata['f_sn'] = $f_sn;
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$o_sn = $initdata['sn'];
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['keywords'] = isset($initdata['keywords']) ? $initdata['keywords'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$s_sn = $initdata['sn'];
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
//取order表sn
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$o_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$o_sn) {
|
||||
$initdata = $dbmodel->data_format($data,$suffix);
|
||||
$initdata['title'] = $o_sn_title;
|
||||
$initdata['value'] = '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
$initdata['f_sn'] = $f_sn;
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$o_sn = $initdata['sn'];
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
$setfor = isset($dataGet['setfor']) ? $dataGet['setfor'] : 'index';
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//TBD uniacid的更复杂逻辑处理,以便平台模式切换
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'null';
|
||||
|
||||
$ac = isset($dataGet['ac']) ? $dataGet['ac'] : 'null';
|
||||
|
||||
$siteId = isset($_FM['apiCert']['siteId']) ? $_FM['apiCert']['siteId'] : 0;
|
||||
|
||||
$platid = (isset($dataGet['platid']) && intval($dataGet['platid'])>0) ? intval($dataGet['platid']) : 0;
|
||||
//TBD 进一步校验platid是否合法
|
||||
$platid = (isset($_FM['platid'])) ? $_FM['platid'] : $platid;
|
||||
|
||||
$uniacid = (isset($dataGet['uniacid']) && intval($dataGet['uniacid'])>0) ? intval($dataGet['uniacid']) : 0;
|
||||
//TBD 进一步校验uniacid是否合法
|
||||
$uniacid = (isset($_FM['uniacid'])) ? $_FM['uniacid'] : $uniacid;
|
||||
|
||||
$shopid = (isset($dataGet['shopid']) && intval($dataGet['shopid'])>0) ? intval($dataGet['shopid']) : 0;
|
||||
//TBD 进一步校验shopid是否合法
|
||||
$shopid = (isset($_FM['shopid'])) ? $_FM['shopid'] : $shopid;
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
global $START_TIME;
|
||||
$START_TIME = getMillisecond();
|
||||
//加载变量设置
|
||||
global $_FM;
|
||||
|
||||
//记录请求日志-20170629
|
||||
$dologs = new common\components\DoLogs;
|
||||
$dologs ->record();
|
||||
|
||||
//授权服务器通讯检查,排除前台登陆演示'我的接口'时的判断
|
||||
$errorCode=0;
|
||||
|
||||
if(substr($_GET['r'],-6) !='/index'){
|
||||
$errorCode = fmFunc_cert_checkAuth();
|
||||
}
|
||||
|
||||
if($errorCode!=0){
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}
|
||||
|
||||
//未登陆不返回数据!
|
||||
if(!isset($_FM['user']['name']))
|
||||
{
|
||||
$errorCode = 45300201;
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}elseif (Yii::$app->user->isGuest)
|
||||
{
|
||||
$errorCode = 45300201;
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}
|
||||
|
||||
//补充添加平台号关联
|
||||
$_FM['platid'] = isset($_GET['platid']) ? intval($_GET['platid']) : 0;
|
||||
if(isset($_FM['apiCert']['platid'])){
|
||||
$_FM['platid'] = $_FM['apiCert']['platid'];
|
||||
}
|
||||
$_FM['uniacid'] = isset($_GET['uniacid']) ? intval($_GET['uniacid']) : 0;
|
||||
if(isset($_FM['apiCert']['uniacid'])){
|
||||
$_FM['uniacid'] = $_FM['apiCert']['uniacid'];
|
||||
}
|
||||
$_FM['shopid'] = isset($_GET['shopid']) ? intval($_GET['shopid']) : 0;
|
||||
if(isset($_FM['apiCert']['shopid'])){
|
||||
$_FM['shopid'] = $_FM['apiCert']['shopid'];
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
global $START_TIME;
|
||||
$START_TIME = getMillisecond();
|
||||
//加载变量设置
|
||||
global $_FM;
|
||||
|
||||
//记录请求日志-20170629
|
||||
$dologs = new common\components\DoLogs;
|
||||
$dologs ->record();
|
||||
|
||||
//授权服务器通讯检查,排除前台登陆演示我的接口时的判断
|
||||
$errorCode=0;
|
||||
|
||||
//未登陆不返回数据!
|
||||
// if(!isset($_FM['user']['name']))
|
||||
// {
|
||||
// $errorCode = 45300201;
|
||||
// die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
// }elseif (Yii::$app->user->isGuest)
|
||||
// {
|
||||
// $errorCode = 45300201;
|
||||
// die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
// }
|
||||
|
||||
//补充添加平台号关联
|
||||
$_FM['platid'] = isset($_GET['platid']) ? intval($_GET['platid']) : 0;
|
||||
if(isset($_FM['apiCert']['platid'])){
|
||||
$_FM['platid'] = $_FM['apiCert']['platid'];
|
||||
}
|
||||
$_FM['uniacid'] = isset($_GET['uniacid']) ? intval($_GET['uniacid']) : 0;
|
||||
if(isset($_FM['apiCert']['uniacid'])){
|
||||
$_FM['uniacid'] = $_FM['apiCert']['uniacid'];
|
||||
}
|
||||
$_FM['shopid'] = isset($_GET['shopid']) ? intval($_GET['shopid']) : 0;
|
||||
if(isset($_FM['apiCert']['shopid'])){
|
||||
$_FM['shopid'] = $_FM['apiCert']['shopid'];
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self表sn,SELF对应到客户端站点系统级——每个站点均支持多个主模型存在
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$s_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$s_sn) {
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['keywords'] = isset($initdata['keywords']) ? $initdata['keywords'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$s_sn = $initdata['sn'];
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置addon表数据
|
||||
$suffix = 'addon';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$o_sn.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['o_sn'] = $o_sn;
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['mid'] = $mid;
|
||||
$record['fid'] = $fid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置data表数据
|
||||
$suffix = 'data';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$o_sn.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['o_sn'] = $o_sn;
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['mid'] = $mid;
|
||||
$record['fid'] = $fid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置param表数据
|
||||
$suffix = 'param';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//更新form表
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对form表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
//更新order表
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对order表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
//OK
|
||||
//更新self表
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对self表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:02:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端用户入口
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use common\models\Fans;
|
||||
|
||||
//‘from’字段为ctms的数据
|
||||
use addons\models\AcFansExt;
|
||||
|
||||
class Common extends Controller
|
||||
{
|
||||
protected $pid = 0;
|
||||
protected $user_id = 0;
|
||||
protected $site_id = 0;
|
||||
protected $user_info;
|
||||
protected $postdata = []; //重新整理一下客户端传输的数据
|
||||
protected $imgHttp = TRUE; //图片附件地址生成http(s) //false:不生成http网址; true:仅生成http网址; https:生成https网址
|
||||
protected $page = 1; //当前数据分页
|
||||
protected $pageSize = 10; //默认数据分页大小
|
||||
public $enableCsrfValidation = FALSE;
|
||||
protected $timestamp = TIMESTAMP;
|
||||
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
//判断请求内容类型 content-type,支持 json请求
|
||||
$postdata = Yii::$app->request->post();
|
||||
$headers = Yii::$app->request->headers;
|
||||
$contentType = $headers->get('content-type');
|
||||
if ($contentType == "application/json") {
|
||||
$postdata = json_decode(file_get_contents('php://input'), TRUE);
|
||||
}
|
||||
$this->postdata = $postdata;
|
||||
|
||||
$session = Yii::$app->session;
|
||||
if (isset($postdata['pid'])) {
|
||||
if ((int)$postdata['pid'] > 0) {
|
||||
$this->pid = (int)$postdata['pid'];
|
||||
$session->set('pid', $this->pid);
|
||||
} else {
|
||||
$session->set('pid', 0);
|
||||
}
|
||||
} else if (isset($_GET['pid'])) {
|
||||
if ((int)$_GET['pid'] > 0) {
|
||||
$this->pid = $_GET['pid'];
|
||||
$session->set('pid', $this->pid);
|
||||
} else {
|
||||
$session->set('pid', 0);
|
||||
}
|
||||
} else {
|
||||
$session->set('pid', 0);
|
||||
}
|
||||
|
||||
$this->site_id = Yii::$app->params['siteId'];
|
||||
|
||||
if (isset($postdata['uid']) && (int)$postdata['uid'] > 0) {
|
||||
$this->user_id = (int)$postdata['uid'];
|
||||
}
|
||||
if ($this->user_id) {
|
||||
$userModel = new Fans();
|
||||
$res = $userModel->findOne($this->user_id);
|
||||
if (!$res) {
|
||||
$this->user_id = 0;
|
||||
} else {
|
||||
$this->user_info = $res;
|
||||
}
|
||||
//TBD 后期需加上更多登陆验证逻辑
|
||||
}
|
||||
|
||||
$page = isset($postdata['page']) ? (int)$postdata['page'] : 1;
|
||||
$this->page = $page <= 0 ? 1 : $page;
|
||||
$pageSize = isset($postdata['psize']) ? (int)$postdata['psize'] : 10;
|
||||
$this->pageSize = $pageSize <= 0 ? 10 : $pageSize;
|
||||
}
|
||||
|
||||
public function result($msg, $data = NULL, $code = 0)
|
||||
{
|
||||
$return = [];
|
||||
$return['code'] = $code;
|
||||
$return['msg'] = $msg;
|
||||
if ($data) {
|
||||
$return['data'] = $data;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function fansToken($user = [], $refresh = FALSE, $expire = NULL)
|
||||
{
|
||||
//生成token(用户数据,是否强制更新,过期时间 // TBD 具体方法有待优化
|
||||
$expire = $expire ? $expire : '+1 day';
|
||||
$token = Yii::$app->session->get('fansToken');
|
||||
$tokenExpired = Yii::$app->session->get('fansTokenExpired');
|
||||
if (!$token || $refresh) {
|
||||
$tokenExpired = strtotime($expire) * 1000;
|
||||
$token = md5('username=' . $user['username'] . '&mobile=' . $user['mobile'] . '&time=' . $tokenExpired);
|
||||
Yii::$app->session->set('fansToken', $token);
|
||||
Yii::$app->session->set('fansTokenExpired', $tokenExpired);
|
||||
}
|
||||
$user['token'] = $token;
|
||||
$user['tokenExpired'] = $tokenExpired;
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:44+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端普通用户入口
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use common\models\Fans;
|
||||
|
||||
//‘from’字段为ctms的数据
|
||||
use addons\models\AcFansExt;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
|
||||
class FansController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'login' => '账号密码登陆',
|
||||
'loginSms' => '手机验证码登陆',
|
||||
'detail' => '个人资料',
|
||||
'register' => '用户注册',
|
||||
'auth' => '授权登陆'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统用户管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$username = $post['username'] ?? NULL;
|
||||
$passwd = $post['passwd'] ?? NULL;
|
||||
|
||||
$return = [];
|
||||
if (!$username && !$passwd) {
|
||||
$this->result('登陆参数错误!', NULL, 400);
|
||||
}
|
||||
if (!$username) {
|
||||
$this->result('请输入您的账号!', NULL, 400);
|
||||
}
|
||||
if (!$passwd) {
|
||||
$this->result('请输入您的密码!', NULL, 400);
|
||||
}
|
||||
$username = trim(htmlspecialchars_decode($username));
|
||||
$passwd = trim(htmlspecialchars_decode($passwd));
|
||||
if (!$username) {
|
||||
$this->result('输入错误,请检查您的账号!', NULL, 400);
|
||||
}
|
||||
if (!$passwd) {
|
||||
$this->result('输入有误,请检查您的密码!', NULL, 400);
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$condition = '(`mobile` = :username OR `email` = :username) AND `from` = :from';
|
||||
$args = [':username' => $username, ':from' => $from];
|
||||
$user = $model->find()->where($condition, $args)->one();
|
||||
if (!$user) {
|
||||
$this->result('查无此人!', NULL, 404);
|
||||
}
|
||||
|
||||
if ($user->status != Fans::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', NULL, 403);
|
||||
}
|
||||
//安全校验,登陆密码
|
||||
$isPwdRight = $user->validatePassword($passwd);
|
||||
|
||||
if (!$isPwdRight) {
|
||||
$this->result('密码错误,禁止登陆!', NULL, 400);
|
||||
}
|
||||
//校验结束
|
||||
|
||||
$_user = $this->fansLogin($user, TRUE);
|
||||
$this->result('登陆成功!', ['user' => $_user], 200);
|
||||
}
|
||||
|
||||
public function actionLoginSms()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$mobile = $post['mobile'] ?? NULL;
|
||||
$vcode = $post['vcode'] ?? NULL;
|
||||
|
||||
$return = [];
|
||||
if (!$mobile && !$vcode) {
|
||||
$this->result('登陆参数错误!', NULL, 400);
|
||||
}
|
||||
if (!$mobile) {
|
||||
$this->result('请输入您的手机号!', NULL, 400);
|
||||
}
|
||||
if (!$vcode) {
|
||||
$this->result('请输入手机验证码!', NULL, 400);
|
||||
}
|
||||
$mobile = trim(htmlspecialchars_decode($mobile));
|
||||
//验证手机号
|
||||
$isPhone = preg_match('/^1\d{10}$/', $mobile) ? TRUE : FALSE;
|
||||
if (!$isPhone) {
|
||||
$this->result('手机号不正确,请检查');
|
||||
}
|
||||
$vcode = trim(htmlspecialchars_decode($vcode));
|
||||
//验证手机验证码
|
||||
$vcodeModel = new CVcode();
|
||||
$where = [];
|
||||
$where['mobile'] = $mobile;
|
||||
$where['deleted'] = 0;
|
||||
$where['code'] = $vcode;
|
||||
$where['type'] = 'login';
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if (!$res) {
|
||||
$this->result('验证码校验失败');
|
||||
}
|
||||
if (($this->timetamp - $res->create_at) > 300) {
|
||||
// 超时5分钟
|
||||
$this->result('验证码已失效,请重新获取');
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$condition = '`mobile` = :username AND `from` = :from';
|
||||
$args = [':username' => $mobile, ':from' => $from];
|
||||
$user = $model->find()->where($condition, $args)->one();
|
||||
$hasExt = TRUE;
|
||||
if (!$user) {
|
||||
$hasExt = FALSE;
|
||||
$userModel = clone $model;
|
||||
$user = $this->fansAdd(['mobile' => $mobile, 'from' => $from], $userModel);
|
||||
} else if ($user->status != Fans::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', NULL, 403);
|
||||
}
|
||||
//校验结束
|
||||
$_user = $this->fansLogin($user, $hasExt);
|
||||
$this->result('登陆成功!', ['user' => $_user], 200);
|
||||
}
|
||||
|
||||
public function actionAuth()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
$openplat = $post['from'] ?? 'uni-app'; //归属的开放平台,默认标记为了uni-app
|
||||
$mobile = isset($post['mobile']) ? trim(htmlspecialchars_decode($post['mobile'])) : '';
|
||||
$openid = isset($post['openid']) ? trim(htmlspecialchars_decode($post['openid'])) : '';
|
||||
|
||||
$return = [];
|
||||
if (!$mobile) {
|
||||
$this->result('未提供授权手机号!');
|
||||
}
|
||||
if (!$openid) {
|
||||
$this->result('未提供授权用户身份ID!');
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$userModel = clone $model;
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$user = $model->findOne(['mobile' => $mobile, 'from' => $from]);
|
||||
//扩展用户信息
|
||||
$AcFansExt = new AcFansExt();
|
||||
$Ext = clone $AcFansExt; //用于更新openid
|
||||
$Ext2 = clone $AcFansExt; //用于更新来源归属的开放平台openplat
|
||||
|
||||
$hasExt = TRUE;
|
||||
if (!$user) {
|
||||
$hasExt = FALSE;
|
||||
//自动注册一个新用户
|
||||
$user = $this->fansAdd(['mobile' => $mobile, 'from' => $from], $userModel);
|
||||
|
||||
// 添加扩展信息
|
||||
$Ext->pid = $this->pid;
|
||||
$Ext->mid = $user->id;
|
||||
$Ext->mobile = $mobile;
|
||||
$Ext->key = 'openid';
|
||||
$Ext->value = $openid;
|
||||
$Ext->deleted = 0;
|
||||
$Ext->save();
|
||||
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
$Ext2->key = 'openplat';
|
||||
$Ext2->value = $openplat;
|
||||
$Ext2->deleted = 0;
|
||||
$Ext2->save();
|
||||
} else {
|
||||
//所有该用户已设置过的openid值添加一次被删除标记
|
||||
$condition = '`mid` = :mid AND `mobile` = :mobile AND `pid` = :pid AND `deleted` = :deleted AND `key` = :key AND `value` != :value';
|
||||
$args = [':mid' => $user->id, ':mobile' => $user->mobile, ':pid' => $pid, ':deleted' => 0, ':value' => $openid, ':key' => 'openid'];
|
||||
$AcFansExt->updateAllCounters(
|
||||
['deleted' => 1],
|
||||
$condition,
|
||||
$args
|
||||
);
|
||||
|
||||
$condition = '`mid` = :mid AND `mobile` = :mobile AND `pid` = :pid AND `key` = :key AND `value` = :value';
|
||||
|
||||
$args = [':mid' => $user->id, ':mobile' => $user->mobile, ':pid' => $pid, ':key' => 'openid', ':value' => $openid];
|
||||
$userExt = $Ext->find()->where($condition, $args)->one();
|
||||
if ($userExt) {
|
||||
$userExt->deleted = 0;
|
||||
$userExt->save();
|
||||
} else {
|
||||
$Ext->pid = $this->pid;
|
||||
$Ext->mid = $user->id;
|
||||
$Ext->mobile = $mobile;
|
||||
$Ext->key = 'openid';
|
||||
$Ext->value = $openid;
|
||||
$Ext->deleted = 0;
|
||||
$Ext->save();
|
||||
}
|
||||
|
||||
$args = [':mid' => $user->id, ':mobile' => $user->mobile, ':pid' => $pid, ':key' => 'openplat', ':value' => $openplat];
|
||||
$userExt2 = $Ext2->find()->where($condition, $args)->one();
|
||||
if ($userExt2) {
|
||||
$userExt2->deleted = 0;
|
||||
$userExt2->save();
|
||||
} else {
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
$Ext2->key = 'openplat';
|
||||
$Ext2->value = $openplat;
|
||||
$Ext2->deleted = 0;
|
||||
$Ext2->save();
|
||||
}
|
||||
}
|
||||
|
||||
// 登陆用户
|
||||
$_user = $this->fansLogin($user, $hasExt);
|
||||
$this->result('登陆成功!', ['user' => $_user], 200);
|
||||
}
|
||||
|
||||
public function actionRegister()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$mobile = isset($post['mobile']) ? trim(htmlspecialchars_decode($post['mobile'])) : '';
|
||||
$vcode = isset($post['vcode']) ? trim(htmlspecialchars_decode($post['vcode'])) : '';
|
||||
$password = isset($post['passwd']) ? trim(htmlspecialchars_decode($post['passwd'])) : '';
|
||||
$username = isset($post['username']) ? trim(htmlspecialchars_decode($post['username'])) : '';
|
||||
$email = isset($post['email']) ? trim(htmlspecialchars_decode($post['email'])) : '';
|
||||
|
||||
$return = [];
|
||||
if (!$mobile) {
|
||||
$this->result('未填写手机号!');
|
||||
}
|
||||
if (!$vcode) {
|
||||
$this->result('未填写手机验证码!');
|
||||
}
|
||||
//验证短信码
|
||||
|
||||
$model = new Fans();
|
||||
$userModel = clone $model;
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
|
||||
$user = $model->findOne(['mobile' => $mobile, 'from' => $from]);
|
||||
//扩展用户信息
|
||||
$AcFansExt = new AcFansExt();
|
||||
$Ext = clone $AcFansExt;
|
||||
|
||||
if (!$user) {
|
||||
//自动注册一个新用户
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->email = $mobile . '@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = $from;
|
||||
$userModel->save();
|
||||
$user = $userModel;
|
||||
}
|
||||
|
||||
$_user = $this->fansLogin($user, TRUE);
|
||||
$this->result('登陆成功!', ['user' => $_user], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个新用户
|
||||
* @param $data 用户数据
|
||||
* @return void
|
||||
*/
|
||||
private function fansAdd($data, $userModel)
|
||||
{
|
||||
$mobile = $data['mobile'];
|
||||
$from = $data['from'] ?? Yii::$app->params['fansFrom'];
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->email = $mobile . '@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = $from;
|
||||
$userModel->save();
|
||||
return $userModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user 用户实例
|
||||
* @param $hasExt 有否扩展
|
||||
* @return void
|
||||
*/
|
||||
private function fansLogin($user, $hasExt = FALSE)
|
||||
{
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$identity = $user;
|
||||
// 登录用户,有效期30d
|
||||
$duration = 3600 * 24 * 30;
|
||||
$_login = Yii::$app->user->login($identity, $duration);
|
||||
if (!$_login) {
|
||||
$this->result('登陆失败!', NULL, 400);
|
||||
}
|
||||
//登陆成功,返回用户信息
|
||||
$_user = ['id' => $user->id, 'username' => $user->mobile, 'mobile' => $user->mobile];
|
||||
if ($hasExt) {
|
||||
//查询关联用户的在当前系统中的扩展信息
|
||||
$AcUserExt = new AcFansExt();
|
||||
$exts = $AcUserExt->find()->where(['mid' => $user->id, 'mobile' => $user->mobile, 'pid' => $this->pid, 'deleted' => 0])->all();
|
||||
if ($exts) {
|
||||
foreach ($exts as $ext) {
|
||||
$_user[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成token(用户数据,是否强制更新,过期时间
|
||||
$isLong = $this->postdata['isLong'] || FALSE;
|
||||
$expire = $isLong ? '+1 Month' : FALSE;
|
||||
$_user = $this->fansToken($_user, $refresh = TRUE, $expire);
|
||||
return $_user;
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-13T09:20:03+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:48+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
|
||||
//主入口页
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcPlat;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcContact;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class IndexController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'h5data' => '拉取APP首页数据',
|
||||
];
|
||||
$this->result('您正使用CMTS系统接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionAdsSplash()
|
||||
{
|
||||
$ads = [
|
||||
// "http://public.hiluker.com/ctms/client/app-kp/kp01.jpg",
|
||||
"http://public.hiluker.com/ctms/client/app-kp/kp03.jpg",
|
||||
];
|
||||
$this->result('开屏广告!', $ads, 200);
|
||||
}
|
||||
|
||||
public function actionAdsBanner()
|
||||
{
|
||||
$ads = [
|
||||
'0' => [
|
||||
"image" => 'http://public.hiluker.com/ctms/client/app-banner/banner01.jpg',
|
||||
"link" => '/pages/uni-starter/ucenter/ucenter'
|
||||
],
|
||||
'1' => [
|
||||
"image" => 'http://public.hiluker.com/ctms/client/app-banner/banner03.jpg',
|
||||
"link" => 'http://ctms.hiluker.cn'
|
||||
],
|
||||
'2' => [
|
||||
"image" => 'http://public.hiluker.com/ctms/client/app-banner/banner02.jpg',
|
||||
"link" => ''
|
||||
]
|
||||
];
|
||||
$this->result('BANNER广告!', $ads, 200);
|
||||
}
|
||||
|
||||
public function actionH5data()
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
$pid = $this->pid;
|
||||
|
||||
$model = new AcOrder();
|
||||
$search = $where = $orwhere = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
$deleted = 0;
|
||||
$where[] = ['=', 'deleted', $deleted]; //排除已删除运单
|
||||
$status_code = -1;
|
||||
$where[] = ['<>', 'status_code', $status_code]; //排除已取消运单
|
||||
|
||||
$start = date('Y-m-d 00:00:00'); //今日0点
|
||||
// $start = date('2020-08-29 00:00:00'); //测试时段
|
||||
$start = strtotime($start);
|
||||
|
||||
$end = date('Y-m-d H:i:s'); //当前时间点
|
||||
// $end = date('2021-09-04 00:00:00'); //测试时段
|
||||
$end = strtotime($end);
|
||||
|
||||
//今日运单
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 0]; //排除交车单
|
||||
$_where[] = ['between', 'sign_date', $start, $end];
|
||||
$data = $model->find()->where($_where);
|
||||
$order_today_count = $data->count();
|
||||
//今日交车
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 1]; //交车单
|
||||
$_where[] = ['between', 'sign_date', $start, $end];
|
||||
$data = $model->find()->where($_where);
|
||||
$jiaoche_today_count = $data->count();
|
||||
//今日录单
|
||||
$_where = $where;
|
||||
$_where[] = ['between', 'create_at', $start, $end];
|
||||
$data = $model->find()->where($_where);
|
||||
$order_today_create = $data->count();
|
||||
|
||||
//昨日
|
||||
$_end = $start;
|
||||
$_start = date('Y-m-d 00:00:00', strtotime("-1 day"));
|
||||
$_start = strtotime($_start);
|
||||
//昨日运单
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 0]; //排除交车单
|
||||
$_where[] = ['between', 'sign_date', $_start, $_end];
|
||||
$data = $model->find()->where($_where);
|
||||
$order_yesterday_count = $data->count();
|
||||
//昨日交车
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 1]; //交车单
|
||||
$_where[] = ['between', 'sign_date', $_start, $_end];
|
||||
$data = $model->find()->where($_where);
|
||||
$jiaoche_yesterday_count = $data->count();
|
||||
//昨日录单
|
||||
$_where = $where;
|
||||
$_where[] = ['between', 'create_at', $_start, $_end];
|
||||
$data = $model->find()->where($_where);
|
||||
$order_yesterday_create = $data->count();
|
||||
|
||||
//本月起始时间点
|
||||
$_start = date('Y-m-01 00:00:00');
|
||||
$ldm = strtotime("last day of " . $_start);
|
||||
$m = date("Y-m-d", $ldm) . " 23:59:59";
|
||||
$_start = strtotime($_start);
|
||||
$_end = strtotime($m);
|
||||
//本月运单
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 0]; //排除交车单
|
||||
$_where[] = ['between', 'sign_date', $_start, $_end];
|
||||
$data = $model->find()->where($_where);
|
||||
$order_month_count = $data->count();
|
||||
//本月交车
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 1];
|
||||
$_where[] = ['between', 'sign_date', $_start, $_end];
|
||||
$data = $model->find()->where($_where);
|
||||
$jiaoche_month_count = $data->count();
|
||||
|
||||
//累计运单
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 0]; //排除交车单
|
||||
$data = $model->find()->where($_where);
|
||||
$order_all_count = $data->count();
|
||||
//累计交车
|
||||
$_where = $where;
|
||||
$_where[] = ['=', 'is_turnover', 1];
|
||||
$data = $model->find()->where($_where);
|
||||
$jiaoche_all_count = $data->count();
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '首页数据下载!';
|
||||
$return['data'] = [
|
||||
'orderToday' => $order_today_count,
|
||||
'orderYesterday' => $order_yesterday_count,
|
||||
'orderMonth' => $order_month_count,
|
||||
'orderTotal' => $order_all_count,
|
||||
'jiaocheToday' => $jiaoche_today_count,
|
||||
'jiaocheYesterday' => $jiaoche_yesterday_count,
|
||||
'jiaocheMonth' => $jiaoche_month_count,
|
||||
'jiaocheTotal' => $jiaoche_all_count,
|
||||
'notice' => 0
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T15:34:01+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:02+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNews;
|
||||
use addons\models\AcNewsCat;
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class NewsController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list' => '文章清单',
|
||||
'detail' => '文章详情'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统文章内容管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show' => 1]);
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'total' => $data->count(),
|
||||
'news' => $list,
|
||||
'page' => $this->page
|
||||
];
|
||||
$this->result('内容查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = $post['id'] ?? 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$id = $post['id'] ?? 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('未指定内容!');
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
if (!$detail) {
|
||||
$this->result('指定的内容不存在!');
|
||||
}
|
||||
if ($detail->deleted) {
|
||||
$this->result('指定的内容已被删除!');
|
||||
}
|
||||
$op = $post['op'] ?? '';
|
||||
if (!$op) {
|
||||
$this->result('无有效指令!');
|
||||
}
|
||||
switch ($op) {
|
||||
case 'read':
|
||||
$detail->reading += 1;
|
||||
break;
|
||||
case 'no_read':
|
||||
$detail->reading -= 1;
|
||||
$detail->reading = $detail->reading < 0 ? 0 : $detail->reading;
|
||||
break;
|
||||
case 'like':
|
||||
$detail->liked += 1;
|
||||
break;
|
||||
case 'no_like':
|
||||
$detail->liked -= 1;
|
||||
$detail->liked = $detail->liked < 0 ? 0 : $detail->liked;
|
||||
break;
|
||||
case 'view':
|
||||
$detail->viewed += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$detail->save();
|
||||
$data = $this->formatDetail($detail->toArray());
|
||||
$this->result('已执行', $data, 200);
|
||||
}
|
||||
|
||||
private function search($ops = [])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNews();
|
||||
$where = '`pid` = :pid';
|
||||
$params = [':pid' => $pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if ($ops) {
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' AND `' . $key . '` = :' . $key;
|
||||
$params[':' . $key] = $value;
|
||||
if (isset($search[$key])) {
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' AND `title` like :title';
|
||||
$params[':title'] = '%' . $search['title'] . '%';
|
||||
}
|
||||
if (!empty($search['cid'])) {
|
||||
$search['cid'] = intval($search['cid']);
|
||||
$where .= ' AND `cid` = :cid';
|
||||
$params[':cid'] = $search['cid'];
|
||||
}
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' AND `deleted` = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where, $params);
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page - 1, TRUE); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res' => $res, 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
|
||||
|
||||
$s['content'] = $s['content'] ? htmlspecialchars_decode($s['content']) : '';
|
||||
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s = [])
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted', 'is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
|
||||
$s['content'] = htmlspecialchars_decode($s['content']);
|
||||
|
||||
// 'src="/upload/pics/'
|
||||
$upload_url = 'https://dacms.hiluker.cn';
|
||||
$s['content'] = str_replace('src="/upload/pics/', 'src="' . $upload_url . '/upload/pics/', $s['content']);
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T16:38:33+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNewsCat;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class NewscatController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list' => '分类清单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统内容分类管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show' => 1]);
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'cats' => $list
|
||||
];
|
||||
$this->result('通知查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
private function search($ops = [])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNewsCat();
|
||||
$where = 'pid = :pid';
|
||||
$params = [':pid' => $pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if ($ops) {
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' & ' . $key . ' = :' . $key;
|
||||
$params[':' . $key] = $value;
|
||||
if (isset($search[$key])) {
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' & title like :title';
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
$pageSize = 10;
|
||||
$data = $model->find()->where($where, $params);
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page - 1, TRUE); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res' => $res, 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted', 'update_at'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s = [])
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted', 'is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
|
||||
$s['des'] = htmlspecialchars_decode($s['des']);
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-02T01:08:31+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNotice;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class NoticeController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list' => '通知清单',
|
||||
'detail' => '通知详情'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统通知管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
// $s = $this->search(['is_show'=>1]);
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'total' => $data->count(),
|
||||
'notices' => $list,
|
||||
'page' => $this->page
|
||||
];
|
||||
$this->result('通知查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcNotice();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
private function search($ops = [])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNotice();
|
||||
$where = 'pid = :pid';
|
||||
$params = [':pid' => $pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if ($ops) {
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' & ' . $key . ' = :' . $key;
|
||||
$params[':' . $key] = $value;
|
||||
if (isset($search[$key])) {
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['title']) && !empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' & title like :title';
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where, $params);
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page - 1, TRUE); //设置分页的当前页面值
|
||||
$_orderby = 'update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res' => $res, 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s = [])
|
||||
{
|
||||
$unsets = ['pid', 'create_at', 'deleted', 'is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+707
@@ -0,0 +1,707 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:15+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use backend\controllers\client\v1\Common;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcPlat;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcContact;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
use common\models\Fans;
|
||||
use addons\models\AcFansExt;
|
||||
|
||||
class OrderController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list' => '搜索运单',
|
||||
'detail' => '运单详情',
|
||||
'create' => '创建运单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统订单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['oid']) ? $post['oid'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = $detail['thumbs'] ? json_decode($detail['thumbs']) : [];
|
||||
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$detail['car_owner_id'] = $detail['car_brand_id'] = $detail['car_series_id'] = 0;
|
||||
$model = new AcCar();
|
||||
$car = $model->findOne($detail['car_id']);
|
||||
if ($car) {
|
||||
$detail['car_owner_id'] = $car->owner_id;
|
||||
$detail['car_brand_id'] = $car->brand_id;
|
||||
$detail['car_series_id'] = $car->series_id;
|
||||
$detail['car_number'] = $car->num_p . $car->num_area . $car->num_left;
|
||||
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid' => $detail['from_mid'], 'pid' => $pid, 'deleted' => 0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$s['id']])) {
|
||||
if ($ext['mobile'] == $user->mobile) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
|
||||
if ($owner) {
|
||||
$_owner = User::findOne($detail['car_owner_id']);
|
||||
$detail['car_owner'] = $_owner->username . '【' . $_owner->mobile . '】';
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
|
||||
if ($brand) {
|
||||
$detail['car_title'] = $brand->title;
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series = $AcCarSeries->findOne($detail['car_series_id']);
|
||||
if ($series) {
|
||||
$detail['car_title'] .= $series->title;
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11 - strlen($id));
|
||||
$sn .= $id;
|
||||
$detail['sn'] = $sn;
|
||||
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $detail['sign_date']);
|
||||
$detail['signdate'] = date('Y-m-d 星期' . $weekdays[$wk], $detail['sign_date']);
|
||||
$detail['from_province'] = isset($detail['start_province']) ? Yii::$app->params['regionAreas'][$detail['start_province']] : '';
|
||||
$detail['to_province'] = isset($detail['aim_province']) ? Yii::$app->params['regionAreas'][$detail['aim_province']] : '';
|
||||
$detail['remark'] = $detail['remark'] || '';
|
||||
$detail['remark'] = trim($detail['remark']) ? htmlspecialchars_decode(trim($detail['remark'])) : '';
|
||||
|
||||
$imgDir = Yii::getAlias('@upload');
|
||||
$imgKeys = ['driving_lisence', 'thumb_f', 'thumb_b', 'thumb_l', 'thumb_r'];
|
||||
foreach ($imgKeys as $k) {
|
||||
$detail[$k] = $detail[$k] ? $detail[$k] : '/pics/nopic.jpg';
|
||||
$url_pre = substr($detail[$k], 0, 4);
|
||||
if ($url_pre == '/pic') {
|
||||
$detail[$k . '_url'] = Url::to('@upload' . $detail[$k], $this->imgHttp);
|
||||
} else if ($url_pre == 'http') {
|
||||
$detail[$k . '_url'] = $detail[$k];
|
||||
}
|
||||
}
|
||||
|
||||
if ($detail['thumbs']) {
|
||||
$thumbs = $detail['thumbs'];
|
||||
$thumbs_url = [];
|
||||
foreach ($thumbs as $k => $v) {
|
||||
$url_pre = substr($v, 0, 4);
|
||||
if ($url_pre == '/pic') {
|
||||
$v_url = Url::to('@upload' . $v, $this->imgHttp);
|
||||
} else if ($url_pre == 'http') {
|
||||
$v_url = $v;
|
||||
}
|
||||
$thumbs_url[] = ['src' => $v, 'url' => $v_url];
|
||||
}
|
||||
$detail['thumbs_url'] = $thumbs_url;
|
||||
}
|
||||
|
||||
$unsets = ['commission', 'commission_left', 'fee_truck', 'create_at', 'create_by', 'deleted', 'income', 'expense', 'fee_deliver', 'fee_extra', 'fee_insurance', 'fee_pickup', 'fee_urgent', 'from_bid', 'from_mid', 'is_commission', 'is_cwqr', 'is_holdon', 'is_over', 'pay_receive_pids', 'pay_send_pids', 'pre_id'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($detail[$us]);
|
||||
}
|
||||
|
||||
$this->result('订单查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$pid = $this->pid;
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province' => 'start_province', 'start_city' => 'start_city', 'aim_province' => 'aim_province', 'aim_city' => 'aim_city', 'aim_address' => 'aim_address',
|
||||
'signer' => 'signer', 'bind' => 'bind', 'wtdw' => "wtdw",
|
||||
'sender_name' => 'sender_name', 'sender_idcard' => 'sender_idcard', 'sender_mobiles' => 'sender_mobiles',
|
||||
'receiver_name' => 'receiver_name', 'receiver_idcard' => 'receiver_idcard', 'receiver_mobiles' => 'receiver_mobiles',
|
||||
'car_extra' => 'car_extra'];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
//'car_id'=>'car_id','employee_id'=>'employee_id',
|
||||
$cols = ['car_value' => 'car_value', 'fee_insurance' => 'fee_insurance', 'fee_truck' => 'fee_truck', 'fee_deliver' => 'fee_deliver', 'fee_pickup' => 'fee_pickup', 'fee_urgent' => 'fee_urgent', 'fee_extra' => 'fee_extra', 'fee_total' => 'fee_total', 'pay_send' => 'pay_send', 'pay_receive' => 'pay_receive', 'not_insurance' => 'not_insurance', 'weituo' => 'weituo'];
|
||||
foreach ($cols as $col => $key) {
|
||||
$data[$col] = 0;
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark' => 'remark'];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
$data['remark'] = isset($data['remark']) ? isset($data['remark']) : '';
|
||||
|
||||
/*@sign_date: 1649952000000*/
|
||||
$sign_date = isset($post['sign_date']) ? $post['sign_date'] / 1000 : '';
|
||||
$data['sign_date'] = $sign_date ? $sign_date : time();
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 11; //11是方孟
|
||||
$data['create_by'] = $mid;
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
//部分规则校验
|
||||
$hasError = 0;
|
||||
$msg = '';
|
||||
$fee_total = $data['fee_truck'] + $data['fee_insurance'] + $data['fee_deliver'] + $data['fee_pickup'] + $data['fee_urgent'] + $data['fee_extra'];
|
||||
$fee_pay = $data['pay_send'] + $data['pay_receive'];
|
||||
if (!$data['fee_truck']) {
|
||||
$hasError += 1;
|
||||
$msg .= '请注意,运费未正确填写!';
|
||||
}
|
||||
|
||||
if ($fee_total != $data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填各项费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
if ($fee_pay != $data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填现付与到收费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 1; //1是宫雪
|
||||
$data['store_id'] = 0;
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($data['employee_id']);
|
||||
if ($employee) {
|
||||
$data['store_id'] = $employee->store_id;
|
||||
}
|
||||
|
||||
//校验生成部分补充数据
|
||||
//生成现付说明
|
||||
$payments = [
|
||||
'wechat' => '微信',
|
||||
'alipay' => '支付宝',
|
||||
'cash' => '现金',
|
||||
'bankcard' => '银行卡',
|
||||
'bankunion' => '银联',
|
||||
'others' => '其他'
|
||||
];
|
||||
if ($post['pay_send']) {
|
||||
$txt = $post['payto'] . '收款' . $post['pay_send'] . '元(' . $payments[$post['payment']] . ')';
|
||||
if ($data['remark']) {
|
||||
$data['remark'] .= ' ; ' . $txt;
|
||||
} else {
|
||||
$data['remark'] = $txt;
|
||||
}
|
||||
}
|
||||
//生成车辆信息
|
||||
$carModel = new AcCar();
|
||||
$where = [];
|
||||
if ($post['isTempCarno']) {
|
||||
$post['carno_left'] .= '临';
|
||||
}
|
||||
if (empty($post['carno_frame'])) {
|
||||
$where['num_p'] = $post['carno_p'];
|
||||
$where['num_area'] = $post['carno_area'];
|
||||
$where['num_left'] = $post['carno_left'];
|
||||
}
|
||||
$post['carno_frame'] = isset($post['carno_frame']) ? $post['carno_frame'] : '';
|
||||
if (!empty($post['carno_frame'])) {
|
||||
$where['num_frame'] = $post['carno_frame'];
|
||||
}
|
||||
$car = $carModel->find()->where($where)->one();
|
||||
if (empty($car)) {
|
||||
$carModel->pid = $pid;
|
||||
$carModel->num_frame = $post['carno_frame'];
|
||||
$carModel->num_p = $post['carno_p'];
|
||||
$carModel->num_area = $post['carno_area'];
|
||||
$carModel->num_left = $post['carno_left'];
|
||||
$carModel->title = $post['carno_title'];
|
||||
$carModel->title = $post['carno_title'];
|
||||
$carModel->status_code = 1;
|
||||
$carModel->create_at = time();
|
||||
$carModel->update_at = time();
|
||||
$carModel->save();
|
||||
$car_id = $carModel->attributes['id'];
|
||||
} else {
|
||||
$car_id = $car->id;
|
||||
}
|
||||
$data['car_id'] = $car_id;
|
||||
|
||||
//查询联系人信息是否在库
|
||||
$sender_mobiles = isset($data['sender_mobiles']) ? $data['sender_mobiles'] : NULL;
|
||||
$receiver_mobiles = isset($data['receiver_mobiles']) ? $data['receiver_mobiles'] : NULL;
|
||||
if ($sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$contactModel = new AcContact();
|
||||
$contactor = $contactModel->find()->where(['mobile' => $data['sender_mobiles'], 'pid' => $pid])->one();
|
||||
if (empty($contactor)) {
|
||||
$contactModel->name = isset($data['sender_name']) ? $data['sender_name'] : '客户';
|
||||
$contactModel->mobile = $data['sender_mobiles'];
|
||||
$contactModel->pid = $pid;
|
||||
$contactModel->idcard = isset($data['sender_idcard']) ? $data['sender_idcard'] : '';
|
||||
$contactModel->create_at = time();
|
||||
$contactModel->status_code = 1;
|
||||
$contactModel->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = isset($data['sender_name']) ? $data['sender_name'] : $contactModel->name;
|
||||
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel->idcard;
|
||||
if ($_contactDatas['name'] == $contactModel->name && $_contactDatas['idcard'] == $contactModel->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel->updateAll($_contactDatas, ['id' => $contactModel->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($sender_mobiles);
|
||||
if (empty($user)) {
|
||||
$userModel->mobile = $sender_mobiles;
|
||||
$userModel->email = $sender_mobiles . '@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = 'ctms';
|
||||
$userModel->save();
|
||||
}
|
||||
}
|
||||
if ($receiver_mobiles && $receiver_mobiles != $sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$contactModel2 = new AcContact();
|
||||
$contactor2 = $contactModel2->find()->where(['mobile' => $data['receiver_mobiles'], 'pid' => $pid])->one();
|
||||
if (empty($contactor2)) {
|
||||
$contactModel2->name = isset($data['receiver_name']) ? $data['receiver_name'] : '客户';
|
||||
$contactModel2->mobile = $data['receiver_mobiles'];
|
||||
$contactModel2->pid = $pid;
|
||||
$contactModel2->idcard = isset($data['receiver_idcard']) ? $data['receiver_idcard'] : '';
|
||||
$contactModel2->create_at = time();
|
||||
$contactModel2->status_code = 1;
|
||||
$contactModel2->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = isset($data['receiver_name']) ? $data['receiver_name'] : $contactModel2->name;
|
||||
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel2->idcard;
|
||||
if ($_contactDatas['name'] == $contactModel2->name && $_contactDatas['idcard'] == $contactModel2->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel2->updateAll($_contactDatas, ['id' => $contactModel2->id]);
|
||||
}
|
||||
}
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($receiver_mobiles);
|
||||
if (empty($user)) {
|
||||
$userModel->mobile = $receiver_mobiles;
|
||||
$userModel->email = $receiver_mobiles . '@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = 'ctms';
|
||||
$userModel->save();
|
||||
}
|
||||
}
|
||||
|
||||
//保存资料
|
||||
$AcOrder = new AcOrder();
|
||||
foreach ($data as $key => $val) {
|
||||
$AcOrder->$key = $val;
|
||||
}
|
||||
|
||||
$res = $AcOrder->save();
|
||||
$id = $AcOrder->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单保存成功!' . $msg;
|
||||
$return['data'] = ['id' => $id];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
} else {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '订单保存失败!';
|
||||
$return['data'] = [];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
}
|
||||
|
||||
//订单列表
|
||||
private function search()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcOrder();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$orwhere = ['or', ['LIKE', 'sender_mobiles', $search['phone']], ['LIKE', 'receiver_mobiles', $search['phone']]];
|
||||
|
||||
//车牌号使用完整精准搜索(皖A88888)
|
||||
$CarModel = new AcCar();
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$sql = 'CONCAT(num_p,num_area,num_left) = :carno or num_frame LIKE :carno';
|
||||
$cars = $CarModel->find()->where($sql, [':carno' => $search['carno']])->limit(5)->offset(0)->all();
|
||||
|
||||
//最多仅显示可匹配车牌号的前5个
|
||||
if (empty($cars)) {
|
||||
$return['code'] = 400;
|
||||
$return['msg'] = '未查询到相关车辆';
|
||||
return ['res' => FALSE, 'data' => $return];
|
||||
} else {
|
||||
$car_ids = [];
|
||||
foreach ($cars as $car) {
|
||||
$car_ids[] = $car->id;
|
||||
}
|
||||
$where[] = ['IN', 'car_id', $car_ids];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['city']) && !empty($search['city'])) {
|
||||
$search['city'] = trim($search['city']);
|
||||
$where[] = ['LIKE', 'aim_city', $search['city']];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : '';
|
||||
$EmployeeModel = new AcEmployee();
|
||||
if (!empty($search['employee'])) {
|
||||
$where[] = ['=', 'employee_id', $search['employee']];
|
||||
$employee = $EmployeeModel->findOne($search['employee']);
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['sotre_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
if (!empty($search['store_id'])) {
|
||||
$where[] = ['=', 'store_id', $search['store_id']];
|
||||
$store = $StoreModel->findOne($search['store_id']);
|
||||
$search['store_title'] = isset($store->title) ? $store->title : '';
|
||||
}
|
||||
|
||||
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
|
||||
if (!empty($search['start_province'])) {
|
||||
$where[] = ['=', 'start_province', $search['start_province']];
|
||||
}
|
||||
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE', 'start_city', $search['start_city']];
|
||||
}
|
||||
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
|
||||
if (!empty($search['aim_province'])) {
|
||||
$where[] = ['=', 'aim_province', $search['aim_province']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE', 'aim_city', $search['aim_city']];
|
||||
}
|
||||
$search['signer'] = isset($search['signer']) ? trim($search['signer']) : '';
|
||||
$search['wtdw'] = isset($search['wtdw']) ? trim($search['wtdw']) : '';
|
||||
$search['weituo'] = isset($search['weituo']) ? (int)$search['weituo'] : 0;
|
||||
if ($search['weituo']) {
|
||||
$where[] = ['=', 'weituo', $search['weituo']];
|
||||
} else if (!empty($search['wtdw'])) {
|
||||
$where[] = ['LIKE', 'wtdw', $search['wtdw']];
|
||||
} else if (!empty($search['signer'])) {
|
||||
$where[] = ['LIKE', 'signer', $search['signer']];
|
||||
}
|
||||
|
||||
$search['sender_name'] = isset($search['sender_name']) ? trim($search['sender_name']) : '';
|
||||
if (!empty($search['sender_name'])) {
|
||||
$where[] = ['LIKE', 'sender_name', $search['sender_name']];
|
||||
}
|
||||
$search['receiver_name'] = isset($search['receiver_name']) ? trim($search['receiver_name']) : '';
|
||||
if (!empty($search['receiver_name'])) {
|
||||
$where[] = ['LIKE', 'receiver_name', $search['receiver_name']];
|
||||
}
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE', 'bind', $search['bind']];
|
||||
}
|
||||
if (isset($search['status_code']) && $search['status_code'] != 'all') {
|
||||
$search['status_code'] = (int)$search['status_code'];
|
||||
$where[] = ['=', 'status_code', $search['status_code']];
|
||||
} else {
|
||||
unset($search['status_code']);
|
||||
}
|
||||
|
||||
if (isset($search['is_holdon'])) {
|
||||
$search['is_holdon'] = (int)$search['is_holdon'];
|
||||
$where[] = ['=', 'is_holdon', $search['is_holdon']];
|
||||
}
|
||||
if (isset($search['is_over'])) {
|
||||
$search['is_over'] = (int)$search['is_over'];
|
||||
$where[] = ['=', 'is_over', $search['is_over']];
|
||||
}
|
||||
if (isset($search['is_commission'])) {
|
||||
$search['is_commission'] = (int)$search['is_commission'];
|
||||
$where[] = ['=', 'is_commission', $search['is_commission']];
|
||||
}
|
||||
$search['is_cwqr'] = isset($search['is_cwqr']) ? $search['is_cwqr'] : '';
|
||||
if ($search['is_cwqr'] == '') {
|
||||
$search['is_cwqr'] = isset($get['is_cwqr']) ? $get['is_cwqr'] : '';
|
||||
}
|
||||
if ($search['is_cwqr'] != '') {
|
||||
$search['is_cwqr'] = (int)$get['is_cwqr'];
|
||||
$where[] = ['=', 'is_cwqr', $search['is_cwqr']];
|
||||
}
|
||||
|
||||
//签约时间筛选
|
||||
$search['sign_m'] = isset($search['sign_m']) ? $search['sign_m'] : '';
|
||||
$search['sign_after'] = isset($search['sign_after']) ? $search['sign_after'] : '';
|
||||
$search['sign_before'] = isset($search['sign_before']) ? $search['sign_before'] : '';
|
||||
//按月份筛选
|
||||
if (!empty($search['sign_m'])) {
|
||||
$start = strtotime($search['sign_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of " . $s);
|
||||
$m = date("Y-m-d", $ldm) . " 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where[] = ['between', 'sign_date', $start, $end];
|
||||
} //按指定时段筛选
|
||||
else if (!empty($search['sign_after']) && !empty($search['sign_before'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['between', 'sign_date', $start, $end];
|
||||
} //按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
else if (!empty($search['sign_after'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$where[] = ['>=', 'sign_date', $start];
|
||||
} else if (!empty($search['sign_before'])) {
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['<=', 'sign_date', $end];
|
||||
}
|
||||
|
||||
//带序列号搜索(TBD:后期考虑改为精准唯一搜索)
|
||||
if (isset($search['sn']) && $search['sn'] != 'undefined' && $search['sn']) {
|
||||
$where[] = ['LIKE', 'sn', $search['sn']];
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[] = ['=', 'deleted', $deleted];
|
||||
$where[] = ['=', 'is_turnover', 0]; //排除交车单
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page - 1, TRUE); //设置分页的当前页面值
|
||||
$_orderby = 'sign_date DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
|
||||
return ['res' => $res, 'data' => $data];
|
||||
}
|
||||
|
||||
/*
|
||||
订单数据显示格式化
|
||||
*/
|
||||
private function showOrder($orderRes, $data)
|
||||
{
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($orderRes) {
|
||||
foreach ($orderRes as $r) {
|
||||
$cids[$r->car_id] = $r->car_id;
|
||||
$sids[$r->store_id] = $r->store_id;
|
||||
$eids[$r->employee_id] = $r->employee_id;
|
||||
$mids[$r->from_mid] = $r->from_mid;
|
||||
}
|
||||
}
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_stores = $model->find()->where(['in', 'id', $sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in', 'id', $eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in', 'id', $mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new AcCar();
|
||||
$cars = [];
|
||||
$_cars = $model->find()->where(['in', 'id', $cids])->indexBy('id')->all();
|
||||
$bids = $sids = [];
|
||||
foreach ($_cars as $s) {
|
||||
$bids[] = $s->brand_id;
|
||||
$sids[] = $s->series_id;
|
||||
$cars[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$model = new AcCarBrand();
|
||||
$brands = $model->find()->where(['in', 'id', $bids])->indexBy('id')->all();
|
||||
$model = new AcCarSeries();
|
||||
$series = $model->find()->where(['in', 'id', $sids])->indexBy('id')->all();
|
||||
|
||||
if ($cars) {
|
||||
foreach ($cars as &$car) {
|
||||
$car['title2'] = '';
|
||||
if (isset($brands[$car['brand_id']])) {
|
||||
$car['title2'] .= $brands[$car['brand_id']]['title'];
|
||||
}
|
||||
if (isset($series[$car['series_id']])) {
|
||||
$car['title2'] .= $series[$car['series_id']]['title'];
|
||||
}
|
||||
$car['number2'] = $car['num_frame'];
|
||||
if ($car['num_p']) {
|
||||
$car['number2'] = $car['num_p'];
|
||||
}
|
||||
if ($car['num_area']) {
|
||||
$car['number2'] .= $car['num_area'];
|
||||
}
|
||||
if ($car['num_left']) {
|
||||
$car['number2'] .= $car['num_left'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($car);
|
||||
|
||||
$orders = [];
|
||||
$unsets = ['pid', 'commission', 'commission_left', 'fee_truck', 'create_at', 'create_by', 'deleted', 'income', 'expense', 'fee_deliver', 'fee_extra', 'fee_insurance', 'fee_pickup', 'fee_urgent', 'from_bid', 'from_mid', 'is_commission', 'is_cwqr', 'is_holdon', 'is_over', 'pay_receive_pids', 'pay_send_pids', 'pre_id', 'remark', 'car_extra', 'thumb_b', 'thumb_f', 'thumb_l', 'thumb_r', 'thumbs', 'driving_lisence', 'videos'];
|
||||
|
||||
foreach ($orderRes as $s) {
|
||||
$car = [];
|
||||
if ($s->car_id) {
|
||||
$car = $cars[$s->car_id];
|
||||
}
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['sign_date']);
|
||||
$s['signdate'] = date('Y-m-d ', $s['sign_date']) . '星期' . $weekdays[$wk];
|
||||
$s['from_province'] = $s['start_province'] ? Yii::$app->params['regionAreas'][$s['start_province']] : '';
|
||||
$s['to_province'] = $s['aim_province'] ? Yii::$app->params['regionAreas'][$s['aim_province']] : '';
|
||||
$s['car_number'] = isset($car['number2']) ? $car['number2'] : '';
|
||||
$s['car_title'] = isset($car['title']) ? $car['title'] : '';
|
||||
$s['car_title'] = $s['car_title'] ? $s['car_title'] : (isset($car['title2']) ? $car['title2'] : '');
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data'] = [
|
||||
'total' => $data->count(),
|
||||
'orders' => $orders,
|
||||
'employees' => $employees,
|
||||
'stores' => $stores,
|
||||
'users' => $users,
|
||||
'page' => $this->page
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:10+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
use addons\models\AcOrder;
|
||||
|
||||
class OrdercheckController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'basic' => '基础验车', //启运网点
|
||||
'online' => '中转验车',
|
||||
'arrive' => '到站验车', //目的地网点
|
||||
];
|
||||
$this->result('您正使用CMTS系统运单验车管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionBasic()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['oid']) ? $post['oid'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
if (!$order) {
|
||||
$this->result('该运单数据不存在!');
|
||||
}
|
||||
if (!isset($post['checks'])) {
|
||||
$this->result('验车参数错误!');
|
||||
}
|
||||
$checks = $post['checks']; //需要更新的验车信息
|
||||
//判断执行权限 S
|
||||
if (!$this->user_info) {
|
||||
$this->result('无有效用户登陆信息,无权操作!');
|
||||
}
|
||||
if (!$this->user_id !== $order->from_mid) {
|
||||
// $this->result('不是当前用户的运单,无权操作!');
|
||||
}
|
||||
//判断执行权限 E
|
||||
$hasChange = 0; //是否有需要更新的数据
|
||||
$op = isset($post['op']) ? $post['op'] : '';
|
||||
$isOss = TRUE; //是否启用OSS服务
|
||||
switch ($op) {
|
||||
case 'data':
|
||||
$hasChange = 1;
|
||||
$checker = isset($checks['checker']) ? trim($checks['checker']) : '';
|
||||
$order->checker = $checker ? $checker : $this->user_info->username;
|
||||
$start_km = isset($checks['start_km']) ? (int)$checks['start_km'] : 0;
|
||||
$order->start_km = $start_km;
|
||||
$is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0;
|
||||
$order->no_driving_lisence = $is_driving_lisence == 1 ? 1 : 0;
|
||||
$car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : '';
|
||||
$order->car_extra = $car_extra;
|
||||
break;
|
||||
case 'driving_lisence':
|
||||
$k = 'driving_lisence';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
if (!$isOss) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
} else {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'thumb_f':
|
||||
$k = 'thumb_f';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
if (!$isOss) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
} else {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'thumb_b':
|
||||
$k = 'thumb_b';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'thumb_l':
|
||||
$k = 'thumb_l';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
if (!$isOss) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
} else {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'thumb_r':
|
||||
$k = 'thumb_r';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
if (!$isOss) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
} else {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'thumbs':
|
||||
$k = 'thumbs';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
$hasChange = 1;
|
||||
$thumbs = json_encode($checks[$k]);
|
||||
$order->$k = $thumbs;
|
||||
}
|
||||
break;
|
||||
case 'all':
|
||||
$keys = ['driving_lisence', 'thumb_f', 'thumb_b', 'thumb_l', 'thumb_r'];
|
||||
foreach ($keys as $k) {
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
if (!$isOss) {
|
||||
$file = Yii::getAlias('@upload-src') . $checks[$k];
|
||||
if (file_exists($file)) {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
} else {
|
||||
$hasChange = 1;
|
||||
$order->$k = $checks[$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
$k = 'thumbs';
|
||||
if (isset($checks[$k]) && $checks[$k]) {
|
||||
$hasChange = 1;
|
||||
$thumbs = json_encode($checks[$k]);
|
||||
$order->$k = $thumbs;
|
||||
}
|
||||
$checker = isset($checks['checker']) ? trim($checks['checker']) : '';
|
||||
$order->checker = $checker ? $checker : $this->user_info->username;
|
||||
$start_km = isset($checks['start_km']) ? (int)$checks['start_km'] : 0;
|
||||
$order->start_km = $start_km;
|
||||
$is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0;
|
||||
$order->no_driving_lisence = $is_driving_lisence == 1 ? 1 : 0;
|
||||
$car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : '';
|
||||
$order->car_extra = $car_extra;
|
||||
if ($hasChange) {
|
||||
$order->is_checked = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($hasChange) {
|
||||
$res = $order->save();
|
||||
$this->result('操作完成!', $order->toArray(), 200);
|
||||
} else {
|
||||
$this->result('没有要更新的数据!', NULL, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:19+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcStore;
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class OrderpreController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list' => '搜索询单',
|
||||
'detail' => '询单详情',
|
||||
'create' => '创建询单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统询价单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
}
|
||||
|
||||
private function search()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcOrderPre();
|
||||
$where = $orwhere = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=', 'from_uid', $this->user_id];
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$where[] = ['=', 'from_mobile', $search['phone']];
|
||||
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$where[] = ['LIKE', 'car_no', $search['carno']];
|
||||
}
|
||||
if (isset($search['phone']) && !empty($search['phone'])) {
|
||||
$search['phone'] = trim($search['phone']);
|
||||
$where[] = ['=', 'from_mobile', $search['phone']];
|
||||
}
|
||||
|
||||
if (isset($search['city']) && !empty($search['city'])) {
|
||||
$search['city'] = trim($search['city']);
|
||||
$where[] = ['LIKE', 'aim_city', $search['city']];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : '';
|
||||
$EmployeeModel = new AcEmployee();
|
||||
if (!empty($search['employee'])) {
|
||||
$where[] = ['=', 'employee_id', $search['employee']];
|
||||
$employee = $EmployeeModel->findOne($search['employee']);
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['sotre_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
if (!empty($search['store_id'])) {
|
||||
$where[] = ['=', 'store_id', $search['store_id']];
|
||||
$store = $StoreModel->findOne($search['store_id']);
|
||||
$search['store_title'] = isset($store->title) ? $store->title : '';
|
||||
}
|
||||
|
||||
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
|
||||
if (!empty($search['start_province'])) {
|
||||
$where[] = ['=', 'start_province', $search['start_province']];
|
||||
}
|
||||
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE', 'start_city', $search['start_city']];
|
||||
}
|
||||
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
|
||||
if (!empty($search['aim_province'])) {
|
||||
$where[] = ['=', 'aim_province', $search['aim_province']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE', 'aim_city', $search['aim_city']];
|
||||
}
|
||||
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE', 'bind', $search['bind']];
|
||||
}
|
||||
if (isset($search['status_code']) && $search['status_code'] != 'all') {
|
||||
$search['status_code'] = (int)$search['status_code'];
|
||||
$where[] = ['=', 'status_code', $search['status_code']];
|
||||
} else {
|
||||
unset($search['status_code']);
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[] = ['=', 'deleted', $deleted];
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page - 1, TRUE); //设置分页的当前页面值
|
||||
$_orderby = 'update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res' => $res, 'data' => $data];
|
||||
}
|
||||
|
||||
private function showOrder($orderRes, $data)
|
||||
{
|
||||
$status = Yii::$app->params['OrderPreStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($orderRes) {
|
||||
foreach ($orderRes as $r) {
|
||||
$sids[$r->store_id] = $r->store_id;
|
||||
$eids[$r->employee_id] = $r->employee_id;
|
||||
}
|
||||
}
|
||||
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
|
||||
$model = new AcStore();
|
||||
$_stores = $model->find()->where(['in', 'id', $sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in', 'id', $eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$orders = [];
|
||||
$unsets = ['pid', 'create_at', 'deleted', 'from_mid', 'car'];
|
||||
|
||||
foreach ($orderRes as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$s['price'] = !empty($s['price']) ? $s['price'] : '尚未报价';
|
||||
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $s['date']);
|
||||
$s['date_plan'] = date('Y-m-d ', $s['date']) . '星期' . $weekdays[$wk];
|
||||
|
||||
$s['from_province'] = isset($s['start_province']) ? Yii::$app->params['regionAreas'][$s['start_province']] : '';
|
||||
$s['to_province'] = isset($s['aim_province']) ? Yii::$app->params['regionAreas'][$s['aim_province']] : '';
|
||||
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data'] = [
|
||||
'total' => $data->count(),
|
||||
'orders' => $orders,
|
||||
'employees' => $employees,
|
||||
'stores' => $stores,
|
||||
'page' => $this->page
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
|
||||
if ($detail['store_id']) {
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
}
|
||||
|
||||
if ($detail['employee_id']) {
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11 - strlen($id));
|
||||
$sn .= $id;
|
||||
$detail['sn'] = $detail['sn'] ? $detail['sn'] : $sn;
|
||||
|
||||
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
|
||||
$wk = date('w', $detail['date']);
|
||||
$detail['date_plan'] = date('Y-m-d 星期' . $weekdays[$wk], $detail['date']);
|
||||
$detail['remark'] = !empty($detail['remark']) ? htmlspecialchars_decode($detail['remark']) : '';
|
||||
$detail['car'] = !empty($detail['car']) ? htmlspecialchars_decode($detail['car']) : '';
|
||||
|
||||
$unsets = ['create_at', 'deleted', 'from_mid'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($detail[$us]);
|
||||
}
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCancel()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('未指定订单!');
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
if ($order->from_uid != $this->user_id) {
|
||||
$this->result('非本人订单,不允许操作!');
|
||||
}
|
||||
if ($order->status_code <= 0 || $order->status_code >= 99) {
|
||||
$this->result('订单已取消或已经完成,不允许操作!');
|
||||
}
|
||||
$order->status_code = -1;
|
||||
$order->save();
|
||||
$this->result('已取消!', $order->toArray(), 200);
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
/**
|
||||
* 创建咨询单
|
||||
* @mid [int] 平台租户身份
|
||||
* @uid [int] 前端用户身份
|
||||
*/
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$pid = $this->pid;
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
$data['from_uid'] = $this->user_id;
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province' => 'start_province', 'start_city' => 'start_city', 'aim_province' => 'aim_province', 'aim_city' => 'aim_city',
|
||||
'car_title' => 'car_title', 'car_no' => 'car_no', 'price' => 'price',
|
||||
'bind' => 'bind', 'receptionist' => "receptionist",
|
||||
'from_name' => 'from_name', 'from_mobile' => 'from_mobile',
|
||||
];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value' => 'car_value', 'from_gender' => 'from_gender'];
|
||||
foreach ($cols as $col => $key) {
|
||||
$data[$col] = 0;
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark' => 'remark', 'car' => 'car'];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/*@date: 1649952000000*/
|
||||
$data['date'] = isset($post['plan_date']) ? $post['plan_date'] / 1000 : strtotime('+7 day');
|
||||
// 计划时间,默认7天后
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0;
|
||||
$data['from_mid'] = $mid;
|
||||
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 0;
|
||||
$data['store_id'] = isset($post['store_id']) ? (int)$post['store_id'] : 0;
|
||||
|
||||
//保存资料
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
foreach ($data as $key => $val) {
|
||||
$AcOrderPre->$key = $val;
|
||||
}
|
||||
|
||||
$res = $AcOrderPre->save();
|
||||
$id = $AcOrderPre->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
订单数据显示格式化
|
||||
*/
|
||||
|
||||
public function actionEdit()
|
||||
{
|
||||
/**
|
||||
* 更新咨询单
|
||||
* @mid [int] 平台租户身份
|
||||
* @uid [int] 前端用户身份
|
||||
*/
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$id = isset($post['id']) ? (int)$post['id'] : 0;
|
||||
if (!$id) {
|
||||
$this->result('未指定询价单!');
|
||||
}
|
||||
$model = new AcOrderPre();
|
||||
$detail = $model->findOne($id);
|
||||
if (!$detail) {
|
||||
$this->result('询价单信息不存在!');
|
||||
}
|
||||
if ($detail->pid != $this->pid) {
|
||||
$this->result('非法操作!');
|
||||
}
|
||||
if ($detail->from_uid != $this->user_id) {
|
||||
$this->result('非法操作,请检查订单归属!');
|
||||
}
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province' => 'start_province', 'start_city' => 'start_city', 'aim_province' => 'aim_province', 'aim_city' => 'aim_city',
|
||||
'car_title' => 'car_title', 'car_no' => 'car_no',
|
||||
'from_name' => 'from_name', 'from_mobile' => 'from_mobile',
|
||||
];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$detail->$col = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value' => 'car_value', 'from_gender' => 'from_gender'];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$detail->$col = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark' => 'remark'];
|
||||
foreach ($cols as $col => $key) {
|
||||
if (isset($post[$key]) && $post[$key] != '') {
|
||||
$detail->$col = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$detail->date = isset($post['plan_date']) ? $post['plan_date'] / 1000 : $detail->date;
|
||||
|
||||
$detail->status_code = 1; //标记订单处于创建待审核状态
|
||||
$detail->update_at = time();
|
||||
|
||||
//保存资料
|
||||
$res = $detail->save();
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:38:52+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:53:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcPlat;
|
||||
|
||||
class SmsController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'vcode' => '获取短信验证码'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统短信管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionSend()
|
||||
{
|
||||
global $START_TIME;
|
||||
|
||||
$session = Yii::$app->session;
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
|
||||
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
|
||||
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
|
||||
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
|
||||
if ($config) {
|
||||
$session->set('sms::config', $config);
|
||||
} else {
|
||||
$config = $session->get('sms::config');
|
||||
}
|
||||
|
||||
$option = array();
|
||||
$sms = new Sms($option, $config);
|
||||
|
||||
$address = isset($dataPost['address']) ? $dataPost['address'] : '';
|
||||
if ($address) {
|
||||
$session->set('sms::address', $address);
|
||||
} else {
|
||||
$address = $session->get('sms::address');
|
||||
}
|
||||
|
||||
$tmpl = isset($dataPost['tmpl']) ? $dataPost['tmpl'] : '';
|
||||
if ($tmpl) {
|
||||
$session->set('sms::tmpl', $tmpl);
|
||||
} else {
|
||||
$tmpl = $session->get('sms::tmpl');
|
||||
}
|
||||
|
||||
$_guests = isset($dataPost['guests']) ? $dataPost['guests'] : '';
|
||||
if (!$_guests) {
|
||||
$guests = $session->get('sms::guests');
|
||||
} else {
|
||||
$_guests = explode("\r\n", $_guests);
|
||||
$guests = array();
|
||||
foreach ($_guests as $c) {
|
||||
$_c = explode(',', $c);
|
||||
if (count($_c) > 1) {
|
||||
$k = trim($_c[1]);
|
||||
$v = trim($_c[0]);
|
||||
$guests[$k] = $v;
|
||||
}
|
||||
}
|
||||
unset($_c);
|
||||
unset($k);
|
||||
unset($v);
|
||||
$guests = array_unique($guests);
|
||||
}
|
||||
|
||||
if (!$guests) {
|
||||
$i = (int)$session->get('sms::success');
|
||||
$session->set('sms::success', 0);
|
||||
$msg = $session->get('sms::msg');
|
||||
$session->set('sms::msg', '');
|
||||
$this->result('群发完成,共成功发送' . $i . '条;详情:' . $msg);
|
||||
}
|
||||
|
||||
$results = [];
|
||||
$msg = "";
|
||||
$content = [];
|
||||
$content['address'] = $address;
|
||||
$i = 0;
|
||||
$j = 50;
|
||||
|
||||
foreach ($guests as $p => $username) {
|
||||
$j--;
|
||||
$content['name'] = !empty($username) ? $username . '安诚托车' : '安诚捷顺运车';
|
||||
$result = $sms->send($p, $tmpl, $content);
|
||||
$results[$p] = $result;
|
||||
|
||||
if (!$result) {
|
||||
$msg .= "【" . $p . "】发送失败,接口提示:" . $sms->errors . "\r\n";
|
||||
} else if ($result->Code != 'OK') {
|
||||
$msg .= "【" . $p . "】发送失败,接口提示:" . $result->Message . "\r\n";
|
||||
} else {
|
||||
$i++;
|
||||
$msg .= "【" . $p . "】发送成功";
|
||||
}
|
||||
unset($guests[$p]);
|
||||
if ($j == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$session->set('sms::guests', $guests);
|
||||
|
||||
$i += (int)$session->get('sms::success');
|
||||
$session->set('sms::success', $i);
|
||||
$msg .= $session->get('sms::msg');
|
||||
$session->set('sms::msg', $msg);
|
||||
$this->result('群发完成,共成功发送' . $i . '条;详情:' . $msg);
|
||||
}
|
||||
|
||||
//发送验证码
|
||||
public function actionVcode()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$plat = AcPlat::findOne($pid);
|
||||
$platExt = json_decode($plat->remark, TRUE);
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = $this->postdata; //YII应用内的真实或模拟POST数据
|
||||
$phone = $dataPost['phone'] ?? 0;
|
||||
//验证手机号
|
||||
$isPhone = FALSE;
|
||||
if ($phone) {
|
||||
$isPhone = preg_match('/^1\d{10}$/', $phone) ? TRUE : FALSE;
|
||||
}
|
||||
if (!$isPhone) {
|
||||
$this->result('手机号不正确,请确认');
|
||||
}
|
||||
// 手机号掩码
|
||||
$phoneMask = substr($phone, 0, 3) . str_repeat('*', strlen($phone) - 7) . substr($phone, -4);
|
||||
|
||||
$params = Yii::$app->params;
|
||||
$codetype = $dataPost['scence'] ?? 'vcode'; //验证码使用场景
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
|
||||
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
|
||||
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
|
||||
|
||||
$option = array();
|
||||
$sms = new Sms($option, $config);
|
||||
$_time = time();
|
||||
$vcodeModel = new CVcode();
|
||||
//查询上次发送记录
|
||||
$where = [];
|
||||
$where['mobile'] = $phone;
|
||||
$where['deleted'] = 0;
|
||||
$where['type'] = $codetype;
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if ($res) {
|
||||
if (($_time - $res->create_at) < 300) {
|
||||
//设置5分钟内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$msg = '上次发送的验证码仍然可用;请注意查看手机 ' . $phoneMask;
|
||||
$data = ['errorcode' => 2];
|
||||
if (YII_DEBUG) {
|
||||
$data['code'] = $code;
|
||||
}
|
||||
$this->result($msg, $data, 200);
|
||||
} else {
|
||||
$res->deleted = 1;
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
$content = [];
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
|
||||
//验证码准备入库
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['type'] = $codetype;
|
||||
$vcode['mobile'] = $phone;
|
||||
$vcode['create_at'] = $_time;
|
||||
foreach ($vcode as $key => $val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
$tmpls = $params['aliDySms']['tmpl'];
|
||||
switch ($codetype) {
|
||||
case 'reg':
|
||||
$tmpl = $tmpls['regVerify'];
|
||||
break;
|
||||
case 'login':
|
||||
$tmpl = $tmpls['loginVcode'];
|
||||
break;
|
||||
case 'info':
|
||||
$tmpl = $tmpls['infoChange'];
|
||||
break;
|
||||
case 'passwd':
|
||||
$tmpl = $tmpls['passwdChange'];
|
||||
break;
|
||||
case 'vcode':
|
||||
default:
|
||||
$tmpl = $tmpls['vcode'];
|
||||
break;
|
||||
}
|
||||
|
||||
// 发送前控制
|
||||
$host = yii::$app->request->hostName;
|
||||
$debug = $params['aliDySms']['debug'] ?? FALSE;
|
||||
$domains = $params['aliDySms']['domains'] ?? [];
|
||||
$sendable = FALSE;
|
||||
if (in_array($host, $domains) || $debug) {
|
||||
$sendable = TRUE;
|
||||
}
|
||||
$result = TRUE;
|
||||
if ($sendable) {
|
||||
$result = $sms->send($phone, $tmpl, $content);
|
||||
}
|
||||
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
$smsdata = [];
|
||||
$sid = $params['siteId'];
|
||||
$smsdata['sid'] = (int)$sid;
|
||||
$smsdata['pid'] = $pid;
|
||||
$smsdata['uid'] = 0;
|
||||
$smsdata['mid'] = $this->user_id;
|
||||
$smsdata['mobile'] = $phone;
|
||||
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
|
||||
$smsdata['create_at'] = $_time;
|
||||
foreach ($smsdata as $key => $val) {
|
||||
$smsModel->$key = $val;
|
||||
}
|
||||
$smsModel->save();
|
||||
|
||||
$errorcode = 0;
|
||||
$msg = '';
|
||||
if (!$result) {
|
||||
$msg .= "发送失败,接口提示:" . $sms->errors;
|
||||
$errorcode = 3;
|
||||
} else if (is_array($result) && $result['Code'] != 'OK') {
|
||||
$msg .= "发送失败,接口提示:" . $result['Message'];
|
||||
$errorcode = 4;
|
||||
} else {
|
||||
$vcodeModel->save();
|
||||
$msg .= "发送成功";
|
||||
}
|
||||
$data = ['errorcode' => $errorcode];
|
||||
if (!$debug || YII_DEBUG) {
|
||||
$data['data'] = $content;
|
||||
}
|
||||
$this->result($msg, $data, 200);
|
||||
}
|
||||
|
||||
//发送给财务
|
||||
public function actionCaiwu()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$plat = AcPlat::findOne($pid);
|
||||
$platExt = json_decode($plat->remark, TRUE);
|
||||
|
||||
$phone = $platExt['cw_phone'];
|
||||
if (!$phone) {
|
||||
$this->result('还没有配置财务手机号,请联系站长管理员进行设置!', ['errorcode' => 1], 200);
|
||||
}
|
||||
|
||||
$vcodeModel = new CVcode();
|
||||
$codetype = 'caiwu';
|
||||
//查询上次发送记录
|
||||
$_time = time();
|
||||
$where = [];
|
||||
$where['mobile'] = $phone;
|
||||
$where['deleted'] = 0;
|
||||
$where['type'] = $codetype;
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if ($res) {
|
||||
if (($_time - $res->create_at) < 7200) {
|
||||
//设置2小时内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$this->result('上次发送的验证码仍然可用;请注意查看财务手机!', ['errorcode' => 2], 200);
|
||||
} else {
|
||||
$res->deleted = 1;
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = $this->postdata; //YII应用内的真实或模拟POST数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$content = [];
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
$tmpl = $params['aliDySms']['tmpl']['cwVcode'];
|
||||
|
||||
//验证码准备入库
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['type'] = $codetype;
|
||||
$vcode['mobile'] = $phone;
|
||||
$vcode['create_at'] = $_time;
|
||||
foreach ($vcode as $key => $val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
|
||||
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
|
||||
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
|
||||
|
||||
$option = array();
|
||||
$sms = new Sms($option, $config);
|
||||
$result = $sms->send($phone, $tmpl, $content); //编排发送短信
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
$smsdata = [];
|
||||
$sid = $params['siteId'];
|
||||
$smsdata['sid'] = (int)$sid;
|
||||
$smsdata['pid'] = $pid;
|
||||
$smsdata['uid'] = 0;
|
||||
$smsdata['mid'] = $this->user_id;
|
||||
$smsdata['mobile'] = $phone;
|
||||
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
|
||||
$smsdata['create_at'] = $_time;
|
||||
foreach ($smsdata as $key => $val) {
|
||||
$smsModel->$key = $val;
|
||||
}
|
||||
$smsModel->save();
|
||||
|
||||
$errorcode = 0;
|
||||
$msg = '';
|
||||
if (!$result) {
|
||||
$msg .= "发送失败,接口提示:" . $sms->errors;
|
||||
$errorcode = 3;
|
||||
} else if (is_array($result) && $result['Code'] != 'OK') {
|
||||
$msg .= "发送失败,接口提示:" . $result['Message'];
|
||||
$errorcode = 4;
|
||||
} else {
|
||||
$vcodeModel->save();
|
||||
$msg .= "发送成功";
|
||||
}
|
||||
$this->result($msg, ['errorcode' => $errorcode], 200);
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:20:31+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//DataApi站点用户专入口
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use common\models\User;
|
||||
|
||||
class UserController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'login' => '登陆'
|
||||
];
|
||||
$this->result('您正使用DACMS系统用户管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
$search = $post['search'] ?? NULL;
|
||||
|
||||
$username = $search['username'] ?? NULL;
|
||||
$username = $post['username'] ?? $username;
|
||||
|
||||
$passwd = $search['passwd'] ?? NULL;
|
||||
$passwd = $post['passwd'] ?? $passwd;
|
||||
|
||||
$return = [];
|
||||
if (!$username && !$passwd) {
|
||||
$this->result('登陆参数错误!', NULL, 400);
|
||||
}
|
||||
if (!$username) {
|
||||
$this->result('请输入您的账号!', NULL, 400);
|
||||
}
|
||||
if (!$passwd) {
|
||||
$this->result('请输入您的密码!', NULL, 400);
|
||||
}
|
||||
$username = trim(htmlspecialchars_decode($username));
|
||||
$passwd = trim(htmlspecialchars_decode($passwd));
|
||||
if (!$username) {
|
||||
$this->result('输入错误,请检查您的账号!', NULL, 400);
|
||||
}
|
||||
if (!$passwd) {
|
||||
$this->result('输入有误,请检查您的密码!', NULL, 400);
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$user = $model->findOne(['mobile' => $username]);
|
||||
if (!$user) {
|
||||
$this->result('查无此人!', NULL, 404);
|
||||
}
|
||||
|
||||
if ($user->status != User::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', NULL, 403);
|
||||
}
|
||||
//安全校验,登陆密码
|
||||
$isPwdRight = $user->validatePassword($passwd);
|
||||
|
||||
if (!$isPwdRight) {
|
||||
$this->result('密码错误,禁止登陆!', NULL, 400);
|
||||
}
|
||||
//用户主信息校验结束
|
||||
|
||||
$_user = $this->userLogin($user, TRUE);
|
||||
$this->result('登陆成功!', ['user' => $_user], 200);
|
||||
}
|
||||
|
||||
private function userLogin($user, $hasExt = FALSE)
|
||||
{
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$identity = $user;
|
||||
// 登录用户,有效期30d
|
||||
$duration = 3600 * 24 * 30;
|
||||
$_login = Yii::$app->user->login($identity, $duration);
|
||||
if (!$_login) {
|
||||
$this->result('登陆失败!', NULL, 400);
|
||||
}
|
||||
//登陆成功,返回用户信息
|
||||
$_user = ['id' => $user->id, 'username' => $user->username, 'mobile' => $user->mobile, 'email' => $user->email, 'avatar' => Url::to($user->avatar)];
|
||||
$_user['employee_id'] = $this->employee_id;
|
||||
|
||||
//生成token(用户数据,是否强制更新,过期时间
|
||||
$isLong = $this->postdata['isLong'] ?? FALSE;
|
||||
$expire = $isLong ? '+1 Month' : FALSE;
|
||||
$_user = $this->userToken($_user, $refresh = TRUE, $expire);
|
||||
return $_user;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
api账号
|
||||
账号:publicapi
|
||||
密码:api.hiluker
|
||||
|
||||
——————————————————————————
|
||||
admin超级账号
|
||||
账号: fm453
|
||||
密码: Lukegzs168.com
|
||||
+32
-17
@@ -1,24 +1,39 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>恭喜,站点创建成功!</title>
|
||||
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
||||
<script src="//cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
||||
<meta charset="utf-8">
|
||||
<title>恭喜,站点创建成功!</title>
|
||||
<style>
|
||||
.container {
|
||||
width: 60%;
|
||||
margin: 10% auto 0;
|
||||
background-color: #f0f0f0;
|
||||
padding: 2% 5%;
|
||||
border-radius: 10px
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
ul li {
|
||||
line-height: 2.3
|
||||
}
|
||||
|
||||
a {
|
||||
color: #20a53a
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin-top:9%;">
|
||||
<div class="jumbotron">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading"><h1>恭喜, 站点创建成功!</h1></div>
|
||||
</div>
|
||||
<p><h3>站点创建成功,本页面由系统自动生成。</h3></p>
|
||||
<p><li>本页面在FTP根目录下的index.html</li></p>
|
||||
<p><li>您可以删除或覆盖本页面</li></p>
|
||||
<p><li>FTP相关信息,请到宝塔后台查看</li></p>
|
||||
<p><li>我们为您提供了完善的数据备份功能,请到后台进行相关设置</li></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1>恭喜, 站点创建成功!</h1>
|
||||
<h3>这是默认index.html,本页面由系统自动生成</h3>
|
||||
<ul>
|
||||
<li>本页面在FTP根目录下的index.html</li>
|
||||
<li>您可以修改、删除或覆盖本页面</li>
|
||||
<li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
*/
|
||||
class ContactForm extends Model
|
||||
{
|
||||
public $name;
|
||||
public $email;
|
||||
public $subject;
|
||||
public $body;
|
||||
public $verifyCode;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// name, email, subject and body are required
|
||||
[['name', 'email', 'subject', 'body'], 'required'],
|
||||
// email has to be a valid email address
|
||||
['email', 'email'],
|
||||
// verifyCode needs to be entered correctly
|
||||
['verifyCode', 'captcha'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'verifyCode' => Yii::t('frontend','Verify Code'),
|
||||
'name' => Yii::t('frontend','Name'),
|
||||
'email' => Yii::t('frontend','Email'),
|
||||
'subject' => Yii::t('frontend','Subject'),
|
||||
'body' => Yii::t('frontend','Body'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an email to the specified email address using the information collected by this model.
|
||||
*
|
||||
* @param string $email the target email address
|
||||
* @return bool whether the email was sent
|
||||
*/
|
||||
public function sendEmail($email)
|
||||
{
|
||||
return Yii::$app->mailer->compose()
|
||||
->setTo($email)
|
||||
->setFrom(Yii::$app->params['noticeEmail'])
|
||||
->setSubject($this->subject)
|
||||
->setTextBody($this->body)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-09 22:18:46
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-09 23:01:13
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\User;
|
||||
use common\models\CLog;
|
||||
|
||||
/**
|
||||
* Login form
|
||||
*/
|
||||
class LoginForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe = true;
|
||||
|
||||
private $_user;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// username and password are both required
|
||||
[['username', 'password'], 'required'],
|
||||
// rememberMe must be a boolean value
|
||||
['rememberMe', 'boolean'],
|
||||
// password is validated by validatePassword()
|
||||
['password', 'validatePassword'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'username' => Yii::t('common','Username'),
|
||||
'password' => Yii::t('common','Password'),
|
||||
'rememberMe' => Yii::t('common','Remember Me'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->hasErrors()) {
|
||||
$user = $this->getUser();
|
||||
if (!$user || !$user->validatePassword($this->password)) {
|
||||
$this->addError($attribute, Yii::t('common','Incorrect username or password.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user using the provided username and password.
|
||||
*
|
||||
* @return bool whether the user is logged in successfully
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if ($this->validate()) {
|
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
|
||||
}
|
||||
|
||||
return false; //如果为true 将允许任意密码登陆
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by [[username]]
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
protected function getUser()
|
||||
{
|
||||
if ($this->_user === null) {
|
||||
$this->_user = User::findByUsername($this->username); //千万注意后端的登陆使用的是Adminer模型,不是User
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
//登录记录
|
||||
public function loginLog(){
|
||||
$request = Yii::$app->getRequest();
|
||||
$nowFile = $request -> getScriptFile();
|
||||
$data = "登陆系统|途径:".$nowFile;
|
||||
|
||||
$model = new CLog();
|
||||
$model->username = $this->username;
|
||||
$model->ip = Yii::$app->request->userIP;
|
||||
$model->data = $data;
|
||||
$model->create_time = time();
|
||||
$model->save();
|
||||
|
||||
//编制邮件发送通知
|
||||
$message = Yii::$app->mailer->compose();
|
||||
$message->setFrom(Yii::$app->params['noticeEmail']);
|
||||
//给登陆者发送
|
||||
$subject = "账号登陆提醒";
|
||||
$body = "您的账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
|
||||
$message->setTo(Yii::$app->user->identity->email)
|
||||
->setSubject($subject)
|
||||
->setTextBody($body)
|
||||
->send();
|
||||
//给管理人员发送
|
||||
$subject = "账号登陆提醒";
|
||||
$body = "API站账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
|
||||
$message->setTo('1280880631@qq.com')
|
||||
->setSubject($subject)
|
||||
->setTextBody($body)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 18:17:47
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 18:19:01
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\User;
|
||||
|
||||
/**
|
||||
* Password reset request form
|
||||
*/
|
||||
class PasswordResetRequestForm extends Model
|
||||
{
|
||||
public $email;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['email', 'trim'],
|
||||
['email', 'required'],
|
||||
['email', 'email'],
|
||||
['email', 'exist',
|
||||
'targetClass' => '\common\models\User',
|
||||
'filter' => ['status' => User::STATUS_ACTIVE],
|
||||
'message' => 'There is no user with this email address.'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an email with a link, for resetting the password.
|
||||
*
|
||||
* @return bool whether the email was send
|
||||
*/
|
||||
public function sendEmail()
|
||||
{
|
||||
/* @var $user User */
|
||||
$user = User::findOne([
|
||||
'status' => User::STATUS_ACTIVE,
|
||||
'email' => $this->email,
|
||||
]);
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
|
||||
$user->generatePasswordResetToken();
|
||||
if (!$user->save()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return Yii::$app
|
||||
->mailer
|
||||
->compose(
|
||||
['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'],
|
||||
['user' => $user]
|
||||
)
|
||||
->setFrom([Yii::$app->params['noticeEmail'] => Yii::$app->name . ' robot'])
|
||||
->setTo($this->email)
|
||||
->setSubject('Password reset for ' . Yii::$app->name)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
namespace frontend\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\base\InvalidParamException;
|
||||
use common\models\User;
|
||||
|
||||
/**
|
||||
* Password reset form
|
||||
*/
|
||||
class ResetPasswordForm extends Model
|
||||
{
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* @var \common\models\User
|
||||
*/
|
||||
private $_user;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a form model given a token.
|
||||
*
|
||||
* @param string $token
|
||||
* @param array $config name-value pairs that will be used to initialize the object properties
|
||||
* @throws \yii\base\InvalidParamException if token is empty or not valid
|
||||
*/
|
||||
public function __construct($token, $config = [])
|
||||
{
|
||||
if (empty($token) || !is_string($token)) {
|
||||
throw new InvalidParamException('Password reset token cannot be blank.');
|
||||
}
|
||||
$this->_user = User::findByPasswordResetToken($token);
|
||||
if (!$this->_user) {
|
||||
throw new InvalidParamException('Wrong password reset token.');
|
||||
}
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['password', 'required'],
|
||||
['password', 'string', 'min' => 6],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets password.
|
||||
*
|
||||
* @return bool if password was reset.
|
||||
*/
|
||||
public function resetPassword()
|
||||
{
|
||||
$user = $this->_user;
|
||||
$user->setPassword($this->password);
|
||||
$user->removePasswordResetToken();
|
||||
|
||||
return $user->save(false);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\User;
|
||||
|
||||
/**
|
||||
* Signup form
|
||||
*/
|
||||
class SignupForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $email;
|
||||
public $password;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['username', 'trim'],
|
||||
['username', 'required'],
|
||||
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => '该用户名已经有人注册了.'],
|
||||
['username', 'string', 'min' => 2, 'max' => 255],
|
||||
|
||||
['email', 'trim'],
|
||||
['email', 'required'],
|
||||
['email', 'email'],
|
||||
['email', 'string', 'max' => 255],
|
||||
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => '该邮箱地址已经有人使用了.'],
|
||||
|
||||
['password', 'required'],
|
||||
['password', 'string', 'min' => 6],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'username' => Yii::t('frontend','Username'),
|
||||
'password' => Yii::t('frontend','Password'),
|
||||
'email' => Yii::t('frontend','Email'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs user up.
|
||||
*
|
||||
* @return User|null the saved model or null if saving fails
|
||||
*/
|
||||
public function signup()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user->username = $this->username;
|
||||
$user->email = $this->email;
|
||||
$user->setPassword($this->password);
|
||||
$user->generateAuthKey();
|
||||
|
||||
return $user->save() ? $user : null;
|
||||
}
|
||||
}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
@Author: 嗨噜客(三亚) <fm453>
|
||||
@Date: 2024-07-06T09:30:10+08:00
|
||||
@Email: 393213759@qq.com
|
||||
@Last modified by: fm453
|
||||
@Last modified time: 2024-07-06T09:30:10+08:00
|
||||
@Copyright: www.hiluker.cn
|
||||
|
||||
轿车托运物流管理系统后台API
|
||||
@@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
Executable
+75160
File diff suppressed because it is too large
Load Diff
Executable
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'username' => 'okirlin',
|
||||
'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv',
|
||||
'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi',
|
||||
'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(),
|
||||
'created_at' => '1391885313',
|
||||
'updated_at' => '1391885313',
|
||||
'email' => 'brady.renner@rutherford.com',
|
||||
],
|
||||
[
|
||||
'username' => 'troy.becker',
|
||||
'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp',
|
||||
'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2',
|
||||
'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(),
|
||||
'created_at' => '1391885313',
|
||||
'updated_at' => '1391885313',
|
||||
'email' => 'nicolas.dianna@hotmail.com',
|
||||
'status' => '0',
|
||||
],
|
||||
];
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace frontend\tests;
|
||||
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
@@ -19,15 +20,8 @@ namespace frontend\tests;
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
|
||||
|
||||
public function seeValidationError($message)
|
||||
{
|
||||
$this->see($message, '.help-block');
|
||||
}
|
||||
|
||||
public function dontSeeValidationError($message)
|
||||
{
|
||||
$this->dontSee($message, '.help-block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace frontend\tests;
|
||||
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class_name: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
url: http://localhost:8080
|
||||
browser: firefox
|
||||
- Yii2:
|
||||
part: init
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace frontend\tests\acceptance;
|
||||
|
||||
use Yii;
|
||||
use frontend\tests\AcceptanceTester;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class HomeCest
|
||||
{
|
||||
public function checkHome(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage(Url::toRoute('/site/index'));
|
||||
$I->see('My Company');
|
||||
|
||||
$I->seeLink('About');
|
||||
$I->click('About');
|
||||
$I->wait(2); // wait for page to be opened
|
||||
|
||||
$I->see('This is the About page.');
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Cepts.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Cept
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
@@ -1,5 +1,4 @@
|
||||
class_name: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Filesystem
|
||||
- Yii2
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
|
||||
class AboutCest
|
||||
{
|
||||
public function checkAbout(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/about');
|
||||
$I->see('About', 'h1');
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
|
||||
/* @var $scenario \Codeception\Scenario */
|
||||
|
||||
class ContactCest
|
||||
{
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage(['site/contact']);
|
||||
}
|
||||
|
||||
public function checkContact(FunctionalTester $I)
|
||||
{
|
||||
$I->see('Contact', 'h1');
|
||||
}
|
||||
|
||||
public function checkContactSubmitNoData(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#contact-form', []);
|
||||
$I->see('Contact', 'h1');
|
||||
$I->seeValidationError('Name cannot be blank');
|
||||
$I->seeValidationError('Email cannot be blank');
|
||||
$I->seeValidationError('Subject cannot be blank');
|
||||
$I->seeValidationError('Body cannot be blank');
|
||||
$I->seeValidationError('The verification code is incorrect');
|
||||
}
|
||||
|
||||
public function checkContactSubmitNotCorrectEmail(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#contact-form', [
|
||||
'ContactForm[name]' => 'tester',
|
||||
'ContactForm[email]' => 'tester.email',
|
||||
'ContactForm[subject]' => 'test subject',
|
||||
'ContactForm[body]' => 'test content',
|
||||
'ContactForm[verifyCode]' => 'testme',
|
||||
]);
|
||||
$I->seeValidationError('Email is not a valid email address.');
|
||||
$I->dontSeeValidationError('Name cannot be blank');
|
||||
$I->dontSeeValidationError('Subject cannot be blank');
|
||||
$I->dontSeeValidationError('Body cannot be blank');
|
||||
$I->dontSeeValidationError('The verification code is incorrect');
|
||||
}
|
||||
|
||||
public function checkContactSubmitCorrectData(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#contact-form', [
|
||||
'ContactForm[name]' => 'tester',
|
||||
'ContactForm[email]' => 'tester@example.com',
|
||||
'ContactForm[subject]' => 'test subject',
|
||||
'ContactForm[body]' => 'test content',
|
||||
'ContactForm[verifyCode]' => 'testme',
|
||||
]);
|
||||
$I->seeEmailIsSent();
|
||||
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
|
||||
class HomeCest
|
||||
{
|
||||
public function checkOpen(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage(\Yii::$app->homeUrl);
|
||||
$I->see('My Company');
|
||||
$I->seeLink('About');
|
||||
$I->click('About');
|
||||
$I->see('This is the About page.');
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user