匹配导出接口
This commit is contained in:
parent
af55bd020b
commit
c522d234a0
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use addons\csmtable\library\xcore\xcore\utils\XcAdminSessionUtils;
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\common\controller\Backend;
|
||||
|
||||
|
@ -33,6 +34,8 @@ class Adminlog extends Backend
|
|||
->column('id,name');
|
||||
|
||||
$this->view->assign('groupdata', $groupName);
|
||||
|
||||
// var_dump(XcAdminSessionUtils::getManystoreToken());die;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
namespace app\admin\controller\school;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\exception\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 夜校站内信
|
||||
|
@ -82,4 +87,96 @@ class Message extends Backend
|
|||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException()->validate($validate);
|
||||
}
|
||||
$params["event"] = "system";
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param $ids
|
||||
* @return string
|
||||
* @throws DbException
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->view->assign('row', $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException()->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if (false === $result) {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ClassesLib extends Backend
|
|||
protected $model = null;
|
||||
|
||||
//不用审核允许修改的字段
|
||||
protected $no_auth_fields = ["user_id","teacher_id","classes_type","classes_cate_ids","classes_label_ids","self_label_tag",'headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"];
|
||||
protected $no_auth_fields = ["title","user_id","teacher_id","classes_type","classes_cate_ids","classes_label_ids","self_label_tag",'headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"];
|
||||
|
||||
//更新数据是否需要触发审核开关
|
||||
protected $need_auth = false;
|
||||
|
|
|
@ -35,6 +35,7 @@ class Order extends Backend
|
|||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("authStatusList", $this->model->getAuthStatusList());
|
||||
$this->getAuthMsg();
|
||||
// $this->setUrlLock();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ class ClassesLib extends Validate
|
|||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => 'require|length:1,50|alphaNum',
|
||||
// 'title' => 'require|length:1,50|alphaNum',
|
||||
'title' => 'require|length:1,50',
|
||||
// 'alphaNum' 是自定义的规则,用于过滤中文、数字和拼音字符
|
||||
];
|
||||
/**
|
||||
|
@ -19,7 +20,7 @@ class ClassesLib extends Validate
|
|||
protected $message = [
|
||||
'title.require' => '课程名不能为空',
|
||||
'title.length' => '课程名长度必须在1到50之间',
|
||||
'title.alphaNum' =>'课程名只允许中文、数字和拼音字符'
|
||||
// 'title.alphaNum' =>'课程名只允许中文、数字和拼音字符'
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
|
|
|
@ -10,7 +10,7 @@ use app\common\model\school\classes\Teacher as Teachermodel;
|
|||
*/
|
||||
class Activity extends Base
|
||||
{
|
||||
protected $noNeedLogin = ["demo_detail","demo_list"];
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
protected $model = null;
|
||||
|
|
|
@ -31,6 +31,7 @@ class Classes extends Base
|
|||
parent::_initialize();
|
||||
|
||||
//判断登录用户是否是员工
|
||||
$this->setUrlLock();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Evaluate extends Base
|
|||
$this->model = new \app\common\model\school\classes\Evaluate;
|
||||
parent::_initialize();
|
||||
|
||||
//判断登录用户是否是员工
|
||||
$this->setUrlLock();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ class HourOrder extends Base
|
|||
$order_no = $this->request->post('order_no/s', ''); //订单号
|
||||
$remark = $this->request->post('remark/s', ''); //下单备注
|
||||
// repeat_filter("appointment\order\create".$user_id, 2);
|
||||
$this->setUrlLock("only");
|
||||
try{
|
||||
//当前申请状态
|
||||
$res = $this->model->cacheCreateOrder($order_no, $user_id,$remark, true);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\api\controller\school;
|
||||
|
||||
use app\common\model\school\classes\ClassesSpec;
|
||||
use app\common\model\school\classes\order\Order as OrderModel;
|
||||
use app\common\model\school\classes\Teacher as Teachermodel;
|
||||
use bw\UrlLock;
|
||||
|
@ -83,6 +84,13 @@ class Order extends Base
|
|||
$classes_lib_id = $this->request->post('classes_lib_id/d', 0); //课程id
|
||||
$classes_lib_spec_id = $this->request->post('classes_lib_spec_id/d', 0); //想同时约的课时id
|
||||
// $param = urldecode($this->request->post('param/s', "{}")); //参数
|
||||
if(!$classes_lib_spec_id){
|
||||
if(ClassesSpec::where("classes_lib_id",$classes_lib_id)->where("status",'1')->count()==1){
|
||||
$classes_lib_spec_id = ClassesSpec::where("classes_lib_id",$classes_lib_id)->where("status",'1')->order("weigh desc,id desc")->value("id");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$param = [];
|
||||
if($classes_lib_spec_id){
|
||||
$param = [
|
||||
|
@ -119,7 +127,7 @@ class Order extends Base
|
|||
if($user)$user_id = $user['id'];
|
||||
$order_no = $this->request->post('order_no/s', ''); //订单号
|
||||
$remark = $this->request->post('remark/s', ''); //下单备注
|
||||
|
||||
$this->setUrlLock("only");
|
||||
// repeat_filter("appointment\order\create".$user_id, 2);
|
||||
try{
|
||||
// $lock = new UrlLock($user_id,"class-order-create-lock-suffix",120,"您的请求过于频繁,请您稍后再试!请求最大锁定间隔120秒!");
|
||||
|
|
|
@ -25,6 +25,7 @@ class Shop extends Base
|
|||
parent::_initialize();
|
||||
|
||||
//判断登录用户是否是员工
|
||||
$this->setUrlLock();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ class Order extends Base
|
|||
if($user)$user_id = $user['id'];
|
||||
$order_no = $this->request->post('order_no/s', ''); //订单号
|
||||
$remark = $this->request->post('remark/s', ''); //下单备注
|
||||
$this->setUrlLock("only");
|
||||
// repeat_filter("appointment\order\create".$user_id, 2);
|
||||
try{
|
||||
//当前申请状态
|
||||
|
|
|
@ -31,6 +31,9 @@ class Classes extends Base
|
|||
parent::_initialize();
|
||||
|
||||
//判断登录用户是否是员工 'add','edit','del'
|
||||
|
||||
$this->setUrlLock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ class HourOrder extends Base
|
|||
$order_no = $this->request->post('order_no/s', ''); //订单号
|
||||
$remark = $this->request->post('remark/s', ''); //下单备注
|
||||
// repeat_filter("appointment\order\create".$user_id, 2);
|
||||
$this->setUrlLock("only");
|
||||
try{
|
||||
//当前申请状态
|
||||
$res = $this->model->cacheCreateOrder($order_no, $user_id,$remark, true);
|
||||
|
|
|
@ -88,8 +88,10 @@ class Api
|
|||
}
|
||||
|
||||
|
||||
public function setUrlLock(){
|
||||
if($this->request->isPost() && !empty($this->model)){
|
||||
protected $needUrlLock = [];
|
||||
|
||||
public function setUrlLock($url_key="",$url_suffix="",$model=null){
|
||||
if(($this->request->isPost() || (!empty($this->needUrlLock) && in_array($this->request->action(),$this->needUrlLock))) && (!empty($this->model) || $model)){
|
||||
$user_id = 0;
|
||||
$user = $this->auth->getUser();//登录用户
|
||||
if($user)$user_id = $user['id'];
|
||||
|
@ -98,9 +100,16 @@ class Api
|
|||
$controllername = Loader::parseName($this->request->controller());
|
||||
$actionname = strtolower($this->request->action());
|
||||
$path = $modulename . '/' . str_replace('.', '/', $controllername) . '/' . $actionname;
|
||||
$this->model::$url_lock_key = $user_id;
|
||||
$this->model::$url_lock_suffix = $path."lock-suffix";
|
||||
$this->model::$url_lock = true;
|
||||
if(!$model){
|
||||
$this->model::$url_lock_key = $url_key ?: $user_id;
|
||||
$this->model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$this->model::$url_lock = true;
|
||||
}else{
|
||||
$model::$url_lock_key = $url_key ?: $user_id;
|
||||
$model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$model::$url_lock = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\common\controller;
|
||||
|
||||
use addons\csmtable\library\xcore\xcore\utils\XcAdminSessionUtils;
|
||||
use app\admin\controller\famysql\Field;
|
||||
use app\admin\library\Auth;
|
||||
use app\admin\model\Admin;
|
||||
|
@ -249,7 +250,30 @@ class Backend extends Controller
|
|||
}
|
||||
|
||||
|
||||
protected $needUrlLock = [];
|
||||
|
||||
public function setUrlLock($url_key="",$url_suffix="",$model=null){
|
||||
if(($this->request->isPost() || (!empty($this->needUrlLock) && in_array($this->request->action(),$this->needUrlLock))) && (!empty($this->model) || $model)){
|
||||
$user_id = $this->auth->id ?? 0;
|
||||
// $user = $this->auth->getUser();//登录用户
|
||||
// if($user)$user_id = $user['id'];
|
||||
|
||||
$modulename = $this->request->module();
|
||||
$controllername = Loader::parseName($this->request->controller());
|
||||
$actionname = strtolower($this->request->action());
|
||||
$path = $modulename . '/' . str_replace('.', '/', $controllername) . '/' . $actionname;
|
||||
if(!$model){
|
||||
$this->model::$url_lock_key = $url_key ?: $user_id;
|
||||
$this->model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$this->model::$url_lock = true;
|
||||
}else{
|
||||
$model::$url_lock_key = $url_key ?: $user_id;
|
||||
$model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$model::$url_lock = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入后台控制器的traits
|
||||
|
@ -297,6 +321,7 @@ class Backend extends Controller
|
|||
if (!$this->auth->match($this->noNeedRight)) {
|
||||
// 判断控制器和方法是否有对应权限
|
||||
if (!$this->auth->check($path)) {
|
||||
// var_dump($path);
|
||||
Hook::listen('admin_nopermission', $this);
|
||||
$this->error(__('You have no permission'), '');
|
||||
}
|
||||
|
@ -352,18 +377,28 @@ class Backend extends Controller
|
|||
'jsname' => 'backend/' . str_replace('.', '/', $controllername),
|
||||
'moduleurl' => rtrim(url("/{$modulename}", '', false), '/'),
|
||||
'language' => $lang,
|
||||
'referer' => Session::get("referer")
|
||||
'referer' => Session::get("referer"),
|
||||
|
||||
|
||||
];
|
||||
$config = array_merge($config, Config::get("view_replace_str"));
|
||||
|
||||
Config::set('upload', array_merge(Config::get('upload'), $upload));
|
||||
|
||||
if($this->auth->isLogin()){
|
||||
$config["clogintoken"] = XcAdminSessionUtils::getToken();
|
||||
$config["manystoretoken"] = "";
|
||||
}
|
||||
|
||||
// 配置信息后
|
||||
Hook::listen("config_init", $config);
|
||||
//加载当前控制器语言包
|
||||
$this->loadlang($controllername);
|
||||
//渲染站点配置
|
||||
$this->assign('site', $site);
|
||||
|
||||
|
||||
|
||||
//渲染配置信息
|
||||
$this->assign('config', $config);
|
||||
//渲染权限对象
|
||||
|
@ -373,7 +408,7 @@ class Backend extends Controller
|
|||
$this->checkAssemblyParameters();
|
||||
|
||||
// $this->view->assign("selfhotList", $this->model->getSelfhotList());
|
||||
|
||||
// $this->assign('clogintoken', XcAdminSessionUtils::getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\common\controller;
|
||||
|
||||
use addons\csmtable\library\xcore\xcore\utils\XcAdminSessionUtils;
|
||||
use app\admin\controller\famysql\Field;
|
||||
use app\common\library\Virtual;
|
||||
use app\common\model\dyqc\ManystoreShop;
|
||||
|
@ -209,6 +210,32 @@ class ManystoreBase extends Controller
|
|||
|
||||
|
||||
|
||||
protected $needUrlLock = [];
|
||||
|
||||
public function setUrlLock($url_key="",$url_suffix="",$model=null){
|
||||
if(($this->request->isPost() || (!empty($this->needUrlLock) && in_array($this->request->action(),$this->needUrlLock))) && (!empty($this->model) || $model)){
|
||||
$user_id = $this->auth->id ?? 0;
|
||||
// $user = $this->auth->getUser();//登录用户
|
||||
// if($user)$user_id = $user['id'];
|
||||
|
||||
$modulename = $this->request->module();
|
||||
$controllername = Loader::parseName($this->request->controller());
|
||||
$actionname = strtolower($this->request->action());
|
||||
$path = $modulename . '/' . str_replace('.', '/', $controllername) . '/' . $actionname;
|
||||
if(!$model){
|
||||
$this->model::$url_lock_key = $url_key ?: $user_id;
|
||||
$this->model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$this->model::$url_lock = true;
|
||||
}else{
|
||||
$model::$url_lock_key = $url_key ?: $user_id;
|
||||
$model::$url_lock_suffix = $url_suffix ?: $path."lock-suffix";
|
||||
$model::$url_lock = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 引入后台控制器的traits
|
||||
*/
|
||||
|
@ -357,6 +384,10 @@ class ManystoreBase extends Controller
|
|||
|
||||
Config::set('upload', array_merge(Config::get('upload'), $upload));
|
||||
|
||||
if($this->auth->isLogin()){
|
||||
$config["manystoretoken"] = $manystore["token"];
|
||||
$config["clogintoken"] = "";
|
||||
}
|
||||
// 配置信息后
|
||||
Hook::listen("config_init", $config);
|
||||
//加载当前控制器语言包
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\library;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\school\classes\ClassesLib;
|
||||
|
||||
/**
|
||||
* 夜校大数据类
|
||||
*/
|
||||
class NightSchoolBigData extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
public static function getAreaBaseData($province,$city,$district){
|
||||
$where = function ($query)use($province,$city,$district){
|
||||
if( $province)$query = $query->where('province',$province);
|
||||
if( $city)$query = $query->where('city',$city);
|
||||
if( $district)$query = $query->where('district',$district);
|
||||
};
|
||||
//统计当前课程总数
|
||||
$count = ClassesLib::where($where)->sum("");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ use app\admin\model\Admin;
|
|||
use app\common\library\Virtual;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\school\Area;
|
||||
use app\common\model\school\classes\activity\Activity;
|
||||
use app\common\model\school\classes\ClassesLib;
|
||||
use app\common\model\school\classes\Teacher;
|
||||
use app\common\model\school\classes\Verification;
|
||||
|
@ -875,6 +876,26 @@ public static function getAuthInfo($user_id){
|
|||
$reason =""; //失败原因
|
||||
$check_full_msg = "";
|
||||
$check_full = false;
|
||||
|
||||
$verification = true; //核销权限
|
||||
$verification_shop_id = 0; //可核销机构
|
||||
|
||||
try{
|
||||
$verification_shop_id = ClassesLib::checkOptionAuth(0,$user_id,"user");
|
||||
}catch (\Exception $e){
|
||||
|
||||
}
|
||||
$verification_classes_lib_ids = (new ClassesLib)->getClassesAuthIds($user_id);
|
||||
$verification_classes_activity_ids = (new Activity())->getActivityAuthIds($user_id);
|
||||
|
||||
//如果没有任何可管理的classes_lib_id 则返回错误
|
||||
if(!$verification_classes_lib_ids && !$verification_shop_id && !$verification_classes_activity_ids){
|
||||
$verification = false;
|
||||
}
|
||||
$verification_auth = compact("verification","verification_shop_id","verification_classes_lib_ids","verification_classes_activity_ids");
|
||||
|
||||
|
||||
|
||||
$check_field = [
|
||||
"address_city",
|
||||
"province",
|
||||
|
@ -890,14 +911,14 @@ public static function getAuthInfo($user_id){
|
|||
"logo"
|
||||
];
|
||||
$apply_info = null;
|
||||
if(!$user_id)return compact("check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
if(!$user_id)return compact("verification_auth","check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
|
||||
//得到申请单
|
||||
$apply_info = self::where("user_id",$user_id)->where("status","1")->find();
|
||||
if(!$apply_info)$apply_info = self::where("user_id",$user_id)->find();
|
||||
//不存在说明未申请,直接返回
|
||||
if(!$apply_info){
|
||||
return compact("check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
return compact("verification_auth","check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
}
|
||||
$type = $apply_info['type'];
|
||||
//从申请单取到申请状态
|
||||
|
@ -916,7 +937,7 @@ public static function getAuthInfo($user_id){
|
|||
$check_full_msg = $self->checkFullMsg($shop_id);
|
||||
$check_full = $self->checkFull($shop_id);
|
||||
|
||||
return compact("check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
return compact("verification_auth","check_full_msg","check_full","check_field",'auth_status','shop_id','reason','apply_info',"type");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ class Message extends BaseModel
|
|||
$unread_system_number = self::getBaseWhere(array_merge(['status'=>'system'],$where))->count();
|
||||
$unread_classes_number = self::getBaseWhere(array_merge(['status'=>'classes'],$where))->count();
|
||||
$unread_order_number = self::getBaseWhere(array_merge(['status'=>'order'],$where))->count();
|
||||
|
||||
$unread_activity_number = self::getBaseWhere(array_merge(['status'=>'activity'],$where))->count();;
|
||||
|
||||
|
||||
$where["type"] = '2';
|
||||
|
@ -317,11 +317,11 @@ class Message extends BaseModel
|
|||
$read_system_number = self::getBaseWhere(array_merge(['status'=>'system'],$where))->count();
|
||||
$read_classes_number = self::getBaseWhere(array_merge(['status'=>'classes'],$where))->count();
|
||||
$read_order_number = self::getBaseWhere(array_merge(['status'=>'order'],$where))->count();
|
||||
$read_activity_number = self::getBaseWhere(array_merge(['status'=>'activity'],$where))->count();
|
||||
|
||||
|
||||
|
||||
return compact('unread_number','unread_system_number','unread_classes_number','unread_order_number',
|
||||
'read_number','read_system_number','read_classes_number','read_order_number');
|
||||
return compact("unread_activity_number",'unread_number','unread_system_number','unread_classes_number','unread_order_number',
|
||||
'read_number','read_system_number','read_classes_number','read_order_number',"read_activity_number");
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,19 +338,24 @@ class Message extends BaseModel
|
|||
$unread_classes_number = 0;
|
||||
$unread_order_number = 0;
|
||||
|
||||
$unread_activity_number = 0;
|
||||
|
||||
$read_number = 0;
|
||||
$read_system_number = 0;
|
||||
$read_classes_number = 0;
|
||||
$read_order_number = 0;
|
||||
$read_activity_number = 0;
|
||||
|
||||
return compact('unread_number',
|
||||
'unread_system_number',
|
||||
'unread_classes_number',
|
||||
'unread_activity_number',
|
||||
'unread_order_number',
|
||||
'read_number',
|
||||
'read_system_number',
|
||||
'read_classes_number',
|
||||
'read_order_number'
|
||||
'read_order_number',
|
||||
'read_activity_number'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1258,6 +1258,7 @@ $user_unpaid_order = $user_paid_order =null;
|
|||
$params["feel"] = "0";
|
||||
}
|
||||
|
||||
if(!isset($params["classes_num"]))$params["classes_num"] = 1;
|
||||
|
||||
$rule = [
|
||||
'manystore_id'=>'require',
|
||||
|
|
|
@ -32,7 +32,7 @@ class ClassesSpec extends BaseModel
|
|||
'time'
|
||||
];
|
||||
|
||||
public $no_auth_fields = ['name','limit_num','status','weigh'];
|
||||
public $no_auth_fields = ['name','limit_num','status','weigh',"start_time","end_time"];
|
||||
protected static function init()
|
||||
{
|
||||
self::afterInsert(function ($row) {
|
||||
|
|
|
@ -770,7 +770,7 @@ class Order extends BaseModel
|
|||
|
||||
//存在同规格正在进行中的课时预约
|
||||
$order_info = self::where('classes_activity_item_id',$classes_activity_item_id)
|
||||
->where('status',"not in",["-3","6"])
|
||||
->where('status',"not in",["-3","5","6"])
|
||||
->where('user_id',$user_id)
|
||||
->find();
|
||||
if($order_info && $check) throw new \Exception("该活动规格已预约或已上过,请勿重复预约!");
|
||||
|
@ -780,7 +780,7 @@ class Order extends BaseModel
|
|||
//允许人数为0说明不限制
|
||||
if($classes_lib_spec_info['limit_num'] > 0 && $check){
|
||||
//得到当前课时已参与人数
|
||||
$sign_num = self::where('classes_activity_item_id',$classes_activity_item_id)->where("status","not in",["-3","6"])->count();
|
||||
$sign_num = self::where('classes_activity_item_id',$classes_activity_item_id)->where("status","not in",["-3","5","6"])->count();
|
||||
|
||||
if($sign_num >= $classes_lib_spec_info['limit_num']){
|
||||
throw new \Exception("该活动已满,请选择其他活动!");
|
||||
|
@ -813,7 +813,7 @@ class Order extends BaseModel
|
|||
$as = (new self)->getWithAlisaName();
|
||||
//判断时间是否有交叠(只查所有的免费的预约记录)
|
||||
$order_info = self::with("detail")->where("detail.price",0)
|
||||
->where("{$as}.status","not in",["-3","6","9"])
|
||||
->where("{$as}.status","not in",["-3","5","6","9"])
|
||||
->where(function ($query) use ($as,$start_time,$end_time) {
|
||||
//兩個時間區間重合 存在任意交集 都不行
|
||||
$query->where("detail.start_time BETWEEN {$start_time} AND {$end_time}");
|
||||
|
@ -837,7 +837,7 @@ class Order extends BaseModel
|
|||
$as = (new self)->getWithAlisaName();
|
||||
//判断时间是否有交叠(只查所有的免费的预约记录)
|
||||
$order_info = self::with("detail")
|
||||
->where("{$as}.status","not in",["-3","6","9"])
|
||||
->where("{$as}.status","not in",["-3","5","6","9"])
|
||||
->where(function ($query) use ($as,$start_time,$end_time) {
|
||||
//兩個時間區間重合 存在任意交集 都不行
|
||||
$query->where("detail.start_time BETWEEN {$start_time} AND {$end_time}");
|
||||
|
|
|
@ -537,7 +537,7 @@ class Order extends BaseModel
|
|||
|
||||
if($detail['sub_num']<=0) throw new \Exception("该课程已无剩余课时!");
|
||||
//不是可用状态
|
||||
if($classesOrder['status']!="3") throw new \Exception("该课程单当前状态不可操作!");
|
||||
if($check && $classesOrder['status']!="3") throw new \Exception("该课程单当前状态不可操作!");
|
||||
//售后中
|
||||
if($classesOrder['server_status']=="3") throw new \Exception("该课程单正在售后中,请勿操作!");
|
||||
|
||||
|
|
|
@ -750,7 +750,7 @@ class Order extends BaseModel
|
|||
$param = [
|
||||
"type" =>'2',
|
||||
"help_user_id" =>$order["user_id"] ,
|
||||
"help_type" => 'admin',
|
||||
"help_type" => 'user',
|
||||
];
|
||||
|
||||
//确认订单
|
||||
|
|
|
@ -0,0 +1,325 @@
|
|||
<?php
|
||||
namespace app\manystore\controller\csmtable;
|
||||
|
||||
use think\App;
|
||||
use app\common\controller\Backend;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use addons\csmtable\library\xcore\xcore\utils\XcRequestUtils;
|
||||
use addons\csmtable\library\xapp\csmtable\utils\CsmTableUtils;
|
||||
|
||||
class Cligenerateexcel extends Backend
|
||||
{
|
||||
private $xlstask = null;
|
||||
|
||||
private $uploadtmppath = RUNTIME_PATH . 'temp' . DS;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->xlstask = new \app\admin\model\csmtable\Xlstask();
|
||||
}
|
||||
|
||||
/**
|
||||
* http://127.0.0.1/fastadmin_plugin_csmmeet/public/q3HJDu2RgE.php/csmtable/cligenerateexcel/index
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
static::p('----generateExcelByClassname begin:');
|
||||
set_time_limit(0);
|
||||
$csmtable_xlstask_id = $this->request->request("csmtable_xlstask_id");
|
||||
|
||||
$pp = $this->request->request("params");
|
||||
static::p($pp);
|
||||
static::p($csmtable_xlstask_id);
|
||||
$csmtable_xlstask_id = 119;
|
||||
$pp = '{"search":null,"filter":"{}","op":"{}","sort":"weigh","order":"desc","offset":"0","limit":"10","csmtable_classname":"app\/admin\/controller\/fa\/Test","csmtable_methodname":"index","csmtable_columns":"[{\"field\":\"id\",\"title\":\"ID\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"title\",\"title\":\"\u6807\u9898\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"admin_id\",\"title\":\"\u7ba1\u7406\u5458ID\",\"datasource\":\"auth\/admin\",\"datafield\":\"nickname\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"category_id\",\"title\":\"\u5206\u7c7bID(\u5355\u9009)\",\"datasource\":\"category\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"category_ids\",\"title\":\"\u5206\u7c7bID(\u591a\u9009)\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"week\",\"title\":\"\u661f\u671f(\u5355\u9009)\",\"formatter\":\"\",\"searchList\":{\"monday\":\"\u661f\u671f\u4e00\",\"tuesday\":\"\u661f\u671f\u4e8c\",\"wednesday\":\"\u661f\u671f\u4e09\"},\"operate\":\"=\"},{\"field\":\"flag\",\"title\":\"\u6807\u5fd7(\u591a\u9009)\",\"formatter\":\"\",\"searchList\":{\"hot\":\"\u70ed\u95e8\",\"index\":\"\u9996\u9875\",\"recommend\":\"\u63a8\u8350\"},\"operate\":\"FIND_IN_SET\"},{\"field\":\"genderdata\",\"title\":\"\u6027\u522b(\u5355\u9009)\",\"formatter\":\"\",\"searchList\":{\"male\":\"\u7537\",\"female\":\"\u5973\"},\"operate\":\"=\"},{\"field\":\"hobbydata\",\"title\":\"\u7231\u597d(\u591a\u9009)\",\"formatter\":\"\",\"searchList\":{\"music\":\"\u97f3\u4e50\",\"reading\":\"\u8bfb\u4e66\",\"swimming\":\"\u6e38\u6cf3\"},\"operate\":\"FIND_IN_SET\"},{\"field\":\"image\",\"title\":\"\u56fe\u7247\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"images\",\"title\":\"\u56fe\u7247\u7ec4\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"attachfile\",\"title\":\"\u9644\u4ef6\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"keywords\",\"title\":\"\u5173\u952e\u5b57\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"description\",\"title\":\"\u63cf\u8ff0\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"city\",\"title\":\"\u7701\u5e02\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"price\",\"title\":\"\u4ef7\u683c\",\"formatter\":\"\",\"operate\":\"BETWEEN\"},{\"field\":\"views\",\"title\":\"\u70b9\u51fb\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"startdate\",\"title\":\"\u5f00\u59cb\u65e5\u671f\",\"formatter\":\"\",\"operate\":\"RANGE\"},{\"field\":\"activitytime\",\"title\":\"\u6d3b\u52a8\u65f6\u95f4(datetime)\",\"formatter\":\"\",\"operate\":\"RANGE\"},{\"field\":\"year\",\"title\":\"\u5e74\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"times\",\"title\":\"\u65f6\u95f4\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"refreshtime\",\"title\":\"\u5237\u65b0\u65f6\u95f4(int)\",\"formatter\":\"Table.api.formatter.datetime\",\"operate\":\"RANGE\"},{\"field\":\"createtime\",\"title\":\"\u521b\u5efa\u65f6\u95f4\",\"formatter\":\"Table.api.formatter.datetime\",\"operate\":\"RANGE\"},{\"field\":\"updatetime\",\"title\":\"\u66f4\u65b0\u65f6\u95f4\",\"formatter\":\"Table.api.formatter.datetime\",\"operate\":\"RANGE\"},{\"field\":\"weigh\",\"title\":\"\u6743\u91cd\",\"formatter\":\"\",\"operate\":\"=\"},{\"field\":\"switch\",\"title\":\"\u5f00\u5173\",\"formatter\":\"\",\"searchList\":{\"0\":\"\u5426\",\"1\":\"\u662f\"},\"operate\":\"=\"},{\"field\":\"status\",\"title\":\"\u72b6\u6001\",\"formatter\":\"\",\"searchList\":{\"normal\":\"\u6b63\u5e38\",\"hidden\":\"\u9690\u85cf\"},\"operate\":\"=\"},{\"field\":\"state\",\"title\":\"\u72b6\u6001\u503c\",\"formatter\":\"\",\"searchList\":{\"0\":\"\u7981\u7528\",\"1\":\"\u6b63\u5e38\",\"2\":\"\u63a8\u8350\"},\"operate\":\"=\"}]","csmtable_xlspagesize":null}';
|
||||
$this->setProgress($csmtable_xlstask_id, 10);
|
||||
|
||||
$params = json_decode($pp, true);
|
||||
|
||||
$classname = str_replace('/', '\\', $this->getParamValue($params, 'csmtable_classname'));
|
||||
$methodname = $this->getParamValue($params, 'csmtable_methodname');
|
||||
|
||||
$columnstr = $this->getParamValue($params, 'csmtable_columns');
|
||||
$columns = json_decode($columnstr, true);
|
||||
|
||||
$excelPagesize = $this->getParamValue($params, 'csmtable_xlspagesize', 1000);
|
||||
$this->generateExcelByClassname($csmtable_xlstask_id, $classname, $methodname, $params, $columns, $excelPagesize);
|
||||
|
||||
static::p('----generateExcelByClassname end:');
|
||||
return;
|
||||
}
|
||||
|
||||
private function setProgress(&$csmtable_xlstask_id, $progress, $filename = '')
|
||||
{
|
||||
// $dao = new \app\admin\model\csmtable\Xlstask();
|
||||
// $this->xlstask->startTrans();
|
||||
$this->xlstask->where("id", "=", $csmtable_xlstask_id)->update([
|
||||
'progress' => $progress,
|
||||
'filename' => $filename,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
static::p('progress:' . $progress);
|
||||
// $dao->commit();
|
||||
}
|
||||
|
||||
private function getParamValue(&$params, $key, $defaultvalue = null)
|
||||
{
|
||||
$sr = null;
|
||||
if (isset($params[$key])) {
|
||||
$sr = $params[$key];
|
||||
}
|
||||
$sr = ($sr == null) ? $defaultvalue : $sr;
|
||||
return $sr;
|
||||
}
|
||||
|
||||
private function generateExcelByClassname(&$csmtable_xlstask_id, &$classname, &$methodname, &$params, &$columns, &$excelPagesize)
|
||||
{
|
||||
$pageno = 0; // 当前页数
|
||||
$pagesize = 1000;
|
||||
|
||||
$excelRowIndex = 0; // 当前excel中的记录行数
|
||||
$excelRows = []; // Excel记录
|
||||
$excelFileNo = 1; // 第N个Excel
|
||||
$excelFiles = [];
|
||||
|
||||
static::p("config excelPagesize:{$excelPagesize}");
|
||||
$request = XcRequestUtils::getRequest();
|
||||
$instance = new $classname($request);
|
||||
while (true) {
|
||||
$request->set('search', $this->getParamValue($params, 'search'));
|
||||
$request->set('filter', $this->getParamValue($params, 'filter'));
|
||||
$request->set('op', $this->getParamValue($params, 'op'));
|
||||
$request->set('sort', $this->getParamValue($params, 'sort'));
|
||||
$request->set('order', $this->getParamValue($params, 'order'));
|
||||
// $request->set('offset',$this->getParamValue($params,'offset'));
|
||||
$request->set('limit', $pagesize);
|
||||
$request->setMethodReturn("isAjax", true);
|
||||
$request->set("offset", $pageno * $pagesize);
|
||||
$sr = App::invokeMethod([
|
||||
$instance,
|
||||
$methodname
|
||||
], null);
|
||||
$request->clear();
|
||||
if ($sr == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
$datarows = &$sr->getData()['rows'];
|
||||
$total = $sr->getData()['total'];
|
||||
|
||||
static::p("--remote total:{$total}/pageno:{$pageno}/offset:" . $pageno * $pagesize);
|
||||
foreach ($datarows as &$row) {
|
||||
if ($excelRowIndex >= $excelPagesize) {
|
||||
$progress = (int) ($pageno * $pagesize / $total * 70) + 10;
|
||||
$this->setProgress($csmtable_xlstask_id, $progress);
|
||||
|
||||
static::p("------generate excel fileno:{$excelFileNo}/progress:{$progress}");
|
||||
$excelFiles[] = static::saveExcel($columns, $excelRows, $excelFileNo);
|
||||
$excelRowIndex = 0;
|
||||
unset($excelRows);
|
||||
$excelRows = [];
|
||||
$excelFileNo ++;
|
||||
}
|
||||
$excelRows[] = $row;
|
||||
$excelRowIndex ++;
|
||||
}
|
||||
unset($datarows);
|
||||
unset($sr);
|
||||
$sr = null;
|
||||
|
||||
if ($total <= $pageno * $pagesize) {
|
||||
break;
|
||||
}
|
||||
$pageno ++;
|
||||
// break;
|
||||
}
|
||||
|
||||
// 有剩余的Excel row,就保存剩余的
|
||||
if ($excelRowIndex > 0) {
|
||||
static::p("--generate excel fileno:{$excelFileNo}");
|
||||
$excelFiles[] = static::saveExcel($columns, $excelRows, $excelFileNo);
|
||||
}
|
||||
// Excel保存到Zip
|
||||
$this->setProgress($csmtable_xlstask_id, 90);
|
||||
$zipfilename = static::saveExcelToZip($excelFiles);
|
||||
echo $zipfilename . '<BR>';
|
||||
$this->setProgress($csmtable_xlstask_id, 100, $zipfilename);
|
||||
}
|
||||
|
||||
private function saveExcel(&$columns, &$rows, &$excelNo)
|
||||
{
|
||||
echo $excelNo . '<BR>';
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$filename = 'excel-' . $excelNo;
|
||||
|
||||
foreach ($columns as $k => $item) {
|
||||
$sheet->setCellValueByColumnAndRow($k + 1, 1, $item['title']);
|
||||
}
|
||||
|
||||
$dsDatas = $this->getDataSourceDatas($columns, $rows);
|
||||
|
||||
foreach ($rows as $k => $item) {
|
||||
foreach ($columns as $k2 => $column) {
|
||||
$vv = $item[$column['field']];
|
||||
$vv = $this->_convertValueByColumn($column, $vv, $dsDatas);
|
||||
$sheet->setCellValueByColumnAndRow($k2 + 1, $k + 2, $vv);
|
||||
}
|
||||
}
|
||||
unset($rows);
|
||||
unset($dsDatas);
|
||||
$filename = 'csmtable_' . time() . '_' . $excelNo . '.xlsx';
|
||||
$filepath = &$this->uploadtmppath;
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($filepath . $filename);
|
||||
unset($writer);
|
||||
$writer = null;
|
||||
return [
|
||||
'filename' => $filename,
|
||||
'filepath' => $filepath
|
||||
];
|
||||
}
|
||||
|
||||
private function getDataSourceDatas(&$columns, &$rows)
|
||||
{
|
||||
$sr = [];
|
||||
foreach ($columns as &$column) {
|
||||
if (isset($column['datasource']) && $column['datasource'] != null) {
|
||||
$datafield = null;
|
||||
if (isset($column['datafield']) && $column['datafield'] != null) {
|
||||
$datafield = $column['datafield'];
|
||||
} else {
|
||||
$datafield = 'name';
|
||||
}
|
||||
$ids = [];
|
||||
foreach ($rows as $item) {
|
||||
$ids[] = $item[$column['field']];
|
||||
}
|
||||
|
||||
//v2.2.5 修复admin账号的安全楼栋
|
||||
$datasdatasource_callremoteource = $column['datasource'];
|
||||
if($datasdatasource_callremoteource=="auth/admin"){
|
||||
$datasdatasource_callremoteource = "csmtable/datasource/admin";
|
||||
}
|
||||
$im = CsmTableUtils::getInstanceAndMethod($datasdatasource_callremoteource);
|
||||
|
||||
if ($im != null) {
|
||||
$classname = $im[0];
|
||||
$methodname = $im[1];
|
||||
|
||||
$request = XcRequestUtils::getRequest();
|
||||
$request->setMethodReturn("isAjax", true);
|
||||
$request->set('filter', '{"id":"' . implode(',', $ids) . '"}');
|
||||
$request->set('op', '{"id":"in"}');
|
||||
$request->set('sort', 'id');
|
||||
$request->set('order', 'desc');
|
||||
|
||||
// \app\admin\controller\auth\Admin;
|
||||
$instance2 = new $classname($request);
|
||||
$json2 = App::invokeMethod([
|
||||
$instance2,
|
||||
$methodname
|
||||
], null);
|
||||
$request->clear();
|
||||
|
||||
if ($json2 == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
$datarows = &$json2->getData()['rows'];
|
||||
|
||||
$vvs = [];
|
||||
foreach ($datarows as &$row) {
|
||||
$vv = null;
|
||||
if (isset($row[$datafield])) {
|
||||
$vv = $row[$datafield];
|
||||
} else {
|
||||
$vv = $row->$datafield;
|
||||
}
|
||||
|
||||
$vvs['ID#' . $row['id']] = $vv;
|
||||
}
|
||||
unset($json2);
|
||||
unset($instance2);
|
||||
$instance2 = null;
|
||||
}
|
||||
$sr[$column['field']] = $vvs;
|
||||
}
|
||||
}
|
||||
return $sr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将value根据table的options转换成文字
|
||||
*/
|
||||
private function _convertValueByColumn(&$column, &$value, &$dsDatas)
|
||||
{
|
||||
$sr = '';
|
||||
|
||||
if (isset($column['searchList']) && $column['searchList'] != null) {
|
||||
// searchlist类型的,将code转为name
|
||||
$searchList = $column['searchList'];
|
||||
// operate类型,字典数组,用逗号分隔
|
||||
if (isset($column['operate']) && $column['operate'] != null && $column['operate'] == 'FIND_IN_SET') {
|
||||
$ssarr = explode(",", $value);
|
||||
$sslabel = [];
|
||||
foreach ($ssarr as $ssarrv) {
|
||||
if (isset($searchList[$ssarrv])) {
|
||||
$sslabel[] = $searchList[$ssarrv];
|
||||
} else {
|
||||
$sslabel[] = $ssarrv;
|
||||
}
|
||||
}
|
||||
$sr = implode(',', $sslabel);
|
||||
} else {
|
||||
// 普通字典
|
||||
if (isset($searchList[$value])) {
|
||||
$sr = $searchList[$value];
|
||||
}
|
||||
}
|
||||
} else if (isset($column['formatter']) && $column['formatter'] != null && $column['formatter'] == "Table.api.formatter.datetime") {
|
||||
// 时间型
|
||||
if ($value != null && $value != '') {
|
||||
$sr = date('Y-m-s h:i:s', $value);
|
||||
}
|
||||
} else if (isset($column['datasource']) && $column['datasource'] != null && $column['datasource'] != "") {
|
||||
// 时间型
|
||||
if (isset($dsDatas[$column['field']]) && $dsDatas[$column['field']] != null) {
|
||||
$dsDataitem = $dsDatas[$column['field']];
|
||||
if (isset($dsDataitem['ID#' . $value]) && $dsDataitem['ID#' . $value] != null) {
|
||||
$sr = $dsDataitem['ID#' . $value];
|
||||
}
|
||||
}
|
||||
if ($sr == null || $sr == '') {
|
||||
$sr = $value;
|
||||
}
|
||||
} else {
|
||||
$sr = $value;
|
||||
}
|
||||
return $sr;
|
||||
}
|
||||
|
||||
private function saveExcelToZip($excelFiles)
|
||||
{
|
||||
$zipfn = 'csmtable_' . time() . '.zip';
|
||||
$zipfilename = $this->uploadtmppath . $zipfn;
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($zipfilename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
foreach ($excelFiles as $item) {
|
||||
$zip->addFile($item['filepath'] . $item['filename'], $item['filename']);
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
foreach ($excelFiles as $item) {
|
||||
unlink($item['filepath'] . $item['filename']);
|
||||
}
|
||||
return $zipfn;
|
||||
}
|
||||
|
||||
private static function p($str){
|
||||
//echo( $str."<BR>\r\n" ) ;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
namespace app\admin\controller\csmtable;
|
||||
|
||||
use addons\csmtable\library\xcore\xcore\base\XcABackend;
|
||||
use addons\csmtable\library\xapp\csmtable\utils\CsmTableUtils;
|
||||
|
||||
|
||||
class Csmgenerate extends XcABackend
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
public function generate()
|
||||
{
|
||||
set_time_limit(0);
|
||||
$request = $this->request;
|
||||
$filesource = $request->request('csmtable_filesource');
|
||||
$indexurl = $request->request('csmtable_indexurl');
|
||||
|
||||
$dao = new \app\admin\model\csmtable\Xlstask();
|
||||
// 限制下载
|
||||
if (true) {
|
||||
$userinfo = $this->auth->getUserInfo();
|
||||
|
||||
$adminId = $userinfo["id"];
|
||||
$row = $dao->where("admin_id", "=", $adminId)
|
||||
->where("progress", "<", "100")
|
||||
->where("createtime", ">", time() - 1800)
|
||||
->where("iserror", "<>", "Y")
|
||||
->find();
|
||||
if ($row) {
|
||||
$this->error("当前有下载任务,请任务结束后再尝试下载。");
|
||||
}
|
||||
}
|
||||
|
||||
// 生成任务记录
|
||||
$dao->where("admin_id", "=", $adminId)
|
||||
->where("filesource", '=', $filesource)
|
||||
->where("status", "=", "normal")
|
||||
->update([
|
||||
"status" => "hidden"
|
||||
]);
|
||||
|
||||
// 触发异步生成Excel任务
|
||||
$route2 = CsmTableUtils::getInstanceAndMethod($indexurl);
|
||||
$classname = $route2[0];
|
||||
|
||||
$getparams = [
|
||||
'search' => $request->request('search'),
|
||||
'filter' => $request->request('filter'),
|
||||
'op' => $request->request('op'),
|
||||
'sort' => $request->request('sort'),
|
||||
'order' => $request->request('order'),
|
||||
'offset' => $request->request('offset'),
|
||||
'limit' => $request->request('limit'),
|
||||
'csmtable_classname' => str_replace('\\', '/', $classname),
|
||||
'csmtable_methodname' => $route2[1],
|
||||
'csmtable_columns' => $request->request('csmtable_columns')
|
||||
];
|
||||
|
||||
|
||||
$param = [
|
||||
'admin_id' => $adminId,
|
||||
'filesource' => $filesource,
|
||||
'param' => json_encode($getparams),
|
||||
'createtime' => time(),
|
||||
|
||||
];
|
||||
$dao->create($param);
|
||||
$this->success();
|
||||
|
||||
// $id = $dao->getLastInsID();
|
||||
|
||||
// $ret = $this->_index($id);
|
||||
// if($ret===true){
|
||||
// $this->success();
|
||||
// }else{
|
||||
// $this->error($ret);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace app\manystore\controller\csmtable;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\admin\library\Auth;
|
||||
|
||||
/**
|
||||
* Excel下载任务管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Csmxlstable extends Backend
|
||||
{
|
||||
protected $noNeedRight = ["*"];
|
||||
|
||||
private $uploadtmppath = RUNTIME_PATH . 'temp' . DS;
|
||||
|
||||
/**
|
||||
* Xlstask模型对象
|
||||
*
|
||||
* @var \app\admin\model\csmtable\Xlstask
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\csmtable\Xlstask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 前台轮询查询下载进度
|
||||
* http://127.0.0.1/fastadmin_plugin_csmmeet/public/q3HJDu2RgE.php/csmtable/csmxlstable/queryGenerageStatus
|
||||
*/
|
||||
public function queryGenerageStatus()
|
||||
{
|
||||
$filesource = $this->request->request("filesource");
|
||||
$auth = Auth::instance();
|
||||
|
||||
$row = $this->model->where("admin_id", "=", $auth->id)
|
||||
->where("filesource", '=', $filesource)
|
||||
->where("status", "=", "normal")
|
||||
->field("id,createtime,progress,iserror,errormsg")
|
||||
->order("id", "desc")
|
||||
->find();
|
||||
// echo $this->model->getLastSql();
|
||||
if ($row != null) {
|
||||
// $row->filesource = str_replace(Config::get('upload.cdnurl'), '', $row->filesource);
|
||||
$row->createtime = date('Y-m-d H:i:s', $row->createtime);
|
||||
}
|
||||
|
||||
$this->success('', null, [
|
||||
'row' => $row
|
||||
]);
|
||||
}
|
||||
|
||||
public function download()
|
||||
{
|
||||
$auth = Auth::instance();
|
||||
$id = $this->request->request("id");
|
||||
$row = $this->model->where("admin_id", "=", $auth->id)
|
||||
->where("id", "=", $id)
|
||||
->find();
|
||||
|
||||
if ($row == null) {
|
||||
$this->error("文件不存在,请重新下载!");
|
||||
}
|
||||
$filename = $row->filename;
|
||||
//var_dump($filename);
|
||||
// $filename='csmtable_1588643591.zip';//完整文件名(路径加名字)
|
||||
if (! file_exists($this->uploadtmppath . $filename)) {
|
||||
header('HTTP/1.1 404 NOT FOUND');
|
||||
} else {
|
||||
$file = fopen($this->uploadtmppath . $filename, "rb");
|
||||
Header("Content-type: application/octet-stream");
|
||||
Header("Accept-Ranges: bytes");
|
||||
Header("Accept-Length: " . filesize($this->uploadtmppath . $filename));
|
||||
Header("Content-Disposition: attachment; filename=" . $filename);
|
||||
echo fread($file, filesize($this->uploadtmppath . $filename));
|
||||
fclose($file);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace app\manystore\controller\csmtable;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 管理员管理
|
||||
*
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class Datasource extends Backend
|
||||
{
|
||||
|
||||
// protected $noNeedLogin = ["*"];
|
||||
// protected $noNeedRight = ["*"];
|
||||
/**
|
||||
* 代替 /auth/admin
|
||||
*
|
||||
* 地址: /csmtable/datasource/admin
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
$filter = $this->request->get("filter", '');
|
||||
$filter = (array)json_decode($filter, true);
|
||||
|
||||
$dao = new \app\admin\model\Admin();
|
||||
$list = $dao->where("id","in",$filter['id'])->field("id,nickname")->select();
|
||||
|
||||
return json(['rows' => $list]);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
namespace app\manystore\controller\csmtable;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use fast\Random;
|
||||
|
||||
/**
|
||||
* 测试管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Test extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Test模型对象
|
||||
*
|
||||
* @var \app\admin\model\fa\Test
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\csmtable\Test();
|
||||
$this->view->assign("weekList", $this->model->getWeekList());
|
||||
$this->view->assign("flagList", $this->model->getFlagList());
|
||||
$this->view->assign("genderdataList", $this->model->getGenderdataList());
|
||||
$this->view->assign("hobbydataList", $this->model->getHobbydataList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("stateList", $this->model->getStateList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
// https://csmtable.163fan.com/amZUNRxJGT.php//csmtable/test/generatedatas
|
||||
protected function generatedatas()
|
||||
{
|
||||
$generatecount = 10;
|
||||
$subsieze = 1001;
|
||||
$count = $this->model->count();
|
||||
|
||||
for ($i = 0; $i < $generatecount; $i ++) {
|
||||
$rows = [];
|
||||
|
||||
for ($ii = 0; $ii < $subsieze; $ii ++) {
|
||||
$co = $i * $subsieze + $ii + $count;
|
||||
$param = [
|
||||
'admin_id' => 1,
|
||||
'category_id' => 1,
|
||||
'category_ids' => '1,2',
|
||||
'week' => 'monday',
|
||||
'flag' => 'index',
|
||||
'hobbydata' => 'music,swimming',
|
||||
'city' => 'xxx',
|
||||
'views' => Random::numeric(2),
|
||||
'price' => 0,
|
||||
'year' => 2020,
|
||||
'status' => 'normal',
|
||||
'state' => '1'
|
||||
];
|
||||
$param['title'] = "我是{$co}篇测试文章" . time();
|
||||
$param['createtime'] = time();
|
||||
$param['content'] = Random::alpha(100);
|
||||
$rows[] = $param;
|
||||
}
|
||||
|
||||
$this->model->saveAll($rows);
|
||||
}
|
||||
$this->success("生成完成记录" . $generatecount * $subsieze, null, null, '10000');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 设置过滤方法
|
||||
$this->request->filter([
|
||||
'strip_tags'
|
||||
]);
|
||||
if ($this->request->isAjax()) {
|
||||
trace('----test------');
|
||||
// 如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list ($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
//在2.2.3版本中调整为fastadmin.1.3.3的写法
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$result = array("total" => $list->total(), "rows" => $list->items(),"totalviews" => 1530);
|
||||
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace app\manystore\controller\csmtable;
|
||||
|
||||
use addons\csmtable\library\xcore\xcore\utils\XcDaoUtils;
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* Excel下载任务管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Xlstask extends Backend
|
||||
{
|
||||
// protected $noNeedRight = [];
|
||||
/**
|
||||
* Xlstask模型对象
|
||||
*
|
||||
* @var \app\admin\model\csmtable\Xlstask
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\csmtable\Xlstask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
XcDaoUtils::bindDbListColumn($list, "admin_id", new \app\admin\model\Admin(), "admin", ["nickname"]);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ class ClassesLib extends ManystoreBase
|
|||
protected $model = null;
|
||||
|
||||
//不用审核允许修改的字段
|
||||
protected $no_auth_fields = ["classes_type","classes_cate_ids","classes_label_ids","self_label_tag",'headimage','images','notice','content',"virtual_num","virtual_collect","underline_price","selfhot","price","classes_num"];
|
||||
protected $no_auth_fields = ["title","classes_type","classes_cate_ids","classes_label_ids","self_label_tag",'headimage','images','notice','content',"virtual_num","virtual_collect","underline_price","selfhot","price","classes_num"];
|
||||
|
||||
//更新数据是否需要触发审核开关
|
||||
protected $need_auth = true;
|
||||
|
|
|
@ -76,6 +76,13 @@ class UrlLock
|
|||
return $this;
|
||||
}
|
||||
|
||||
/** 析构时释放锁
|
||||
* @throws UrlLockException
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->is_lock)$this->free();
|
||||
}
|
||||
public function hasLock(){
|
||||
return $this->is_lock;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ class Auth
|
|||
if ('and' == $relation && empty($diff)) {
|
||||
return true;
|
||||
}
|
||||
// var_dump($name,$uid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -79,20 +79,30 @@ trait CacheTrait
|
|||
// $redis->del($hashKey);
|
||||
// var_dump($hashKey);die;
|
||||
//判断锁是否存在,如果存在,返回错误
|
||||
if ($redis->exists($hashKey)){
|
||||
// var_dump(111111222);die;
|
||||
// if ($redis->exists($hashKey)){
|
||||
//// var_dump(111111222);die;
|
||||
// if($this->cache_lock_thorws_excption){
|
||||
// throw new \Exception($this->cache_lock_error_msg);
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//如果不存在创建锁并返回
|
||||
// $redis->set($hashKey, 1,$timeout);//注释掉
|
||||
//替换成原子操作的命令
|
||||
$nxLock = $redis->set($hashKey, 1,['nx', 'ex' => $timeout]);
|
||||
if ($nxLock == 1) {
|
||||
return true;
|
||||
} else {
|
||||
if($this->cache_lock_thorws_excption){
|
||||
throw new \Exception($this->cache_lock_error_msg);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//如果不存在创建锁并返回
|
||||
// $redis->set($hashKey, 1,$timeout);//注释掉
|
||||
//替换成原子操作的命令
|
||||
$redis->set($hashKey, 1,['nx', 'ex' => $timeout]);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,9 +122,25 @@ trait CacheTrait
|
|||
$redis = $this->getRedis();
|
||||
if(!$key || !$suffix) return true;
|
||||
$hashKey = $key.$suffix;
|
||||
if (!$redis->EXISTS($hashKey)) return true;
|
||||
$redis->del($hashKey);
|
||||
return true;
|
||||
|
||||
//执行lua脚本,确保删除锁是原子操作
|
||||
$lua = 'if redis.call("get",KEYS[1]) == ARGV[1]
|
||||
then
|
||||
return redis.call("del",KEYS[1])
|
||||
else
|
||||
return 0
|
||||
end';
|
||||
$result = $redis->eval($lua, [$hashKey, 1], 1);
|
||||
|
||||
if ('1' == $result) {
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
// if (!$redis->EXISTS($hashKey)) return true;
|
||||
// $redis->del($hashKey);
|
||||
// return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -123,5 +149,4 @@ trait CacheTrait
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
@ -31,6 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
sortName: 'weigh',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 2,
|
||||
asyndownload: true,
|
||||
columns: [
|
||||
[
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
@ -25,6 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
asyndownload: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
|
|
|
@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde
|
|||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
// asyndownload: true,
|
||||
asyndownload: true,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
@ -23,6 +23,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
sortName: 'user.id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
asyndownload: true,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
sortName: 'weigh',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 2,
|
||||
|
||||
asyndownload: true,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
|
|
Loading…
Reference in New Issue