diff --git a/application/admin/controller/style/HomeImages.php b/application/admin/controller/style/HomeImages.php index 9b0782e..83957b6 100644 --- a/application/admin/controller/style/HomeImages.php +++ b/application/admin/controller/style/HomeImages.php @@ -23,6 +23,8 @@ class HomeImages extends Backend parent::_initialize(); $this->model = new \app\admin\model\style\HomeImages; $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign("showtypeList", $this->model->getShowtypeList()); + $this->view->assign("showtypeListJson", json_encode($this->model->getShowtypeList(), JSON_UNESCAPED_UNICODE)); } diff --git a/application/admin/lang/zh-cn/style/home_images.php b/application/admin/lang/zh-cn/style/home_images.php index 2673431..2ed2b98 100644 --- a/application/admin/lang/zh-cn/style/home_images.php +++ b/application/admin/lang/zh-cn/style/home_images.php @@ -5,6 +5,11 @@ return [ 'Type' => '跳转类型', 'Type in' => '内部跳转', 'Type out' => '外部跳转', + 'Showtype' => '展示类型', + 'Showtype image' => '图片', + 'Showtype video' => '视频', + + 'Url' => '跳转链接', 'Weigh' => '权重', 'Createtime' => '创建时间', diff --git a/application/admin/model/style/HomeImages.php b/application/admin/model/style/HomeImages.php index 1532e08..155e82a 100644 --- a/application/admin/model/style/HomeImages.php +++ b/application/admin/model/style/HomeImages.php @@ -25,7 +25,8 @@ class HomeImages extends Model // 追加属性 protected $append = [ - 'type_text' + 'type_text', + 'showtype_text' ]; @@ -53,6 +54,19 @@ class HomeImages extends Model return isset($list[$value]) ? $list[$value] : ''; } + public function getShowtypeList() + { + return ['image' => __('Showtype image'), 'video' => __('Showtype video')]; + } + + + public function getShowtypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['showtype']) ? $data['showtype'] : ''); + $list = $this->getShowtypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + diff --git a/application/admin/view/style/home_images/add.html b/application/admin/view/style/home_images/add.html index bd9b1fe..f1e0e3e 100644 --- a/application/admin/view/style/home_images/add.html +++ b/application/admin/view/style/home_images/add.html @@ -1,13 +1,27 @@
+ +
+ +
+ + + +
+
+
- - + +
diff --git a/application/admin/view/style/home_images/edit.html b/application/admin/view/style/home_images/edit.html index bf552cd..504559b 100644 --- a/application/admin/view/style/home_images/edit.html +++ b/application/admin/view/style/home_images/edit.html @@ -1,13 +1,26 @@ + +
+ +
+ + + +
+
- - + +
diff --git a/application/admin/view/style/home_images/index.html b/application/admin/view/style/home_images/index.html index b45fd89..1217030 100644 --- a/application/admin/view/style/home_images/index.html +++ b/application/admin/view/style/home_images/index.html @@ -27,3 +27,6 @@
+ diff --git a/application/common/controller/ManystoreApiBase.php b/application/common/controller/ManystoreApiBase.php index 4bde684..5993691 100644 --- a/application/common/controller/ManystoreApiBase.php +++ b/application/common/controller/ManystoreApiBase.php @@ -6,6 +6,8 @@ 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; +use app\common\model\school\classes\activity\Activity; +use app\common\model\school\classes\ClassesLib; use app\manystoreapi\library\Auth; use app\common\model\ManystoreConfig; use app\manystore\model\Manystore; @@ -27,6 +29,34 @@ use think\Validate; class ManystoreApiBase extends Controller { + protected $classes_lib_ids = []; + protected $classes_activity_ids = []; + protected $shop_id = 0; + + + + protected function check_worker_auth(){ + //判断登录用户是否是员工 + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + if(!$user_id)$this->apierror("请登录后再访问该接口!",['errcode'=>30002], 401); + + try{ + $this->shop_id = ClassesLib::checkOptionAuth(0,$user['id'],"shop"); + }catch (\Exception $e){ + $this->apierror($e->getMessage(),['errcode'=>30003]); + } + $this->classes_lib_ids = (new ClassesLib)->getClassesAuthIds($user_id); + $this->classes_activity_ids = (new Activity())->getActivityAuthIds($user_id); + + //如果没有任何可管理的classes_lib_id 则返回错误 + if(!$this->classes_lib_ids && !$this->shop_id && !$this->classes_activity_ids)$this->apierror("您没有员工权限访问该接口!",['errcode'=>30003]); + + + } + + /** * 无需登录的方法,同时也就不需要鉴权了 * @var array diff --git a/application/common/model/BaseModel.php b/application/common/model/BaseModel.php index 354ff97..09f1620 100644 --- a/application/common/model/BaseModel.php +++ b/application/common/model/BaseModel.php @@ -129,6 +129,28 @@ class BaseModel extends Model } } + //关联查询条件 + if($with && is_array($with)){ + foreach ($whereData as $param => $value) + { + //如果存在.则按.分割取到表别名 + //如果表别名属于$with中的表别名,则塞入查询条件里 + if(strpos($param,'.')!==false){ + $param_alisa = explode('.',$param)[0]; + if(in_array($param_alisa,$with)){ + if(is_array($value)){ + $model = $model->where($param, $value[0], $value[1]); + }else{ + $model = $model->where($param, $value); + } + } + } + } + } + return self::getDivWhere($whereData, $model, $alisa,$with); + } + public static function getDivWhere($whereData = [], $model = null, $alisa = '',$with = false) + { return $model; } diff --git a/application/common/model/User.php b/application/common/model/User.php index c2ff29e..a174cf6 100644 --- a/application/common/model/User.php +++ b/application/common/model/User.php @@ -383,9 +383,15 @@ class User extends BaseModel //得到授权的用户 if($shop_id){ if($has_order_user){ + $classes_lib_id = $params["classes_lib_id"] ?? 0; + $classes_activity_id = $params["classes_activity_id"] ?? 0; + $classeswhere = $activitywhere = [[]]; + if($classes_lib_id)$classeswhere = ["classes_lib_id","in",$classes_lib_id]; + if($classes_activity_id)$activitywhere = ["classes_activity_id","in",$classes_activity_id]; + //只查下过单的 - $user_ids = Order::where("shop_id",$shop_id)->column("user_id"); - $user_ids = array_merge($user_ids,\app\common\model\school\classes\activity\order\Order::where("shop_id",$shop_id)->column("user_id")); + $user_ids = Order::where("shop_id",$shop_id)->where(...$classeswhere)->column("user_id"); + $user_ids = array_merge($user_ids,\app\common\model\school\classes\activity\order\Order::where(...$activitywhere)->where("shop_id",$shop_id)->column("user_id")); $where_params = [ 'id'=> implode(',',$user_ids), ]; diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php index 536513e..e2df2f8 100644 --- a/application/common/model/school/classes/ClassesLib.php +++ b/application/common/model/school/classes/ClassesLib.php @@ -1505,8 +1505,8 @@ $user_unpaid_order = $user_paid_order =null; switch ($oper_type) { case 'user': - if($only_admin)throw new \Exception("您无权操作该订单!"); - if($only_shop)throw new \Exception("您无权操作该订单!"); + if($only_admin)throw new \Exception("您无权操作该课程!"); + if($only_shop)throw new \Exception("您无权操作该课程!"); //自己或操作员 $Shop = Shop::where("user_id",$oper_id)->find(); if($Shop)$shop_id = $Shop["id"]; @@ -1538,9 +1538,9 @@ $user_unpaid_order = $user_paid_order =null; if(!$admin_info) throw new \Exception("代下单管理员不存在!"); break; case 'shop': - if($only_admin)throw new \Exception("您无权操作该订单!"); + if($only_admin)throw new \Exception("您无权操作该课程!"); - if($only_user) throw new \Exception("您无权操作该订单!"); + if($only_user) throw new \Exception("您无权操作该课程!"); $admin_info = Manystore::where('id',$oper_id)->find(); if(!$admin_info) throw new \Exception("代下单管理员不存在!"); diff --git a/application/common/model/school/classes/activity/Activity.php b/application/common/model/school/classes/activity/Activity.php index 5573d60..a47b03e 100644 --- a/application/common/model/school/classes/activity/Activity.php +++ b/application/common/model/school/classes/activity/Activity.php @@ -2,6 +2,7 @@ namespace app\common\model\school\classes\activity; +use app\admin\model\Admin; use app\admin\model\manystore\Shop; use app\common\library\Virtual; use app\common\model\manystore\UserAuth; @@ -17,6 +18,7 @@ use app\common\model\school\classes\Label; use app\common\model\school\classes\Type; use app\common\model\school\classes\Verification; use app\common\model\school\classes\VirtualUser; +use app\common\model\User; use app\manystore\model\Manystore; use think\Model; use traits\model\SoftDelete; @@ -1603,4 +1605,88 @@ class Activity extends BaseModel return Virtual::getMiniQrcodeLink("activity",["activity_id"=>$id]); } + + + + + + /** 操作权限检测 + * @param $activity_id 活动id + * @param $oper_id 操作人id + * @param $oper_type 操作人类型:user-用户或员工,admin-管理员 + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function checkOptionAuth($activity_id,$oper_id,$oper_type,$only_user=false,$only_shop=false,$only_admin=false){ + $activity = null; + $shop_id = 0; + //课程是否存在并上架 + if($activity_id){ + $activity = self::get($activity_id); + if(!$activity) throw new \Exception("活动不存在或已下架!"); + $shop_id = $activity["shop_id"]; + } + + + + switch ($oper_type) { + case 'user': + if($only_admin)throw new \Exception("您无权操作该活动!"); + if($only_shop)throw new \Exception("您无权操作该活动!"); + //自己或操作员 + $Shop = \app\common\model\manystore\Shop::where("user_id",$oper_id)->find(); + if($Shop)$shop_id = $Shop["id"]; + if($Shop && $activity){ + if($Shop["id"] == $activity["shop_id"]){ + break; + } + } + + + //说明是操作员 + $help_user_info = User::where('id',$oper_id)->find(); + if(!$help_user_info) throw new \Exception("代下单员工不存在!"); + $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($oper_id); + $activity_lib_ids = (new Activity())->getActivityAuthIds($oper_id); + + + if(!$shop_id && $classes_lib_ids)$shop_id = self::where("id" ,"in", $classes_lib_ids)->value("shop_id"); + if(!$shop_id && $activity_lib_ids)$shop_id = Activity::where("id" ,"in", $activity_lib_ids)->value("shop_id"); + + + + //判断当前订单课程是否在此课程授权范围内 + if($activity && !in_array($activity_id,$activity_lib_ids)) throw new \Exception("该活动不在您的授权范围内,无法代操作!"); + + break; + case 'admin': + $admin_info = Admin::where('id',$oper_id)->find(); + if(!$admin_info) throw new \Exception("代下单管理员不存在!"); + break; + case 'shop': + if($only_admin)throw new \Exception("您无权操作该活动!"); + + if($only_user) throw new \Exception("您无权操作该活动!"); + + $admin_info = Manystore::where('id',$oper_id)->find(); + if(!$admin_info) throw new \Exception("代下单管理员不存在!"); + $shop_id = $admin_info["shop_id"]; + + $activity_lib_ids = Activity::where("manystore_id",$oper_id)->column("id"); + //判断当前订单课程是否在此课程授权范围内 + if($activity && !in_array($activity_id,$activity_lib_ids)) throw new \Exception("该活动不在您的授权范围内,无法代操作!"); + break; + default: + throw new \Exception("请选择正确的代下单类型!"); + } + if(!$shop_id) throw new \Exception("无法判定活动所属店铺!"); + + return $shop_id; + } + + + + } diff --git a/application/common/model/school/classes/activity/ActivityAuth.php b/application/common/model/school/classes/activity/ActivityAuth.php index 12ad828..5013300 100644 --- a/application/common/model/school/classes/activity/ActivityAuth.php +++ b/application/common/model/school/classes/activity/ActivityAuth.php @@ -643,4 +643,48 @@ class ActivityAuth extends BaseModel + + + /** 小程序端操作活动审核添加 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function createActivityByOper(&$params,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + + $model = new self; + + + //用户操作权限检测 + $shop_id = Activity::checkOptionAuth(0, $oper_id,$oper_type); + $params["shop_id"] = $shop_id; + + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + + + + + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $model; + } + + } diff --git a/application/common/model/school/classes/activity/order/Order.php b/application/common/model/school/classes/activity/order/Order.php index 488dacf..421adb5 100644 --- a/application/common/model/school/classes/activity/order/Order.php +++ b/application/common/model/school/classes/activity/order/Order.php @@ -355,7 +355,7 @@ class Order extends BaseModel - public static function allList($user_id,$page, $limit,$keywords,$status,$classes_activity_id=[],$has_evaluate=0,$auth_status=""){ + public static function allList($user_id,$page, $limit,$keywords,$status,$classes_activity_id=[],$has_evaluate=0,$auth_status="",$params=[]){ $with_field = [ 'user'=>['nickname','mobile','avatar','realname'], 'base'=>['*'], @@ -376,7 +376,7 @@ class Order extends BaseModel $sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$RESERV}','{$FINISH}','{$REFUND}','{$IN_SERVICE}','{$CANCEL}' ,'{$IN_REFUND}') asc,{$alisa}.id desc"; $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,"classes_activity_id"=>$classes_activity_id,"has_evaluate"=>$has_evaluate,"auth_status"=>$auth_status]; // if($type)$serch_where['type'] = $type; - return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field); } @@ -413,15 +413,15 @@ class Order extends BaseModel * @param int $user_id * @return array */ - public static function orderCount($user_id = 0,$classes_activity_id=[]){ - return self::baseCount(['user_id'=>$user_id,"classes_activity_id"=>$classes_activity_id]); + public static function orderCount($user_id = 0,$classes_activity_id=[],$params=[]){ + return self::baseCount(array_merge(['user_id'=>$user_id,"classes_activity_id"=>$classes_activity_id],$params)); } - public static function workList($user_id,$page, $limit,$keywords,$status,$classes_activity_id=[],$classes_activity_ids=[],$has_evaluate=0,$auth_status=""){ + public static function workList($user_id,$page, $limit,$keywords,$status,$classes_activity_id=[],$classes_activity_ids=[],$has_evaluate=0,$auth_status="",$params=[]){ if(!$classes_activity_ids) $classes_activity_ids = [-5]; $with_field = [ @@ -443,7 +443,7 @@ class Order extends BaseModel $sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$RESERV}','{$FINISH}','{$REFUND}','{$IN_SERVICE}','{$CANCEL}','{$IN_REFUND}') asc,{$alisa}.id desc"; $serch_where = ['status'=>$status,'keywords'=>$keywords,"classes_activity_id"=>$classes_activity_id,"classes_activity_ids"=>$classes_activity_ids,"auth_status"=>$auth_status]; // if($type)$serch_where['type'] = $type; - return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field); } @@ -455,10 +455,10 @@ class Order extends BaseModel * @param int $user_id * @return array */ - public static function workCount($classes_activity_id=[],$classes_activity_ids=[]){ + public static function workCount($classes_activity_id=[],$classes_activity_ids=[],$params=[]){ if(!$classes_activity_ids) $classes_activity_ids = [-5]; - return self::baseCount(["classes_activity_id"=>$classes_activity_id,"classes_activity_ids"=>$classes_activity_ids]); + return self::baseCount(array_merge(["classes_activity_id"=>$classes_activity_id,"classes_activity_ids"=>$classes_activity_ids],$params)); } diff --git a/application/common/model/school/classes/activity/order/OrderLog.php b/application/common/model/school/classes/activity/order/OrderLog.php index 2a1efb0..33837c5 100644 --- a/application/common/model/school/classes/activity/order/OrderLog.php +++ b/application/common/model/school/classes/activity/order/OrderLog.php @@ -99,4 +99,20 @@ class OrderLog extends BaseModel } + + public static function allList($page, $limit,$params=[]){ + $with_field = [ + 'activityorder'=>['order_no',"pay_no","manystore_id","shop_id","classes_activity_id","activity_order_detail_id","classes_activity_item_id","activity_order_item_id","user_id","code"], + 'base'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "{$alisa}.id desc"; + $serch_where = $params; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + } diff --git a/application/common/model/school/classes/hourorder/OrderLog.php b/application/common/model/school/classes/hourorder/OrderLog.php index f602d1a..031eea1 100644 --- a/application/common/model/school/classes/hourorder/OrderLog.php +++ b/application/common/model/school/classes/hourorder/OrderLog.php @@ -46,7 +46,7 @@ class OrderLog extends BaseModel - public function order() + public function hourorder() { return $this->belongsTo(Order::class, 'classes_hour_order_id', 'id', [], 'LEFT')->setEagerlyType(0); } @@ -99,4 +99,83 @@ class OrderLog extends BaseModel } return $log; } + + + + + /**得到基础条件 + * @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, ['status','auth_status','classes_hour_order_id']))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'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']); + + if (isset($whereData['auth_status']) && $whereData['auth_status']) $model = $model->where("{$alisa}auth_status", 'in', $whereData['auth_status']); + + if (isset($whereData['not_auth_status'])) $model = $model->where("{$alisa}auth_status", 'not in', $whereData['not_auth_status']); + + + + if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}id|{$alisa}classes_hour_order_id|{$alisa}log_text", 'LIKE', "%".$whereData['keywords']."%"); + if (isset($whereData['time'])&&$whereData['time']){ + + $model = $model->time(["{$alisa}createtime",$whereData['time']]); + } + if (isset($whereData['classes_hour_order_id']) && $whereData['classes_hour_order_id']) $model = $model->where("{$alisa}classes_hour_order_id", 'in', $whereData['classes_hour_order_id']); + + + return $model; + } + + + + + + + public static function allList($user_id,$page, $limit,$keywords,$status,$auth_status,$classes_hour_order_id=[]){ + $with_field = [ + 'hourorder'=>['*'], + 'base'=>['*'], +// 'classesorder'=>['*'], +// 'detail'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "{$alisa}.id desc"; + $serch_where = ['status'=>$status,'user_id'=>$user_id, + 'keywords'=>$keywords,"classes_hour_order_id"=>$classes_hour_order_id, + "service_stauts"=>$auth_status + ]; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + } diff --git a/application/common/model/school/classes/order/ServiceOrder.php b/application/common/model/school/classes/order/ServiceOrder.php index d30cb99..43985db 100644 --- a/application/common/model/school/classes/order/ServiceOrder.php +++ b/application/common/model/school/classes/order/ServiceOrder.php @@ -745,7 +745,7 @@ class ServiceOrder extends BaseModel - public static function allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[]){ + public static function allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[],$params=[]){ $with_field = [ 'user'=>['nickname','mobile','avatar','realname'], 'base'=>['*'], @@ -761,7 +761,7 @@ class ServiceOrder extends BaseModel "service_stauts"=>$service_stauts,"sales_type"=>$sales_type ]; // if($type)$serch_where['type'] = $type; - return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field); } @@ -782,15 +782,15 @@ class ServiceOrder extends BaseModel * @param int $user_id * @return array */ - public static function orderCount($user_id = 0,$classes_order_id=0,$classes_lib_id=[]){ - return self::baseCount(['user_id'=>$user_id,"classes_lib_id"=>$classes_lib_id,"classes_order_id"=>$classes_order_id]); + public static function orderCount($user_id = 0,$classes_order_id=0,$classes_lib_id=[],$params=[]){ + return self::baseCount(array_merge(['user_id'=>$user_id,"classes_lib_id"=>$classes_lib_id,"classes_order_id"=>$classes_order_id],$params)); } - public static function workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[],$classes_lib_ids=[]){ + public static function workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[],$classes_lib_ids=[],$params=[]){ if(!$classes_lib_ids) $classes_lib_ids = [-5]; $with_field = [ @@ -806,7 +806,7 @@ class ServiceOrder extends BaseModel ,"service_stauts"=>$service_stauts,"sales_type"=>$sales_type ]; // if($type)$serch_where['type'] = $type; - return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + return (new self)->getBaseList(array_merge( $serch_where,$params), $page, $limit,$sort,$with_field); } @@ -818,10 +818,10 @@ class ServiceOrder extends BaseModel * @param int $user_id * @return array */ - public static function workCount($classes_order_id=0,$classes_lib_id=[],$classes_lib_ids=[]){ + public static function workCount($classes_order_id=0,$classes_lib_id=[],$classes_lib_ids=[],$params=[]){ if(!$classes_lib_ids) $classes_lib_ids = [-5]; - return self::baseCount(["classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"classes_order_id"=>$classes_order_id]); + return self::baseCount(array_merge(["classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"classes_order_id"=>$classes_order_id],$params)); } diff --git a/application/common/model/style/HomeImages.php b/application/common/model/style/HomeImages.php index dc221f5..9191c0e 100644 --- a/application/common/model/style/HomeImages.php +++ b/application/common/model/style/HomeImages.php @@ -26,7 +26,8 @@ class HomeImages extends BaseModel // 追加属性 protected $append = [ - 'type_text' + 'type_text', + 'showtype_text' ]; @@ -54,6 +55,20 @@ class HomeImages extends BaseModel return isset($list[$value]) ? $list[$value] : ''; } + public function getShowtypeList() + { + return ['image' => __('Showtype image'), 'video' => __('Showtype video')]; + } + + + public function getShowtypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['showtype']) ? $data['showtype'] : ''); + $list = $this->getShowtypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + public function getImageAttr($value, $data) { diff --git a/application/config.php b/application/config.php index 95d74e0..bd71b61 100644 --- a/application/config.php +++ b/application/config.php @@ -159,7 +159,7 @@ return [ // 错误显示信息,非调试模式有效 'error_message' => '你所浏览的页面暂时无法访问', // 显示错误信息 - 'show_error_msg' => false, + 'show_error_msg' => true, // 异常处理handle类 留空使用 \think\exception\Handle 'exception_handle' => '', // +---------------------------------------------------------------------- diff --git a/application/extra/upload.php b/application/extra/upload.php index 3f4b9b6..ad8d6df 100644 --- a/application/extra/upload.php +++ b/application/extra/upload.php @@ -18,7 +18,7 @@ return [ /** * 最大可上传大小 */ - 'maxsize' => '2mb', + 'maxsize' => '10mb', /** * 可上传的文件类型 */ diff --git a/application/manystoreapi/controller/ActivityOrder.php b/application/manystoreapi/controller/ActivityOrder.php new file mode 100644 index 0000000..7bed557 --- /dev/null +++ b/application/manystoreapi/controller/ActivityOrder.php @@ -0,0 +1,296 @@ +model = new OrderModel; + parent::_initialize(); + + //判断登录用户是否是员工 + $this->setUrlLock(); + // 判断员工权限 + $this->check_worker_auth(); + } + + + + /** + * @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->error(__('缺少必要参数')); + } + + try { + $res = OrderModel::getDetail($id); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['detail' => $res]); + } + + + + + + /** + * @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 = "status", type = "string",required=false,description = "订单状态:-3=已取消,0=待支付,2=已报名待审核,3=已预约,4=售后中,6=已退款,9=已完成") + * @ApiParams(name = "auth_status", type = "string",required=false,description = "审核状态:0=待审核,1=审核通过,2=审核失败") + * @ApiParams(name = "classes_activity_id", type = "int",required=false,description = "课程活动id") + * @ApiReturn({ + * + *}) + */ + public function order_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $auth_status = $this->request->get('auth_status/s', ''); //搜索关键字 + $classes_activity_id = $this->request->get('classes_activity_id/s', ''); //搜索关键字 + + $has_evaluate = $this->request->get('has_evaluate/d', 0); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + $params = [ + "shop_id"=>$this->auth->shop_id, + ]; + try{ + //当前申请状态 + $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_activity_id,$has_evaluate,$auth_status,$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 = "classes_activity_id", type = "int",required=false,description = "课程活动id(非必填)") + * @ApiReturn({ + * + *}) + */ + public function order_count(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $classes_activity_id = $this->request->get('classes_activity_id/s', ''); //搜索关键字 + $params = [ + "shop_id"=>$this->auth->shop_id, + ]; + + try{ + $res = $this->model::orderCount($user_id,$classes_activity_id,$params); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('查询成功', $res); + } + + + + + /** + * @ApiTitle(活动单取消接口) + * @ApiSummary(活动单取消接口(已完成的单无法取消)) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiReturn({ + * + *}) + */ + public function cancel(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->cancel($order_no,0,true,'shop',$this->auth->id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('活动取消成功', $res); + } + + + + + /** + * @ApiTitle(预约审核) + * @ApiSummary(预约审核) + * @ApiMethod(POST) + * @ApiParams(name = "auth_status", type = "string",required=true,description = "审核状态:0=待审核,1=审核通过,2=审核失败") + * @ApiParams(name = "reason", type = "string",required=true,description = "审核不通过原因") + * @ApiParams(name = "id", type = "string",required=true,description = "订单id") + * @ApiReturn({ + * + *}) + */ + public function examine(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $id = $this->request->post('id/s', ''); //订单号 + $reason = $this->request->post('reason/s', ''); //订单号 + $auth_status = $this->request->post('auth_status/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->examine($id,$auth_status,$reason,0,true,'shop',$this->auth->id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('预约审核完成', $res); + } + + + + /** + * @ApiTitle(活动单后台核销接口) + * @ApiSummary(活动单后台核销接口) + * @ApiMethod(POST) + * @ApiParams(name = "ids", type = "string",required=true,description = "订单id") + * @ApiReturn({ + * + *}) + */ + public function verification(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $ids = $this->request->post('ids/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->verification($ids,0,true,'shop',$this->auth->id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('活动核销成功', $res); + } + + + + /** + * @ApiTitle(活动单退款重试) + * @ApiSummary(活动单退款重试) + * @ApiMethod(POST) + * @ApiParams(name = "ids", type = "string",required=true,description = "订单id") + * @ApiReturn({ + * + *}) + */ + public function refund(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $ids = $this->request->post('ids/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->orderRefund($ids,null,'shop',$this->auth->id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('已重新发起退款,如果是第三方支付请等待回调!', $res); + } + + + + + + + + /** + * @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 = "status", type = "string",required=false,description = "订单状态:-3=已取消,0=待支付,2=已报名待审核,3=已预约,4=售后中,5=退款结算中,6=已退款,9=已完成") + * @ApiParams(name = "classes_activity_order_id", type = "int",required=false,description = "课程活动订单id") + * @ApiReturn({ + * + *}) + */ + public function log_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $params=[ +// "shop_id"=>$this->auth->shop_id, + ]; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $classes_activity_order_id = $this->request->get('classes_activity_order_id/s', ''); //搜索关键字 + + $params["keywords"] = $keywords; + $params["status"] = $status; + $params["classes_activity_order_id"] = $classes_activity_order_id; + if(empty($classes_activity_order_id)) $this->apierror( __('课程活动订单id必传')); + + try{ + //当前申请状态 + $res = \app\common\model\school\classes\activity\order\OrderLog::allList($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); + } + + + +} \ No newline at end of file diff --git a/application/manystoreapi/controller/Attachment.php b/application/manystoreapi/controller/Attachment.php index a4832db..1414759 100644 --- a/application/manystoreapi/controller/Attachment.php +++ b/application/manystoreapi/controller/Attachment.php @@ -3,6 +3,7 @@ namespace app\manystoreapi\controller; use app\common\controller\ManystoreApiBase; use app\common\model\ManystoreAttachment; +use think\exception\PDOException; /** * 机构API后台:附件管理接口 @@ -31,6 +32,9 @@ class Attachment extends ManystoreApiBase * @ApiMethod (GET) * @ApiParams (name="category", type="string", required=true, description="附件分类分类标识:category1=非机密类1,category2=非机密类2,cert=证件机密类,code=二维码类,user=用户普通上传") * @ApiParams (name="mimetype", type="string", required=true, description="消息类型image/*=图片,audio/*=音频,video/*=视频,text/*=文档,application/*=应用程序,zip,rar,7z,tar=压缩文件") + * @ApiParams (name="page", type="number", required=true, description="页数") + * @ApiParams (name="limit", type="number", required=true, description="条数") + * @ApiParams (name="keyword", type="number", required=true, description="关键词") */ public function index() { @@ -41,6 +45,18 @@ class Attachment extends ManystoreApiBase $filter = $this->request->request('filter'); $filterArr = $this->request->param(); + $page = $this->request->param("page/d",1); + $limit = $this->request->param("limit/d",10); + $category = $this->request->param("category/s",""); + $keyword = $this->request->param("keyword/s",""); + $where = []; + $wherekeyword =[[]]; + if($category)$where["category"] = $category; + if($keyword){ + $wherekeyword = [ + 'filename', 'like', "%{$keyword}%", + ]; + } if (isset($filterArr['category']) && $filterArr['category'] == 'unclassed') { $filterArr['category'] = ',unclassed'; $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]); @@ -60,14 +76,22 @@ class Attachment extends ManystoreApiBase }; } - list($where, $sort, $order, $offset, $limit) = $this->buildparams(); +// list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + try { + $as = $this->model->getWithAlisaName(); $list = $this->model->with(["user"]) ->where($mimetypeQuery) ->whereRaw("`filename` NOT REGEXP '^[0-9A-Fa-f]{32}'") ->where($where) - ->order($sort, $order) + ->where(...$wherekeyword) + ->order("{$as}.id desc") ->paginate($limit); +// var_dump(111);die; + }catch (PDOException $e){ + var_dump($e->getData());die; + } foreach ($list as $row) { $row->getRelation('user')->visible(['nickname', 'realname', 'mobile', 'avatar']); diff --git a/application/manystoreapi/controller/ClassesLib.php b/application/manystoreapi/controller/ClassesLib.php new file mode 100644 index 0000000..5ec64db --- /dev/null +++ b/application/manystoreapi/controller/ClassesLib.php @@ -0,0 +1,631 @@ +model = new ClassesLibModel; + parent::_initialize(); + +// //判断登录用户是否是员工 +// $this->setUrlLock(); + // 判断员工权限 + $this->check_worker_auth(); + } + + + + + + /** + * + * @ApiTitle( 课程跳转链接) + * @ApiSummary(课程跳转链接) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiReturn({ + * + *}) + */ + public function url($ids = ''){ + $param = $this->request->param(); + if($this->request->isPost()){ + try{ + if(isset($param['ids']))$ids = $param['id']; + //设置模拟资格 + $url = \app\common\model\school\classes\ClassesLib::getPath($ids); + + }catch (\Exception $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess($url); + } + } + + + + + /** + * + * @ApiTitle( 课程微信小程序码) + * @ApiSummary(课程微信小程序码) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiReturn({ + * + *}) + */ + public function miniqrcode($ids = ''){ + $param = $this->request->param(); + try{ + if(isset($param['ids']))$ids = $param['id']; + //设置模拟资格 + $url = \app\common\model\school\classes\ClassesLib::getMiniQrcodeLink($ids); + + }catch (\Exception $e){ + $this->apierror($e->getMessage()); + } + + return $url["response"]; + } + + + + + + + /** + * @ApiTitle(员工课程添加) + * @ApiSummary(员工课程添加) + * @ApiMethod(POST) + * @ApiParams(name = "classes_num", type = "int",required=true,description = "核销次数") + * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架") + * @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id") + * @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型") + * @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接") + * @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签") + * @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接") + * @ApiParams(name = "title", type = "string",required=true,description = "课程标题") + * @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图") + * @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接") + * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内") + * @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ") + * @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置") + * @ApiParams(name = "province", type = "string",required=false,description = "省编号") + * @ApiParams(name = "city", type = "string",required=false,description = "市编号") + * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") + * @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址") + * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址") + * @ApiParams(name = "longitude", type = "string",required=false,description = "经度") + * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度") + * @ApiParams(name = "content", type = "string",required=false,description = "课程详情") + * @ApiParams(name = "notice", type = "string",required=false,description = "课程须知") + * @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费") + * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") + * @ApiReturn({ + * + *}) + */ + public function add(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $params = []; + $params["status"] = $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架 + $params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id + $params["classes_type"] = $this->request->post('classes_type/s', ''); //老师id + $params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', ''); //课程标签 + $params["classes_label_ids"] = $this->request->post('classes_label_ids/s', ''); //课程热门标签 + $params["self_label_tag"] = $this->request->post('self_label_tag/s', ''); //老师id + $params["title"] = $this->request->post('title/s', ''); //老师id + $params["headimage"] = $this->request->post('headimage/s', ''); //老师id + $params["images"] = $this->request->post('images/s', ''); //老师id + $params["type"] = $this->request->post('type/s', ''); //老师id + $params["spec"] = $this->request->post('spec/s', ''); //老师id + $params["classes_num"] = $this->request->post('classes_num/d', 0); //核销次数 + // + $params["address_type"] = $this->request->post('address_type/s', ''); //老师id + $params["province"] = $this->request->post('province/d', 0); //老师id + $params["city"] = $this->request->post('city/d', 0); //老师id + $params["district"] = $this->request->post('district/d', 0); //老师id + $params["address"] = $this->request->post('address/s', ''); //老师id + $params["address_detail"] = $this->request->post('address_detail/s', ''); //老师id + $params["longitude"] = $this->request->post('longitude/s', 0); //老师id + $params["latitude"] = $this->request->post('latitude/s', 0); //老师id + $params["content"] = $this->request->post('content/s', ''); //老师id + $params["notice"] = $this->request->post('notice/s', ''); //老师id + $params["price"] = $this->request->post('price/f', 0); //老师id + $params["selfhot"] = $this->request->post('selfhot/s', ''); //老师id + + + //classes_type + + try{ + $res = $this->model->createClassesByOper($params,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('添加成功', $res); + } + + + + + + + /** + * @ApiTitle(员工课程编辑) + * @ApiSummary(员工课程编辑) + * @ApiMethod(POST) + * @ApiParams(name = "id", type = "string",required=true,description = "课程id") + * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架") + * @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id") + * @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型") + * @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接") + * @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签") + * @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接") + * @ApiParams(name = "title", type = "string",required=true,description = "课程标题") + * @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图") + * @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接") + * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内") + * @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ") + * @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置") + * @ApiParams(name = "province", type = "string",required=false,description = "省编号") + * @ApiParams(name = "city", type = "string",required=false,description = "市编号") + * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") + * @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址") + * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址") + * @ApiParams(name = "longitude", type = "string",required=false,description = "经度") + * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度") + * @ApiParams(name = "content", type = "string",required=false,description = "课程详情") + * @ApiParams(name = "notice", type = "string",required=false,description = "课程须知") + * @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费") + * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") + * @ApiReturn({ + * + *}) + */ + public function edit(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $params = []; + $id = $this->request->post('id/d', 0); + $params["status"] = $this->request->post('status/s', ''); //上架状态:1=上架,2=下架,3=平台下架 + $params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id + $params["classes_type"] = $this->request->post('classes_type/s', ''); //老师id + $params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', ''); //课程标签 + $params["classes_label_ids"] = $this->request->post('classes_label_ids/s', ''); //课程热门标签 + $params["self_label_tag"] = $this->request->post('self_label_tag/s', ''); //老师id + $params["title"] = $this->request->post('title/s', ''); //老师id + $params["headimage"] = $this->request->post('headimage/s', ''); //老师id + $params["images"] = $this->request->post('images/s', ''); //老师id + $params["type"] = $this->request->post('type/s', ''); //老师id + $params["spec"] = $this->request->post('spec/s', ''); //老师id + $params["address_type"] = $this->request->post('address_type/s', ''); //老师id + $params["province"] = $this->request->post('province/d', 0); //老师id + $params["city"] = $this->request->post('city/d', 0); //老师id + $params["district"] = $this->request->post('district/d', 0); //老师id + $params["address"] = $this->request->post('address/s', ''); //老师id + $params["address_detail"] = $this->request->post('address_detail/s', ''); //老师id + $params["longitude"] = $this->request->post('longitude/s', 0); //老师id + $params["latitude"] = $this->request->post('latitude/s', 0); //老师id + $params["content"] = $this->request->post('content/s', ''); //老师id + $params["notice"] = $this->request->post('notice/s', ''); //老师id + $params["price"] = $this->request->post('price/f', 0); //老师id + $params["selfhot"] = $this->request->post('selfhot/s', ''); //老师id + + + //classes_type + + try{ + $res = $this->model->updateClassesByOper($params,$id,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('编辑成功', $res); + } + + + + + + /** + * @ApiTitle(员工课程批量删除) + * @ApiSummary(员工课程批量删除) + * @ApiMethod(POST) + * @ApiParams(name = "ids", type = "string",required=true,description = "需要删除的一组课程id,多值逗号拼接") + * @ApiReturn({ + * + *}) + */ + public function del(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $ids = $this->request->post('ids/s', ''); + + try{ + $res = $this->model->deleteClassesByOper($ids,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess("成功删除{$res}条数据",["delete_number"=>$res]); + } + + + + + /** + * @ApiTitle(课程更改状态) + * @ApiSummary(课程更改状态) + * @ApiMethod(POST) + * @ApiParams(name = "id", type = "string",required=true,description = "需要更改状态的课程id") + * @ApiParams(name = "status", type = "string",required=true,description = "需要更改状态:1=上架,2=下架") + * @ApiReturn({ + * + *}) + */ + public function update_status(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $id = $this->request->post('id/s', ''); + $status = $this->request->post('status/s', ''); + try{ + $res = $this->model->updateStatusByOper($status,$id,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess("状态更改成功",["self"=>$res]); + } + + + + /** + * @ApiTitle(课程详情接口) + * @ApiSummary(课程详情接口) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiReturn({ + + * + *}) + */ + public function detail(){ + $id = $this->request->get('id/d',''); + $user_id = 0; + $user = $this->auth->getUser();//登录用户 +// if($user)$user_id = $user['id']; + if(empty($id)){ + $this->apierror(__('缺少必要参数')); + } + + try { + $res = $this->model->detail($id,$user_id); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['detail' => $res]); + } + + + + + + /** + * @ApiTitle(课程参与者和报名者) + * @ApiSummary(课程参与者和报名者) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiParams(name = "have_real", type = "int",required=true,description = "是否只查真實的 1是 0否") + * @ApiReturn({ unpaid_user_data 参与中 paid_user_data 已报名 }) + */ + public function people(){ + $id = $this->request->get('id/d',''); + $have_real = $this->request->get('have_real/d',''); + $user_id = 0; + $user = $this->auth->getUser();//登录用户 +// if($user)$user_id = $user['id']; + if(empty($id)){ + $this->apierror(__('缺少必要参数')); + } + + try { + $res = $this->model->virtualParticipants($id,$user_id,$have_real); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', $res); + } + + + /** + * @ApiTitle(课程课时规格) + * @ApiSummary(课程课时规格) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiParams(name = "user_id", type = "int",required=true,description = "需要查询是否下单的用户id") + * @ApiReturn({ spec 课时规格 }) + */ + public function spec(){ + $user_id = $this->request->get('user_id/d',0); + $id = $this->request->get('id/d',''); + $user = $this->auth->getUser();//登录用户 + + if(empty($id)){ + $this->apierror(__('缺少必要参数')); + } + + try { + //如果是员工端操作 + if($user_id && $id && $user){ + //判断是否有操作权限 + $classes_lib_ids = (new \app\common\model\school\classes\ClassesLib)->getClassesAuthIds($user['user_id']); + //判断当前订单课程是否在此课程授权范围内 + if(!in_array($id,$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法查看!"); + + } + + + if($user && !$user_id)$user_id = $user['id']; + + + $res = $this->model->spec($id,$user_id); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['spec'=>$res]); + } + + + + + + + /** + * @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 = "hot", type = "string",required=false,description = "状态搜索条件:-1=全部分类,0=非热门分类,1=热门分类") + * @ApiReturn({ + * + *}) + */ + public function cate_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $hot = $this->request->get('hot/s', '-1'); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = Cate::showList($page, $limit,$keywords,$hot); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + + + /** + * @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 = "条数") + * @ApiReturn({ + * + *}) + */ + public function type_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = Type::showList($page, $limit,$keywords); +// 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 = "keywords", type = "string",required=false,description = "搜索关键字") + * @ApiParams(name = "page", type = "string",required=true,description = "页数") + * @ApiParams(name = "limit", type = "string",required=true,description = "条数") + * @ApiReturn({ + * + *}) + */ + public function label_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = Label::showList($page, $limit,$keywords); +// 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 = "keywords", type = "string",required=false,description = "搜索关键字") + * @ApiParams(name = "page", type = "string",required=true,description = "页数") + * @ApiParams(name = "limit", type = "string",required=true,description = "条数") + * @ApiParams(name = "start_time", type = "int",required=false,description = "开始时间10位秒级时间戳") + * @ApiParams(name = "end_time", type = "int",required=false,description = "结束时间10位秒级时间戳") + * @ApiParams(name = "has_shop", type = "int",required=false,description = "是否查机构") + * @ApiParams(name = "is_expire", type = "int",required=false,description = "是否查过期:1只查过期,2只查不过期,0全查") + * @ApiParams(name = "user_id", type = "int",required=false,description = "主讲师用户id") + * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构店铺id") + * @ApiParams(name = "teacher_id", type = "int",required=false,description = "老师id") + * @ApiParams(name = "classes_cate_ids", type = "string",required=false,description = "平台课程分类ids") + * @ApiParams(name = "classes_label_ids", type = "string",required=false,description = "平台课程热门标签ids") + * @ApiParams(name = "self_label_tag", type = "string",required=false,description = "机构特色标签") + * @ApiParams(name = "classes_type", type = "string",required=false,description = "平台课程类型") + * @ApiParams(name = "keyword", type = "string",required=false,description = "关键字搜索") + * @ApiParams(name = "type", type = "string",required=false,description = "地点类型:out=户外,in=室内") + * @ApiParams(name = "address_type", type = "string",required=false,description = "地址类型:1=按机构,2=独立位置") + * @ApiParams(name = "province", type = "string",required=false,description = "省编号") + * @ApiParams(name = "city", type = "string",required=false,description = "市编号") + * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") + * @ApiParams(name = "status", type = "string",required=false,description = "不传则默认查上架的 状态: 1=上架,2=下架,3=平台下架") + * @ApiParams(name = "recommend", type = "string",required=false,description = "平台推荐:0=否,1=是") + * @ApiParams(name = "hot", type = "string",required=false,description = "平台热门:0=否,1=是") + * @ApiParams(name = "new", type = "string",required=false,description = "平台最新:0=否,1=是") + * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") + * @ApiParams(name = "feel", type = "string",required=false,description = "是否免费:0=否,1=是") + * @ApiParams(name = "collect", type = "int",required=false,description = "是否专查我的收藏(需登录):1=是") + * @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先,views=浏览量优先,collect=收藏量优先") + * @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)") + * @ApiParams(name = "latitude", type = "string",required=false,description = "latitude") + * @ApiParams(name = "longitude", type = "string",required=false,description = "longitude") + * @ApiParams(name = "auth_status", type = "string",required=false,description = "审核状态:-1=不计入条件 ,0=待审核,1=审核通过,2=审核失败") + * @ApiReturn({ + * + *}) + */ + public function classes_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + $params =[]; + $params["my_user_id"] = $user_id; + $params["collect"] = $this->request->get('collect/d', 0); //页数 + $params["page"] = $this->request->get('page/d', 1); //页数 + $params["limit"] = $this->request->get('limit/d', 10); //条数 + $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字 + $params["user_id"] = $this->request->get('user_id/d', ''); //主讲师用户id + $params["shop_id"] = $this->request->get('shop_id/d', ''); //机构店铺id + $params["teacher_id"] = $this->request->get('teacher_id/d', ''); //机构店铺id + $params["classes_cate_ids"] = $this->request->get('classes_cate_ids/s', ''); //机构店铺id + $params["classes_label_ids"] = $this->request->get('classes_label_ids/s', ''); //机构店铺id + $params["self_label_tag"] = $this->request->get('self_label_tag/s', ''); //机构店铺id + $params["keyword"] = $this->request->get('keyword/s', ''); //机构店铺id + $params["type"] = $this->request->get('type/s', ''); //机构店铺id + $params["address_type"] = $this->request->get('address_type/s', ''); //机构店铺id + $params["province"] = $this->request->get('province/s', ''); //机构店铺id + + $params["classes_type"] = $this->request->get('classes_type/s', ''); //机构店铺id + + $params["city"] = $this->request->get('city/s', ''); //机构店铺id + $params["district"] = $this->request->get('district/s', ''); //机构店铺id + $params["status"] = $this->request->get('status/s', '-2'); //机构店铺id + $params["recommend"] = $this->request->get('recommend/s', ''); //机构店铺id + $params["hot"] = $this->request->get('hot/s', ''); //机构店铺id + $params["new"] = $this->request->get('new/s', ''); //机构店铺id + $params["selfhot"] = $this->request->get('selfhot/s', ''); //机构店铺id + $params["feel"] = $this->request->get('feel/s', ''); //机构店铺id + + $params["is_expire"] = $this->request->get('is_expire/d', 0); //机构店铺id + + + $params["order"] = $this->request->get('order/s', ''); //机构店铺id + $params["nearby"] = $this->request->get('nearby/s', ''); //机构店铺id + $params["has_shop"] = $this->request->get('has_shop/d', ''); //主讲师用户id + + $params["latitude"] = $this->request->get('latitude/s', ''); //机构店铺id + $params["longitude"] = $this->request->get('longitude/s', ''); //机构店铺id + + + $params["start_time"] = $this->request->get('start_time/d', ''); //主讲师用户id + $params["end_time"] = $this->request->get('end_time/d', ''); //机构店铺id + $params["auth_status"] = $this->request->get('auth_status/d', '-2'); //机构店铺id + + + +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = \app\common\model\school\classes\ClassesLib::getVaildList($params); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + + $this->apierror($e->getMessage()); + } + $this->apisuccess('查询成功', ["list"=>$res]); + } + + + + +} \ No newline at end of file diff --git a/application/manystoreapi/controller/ClassesOrder.php b/application/manystoreapi/controller/ClassesOrder.php index 8900564..0c56273 100644 --- a/application/manystoreapi/controller/ClassesOrder.php +++ b/application/manystoreapi/controller/ClassesOrder.php @@ -105,6 +105,53 @@ class ClassesOrder extends ManystoreApiBase + /** + * @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 = "status", type = "string",required=false,description = "订单状态:-3=已取消,0=待支付,3=使用中,4=售后中,6=已退款,9=已完成") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiReturn({ + * + *}) + */ + public function log_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $params=[ +// "shop_id"=>$this->auth->shop_id, + ]; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); //搜索关键字 + + $params["keywords"] = $keywords; + $params["status"] = $status; + $params["classes_order_id"] = $classes_order_id; + if(empty($classes_order_id)) $this->apierror( __('课程订单id必传')); + + try{ + //当前申请状态 + $res = \app\common\model\school\classes\order\OrderLog::allList($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); + } + + /** diff --git a/application/manystoreapi/controller/Evaluate.php b/application/manystoreapi/controller/Evaluate.php new file mode 100644 index 0000000..1b41391 --- /dev/null +++ b/application/manystoreapi/controller/Evaluate.php @@ -0,0 +1,118 @@ +model = new EvaluateModel; + parent::_initialize(); + + //判断登录用户是否是员工 + } + + + + + /** + * @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 = "my", type = "string",required=false,description = "是否查我的评价(需登录)") + * @ApiParams(name = "classes_lib_id", type = "string",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "string",required=false,description = "课程订单id") + * @ApiParams(name = "teacher_id", type = "string",required=false,description = "老师id") + * @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 evaluate_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + + $params = [ + "shop_id"=>$this->auth->shop_id, + ]; + $my = $this->request->get('my/d', 0); //我的评价 + if($my && $user_id){ + $params['user_id'] = $user_id; + } + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字 + $params["classes_lib_id"] = $this->request->get('classes_lib_id/d', ''); //搜索关键字 + $params["classes_order_id"] = $this->request->get('classes_order_id/d', ''); //搜索关键字 +// $params["shop_id"] = $this->request->get('shop_id/d', ''); //时间 + $params["teacher_id"] = $this->request->get('teacher_id/d', ''); //时间 + $params["time"] = $this->request->get('time/s', ''); //时间 + + try{ + //当前申请状态 + $res = $this->model::evaluateList($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->error(__('缺少必要参数')); + } + + try { + $res = $this->model::detail($id); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['detail' => $res]); + } + + + + +} + diff --git a/application/manystoreapi/controller/HourOrder.php b/application/manystoreapi/controller/HourOrder.php new file mode 100644 index 0000000..dda18da --- /dev/null +++ b/application/manystoreapi/controller/HourOrder.php @@ -0,0 +1,399 @@ +model = new OrderModel; + parent::_initialize(); + + //判断登录用户是否是员工 + $this->setUrlLock(); + // 判断员工权限 + $this->check_worker_auth(); + } + + + + + + + /** + * @ApiTitle( 机构代下预约单) + * @ApiSummary(机构代下预约单) + * @ApiMethod(POST) + * @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id") + * @ApiParams(name = "classes_lib_spec_id", type = "int",required=false,description = "课时规格id") + * @ApiReturn({ + * + *}) + */ + public function add(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $classes_order_id = $this->request->post('classes_order_id/d', 0); //课程id + $classes_lib_spec_id = $this->request->post('classes_lib_spec_id/d', 0); //课程id + +// $order_no = $this->request->post('order_no/s', ''); //订单号 +// $is_compute = $this->request->post('is_compute/d', 1); //是否重新计算并更新缓存 + try{ + + + //记录代下单人信息 + $param = [ + "type" =>'2', + "help_user_id" =>$this->auth->id, + "help_type" => 'shop', + ]; + //确认订单 + $res = $this->model->confirm($this->auth->id,$classes_order_id,null, $classes_lib_spec_id,$param, true); + $remark = "总后台管理员帮忙下课时预约"; + //创建订单 + $result = $this->model->cacheCreateOrder($res['order_no'], $this->auth->id,$remark, true); + + + }catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('预约成功', $result); + } + + + + + + + /** + * @ApiTitle( 机构代修改预约单预约课时) + * @ApiSummary(机构代修改预约单预约课时) + * @ApiMethod(POST) + * @ApiParams(name = "id", type = "int",required=true,description = "预约id") + * @ApiParams(name = "classes_lib_spec_id", type = "int",required=false,description = "课时规格id") + * @ApiReturn({ + * + *}) + */ + public function edit(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $id = $this->request->post('id/d', 0); //课程id + $classes_lib_spec_id = $this->request->post('classes_lib_spec_id/d', 0); //课程id + +// $order_no = $this->request->post('order_no/s', ''); //订单号 +// $is_compute = $this->request->post('is_compute/d', 1); //是否重新计算并更新缓存 + try{ + $result = $this->model->updateClassesSpec($id,$classes_lib_spec_id,0,true,'shop',$this->auth->id,true); + }catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('预约修改成功', $result); + } + + + + + + /** + * @ApiTitle( 机构代取消预约单) + * @ApiSummary(机构代取消预约单) + * @ApiMethod(POST) + * @ApiParams(name = "ids", type = "string",required=true,description = "预约id,多值逗号拼接") + * @ApiReturn({ + * + *}) + */ + public function cancel($ids = "") + { + if (!$this->request->isPost()) { + $this->apierror(__("Invalid parameters")); + } + $ids = $ids ? $ids : $this->request->post("ids/s",""); + if ($ids) { + $pk = $this->model->getPk(); + if($this->shopIdAutoCondition){ + $this->model->where(array('shop_id'=>SHOP_ID)); + } + $list = $this->model->where($pk, 'in', $ids)->select(); + + $count = 0; + + try { + foreach ($list as $k => $v) { + $res = $this->model->cancel($v["id"],0,true,'shop',$this->auth->id,true); + + $count ++; + } + + } catch (PDOException $e) { + + $this->apierror($e->getMessage()); + } catch (\Exception $e) { + + $this->apierror($e->getMessage()); + } + if ($count) { + $this->apisuccess(); + } else { + $this->apierror(__('No rows were deleted')); + } + } + $this->apierror(__('Parameter %s can not be empty', 'ids')); + } + + + + + + /** + * @ApiTitle( 机构代操作:预约课时单审核接口) + * @ApiSummary(预约课时单审核接口) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "预约订单号") + * @ApiParams(name = "auth_status", type = "int",required=true,description = "审核状态:1=审核通过,2=审核失败") + * @ApiParams(name = "reason", type = "string",required=false,description = "审核失败理由") + * @ApiReturn({ + * + *}) + */ + public function examine(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + $auth_status = $this->request->post('auth_status/d', ''); //审核状态 + $reason = $this->request->post('reason/s', ''); //审核失败理由 + try{ + //当前申请状态 + $res = $this->model->examine($order_no,$auth_status,$reason,0,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('预约课时取消成功', $res); + } + + + + + /** + * @ApiTitle( 机构代操作:预约课时单核销完成接口) + * @ApiSummary(预约课时单核销完成接口) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "预约订单号") + * @ApiReturn({ + * + *}) + */ + public function verification(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->verification($order_no,0,true,'shop',$user_id,true); + }catch (\Throwable $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->error(__('缺少必要参数')); + } + + try { + $res = OrderModel::getDetail($id,$this->classes_lib_ids); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['detail' => $res]); + } + + + + + + /** + * @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 = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成") + * @ApiParams(name = "classes_order_id", type = "string",required=false,description = "课程订单id") + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构shopid") + * @ApiParams(name = "start_time", type = "string",required=false,description = "按开始时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") + * @ApiParams(name = "createtime", type = "string",required=false,description = "按创建时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") + * @ApiParams(name = "time", type = "string",required=false,description = "按开始和结束时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") + * @ApiReturn({ + * + *}) + */ + public function order_list() + { + + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字 + $classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字 + $shop_id = $this->request->get('shop_id/d', 0); //搜索关键字 + + $start_time = $this->request->get('start_time/s', ''); //搜索关键字 + $createtime = $this->request->get('createtime/s', ''); //搜索关键字 + $time = $this->request->get('time/s', ''); //搜索关键字 + +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 +// var_dump($this->classes_lib_ids);die; + try{ + //当前申请状态 + $res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$classes_lib_ids,$this->classes_lib_ids,$start_time,$createtime,$time,$shop_id); +// var_dump($this->model->getLastSql());die; +// 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 = "classes_order_id", type = "int",required=true,description = "课程订单id") + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构shopid") + * @ApiReturn({ + * + *}) + */ + public function order_count(){ + + + $classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字 + $classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字 + $shop_id = $this->request->get('shop_id/d', 0); //搜索关键字 + + try{ + $res = $this->model::workCount($classes_lib_ids,$this->classes_lib_ids,$classes_order_id,$shop_id); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('查询成功', $res); + } + + + + + + + /** + * @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 = "status", type = "string",required=false,description = "状态搜索条件:-3=已取消,-1=已报名待审核,0=已预约,3=已完成") + * @ApiParams(name = "auth_status", type = "string",required=false,description = "审核状态:0=待审核,1=审核通过,2=审核失败") + * @ApiParams(name = "classes_hour_order_id", type = "int",required=false,description = "课时预约订单id") + * @ApiReturn({ + * + *}) + */ + public function order_log_list() + { + $user_id = 0; +// $user = $this->auth->getUser();//登录用户 +// if($user)$user_id = $user['user_id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $auth_status = $this->request->get('auth_status/s', ''); //搜索关键字 + + $classes_hour_order_id = $this->request->get('classes_hour_order_id/s', ''); //搜索关键字 + if(!$classes_hour_order_id) $this->apierror('缺少课时预约订单id'); +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = OrderLog::allList($user_id,$page, $limit,$keywords,$status,$auth_status,$classes_hour_order_id); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('查询成功', $res); + } + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/application/manystoreapi/controller/Index.php b/application/manystoreapi/controller/Index.php index 097a0be..d928762 100644 --- a/application/manystoreapi/controller/Index.php +++ b/application/manystoreapi/controller/Index.php @@ -49,6 +49,7 @@ class Index extends ManystoreApiBase "fixedmenu" =>$fixedmenu, "referermenu" =>$referermenu, "title", __('Home'), + "attachmentcategory"=>config("site.attachmentcategory") ]); // } diff --git a/application/manystoreapi/controller/ServiceOrder.php b/application/manystoreapi/controller/ServiceOrder.php new file mode 100644 index 0000000..4c1d9e1 --- /dev/null +++ b/application/manystoreapi/controller/ServiceOrder.php @@ -0,0 +1,218 @@ +model = new OrderModel; + parent::_initialize(); + + //判断登录用户是否是员工 + $this->setUrlLock(); + // 判断员工权限 + $this->check_worker_auth(); + } + + + /** + * @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 = $this->model::getDetail($id,$this->classes_lib_ids); + if(!$res)throw new \Exception('您无操作权限!',40003); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->apisuccess('获取成功', ['detail' => $res]); + } + + + + /** + * @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 = "status", type = "string",required=false,description = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单中,10=售后结单完成,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiParams(name = "classes_order_detail_id", type = "int",required=false,description = "订单课程id") + * @ApiReturn({ + * + *}) + */ + public function order_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); //搜索关键字 + $classes_order_detail_id = $this->request->get('classes_order_detail_id/s', ''); //搜索关键字 + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = $this->model::workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id,$classes_order_detail_id,$classes_lib_id,$this->classes_lib_ids); +// 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 = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiReturn({ + * + *}) + */ + public function order_count(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); + try{ + $res = $this->model::workCount($classes_order_id,$classes_lib_id,$this->classes_lib_ids); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('查询成功', $res); + } + + + + /** + * @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 = "status", type = "string",required=false,description = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单中,10=售后结单完成,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_service_order_id", type = "int",required=false,description = "售后订单id") + * @ApiReturn({ + * + *}) + */ + public function order_log_list() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['user_id']; + $page = $this->request->get('page/d', 0); //页数 + $limit = $this->request->get('limit/d', 0); //条数 + $keywords = $this->request->get('keywords/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_service_order_id = $this->request->get('classes_service_order_id/s', ''); //搜索关键字 + if(!$classes_service_order_id) $this->apierror('售后订单id不能为空'); +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = ServiceOrderLog::workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id,$this->classes_lib_ids); +// 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(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "售后订单id或售后订号") + * @ApiParams(name = "status", type = "string",required=true,description = "yes=同意,no=驳回") + * @ApiParams(name = "price", type = "string",required=false,description = "同意的售后金额") + * @ApiParams(name = "reject_reason", type = "string",required=false,description = "驳回原因") + * @ApiParams(name = "reject_images", type = "string",required=false,description = "(非必填)驳回图片说明:多图逗号拼接") + * @ApiReturn({ + * + *}) + */ + public function shop_confirmation(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + $status = $this->request->post('status/s', 0); //审核状态 + $price = $this->request->post('price/f', 0); + $reject_reason = $this->request->post('reject_reason/s', ''); + $reject_images = $this->request->post('reject_images/s', ''); + + try{ + //当前申请状态 + $res = $this->model->shopConfirmation($order_no,$status,$price,$reject_reason,$reject_images,0,true,'shop',$user_id,true); + }catch (\Throwable $e){ + $this->apierror($e->getMessage()); + } + $this->apisuccess('调用成功', $res); + } + + + + + +} \ No newline at end of file diff --git a/application/manystoreapi/controller/User.php b/application/manystoreapi/controller/User.php index b27dd37..a474ca1 100644 --- a/application/manystoreapi/controller/User.php +++ b/application/manystoreapi/controller/User.php @@ -340,6 +340,8 @@ class User extends ManystoreApiBase * @ApiParams(name = "realname", type = "string",required=false,description = "真实姓名") * @ApiParams(name = "mobile", type = "string",required=false,description = "手机号") * @ApiParams(name = "has_order_user", type = "string",required=false,description = "是否只查下单用户") + * @ApiParams(name = "classes_activity_id", type = "string",required=false,description = "查询的课程活动id") + * @ApiParams(name = "classes_lib_id", type = "string",required=false,description = "查询的课程id") * @ApiReturn({ * *}) @@ -355,6 +357,7 @@ class User extends ManystoreApiBase $params['keywords'] = $this->request->get('keywords/s', ''); //搜索关键字 $params['status'] = $this->request->get('status/s', ''); //搜索关键字 $shop_id = $this->request->get('shop_id/d', ''); //搜索关键字 + if(!$shop_id) $shop_id = $user['shop_id']; $has_order_user = $this->request->get('has_order_user/d', ''); //搜索关键字 $params['nickname'] = $this->request->get('nickname/s', ''); @@ -364,7 +367,8 @@ class User extends ManystoreApiBase $params['mobile'] = $this->request->get('mobile/s', ''); if($params['mobile']) $params['mobile'] = ["LIKE", "%".$params['mobile'] ."%" ]; - + $params['classes_activity_id'] = $this->request->get('classes_activity_id/s', ''); //搜索关键字 + $params['classes_lib_id'] = $this->request->get('classes_lib_id/s', ''); //搜索关键字 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ diff --git a/public/assets/js/backend/style/home_images.js b/public/assets/js/backend/style/home_images.js index abfbfa3..38284ae 100644 --- a/public/assets/js/backend/style/home_images.js +++ b/public/assets/js/backend/style/home_images.js @@ -26,8 +26,45 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, + {field: 'image', title: __('Image'), operate: false, events:{ + 'click .img-center': function (e, value, row, index) { + if(row.showtype == 'image'){ + + var data = []; + value = value === null ? '' : value.toString(); + var arr = value != '' ? value.split(",") : []; + var url; + $.each(arr, function (index, value) { + url = Fast.api.cdnurl(value); + data.push({ + src: url, + thumb: url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle + }); + }); + Layer.photos({ + photos: { + "start": $(this).parent().index(), + "data": data + }, + anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) + }); + + }else{ + + } + + + }, + }, formatter:function (value, row, index) { + if(row.showtype == 'image'){ + return Table.api.formatter.images.call(this, value, row, index); + }else{ + return Table.api.formatter.files.call(this, value, row, index); + } + + }}, {field: 'type', title: __('Type'), searchList: {"in":__('Type in'),"out":__('Type out')}, formatter: Table.api.formatter.normal}, + {field: 'showtype', title: __('Showtype'), searchList: showtypeListJson, formatter: Table.api.formatter.normal}, {field: 'url', title: __('Url'), operate: 'LIKE', formatter: Table.api.formatter.url}, {field: 'weigh', title: __('Weigh'), operate: false}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},