diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php
index 850fa78..d37f8fc 100644
--- a/application/admin/controller/manystore/Index.php
+++ b/application/admin/controller/manystore/Index.php
@@ -106,7 +106,7 @@ class Index extends Backend
$result = $auth->freelogin($ids, 0);
if ($result === true) {
Hook::listen("admin_login_after", $this->request);
- $this->success(__('Login successful'), null, [ 'id' => $auth->id, 'avatar' => $auth->avatar]);
+ $this->success(__('Login successful'), null, [ 'id' => $auth->id, 'avatar' => $auth->avatar,'token' => $this->request->token()]);
} else {
$msg = $auth->getError();
$msg = $msg ? $msg : __('Username or password is incorrect');
@@ -139,33 +139,33 @@ class Index extends Backend
$param = $this->request->param();
if($this->request->isPost()){
- $this->error("API版本后台正在开发中,敬请期待!");
-// try{
+// $this->error("API版本后台正在开发中,敬请期待!");
+ try{
if(isset($param['ids']))$ids = $param['ids'];
-// //机构登录
-// //如果存在登录,先退出登录
-// $auth = \app\manystore\library\Auth::instance();
-// if($auth->isLogin()){
-// $auth->logout();
-// Hook::listen("manystore_logout_after", $this->request);
-// }
-// //执行登录
-// ManystoreLog::setTitle(__('Login'));
-// $result = $auth->freelogin($ids, 0);
-// if ($result === true) {
-// Hook::listen("admin_login_after", $this->request);
-// $this->success(__('Login successful'), null, [ 'id' => $auth->id, 'avatar' => $auth->avatar]);
-// } else {
-// $msg = $auth->getError();
-// $msg = $msg ? $msg : __('Username or password is incorrect');
-// $this->error($msg, null, ['token' => $this->request->token()]);
-// }
-//
+ //机构登录
+ //如果存在登录,先退出登录
+ $auth = \app\manystoreapi\library\Auth::instance();
+ if($auth->isLogin()){
+ $auth->logout();
+ Hook::listen("manystore_logout_after", $this->request);
+ }
+ //执行登录
+ ManystoreLog::setTitle(__('Login'));
+ $result = $auth->direct($ids);
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+
+ if ($result === true) {
+ Hook::listen("manystore_login_after", $this->request);
+ $this->success(__('Login successful'), null, [ 'id' => $auth->id, 'avatar' => $auth->avatar,'token' => $this->request->token()]);
+ } else {
+ $msg = $auth->getError();
+ $msg = $msg ? $msg : __('Username or password is incorrect');
+ $this->error($msg, null, ['token' => $this->request->token()]);
+ }
-// }catch (\Exception $e){
-// $this->error($e->getMessage());
-// }
}
$row = $this->model->get($ids);
diff --git a/application/common/controller/ManystoreApiBase.php b/application/common/controller/ManystoreApiBase.php
index f322177..4bde684 100644
--- a/application/common/controller/ManystoreApiBase.php
+++ b/application/common/controller/ManystoreApiBase.php
@@ -266,7 +266,7 @@ class ManystoreApiBase extends Controller
$controllername = Loader::parseName($this->request->controller());
$actionname = strtolower($this->request->action());
- $path = str_replace('.', '/', $controllername) . '/' . $actionname;
+ $path = $modulename. '/' . str_replace('.', '/', $controllername) . '/' . $actionname;
// 定义是否Addtabs请求
!defined('IS_ADDTABS') && define('IS_ADDTABS', input("addtabs") ? true : false);
@@ -282,6 +282,10 @@ class ManystoreApiBase extends Controller
if(!$token)$token = $this->request->server('HTTP_SHOP_TOKEN',"");
// 设置当前请求的URI
$this->auth->setRequestUri($path);
+
+
+
+
// 检测是否需要验证登录
if (!$this->auth->match($this->noNeedLogin)) {
//初始化
@@ -307,6 +311,7 @@ class ManystoreApiBase extends Controller
if (!$this->auth->match($this->noNeedRight)) {
// 判断控制器和方法判断是否有对应权限
if (!$this->auth->check($path)) {
+// var_dump($path);
Hook::listen('manystore_nopermission', $this);
$this->apierror(__('You have no permission'), null, 403);
}
@@ -319,6 +324,14 @@ class ManystoreApiBase extends Controller
}
}
+ // 设置面包屑导航数据
+ $this->auth->getRuleList();
+ $breadcrumb = $this->auth->getBreadCrumb($path);
+
+ array_pop($breadcrumb);
+ $this->view->breadcrumb = $breadcrumb;
+
+
if(!defined('SHOP_ID')){
define('SHOP_ID', $this->auth->shop_id);
}
@@ -331,7 +344,7 @@ class ManystoreApiBase extends Controller
// }
$manystore = Manystore::where("id",$this->auth->id)->find();
if($manystore) {
- if($manystore["status"]!="normal") $this->error(__('账号正处于审核中,无法进行任何操作!!'), null, 403);
+ if($manystore["status"]!="normal") $this->apierror(__('账号正处于审核中,无法进行任何操作!!'), null, 403);
}
}
@@ -365,10 +378,7 @@ class ManystoreApiBase extends Controller
// exit;
// }
-// // 设置面包屑导航数据
-// $breadcrumb = $this->auth->getBreadCrumb($path);
-// array_pop($breadcrumb);
-// $this->view->breadcrumb = $breadcrumb;
+//
// 如果有使用模板布局
if ($this->layout) {
diff --git a/application/common/library/NightSchoolBigData.php b/application/common/library/NightSchoolBigData.php
index ab9ba31..21a4385 100644
--- a/application/common/library/NightSchoolBigData.php
+++ b/application/common/library/NightSchoolBigData.php
@@ -24,6 +24,9 @@ class NightSchoolBigData extends BaseModel
public static function getAreaBaseData($province,$city,$district){
+ $have_time = false;
+ if($district)$have_time = true;
+
$whereArea = function ($query)use($province,$city,$district){
$query = $query->where('1=1');
if( $province)$query = $query->where('province',$province);
@@ -34,8 +37,15 @@ class NightSchoolBigData extends BaseModel
$classes_num = ClassesLib::where($whereArea)->count();
$activity_num = Activity::where($whereArea)->count();
- //统计当前总报名人数
- $classes_sign_num = ClassesLib::where($whereArea)->sum('sign_num');
+ if($have_time){
+ //统计当前总报名人数
+ $classes_sign_num = ClassesLib::where($whereArea)->sum('sign_num');
+ }else{
+ //统计当前总报名人数
+ $classes_sign_num = (config("site.sign_up_toal_number")?:0) + ClassesLib::where($whereArea)->sum('sign_num');
+
+ }
+
$activity_sign_num = Activity::where($whereArea)->sum('sign_num');
@@ -58,7 +68,7 @@ class NightSchoolBigData extends BaseModel
$activity_views = Activity::where($whereArea)->sum('views');
//注册总人数
- $user_num = User::count();
+ $user_num = (config("site.register_total_numebr")?:0) + User::count();
//总点击
$visitn_nmber = Virtual::getVisitNnmber();
diff --git a/application/common/library/Token.php b/application/common/library/Token.php
index d0e927d..7553494 100644
--- a/application/common/library/Token.php
+++ b/application/common/library/Token.php
@@ -31,6 +31,7 @@ class Token
*/
public static function connect(array $options = [], $name = false)
{
+
$type = !empty($options['type']) ? $options['type'] : 'File';
if (false === $name) {
@@ -49,7 +50,7 @@ class Token
return new $class($options);
}
$options = array_merge(Config::get('token'), $options);
-
+// var_dump($options,$class);die;
self::$instance[$name] = new $class($options);
}
@@ -64,6 +65,7 @@ class Token
*/
public static function init(array $options = [])
{
+// var_dump($options);die;
if (is_null(self::$handler)) {
if (empty($options) && 'complex' == Config::get('token.type')) {
$default = Config::get('token.default');
@@ -73,6 +75,7 @@ class Token
$options = Config::get('token');
}
+//
self::$handler = self::connect($options);
}
diff --git a/application/common/model/dyqc/ManystoreShop.php b/application/common/model/dyqc/ManystoreShop.php
index cceed43..08ccf77 100644
--- a/application/common/model/dyqc/ManystoreShop.php
+++ b/application/common/model/dyqc/ManystoreShop.php
@@ -709,7 +709,7 @@ class ManystoreShop extends BaseModel
//调用订单事件
$data = ['shop' => $shop];
\think\Hook::listen('shop_apply_after', $data);
-
+ \think\Hook::listen('shop_update_after', $data);
if($trans){
self::commitTrans();
}
diff --git a/application/common/model/school/classes/Evaluate.php b/application/common/model/school/classes/Evaluate.php
index 26ee855..222677b 100644
--- a/application/common/model/school/classes/Evaluate.php
+++ b/application/common/model/school/classes/Evaluate.php
@@ -289,7 +289,7 @@ class Evaluate extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"classes_evaluate"=>$classes_evaluate,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"classes_evaluate"=>$classes_evaluate,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_order_evaluate_after', $data);
//执行课时数更新
$res1 = order::statisticsAndUpdateClassesNumber($order['id']);
@@ -390,7 +390,7 @@ class Evaluate extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"classes_evaluate"=>$classes_evaluate,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"classes_evaluate"=>$classes_evaluate,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_order_evaluate_update_after', $data);
//执行课时数更新
$res1 = order::statisticsAndUpdateClassesNumber($order['id']);
diff --git a/application/common/model/school/classes/activity/order/Order.php b/application/common/model/school/classes/activity/order/Order.php
index f39fdeb..488dacf 100644
--- a/application/common/model/school/classes/activity/order/Order.php
+++ b/application/common/model/school/classes/activity/order/Order.php
@@ -964,7 +964,7 @@ class Order extends BaseModel
//记录订单日志
OrderLog::log($res1['id'],"活动订单创建成功,等待【学员】支付",'user',$user_id);
//7事件
- $data = ['order' => $res1];
+ $data = ['order' => self::where("id",$res1['id'])->find()];
\think\Hook::listen('classes_activity_order_create_after', $data);
@@ -1090,7 +1090,7 @@ class Order extends BaseModel
//记录订单日志
OrderLog::log($order['id'],"活动订单支付成功,核销码生成,等待审核结果",'user',$order['user_id']);
//调用支付成功事件
- $data = ['order' => $order];
+ $data = ['order' => self::where("id",$order['id'])->find()];
\think\Hook::listen('classes_activity_order_payed_after', $data);
//更新订单数据
self::statisticsAndUpdateClassesNumber($order);
@@ -1382,7 +1382,7 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_cancel_after', $data);
//执行课时数更新
$res1 = self::statisticsAndUpdateClassesNumber($order['id']);
@@ -1538,7 +1538,7 @@ class Order extends BaseModel
OrderLog::log($order['id'],$pron."课程活动单审核成功,预约成功等待核销!",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_auth_success_after', $data);
}else{
@@ -1553,7 +1553,7 @@ class Order extends BaseModel
//审核失败逻辑
OrderLog::log($order['id'],$pron."课程活动单审核不通过,原因;{$reason},该活动单将取消",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_auth_fail_after', $data);
//执行订单取消逻辑
$this->cancel($order_no,$user_id,false,$oper_type,$oper_id);
@@ -1565,7 +1565,7 @@ class Order extends BaseModel
//审核失败逻辑
OrderLog::log($order['id'],$pron."课程活动单审核不通过,原因;{$reason},该活动单将自动退款以便重新下单",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_auth_fail_after', $data);
$return = true;
// throw new \Exception("测试错误!".$order["status"]);
@@ -1796,7 +1796,7 @@ class Order extends BaseModel
$res1 = self::statisticsAndUpdateClassesNumber($order['id']);
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$order['user_id'],"oper_type"=>'admin',"oper_id"=>0];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$order['user_id'],"oper_type"=>'admin',"oper_id"=>0];
\think\Hook::listen('classes_activity_order_refund_success_after', $data);
@@ -1838,7 +1838,7 @@ class Order extends BaseModel
OrderLog::log($order['id'],"活动订单退款失败:".$msg, $oper_type, $oper_id);
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$order['user_id'],"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$order['user_id'],"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_refund_fail_after', $data);
if($trans){
@@ -1936,7 +1936,7 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_activity_order_finish_after', $data);
//执行课时数更新
self::statisticsAndUpdateClassesNumber($order['id']);
diff --git a/application/common/model/school/classes/hourorder/Order.php b/application/common/model/school/classes/hourorder/Order.php
index ded9642..e5bd763 100644
--- a/application/common/model/school/classes/hourorder/Order.php
+++ b/application/common/model/school/classes/hourorder/Order.php
@@ -787,7 +787,7 @@ class Order extends BaseModel
}
//7事件
- $data = ['order' => $res1];
+ $data = ['order' => self::where("id",$res1['id'])->find()];
\think\Hook::listen('classeshour_order_create_after', $data);
return $res1;
}
@@ -869,7 +869,7 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_cancel_after', $data);
//执行课时数更新
\app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
@@ -1278,7 +1278,7 @@ class Order extends BaseModel
OrderLog::log($order['id'],$pron."课时预约单审核成功,预约成功等待核销!",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_auth_success_after', $data);
}else{
@@ -1289,7 +1289,7 @@ class Order extends BaseModel
//审核失败逻辑
OrderLog::log($order['id'],$pron."课时预约单审核不通过,原因;{$reason},该课时单将取消以便重新下单",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_auth_fail_after', $data);
//执行订单取消逻辑
@@ -1393,7 +1393,7 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_finish_after', $data);
//执行课时数更新
\app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
@@ -1463,7 +1463,7 @@ class Order extends BaseModel
}
//调用订单事件
- $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_update_after', $data);
//执行课时数更新
$res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
diff --git a/application/common/model/school/classes/order/ServiceOrder.php b/application/common/model/school/classes/order/ServiceOrder.php
index d318e0a..d30cb99 100644
--- a/application/common/model/school/classes/order/ServiceOrder.php
+++ b/application/common/model/school/classes/order/ServiceOrder.php
@@ -397,7 +397,7 @@ class ServiceOrder extends BaseModel
ServiceOrderLog::log($serverorder['id'],$mark ?:"售后单申请已提交,等待商家处理",$oper_type,$oper_id);
//7事件
- $data = ['serviceorder' => $serverorder,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$serverorder['id'])->find(),"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_create_after', $data);
@@ -661,7 +661,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_cancel_after', $data);
//执行课时数更新
$res1 = order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
@@ -918,7 +918,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_shop_confirm_after', $data);
@@ -942,7 +942,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_shop_reject_after', $data);
@@ -1153,7 +1153,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_user_confirm_after', $data);
@@ -1176,7 +1176,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_user_reject_after', $data);
@@ -1351,7 +1351,7 @@ class ServiceOrder extends BaseModel
}
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_serviceorder_system_reject_after', $data);
@@ -1480,7 +1480,7 @@ class ServiceOrder extends BaseModel
$res1 = order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
//调用订单取消事件
- $data = ['serviceorder' => $order,"user_id"=>$order['user_id'],"oper_type"=>'admin',"oper_id"=>0];
+ $data = ['serviceorder' => self::where("id",$order['id'])->find(),"user_id"=>$order['user_id'],"oper_type"=>'admin',"oper_id"=>0];
\think\Hook::listen('classes_serviceorder_system_confirm_after', $data);
diff --git a/application/config.php b/application/config.php
index d1aa580..95d74e0 100644
--- a/application/config.php
+++ b/application/config.php
@@ -18,7 +18,7 @@ return [
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
- 'app_debug' => Env::get('app.debug', false),
+ 'app_debug' => Env::get('app.debug', true),
// 应用Trace
'app_trace' => Env::get('app.trace', false),
// 应用模式状态
@@ -296,9 +296,9 @@ return [
//是否默认展示子菜单
'show_submenu' => false,
//后台皮肤,为空时表示使用skin-black-blue
- 'adminskin' => '',
+ 'adminskin' => 'skin-blue-light',
//后台皮肤,为空时表示使用skin-black-blue
- 'manystoreskin' => '',
+ 'manystoreskin' => 'skin-black-light',
//后台是否启用面包屑
'breadcrumb' => false,
//是否允许未知来源的插件压缩包
diff --git a/application/manystore/controller/csmtable/Cligenerateexcel.php b/application/manystore/controller/csmtable/Cligenerateexcel.php
index c57a368..34b2584 100644
--- a/application/manystore/controller/csmtable/Cligenerateexcel.php
+++ b/application/manystore/controller/csmtable/Cligenerateexcel.php
@@ -1,13 +1,14 @@
request->request("filesource");
$auth = Auth::instance();
- $row = $this->model->where("admin_id", "=", $auth->id)
- ->where("filesource", '=', $filesource)
+// $row = $this->model->where("admin_id", "=", $auth->id)
+// ->where("filesource", '=', $filesource)
+// ->where("status", "=", "normal")
+// ->field("id,createtime,progress,iserror,errormsg")
+// ->order("id", "desc")
+// ->find();
+
+ $row = $this->model->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);
@@ -59,8 +66,11 @@ class Csmxlstable extends Backend
{
$auth = Auth::instance();
$id = $this->request->request("id");
- $row = $this->model->where("admin_id", "=", $auth->id)
- ->where("id", "=", $id)
+// $row = $this->model->where("admin_id", "=", $auth->id)
+// ->where("id", "=", $id)
+// ->find();
+
+ $row = $this->model->where("id", "=", $id)
->find();
if ($row == null) {
diff --git a/application/manystore/controller/csmtable/Datasource.php b/application/manystore/controller/csmtable/Datasource.php
index 67d61da..164835c 100644
--- a/application/manystore/controller/csmtable/Datasource.php
+++ b/application/manystore/controller/csmtable/Datasource.php
@@ -1,7 +1,7 @@
{include file="common/meta" /}
-
+
diff --git a/application/manystoreapi/behavior/ManystoreApiLog.php b/application/manystoreapi/behavior/ManystoreApiLog.php
new file mode 100644
index 0000000..5c56297
--- /dev/null
+++ b/application/manystoreapi/behavior/ManystoreApiLog.php
@@ -0,0 +1,16 @@
+isPost() && config('fastadmin.auto_record_log')) {
+// \app\manystoreapi\model\ManystoreApiLog::record();
+// }
+ if (config('fastadmin.auto_record_log')) {
+ \app\manystoreapi\model\ManystoreApiLog::record();
+ }
+ }
+}
diff --git a/application/manystoreapi/controller/Attachment.php b/application/manystoreapi/controller/Attachment.php
index d9fd81a..a4832db 100644
--- a/application/manystoreapi/controller/Attachment.php
+++ b/application/manystoreapi/controller/Attachment.php
@@ -10,7 +10,7 @@ use app\common\model\ManystoreAttachment;
class Attachment extends ManystoreApiBase
{
protected $noNeedLogin = [];
- protected $noNeedRight = '*';
+// protected $noNeedRight = '*';
/**
* @var \app\common\model\ManystoreAttachment
diff --git a/application/manystoreapi/controller/Common.php b/application/manystoreapi/controller/Common.php
index d57305f..81c9ae2 100644
--- a/application/manystoreapi/controller/Common.php
+++ b/application/manystoreapi/controller/Common.php
@@ -21,7 +21,7 @@ use think\Hook;
class Common extends ManystoreApiBase
{
protected $noNeedLogin = ['init', 'captcha','virtualgenerate','get_week_by_time'];
- protected $noNeedRight = '*';
+// protected $noNeedRight = '*';
public function _initialize()
{
diff --git a/application/manystoreapi/controller/Index.php b/application/manystoreapi/controller/Index.php
new file mode 100644
index 0000000..097a0be
--- /dev/null
+++ b/application/manystoreapi/controller/Index.php
@@ -0,0 +1,64 @@
+request->filter('trim,strip_tags,htmlspecialchars');
+ }
+
+
+ /**
+ * 后台首页
+ */
+ public function index()
+ {
+ //左侧菜单
+ $cookieArr = ['adminskin' => "/^skin\-([a-z\-]+)\$/i", 'multiplenav' => "/^(0|1)\$/", 'multipletab' => "/^(0|1)\$/", 'show_submenu' => "/^(0|1)\$/"];
+ foreach ($cookieArr as $key => $regex) {
+ $cookieValue = $this->request->cookie($key);
+ if (!is_null($cookieValue) && preg_match($regex, $cookieValue)) {
+ config('fastadmin.' . $key, $cookieValue);
+ }
+ }
+ list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
+ 'dashboard' => 'hot',
+ 'addon' => ['new', 'red', 'badge'],
+ 'auth/rule' => __('Menu'),
+ 'general' => ['new', 'purple'],
+ ], $this->view->site['fixedpage']);
+ $action = $this->request->request('action');
+// if ($this->request->isPost()) {
+ $this->apisuccess('', [
+ 'menulist' => $menulist,
+ 'navlist' => $navlist,
+ 'cookie' => ['prefix' => config('cookie.prefix')],
+ "fixedmenu" =>$fixedmenu,
+ "referermenu" =>$referermenu,
+ "title", __('Home'),
+ ]);
+
+// }
+// $this->assignconfig('cookie', ['prefix' => config('cookie.prefix')]);
+// $this->view->assign('menulist', $menulist);
+// $this->view->assign('navlist', $navlist);
+// $this->view->assign('fixedmenu', $fixedmenu);
+// $this->view->assign('referermenu', $referermenu);
+// $this->view->assign('title', __('Home'));
+// return $this->view->fetch();
+ }
+
+}
\ No newline at end of file
diff --git a/application/manystoreapi/controller/Shop.php b/application/manystoreapi/controller/Shop.php
new file mode 100644
index 0000000..16776a6
--- /dev/null
+++ b/application/manystoreapi/controller/Shop.php
@@ -0,0 +1,315 @@
+request->filter('trim,strip_tags,htmlspecialchars');
+
+ $this->model = Manystore::where(array('id'=>STORE_ID))->find();
+ $this->shopModel = ManystoreShop::where(array('id'=>SHOP_ID))->find();
+
+ }
+
+ /**
+ * 机构信息查询
+ */
+ public function index(){
+ $res = [];
+ $res['statusList']=[0=>'待审核',1=>'审核通过',2=>'审核拒绝'];
+ $res['typeList']=$this->shopModel->getTypeList();
+
+ $res['shop_info']=$this->shopModel;
+ $res['manystore_info']=$this->model;
+ $res['check_full']=(new \app\common\model\dyqc\ManystoreShop)->checkFull(SHOP_ID);
+ $res['check_full_msg']=(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg(SHOP_ID);
+ $res['now_city']= Virtual::getNowCity();
+ $res['miniqrcode_link']=Url::build("/manystoreapi/shop/miniqrcode", ["ids" => SHOP_ID]);
+ $this->apisuccess("查询成功!",$res);
+ }
+
+
+ /**
+ * 更新账号密码,邮件,头像信息
+ * @ApiMethod (POST)
+ * @ApiParams (name="email", type="string", required=true, description="邮件")
+ * @ApiParams (name="nickname", type="string", required=true, description="昵称")
+ * @ApiParams (name="avatar", type="string", required=true, description="头像")
+ * @ApiParams (name="password", type="string", required=false, description="密码(非必填)")
+ */
+ public function update()
+ {
+ if ($this->request->isPost()) {
+ $this->token();
+ $params = $this->request->post();
+ $params = array_filter(array_intersect_key(
+ $params,
+ array_flip(array('email', 'nickname', 'password', 'avatar'))
+ ));
+ unset($v);
+ if (!Validate::is($params['email'], "email")) {
+ $this->apierror(__("Please input correct email"));
+ }
+// if (!Validate::is($params['nickname'], "/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u")) {
+// $this->error(__("Please input correct nickname"));
+// }
+ if (isset($params['password'])) {
+ if (!Validate::is($params['password'], "/^[\S]{6,16}$/")) {
+ $this->apierror(__("Please input correct password"));
+ }
+ $params['salt'] = Random::alnum();
+ $params['password'] = md5(md5($params['password']) . $params['salt']);
+ }
+ $exist = Manystore::where('email', $params['email'])->where('id', '<>', $this->auth->id)->find();
+ if ($exist) {
+ $this->apierror(__("Email already exists"));
+ }
+ if ($params) {
+ $manystore = Manystore::get($this->auth->id);
+ $manystore->save($params);
+
+ Session::set("manystoreapi", $manystore->toArray());
+
+
+ $this->apisuccess();
+ }
+ $this->apierror();
+ }
+ return;
+ }
+
+
+ /** 编辑机构认证信息
+ * @ApiTitle( 编辑机构认证信息)
+ * @ApiSummary(编辑机构认证信息)
+ * @ApiMethod(POST)
+ * @ApiParams(name = "name", type = "string",required=true,description = "机构名称")
+ * @ApiParams(name = "logo", type = "string",required=true,description = "logo单图")
+ * @ApiParams(name = "image", type = "string",required=true,description = "封面单图")
+ * @ApiParams(name = "content", type = "string",required=true,description = "店铺详情")
+ * @ApiParams(name = "tel", type = "string",required=true,description = "服务电话(非必填)")
+ * @ApiParams(name = "desc", type = "string",required=false,description = "申请备注(非必填)")
+ * @ApiParams(name = "front_idcard_image", type = "string",required=true,description = "法人身份证正面")
+ * @ApiParams(name = "reverse_idcard_image", type = "string",required=true,description = "法人身份证反面")
+ * @ApiParams(name = "images", type = "string",required=true,description = "环境照片(多个逗号拼接)")
+ * @ApiParams(name = "yyzzdm", type = "string",required=true,description = "社会统一信用代码")
+ * @ApiParams(name = "yyzz_images", type = "string",required=true,description = "营业执照照片(多个逗号拼接)")
+ * @ApiParams(name = "address", type = "string",required=true,description = "店铺地址")
+ * @ApiParams(name = "address_detail", type = "string",required=true,description = "店铺详细地址")
+ * @ApiParams(name = "longitude", type = "string",required=true,description = "经度")
+ * @ApiParams(name = "latitude", type = "string",required=true,description = "纬度")
+ * @ApiParams(name = "province", type = "int",required=true,description = "省编号")
+ * @ApiParams(name = "city", type = "int",required=true,description = "市编号")
+ * @ApiParams(name = "district", type = "int",required=true,description = "县区编号")
+ * @ApiParams(name = "establish_time", type = "int",required=true,description = "成立时间10位秒级时间戳")
+ * @ApiParams(name = "people", type = "int",required=true,description = "员工人数")
+ * @ApiParams(name = "legal_entity", type = "string",required=true,description = "法人姓名")
+ * @ApiParams(name = "gender", type = "int",required=true,description = "法人性别:0=女,1=男")
+ * @ApiParams(name = "nation", type = "string",required=true,description = "法人民族")
+ * @ApiParams(name = "out_look", type = "string",required=true,description = "法人政治面貌")
+ * @ApiParams(name = "birthtime", type = "int",required=true,description = "法人出生日期10位秒级时间戳")
+ * @ApiParams(name = "native_place", type = "string",required=true,description = "法人籍贯")
+ * @ApiParams(name = "card_number", type = "string",required=true,description = "法人身份证号码")
+ * @ApiParams(name = "diploma", type = "string",required=true,description = "法人学历")
+ * @ApiParams(name = "post", type = "string",required=true,description = "法人职务")
+ * @ApiParams(name = "social_position", type = "string",required=true,description = "法人社会职务")
+ *
+ *
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function shop_update(){
+ $params=[];
+ $params["name"] = $this->request->post('name/s','');
+ $params["logo"] = $this->request->post('logo/s','');
+ $params["image"] = $this->request->post('image/s','');
+ $params["content"] = $this->request->post('content/s','');
+
+ $params["tel"] = $this->request->post('tel/s','');
+ $params["desc"] = $this->request->post('desc/s','');
+ $params["front_idcard_image"] = $this->request->post('front_idcard_image/s','');
+ $params["reverse_idcard_image"] = $this->request->post('reverse_idcard_image/s','');
+
+ $params["images"] = $this->request->post('images/s','');
+ $params["yyzz_images"] = $this->request->post('yyzz_images/s','');
+ $params["yyzzdm"] = $this->request->post('yyzzdm/s','');
+
+
+ $params["address"] = $this->request->post('address/s','');
+ $params["address_detail"] = $this->request->post('address_detail/s','');
+ $params["longitude"] = $this->request->post('longitude/s','');
+ $params["latitude"] = $this->request->post('latitude/s','');
+
+
+
+
+ $params["province"] = $this->request->post('province/d','');
+ $params["city"] = $this->request->post('city/d','');
+ $params["district"] = $this->request->post('district/d','');
+
+
+
+ $params["establish_time"] = $this->request->post('establish_time/d','');
+ $params["people"] = $this->request->post('people/d','');
+ $params["legal_entity"] = $this->request->post('legal_entity/s','');
+ $params["gender"] = $this->request->post('gender/d','');
+ $params["nation"] = $this->request->post('nation/s','');
+ $params["out_look"] = $this->request->post('out_look/s','');
+ $params["birthtime"] = $this->request->post('birthtime/d','');
+ $params["native_place"] = $this->request->post('native_place/s','');
+ $params["card_number"] = $this->request->post('card_number/s','');
+ $params["diploma"] = $this->request->post('diploma/s','');
+ $params["post"] = $this->request->post('post/s','');
+ $params["social_position"] = $this->request->post('social_position/s','');
+
+
+
+
+// if(empty($id)){
+// $this->error(__('缺少必要参数'));
+// }
+
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+ try {
+ $res = (new \app\common\model\dyqc\ManystoreShop)->updateData($user_id,$params,true,true);
+ } catch (\Exception $e){
+// Log::log($e->getMessage());
+ $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
+ }
+ $this->success('编辑成功', ['detail' => $res]);
+ }
+
+
+
+
+ /**
+ * 获取微信小程序码
+ * @ApiMethod (POST)
+ * @throws \think\Exception
+ * @throws \think\db\exception\BindParamException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+ public function miniqrcode($ids = ''){
+ $param = $this->request->param();
+ try{
+ if(isset($param['ids']))$ids = $param['ids'];
+ //设置模拟资格
+ $url = \app\common\model\dyqc\ManystoreShop::getMiniQrcodeLink($ids);
+
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+
+ return $url["response"];
+ }
+
+
+
+
+
+
+
+
+ /**
+ * @ApiTitle( 后台请求日志列表)
+ * @ApiSummary(后台请求日志列表)
+ * @ApiMethod(GET)
+ * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
+ * @ApiParams(name = "page", type = "string",required=true,description = "页数")
+ * @ApiParams(name = "limit", type = "string",required=true,description = "条数")
+ * @ApiParams(name = "shop_id", type = "string",required=false,description = "机构店铺id")
+ * @ApiParams(name = "store_id", type = "string",required=false,description = "机构账号ID")
+ * @ApiParams(name = "user_id", type = "string",required=false,description = "机构用户ID")
+ * @ApiParams(name = "ip", type = "string",required=false,description = "请求ip")
+ * @ApiParams(name = "time", type = "string",required=false,description = "操作时间查询:today今天,week本周,month本月,year本年,yesterday昨天,last year上一年,last week上周,last month上個月,lately7最近7天 , lately30最近30天,按开始时间区间查传值格式:Y/m/d H:M:S-Y/m/d H:M:S")
+ *
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function log_list()
+ {
+ $params = [];
+ $page = $this->request->get('page/d', 0); //页数
+ $limit = $this->request->get('limit/d', 0); //条数
+ $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
+ $params["shop_id"] = $this->request->get('shop_id/d', ''); //搜索关键字
+ $params["store_id"] = $this->request->get('store_id/d', ''); //搜索关键字
+ $params["user_id"] = $this->request->get('user_id/d', ''); //搜索关键字
+ $params["ip"] = $this->request->get('ip/d', ''); //时间
+ if($params["ip"]) $params["ip"] = ["LIKE","%".$params["ip"] ."%"];
+ $params["time"] = $this->request->get('time/s', ''); //时间
+ if(!$params["shop_id"]) $params["shop_id"] = $this->auth->shop_id;
+ if(!$params["store_id"]) $params["store_id"] = $this->auth->id;
+ try{
+ //当前申请状态
+ $res = ManystoreApiLog::logList($page, $limit,$params);
+// if($user_id =='670153'){
+// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
+// }
+ }catch (\Exception $e){
+
+ $this->apierror($e->getMessage());
+ }
+ $this->apisuccess('查询成功', $res);
+ }
+
+
+
+ /**
+ * @ApiTitle( 后台请求日志列表详情)
+ * @ApiSummary(后台请求日志列表详情)
+ * @ApiMethod(GET)
+ * @ApiParams(name = "id", type = "int",required=true,description = "后台请求日志id")
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function detail(){
+ $id = $this->request->get('id/d','');
+
+ if(empty($id)){
+ $this->apierror(__('缺少必要参数'));
+ }
+
+ try {
+ $res = ManystoreApiLog::detail($id);
+ } catch (\Exception $e){
+// Log::log($e->getMessage());
+ $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
+ }
+ $this->apisuccess('获取成功', ['detail' => $res]);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/application/manystoreapi/library/Auth.php b/application/manystoreapi/library/Auth.php
index 9be13b0..d354c23 100644
--- a/application/manystoreapi/library/Auth.php
+++ b/application/manystoreapi/library/Auth.php
@@ -28,17 +28,47 @@ class Auth extends ManystoreAuth
protected $keeptime = 2592000;
protected $requestUri = '';
protected $rules = [];
- //默认配置
- protected $config = [];
+// //默认配置
+// protected $config = [];
protected $options = [];
protected $allowFields = ['id','username', 'nickname', 'avatar','user_id', 'email',"shop_id"];
-
+ protected $breadcrumb = [];
protected $init_data = [
'table' => 'manystore_token',
+ 'type' => 'Mysql',
'userprefix' => 'shopup:',
'tokenprefix' => 'shoptp:',
];
+// protected $config = [
+// 'auth_on' => 1, // 权限开关
+// 'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。
+// 'auth_group' => 'manystore_api_auth_group', // 用户组数据表名
+// 'auth_group_access' => 'manystore_api_auth_group_access', // 用户-用户组关系表
+// 'auth_rule' => 'manystore_api_auth_rule', // 权限规则表
+// 'auth_user' => 'user', // 用户信息表
+// ];
+
+
+
+
+
+// public function __construct(Request $request = null)
+// {
+//
+// // 控制器初始化
+// $this->_initialize();
+//
+// // 前置操作方法
+// if ($this->beforeActionList) {
+// foreach ($this->beforeActionList as $method => $options) {
+// is_numeric($method) ?
+// $this->beforeAction($options) :
+// $this->beforeAction($method, $options);
+// }
+// }
+// }
+
/**
*
* @param array $options 参数
@@ -70,6 +100,8 @@ class Auth extends ManystoreAuth
*/
public function __get($name)
{
+ $res = Session::get('manystoreapi.' . $name);
+ if($res)return $res;
return $this->_user ? $this->_user->$name : null;
}
@@ -96,6 +128,14 @@ class Auth extends ManystoreAuth
return false;
}
$data = Token::init($this->init_data)->get($token) ?:false;
+
+ if(!$data){
+ $manystoreapi = Session::get('manystoreapi');
+ if($manystoreapi){
+ $data["user_id"] = $manystoreapi['id'];
+ }
+ }
+
if (!$data) {
return false;
}
@@ -182,8 +222,8 @@ class Auth extends ManystoreAuth
//删除Token
Token::init($this->init_data)->delete($this->_token) ?:false;
-// Session::delete("manystore");
-// Cookie::delete("keeplogin");
+ Session::delete("manystoreapi");
+ Cookie::delete("keeplogin");
//退出成功的事件
Hook::listen("manystore_logout_successed", $this->_user);
return true;
@@ -256,6 +296,9 @@ class Auth extends ManystoreAuth
//登录成功的事件
Hook::listen("manystore_login_successed", $this->_user);
+
+ Session::set("manystoreapi", $manystore->toArray());
+
Db::commit();
} catch (Exception $e) {
Db::rollback();
@@ -620,10 +663,13 @@ class Auth extends ManystoreAuth
*/
public function getBreadCrumb($path = '')
{
+// var_dump($this->breadcrumb);
if ($this->breadcrumb || !$path) {
+// var_dump($path);die;
return $this->breadcrumb;
}
$path_rule_id = 0;
+// var_dump($this->rules);die;
foreach ($this->rules as $rule) {
$path_rule_id = $rule['name'] == $path ? $rule['id'] : $path_rule_id;
}
@@ -634,6 +680,7 @@ class Auth extends ManystoreAuth
$v['title'] = __($v['title']);
}
}
+
return $this->breadcrumb;
}
@@ -676,15 +723,18 @@ class Auth extends ManystoreAuth
$refererUrl = Session::get('referer');
$pinyin = new \Overtrue\Pinyin\Pinyin('Overtrue\Pinyin\MemoryFileDictLoader');
// 必须将结果集转换为数组
- $ruleList = collection(\app\manystore\model\ManystoreAuthRule::where('status', 'normal')
+ $ruleList = collection(\app\manystore\model\ManystoreApiAuthRule::where('status', 'normal')
->where('ismenu', 1)
->order('weigh', 'desc')
- ->cache("__manystore_menu__")
+ ->cache("__manystore_api_menu__")
->select())->toArray();
- $indexRuleList = \app\manystore\model\ManystoreAuthRule::where('status', 'normal')
+ $indexRuleList = \app\manystore\model\ManystoreApiAuthRule::where('status', 'normal')
->where('ismenu', 0)
->where('name', 'like', '%/index')
->column('name,pid');
+
+// var_dump($ruleList);
+
$pidArr = array_filter(array_unique(array_map(function ($item) {
return $item['pid'];
}, $ruleList)));
@@ -726,6 +776,9 @@ class Auth extends ManystoreAuth
$select_id = $selected ? $selected['id'] : 0;
$menu = $nav = '';
+ $menu = $ruleList;
+ return [$menu, $nav, $selected, $referer];
+
if (Config::get('fastadmin.multiplenav')) {
$topList = [];
foreach ($ruleList as $index => $item) {
diff --git a/application/manystoreapi/library/ManystoreAuth.php b/application/manystoreapi/library/ManystoreAuth.php
index 73c12c5..0357989 100644
--- a/application/manystoreapi/library/ManystoreAuth.php
+++ b/application/manystoreapi/library/ManystoreAuth.php
@@ -174,12 +174,14 @@ class ManystoreAuth
if (isset($_rulelist[$uid])) {
return $_rulelist[$uid];
}
+
if (2 == $this->config['auth_type'] && Session::has('_manystore_api_rule_list_' . $uid)) {
return Session::get('_manystore_api_rule_list_' . $uid);
}
// 读取用户规则节点
$ids = $this->getRuleIds($uid);
+
if (empty($ids)) {
$_rulelist[$uid] = [];
return [];
@@ -200,6 +202,8 @@ class ManystoreAuth
if (in_array('*', $ids)) {
$rulelist[] = "*";
}
+
+
foreach ($this->rules as $rule) {
//超级管理员无需验证condition
if (!empty($rule['condition']) && !in_array('*', $ids)) {
@@ -223,7 +227,9 @@ class ManystoreAuth
$rulelist[$rule['id']] = strtolower($rule['name']);
}
}
+// var_dump( $rulelist);
$_rulelist[$uid] = $rulelist;
+// var_dump($rulelist);
//登录验证则需要保存规则列表
if (2 == $this->config['auth_type']) {
//规则列表结果保存到session
@@ -236,10 +242,12 @@ class ManystoreAuth
{
//读取用户所属用户组
$groups = $this->getGroups($uid);
+
$ids = []; //保存用户所属用户组设置的所有权限规则id
foreach ($groups as $g) {
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
}
+
$ids = array_unique($ids);
return $ids;
}
diff --git a/application/manystoreapi/model/ManystoreApiLog.php b/application/manystoreapi/model/ManystoreApiLog.php
new file mode 100644
index 0000000..b502621
--- /dev/null
+++ b/application/manystoreapi/model/ManystoreApiLog.php
@@ -0,0 +1,215 @@
+isLogin()){
+ $shop_id = SHOP_ID ;
+ $store_id = STORE_ID;
+ $username = $auth->username;
+ }
+ $content = self::$content;
+ if (!$content) {
+ $content = request()->param('', null, 'trim,strip_tags,htmlspecialchars');
+ foreach ($content as $k => $v) {
+ if (is_string($v) && strlen($v) > 200 || stripos($k, 'password') !== false) {
+ unset($content[$k]);
+ }
+ }
+ }
+ $title = self::$title;
+ if (!$title) {
+ $title = [];
+ $breadcrumb = Auth::instance()->getBreadcrumb();
+
+ foreach ($breadcrumb as $k => $v) {
+ $title[] = $v['title'];
+ }
+ $title = implode(' ', $title);
+ }
+// var_dump($breadcrumb);
+
+ self::create([
+ 'shop_id' => $shop_id ? $shop_id : 0,
+ 'store_id' => $store_id ? $store_id : 0,
+ 'user_id' => SHOP_USER_ID,
+ 'title' => $title ?: ManystoreApiAuthRule::where("name",substr(request()->url(), 0, 1500))->value('title')?:"",
+ 'content' => !is_scalar($content) ? json_encode($content) : $content,
+ 'url' => substr(request()->url(), 0, 1500),
+ 'username' => $username,
+ 'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255),
+ 'ip' => request()->ip()
+ ]);
+
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+
+
+ public function store()
+ {
+ return $this->belongsTo(Manystore::class, 'store_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function shop()
+ {
+ return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+
+
+ /**得到基础条件
+ * @param $status
+ * @param null $model
+ * @param string $alisa
+ */
+ public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
+ {
+
+ if (!$model) {
+ $model = new static;
+ if ($alisa&&!$with) $model = $model->alias($alisa);
+ }
+ if ($alisa) $alisa = $alisa . '.';
+ $tableFields = (new static)->getTableFields();
+ foreach ($tableFields as $fields)
+ {
+ if(in_array($fields, ['content']))continue;
+// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
+
+ if (isset($whereData[$fields]) && $whereData[$fields]){
+ if(is_array($whereData[$fields])){
+ $model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
+ }else{
+ $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
+ }
+
+ }
+
+
+ }
+// if (isset($whereData['status']) && $whereData['status']) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
+// if (isset($whereData['not_status']) && $whereData['not_status']) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
+
+
+ if (isset($whereData['keywords'])&&$whereData['keywords']){
+
+ if($with){
+ $model = $model->where( function($query) use($whereData,$alisa,$with){
+ $query = $query->where("{$alisa}url|{$alisa}title|{$alisa}content|{$alisa}ip", 'like', "%". $whereData['keywords']."%");
+ if(in_array('user',$with)){
+ $query = $query->whereOr("user.nickname|user.realname|user.mobile", 'like', "%". $whereData['keywords']."%");
+ }
+ if(in_array('shop',$with)){
+ $query = $query->whereOr("shop.name|shop.address|shop.address_detail|shop.tel", 'like', "%". $whereData['keywords']."%");
+ }
+ if(in_array('store',$with)){
+ $query = $query->whereOr("store.username|store.nickname|store.email", 'like', "%". $whereData['keywords']."%");
+ }
+ });
+ }else{
+ $model = $model->where("{$alisa}url|{$alisa}title|{$alisa}content|{$alisa}ip", 'like', "%". $whereData['keywords']."%");
+ }
+
+ }
+ if (isset($whereData['time'])&&$whereData['time']){
+ $model = $model->time(["{$alisa}createtime",$whereData['time']]);
+ }
+
+
+ return $model;
+ }
+
+
+
+
+ public static function logList($page, $limit,$params=[]){
+ $with_field = [
+ 'base'=>['*'],
+ 'user'=>['nickname',"realname","mobile","avatar"],
+ 'shop'=>['name','address',"address_detail","tel","logo","image"],
+ 'store'=>['username','nickname',"email","user_id","avatar"],
+ ];
+
+ $alisa = (new self)->getWithAlisaName();
+ $sort = "{$alisa}.id desc,{$alisa}.createtime desc";
+ $serch_where = [];
+ $serch_where = array_merge($serch_where,$params);
+ return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
+ }
+
+
+
+
+ /** 日志详情
+ * @param $id
+ * @throws \think\exception\DbException
+ */
+ public static function detail($id){
+ $self = self::get($id,['user','shop',"store"]);
+ if(!$self) throw new \Exception("未找到相关数据");
+
+
+ $self->getRelation('user')->visible(['nickname',"realname","mobile","avatar"]);
+ $self->getRelation('shop')->visible(['name','address',"address_detail","tel","logo","image"]);
+ $self->getRelation('store')->visible(['username','nickname',"email","user_id","avatar"]);
+ //参与人数 = 虚拟人数 + 平台人数
+ return $self;
+ }
+
+
+}
diff --git a/application/manystoreapi/tags.php b/application/manystoreapi/tags.php
index 66385df..26c1dd7 100644
--- a/application/manystoreapi/tags.php
+++ b/application/manystoreapi/tags.php
@@ -13,6 +13,6 @@
return [
// 应用结束
'app_end' => [
- 'app\\manystore\\behavior\\ManystoreLog',
+ 'app\\manystoreapi\\behavior\\ManystoreApiLog',
],
];