diff --git a/application/admin/controller/school/activity/Activity.php b/application/admin/controller/school/activity/Activity.php
index 9517167..5342500 100644
--- a/application/admin/controller/school/activity/Activity.php
+++ b/application/admin/controller/school/activity/Activity.php
@@ -3,6 +3,12 @@
namespace app\admin\controller\school\activity;
use app\common\controller\Backend;
+use think\Db;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\exception\DbException;
+use think\exception\PDOException;
+use think\exception\ValidateException;
/**
* 活动
@@ -18,10 +24,17 @@ class Activity extends Backend
*/
protected $model = null;
+
+ protected $qSwitch = true;
+ protected $qFields = ["user_id"];
+
+
+
public function _initialize()
{
- parent::_initialize();
+
$this->model = new \app\admin\model\school\activity\Activity;
+ parent::_initialize();
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("cancelTypeList", $this->model->getCancelTypeList());
$this->view->assign("recommendList", $this->model->getRecommendList());
@@ -30,6 +43,13 @@ class Activity extends Backend
$this->view->assign("addTypeList", $this->model->getAddTypeList());
$this->view->assign("feelList", $this->model->getFeelList());
$this->view->assign("authStatusList", $this->model->getAuthStatusList());
+
+
+ $this->view->assign("cateList", $this->model->getCateList());
+ $this->view->assign("cateListJson", json_encode($this->model->getCateList(), JSON_UNESCAPED_UNICODE));
+
+
+
}
@@ -41,6 +61,36 @@ class Activity extends Backend
*/
+ /** 更新或新增后判断
+ * @param $classes_activity_id
+ * @return void
+ */
+ protected function update_classes($classes_activity_id,$params){
+ (new \app\common\model\school\activity\Activity)->update_classes($classes_activity_id);
+
+
+
+ }
+
+
+ /** 更新或新增前判断
+ * @param $classes_activity_id
+ * @return void
+ */
+ protected function update_check(&$params,$row=null){
+ (new \app\common\model\school\activity\Activity)->update_check($params,$row);
+ }
+
+ /** 删除前判断
+ * @param $id
+ * @param $params
+ * @param $row
+ * @return void
+ */
+ protected function updateCheck($id,$params=[],$row=null){
+ (new \app\common\model\school\activity\Activity)->updateCheck($id,$params,$row);
+ }
+
/**
* 查看
*/
@@ -76,4 +126,163 @@ class Activity extends Backend
return $this->view->fetch();
}
+
+ /**
+ * 添加
+ *
+ * @return string
+ * @throws \think\Exception
+ */
+ public function add()
+ {
+ if (false === $this->request->isPost()) {
+ return $this->view->fetch();
+ }
+ $params = $this->request->post('row/a');
+ if (empty($params)) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $params = $this->preExcludeFields($params);
+
+ if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+ $params[$this->dataLimitField] = $this->auth->id;
+ }
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+ $this->model->validateFailException()->validate($validate);
+ }
+ $this->update_check($params,$row=null);
+ $result = $this->model->allowField(true)->save($params);
+ $this->update_classes($this->model["id"],$params);
+
+ $row = $this->model->get($this->model[ "id" ]);
+ if($params["auth_status"] == 1){
+ //审核通过
+ //调用事件
+ $data = ['activity' => $row,"user_id"=>$row["user_id"],"oper_type"=>"admin","oper_id"=>$this->auth->id];
+ \think\Hook::listen('new_activity_auth_success_after', $data);
+
+ }else{
+ //审核不通过
+ //审核通过
+ //调用事件
+ $data = ['activity' => $row,"user_id"=>$row["user_id"],"oper_type"=>"admin","oper_id"=>$this->auth->id];
+ \think\Hook::listen('new_activity_auth_fail_after', $data);
+
+ }
+
+
+ Db::commit();
+ } catch (ValidateException|PDOException|\Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if ($result === false) {
+ $this->error(__('No rows were inserted'));
+ }
+ $this->success();
+ }
+
+ /**
+ * 编辑
+ *
+ * @param $ids
+ * @return string
+ * @throws DbException
+ * @throws \think\Exception
+ */
+ public function edit($ids = null)
+ {
+ $row = $this->model->get($ids);
+ if (!$row) {
+ $this->error(__('No Results were found'));
+ }
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
+ $this->error(__('You have no permission'));
+ }
+ if (false === $this->request->isPost()) {
+ $this->view->assign('row', $row);
+ return $this->view->fetch();
+ }
+ $params = $this->request->post('row/a');
+ if (empty($params)) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $params = $this->preExcludeFields($params);
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+ $row->validateFailException()->validate($validate);
+ }
+ $this->update_check($params,$row);
+ $result = $row->allowField(true)->save($params);
+ $this->update_classes($row["id"],$params);
+
+
+
+ Db::commit();
+ } catch (ValidateException|PDOException|\Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if (false === $result) {
+ $this->error(__('No rows were updated'));
+ }
+ $this->success();
+ }
+
+ /**
+ * 删除
+ *
+ * @param $ids
+ * @return void
+ * @throws DbException
+ * @throws DataNotFoundException
+ * @throws ModelNotFoundException
+ */
+ public function del($ids = null)
+ {
+ if (false === $this->request->isPost()) {
+ $this->error(__("Invalid parameters"));
+ }
+ $ids = $ids ?: $this->request->post("ids");
+ if (empty($ids)) {
+ $this->error(__('Parameter %s can not be empty', 'ids'));
+ }
+ $pk = $this->model->getPk();
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds)) {
+ $this->model->where($this->dataLimitField, 'in', $adminIds);
+ }
+ $list = $this->model->where($pk, 'in', $ids)->select();
+ foreach ($list as $item) {
+ $this->updateCheck($item->id);
+ }
+ $count = 0;
+ Db::startTrans();
+ try {
+ foreach ($list as $item) {
+ $count += $item->delete();
+ }
+ Db::commit();
+ } catch (PDOException|Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if ($count) {
+ $this->success();
+ }
+ $this->error(__('No rows were deleted'));
+ }
+
}
diff --git a/application/admin/controller/school/activity/order/SettleLog.php b/application/admin/controller/school/activity/order/SettleLog.php
index 4d25e3b..2c19d63 100644
--- a/application/admin/controller/school/activity/order/SettleLog.php
+++ b/application/admin/controller/school/activity/order/SettleLog.php
@@ -51,7 +51,7 @@ class SettleLog extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
- ->with(['order','log','user','third'])
+ ->with(['order','log','touser','payuser'])
->where($where)
->order($sort, $order)
->paginate($limit);
@@ -60,8 +60,8 @@ class SettleLog extends Backend
$row->getRelation('order')->visible(['order_no']);
$row->getRelation('log')->visible(['id','price']);
- $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']);
- $row->getRelation('third')->visible(['openname']);
+ $row->getRelation('touser')->visible(['nickname','realname','mobile','avatar']);
+ $row->getRelation('payuser')->visible(['nickname','realname','mobile','avatar']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
diff --git a/application/admin/model/school/activity/Activity.php b/application/admin/model/school/activity/Activity.php
index ddfb72c..9db30fa 100644
--- a/application/admin/model/school/activity/Activity.php
+++ b/application/admin/model/school/activity/Activity.php
@@ -40,7 +40,11 @@ class Activity extends Model
'auth_time_text',
'canceltime_text'
];
-
+
+
+ public function getCateList(){
+ return \app\admin\model\school\activity\Cate::column("name", 'id');
+ }
protected static function init()
{
@@ -232,7 +236,7 @@ class Activity extends Model
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
diff --git a/application/admin/model/school/activity/order/Order.php b/application/admin/model/school/activity/order/Order.php
index e112dea..bbac747 100644
--- a/application/admin/model/school/activity/order/Order.php
+++ b/application/admin/model/school/activity/order/Order.php
@@ -2,6 +2,7 @@
namespace app\admin\model\school\activity\order;
+use app\admin\model\school\activity\Activity;
use think\Model;
use traits\model\SoftDelete;
@@ -193,18 +194,18 @@ class Order extends Model
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function activity()
{
- return $this->belongsTo('app\admin\model\school\Activity', 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function detail()
{
- return $this->belongsTo('Detail', 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/model/school/activity/order/OrderCode.php b/application/admin/model/school/activity/order/OrderCode.php
index 1593ee4..ee91bd2 100644
--- a/application/admin/model/school/activity/order/OrderCode.php
+++ b/application/admin/model/school/activity/order/OrderCode.php
@@ -59,12 +59,12 @@ class OrderCode extends Model
public function order()
{
- return $this->belongsTo('app\admin\model\school\activity\Order', 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'verification_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'verification_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/model/school/activity/order/OrderDetail.php b/application/admin/model/school/activity/order/OrderDetail.php
index 13fbb6b..9569b76 100644
--- a/application/admin/model/school/activity/order/OrderDetail.php
+++ b/application/admin/model/school/activity/order/OrderDetail.php
@@ -2,6 +2,7 @@
namespace app\admin\model\school\activity\order;
+use app\admin\model\school\activity\Activity;
use think\Model;
use traits\model\SoftDelete;
@@ -164,18 +165,18 @@ class OrderDetail extends Model
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function order()
{
- return $this->belongsTo('app\admin\model\school\activity\Order', 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function activity()
{
- return $this->belongsTo('app\admin\model\school\Activity', 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/model/school/activity/order/SettleLog.php b/application/admin/model/school/activity/order/SettleLog.php
index b759737..101ac8a 100644
--- a/application/admin/model/school/activity/order/SettleLog.php
+++ b/application/admin/model/school/activity/order/SettleLog.php
@@ -2,6 +2,7 @@
namespace app\admin\model\school\activity\order;
+use app\admin\model\user\withdrawal\UserwithdrawalLog;
use think\Model;
use traits\model\SoftDelete;
@@ -85,24 +86,24 @@ class SettleLog extends Model
public function order()
{
- return $this->belongsTo('app\admin\model\school\activity\Order', 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function log()
{
- return $this->belongsTo('app\admin\model\user\withdrawal\Log', 'withdrawal_log_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo(UserwithdrawalLog::class, 'withdrawal_log_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
- public function user()
+ public function touser()
{
- return $this->belongsTo('app\admin\model\User', 'to_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'to_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
- public function third()
+ public function payuser()
{
- return $this->belongsTo('app\admin\model\Third', 'pay_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'pay_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/model/user/withdrawal/Userwithdrawal.php b/application/admin/model/user/withdrawal/Userwithdrawal.php
index c76f5fd..de601e1 100644
--- a/application/admin/model/user/withdrawal/Userwithdrawal.php
+++ b/application/admin/model/user/withdrawal/Userwithdrawal.php
@@ -39,6 +39,6 @@ class Userwithdrawal extends Model
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/model/user/withdrawal/UserwithdrawalLog.php b/application/admin/model/user/withdrawal/UserwithdrawalLog.php
index f29afa9..191a92b 100644
--- a/application/admin/model/user/withdrawal/UserwithdrawalLog.php
+++ b/application/admin/model/user/withdrawal/UserwithdrawalLog.php
@@ -100,6 +100,6 @@ class UserwithdrawalLog extends Model
public function user()
{
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
diff --git a/application/admin/view/school/activity/activity/add.html b/application/admin/view/school/activity/activity/add.html
index 493521c..e3167d2 100644
--- a/application/admin/view/school/activity/activity/add.html
+++ b/application/admin/view/school/activity/activity/add.html
@@ -3,7 +3,13 @@
diff --git a/application/api/controller/school/Activity.php b/application/api/controller/school/Activity.php
index a8dd27a..eb4c4f9 100644
--- a/application/api/controller/school/Activity.php
+++ b/application/api/controller/school/Activity.php
@@ -6,7 +6,7 @@ use app\common\model\school\classes\ActivityDemo;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\Teacher as Teachermodel;
/**
- * 活动接口
+ * 活动接口(已废弃)
*/
class Activity extends Base
{
diff --git a/application/api/controller/school/NewActivity.php b/application/api/controller/school/NewActivity.php
new file mode 100644
index 0000000..41dc0b6
--- /dev/null
+++ b/application/api/controller/school/NewActivity.php
@@ -0,0 +1,297 @@
+model = new \app\common\model\school\activity\Activity();
+ 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 = "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 = "my", type = "string",required=true,description = "是否查自己(需登录) 1是 0否")
+ * @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 = "sign_start_time", type = "int",required=false,description = "报名开始时间10位秒级时间戳")
+ * @ApiParams(name = "sign_end_time", type = "int",required=false,description = "报名结束时间10位秒级时间戳")
+ * @ApiParams(name = "auth_status", type = "int",required=false,description = "审核状态:0=待审核,1=审核通过,2=审核不通过 ,不传查所有,可按多值逗号拼接")
+ * @ApiParams(name = "keyword", type = "string",required=false,description = "关键字搜索")
+ * @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=待开始,4=进行中,5=已结束,-1=已取消 ,不传查所有,可按多值逗号拼接")
+ * @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=平台最新优先,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")
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function activity_list()
+ {
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+ $params =[];
+ $params["my"] = $this->request->get('my/d', 0); //机构店铺id
+ $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["shop_id"] = $this->request->get('shop_id/d', ''); //机构店铺id
+
+ $params["keyword"] = $this->request->get('keyword/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["is_sign_expire"] = $this->request->get('is_sign_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["sign_start_time"] = $this->request->get('sign_start_time/d', ''); //主讲师用户id
+ $params["sign_end_time"] = $this->request->get('sign_end_time/d', ''); //机构店铺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/s', ''); //机构店铺id
+
+
+
+// $type = $this->request->get('type/s', ''); //筛选学员和教练单
+
+ try{
+ //当前申请状态
+ $res = $this->model::getVaildList($params);
+// if($user_id =='670153'){
+// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
+// }
+ }catch (\Exception $e){
+
+ $this->error($e->getMessage());
+ }
+ $this->success('查询成功', ["list"=>$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->error(__('缺少必要参数'));
+ }
+
+ try {
+ $res = $this->model->detail($id,$user_id);
+ } catch (\Exception $e){
+// Log::log($e->getMessage());
+ $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
+ }
+ $this->success('获取成功', ['detail' => $res]);
+ }
+
+
+
+
+ /**
+ * @ApiTitle( 设置活动收藏和取消收藏)
+ * @ApiSummary(设置活动收藏和取消收藏)
+ * @ApiMethod(POST)
+ * @ApiParams(name = "id", type = "int",required=true,description = "活动id")
+ * @ApiParams(name = "is_collect", type = "int",required=true,description = "收藏操作:0取消收藏,1收藏")
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function collect(){
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+
+ $id = $this->request->post('id/d', 0); //搜索关键字
+ $collect = $this->request->post('is_collect/d', 0); //搜索关键字
+
+ try{
+ $res = $this->model->collect($id,$user_id,$collect,'user',$user_id,true);
+ }catch (\Throwable $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('查询成功', $res);
+ }
+
+
+
+
+
+ /**
+ * @ApiTitle(活动添加)
+ * @ApiSummary(活动添加)
+ * @ApiMethod(POST)
+ * @ApiParams(name = "cate_ids", type = "string",required=true,description = "平台分类ids 多值逗号拼接")
+ * @ApiParams(name = "title", type = "string",required=true,description = "标题")
+ * @ApiParams(name = "sign_time", type = "string",required=true,description = "报名区间示例: 2025-04-08 00:01:00 - 2025-04-08 15:29:00")
+ * @ApiParams(name = "time", type = "string",required=true,description = "活动区间示例: 2025-04-09 00:01:00 - 2025-04-09 15:29:00")
+ * @ApiParams(name = "images", type = "string",required=true,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 = "price", type = "string",required=false,description = "报名单价 0为免费")
+ * @ApiParams(name = "stock", type = "string",required=false,description = "活动限制人数")
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function add(){
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+ $params = [];
+ $params["user_id"] = $user_id; //老师id
+ $params["cate_ids"] = $this->request->post('cate_ids/s', ''); //课程标签
+
+ $params["title"] = $this->request->post('title/s', ''); //老师id
+ $params["images"] = $this->request->post('images/s', ''); //老师id
+
+ $params["stock"] = $this->request->post('stock/d', 0); //核销次数
+ //
+
+
+ $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["price"] = $this->request->post('price/f', 0); //老师id
+
+
+ $params["sign_time"] = $this->request->post('sign_time/s', 0);
+ $params["time"] = $this->request->post('time/s', 0);
+
+
+ //classes_type
+
+ try{
+ $res = $this->model->add($params,$user_id,'user',$user_id,true);
+ }catch (\Throwable $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('添加成功', $res);
+ }
+
+}
+
diff --git a/application/common/hooks.php b/application/common/hooks.php
index 6288a59..e1ed337 100644
--- a/application/common/hooks.php
+++ b/application/common/hooks.php
@@ -241,6 +241,33 @@ $helpHooks = [
+
+//新活动事件钩子
+$newactivityHooks = [
+ // 订单创建
+ 'new_activity_auth_need_after' => [ // 活动审核提交
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+ 'new_activity_auth_success_after' => [ // 活动审核通过后
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+ 'new_activity_auth_fail_after' => [ // 活动审核失败后
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+ 'new_activity_view_after' => [ // 活动触发浏览后
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+ 'new_activity_collect_success_after' => [ // 活动收藏后
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+ 'new_activity_collect_cancel_after' => [ // 活动取消收藏后
+ 'app\\common\\listener\\activity\\ActivityHook'
+ ],
+
+];
+
+
+
//
//if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) {
// $defaultHooks = array_merge_recursive($defaultHooks, $commissionHooks);
@@ -256,6 +283,9 @@ $defaultHooks = array_merge_recursive($defaultHooks, $activityOrderHooks);
$defaultHooks = array_merge_recursive($defaultHooks, $helpHooks);
+$defaultHooks = array_merge_recursive($defaultHooks, $newactivityHooks);
+
+
return $defaultHooks;
diff --git a/application/common/listener/activity/ActivityHook.php b/application/common/listener/activity/ActivityHook.php
new file mode 100644
index 0000000..ff50916
--- /dev/null
+++ b/application/common/listener/activity/ActivityHook.php
@@ -0,0 +1,88 @@
+ $activity,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+//访问记录
+ Visit::create([
+ "classes_lib_id"=>0,
+ "classes_activity_id"=>$activity["id"],
+// "shop_id"=>$activity["shop_id"],
+ "status"=>'2',
+ "user_id"=>$user_id,
+ ]);
+ }
+
+
+
+ public function newActivityCollectSuccessAfter(&$params)
+ {
+ ['activity' => $activity,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+
+ }
+
+ public function newActivityCollectCancelAfter(&$params)
+ {
+ ['activity' => $activity,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+
+ }
+
+
+
+ public function newActivityAuthNeedAfter(&$params)
+ {
+ ['activity' => $activity,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+
+
+ //课程推送给老师
+
+ $mini_type = "activity_apply";
+
+ $to_id = $user_id;
+ $status ="activity";
+
+ $params=[
+ "event"=>"new_activity_auth_need_after",
+ "activity_id"=>$activity["id"],
+ ];
+
+
+ $param = [
+ "title" => $activity['title'],
+ "address"=>$activity["address"]."(".$activity["address_detail"].")",
+ "price" => $activity["price"],
+ "start_time" => date("Y-m-d H:i",$activity["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
+ "end_time" => date("Y-m-d H:i",$activity["end_time"]),
+ "sign_start_time" => date("Y-m-d H:i",$activity["sign_start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
+ "sign_end_time" => date("Y-m-d H:i",$activity["sign_end_time"]),
+ "reason" => $activity['reason'],
+ ];
+
+ //发给用户
+ (new MessageConfig)
+ ->setTemplate($params["event"])
+ ->setTemplateData($param)
+ ->setToUid($to_id)
+ ->setMessageStatus($status)
+ ->setMessageMiniType($mini_type)
+ ->setMessageParams($params)
+ ->sendMessage();
+
+
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/common/model/school/activity/Activity.php b/application/common/model/school/activity/Activity.php
new file mode 100644
index 0000000..7c3a865
--- /dev/null
+++ b/application/common/model/school/activity/Activity.php
@@ -0,0 +1,1125 @@
+= 1000;
+ $distance_text = round(($distance / 1000), 2) . 'km';
+ break;
+ default :
+ $distance_text = $distance . 'm';
+ break;
+
+ }
+
+ return $distance_text;
+ }
+
+
+ protected static function init()
+ {
+ self::afterInsert(function ($row) {
+ if (!$row['weigh']) {
+ $pk = $row->getPk();
+ $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+ }
+ });
+ }
+
+
+ public function getStatusList()
+ {
+ return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5'), '-1' => __('Status -1')];
+ }
+
+ public function getCancelTypeList()
+ {
+ return ['1' => __('Cancel_type 1'), '2' => __('Cancel_type 2')];
+ }
+
+ public function getRecommendList()
+ {
+ return ['0' => __('Recommend 0'), '1' => __('Recommend 1')];
+ }
+
+ public function getHotList()
+ {
+ return ['0' => __('Hot 0'), '1' => __('Hot 1')];
+ }
+
+ public function getNewList()
+ {
+ return ['0' => __('New 0'), '1' => __('New 1')];
+ }
+
+ public function getAddTypeList()
+ {
+ return ['1' => __('Add_type 1'), '2' => __('Add_type 2')];
+ }
+
+ public function getFeelList()
+ {
+ return ['0' => __('Feel 0'), '1' => __('Feel 1')];
+ }
+
+ public function getAuthStatusList()
+ {
+ return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
+ }
+
+
+ public function getStartTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['start_time']) ? $data['start_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getEndTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['end_time']) ? $data['end_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getSignStartTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['sign_start_time']) ? $data['sign_start_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getSignEndTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['sign_end_time']) ? $data['sign_end_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getCancelTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['cancel_type']) ? $data['cancel_type'] : '');
+ $list = $this->getCancelTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getRecommendTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['recommend']) ? $data['recommend'] : '');
+ $list = $this->getRecommendList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getHotTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : '');
+ $list = $this->getHotList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getNewTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['new']) ? $data['new'] : '');
+ $list = $this->getNewList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getAddTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['add_type']) ? $data['add_type'] : '');
+ $list = $this->getAddTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getFeelTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['feel']) ? $data['feel'] : '');
+ $list = $this->getFeelList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getAuthStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : '');
+ $list = $this->getAuthStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getAuthTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_time']) ? $data['auth_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getCanceltimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setStartTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setEndTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setSignStartTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setSignEndTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setAuthTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setCanceltimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function admin()
+ {
+ return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ /** 更新或新增后判断
+ * @param $classes_activity_id
+ * @return void
+ */
+ public function update_classes($classes_activity_id){
+
+ }
+
+
+ /** 更新或新增前判断
+ * @param $classes_activity_id
+ * @return void
+ */
+ public function update_check(&$params,$row=null){
+
+
+
+
+
+
+
+
+
+
+ if($row){
+ //统一时间格式成时间戳
+ if( is_string($row["start_time"]))$row["start_time"]=strtotime($row["start_time"]);
+ if( is_string($row["end_time"]))$row["end_time"]=strtotime($row["end_time"]);
+ if( is_string($row["sign_start_time"]))$row["sign_start_time"]=strtotime($row["sign_start_time"]);
+ if( is_string($row["sign_end_time"]))$row["sign_end_time"]=strtotime($row["sign_end_time"]);
+ }
+
+
+
+//开始和结束时间不能为空
+ $time = $params["time"];
+
+ if(empty($time))throw new \Exception("{$params["title"]}请选择开始和结束时间".$time);
+ $split_line = " - ";
+ $time_arr = explode($split_line,$time);
+ $params["start_time"] = $time_arr[0] ;
+ $params["end_time"] = $time_arr[1];
+ unset($params["time"]);
+
+ $start_time = $params["start_time"];
+ $end_time = $params["end_time"];
+
+ if(empty($start_time) || empty($end_time)){
+ throw new \Exception("{$params["title"]}请选择开始和结束时间".$time);
+ }
+ //转化时间戳
+ $start_time = $params["start_time"] && !is_numeric($params["start_time"]) ? strtotime($params["start_time"]) : $params["start_time"];
+ $end_time = $params["end_time"] && !is_numeric($params["end_time"]) ? strtotime($params["end_time"]) : $params["end_time"];
+ //结束时间不能小于开始时间
+ if($end_time<=$start_time){
+ throw new \Exception("{$params["title"]}结束时间不能小于开始时间");
+ }
+
+
+
+
+
+
+ //开始和结束时间不能为空
+ $time = $params["sign_time"];
+
+ if(empty($time))throw new \Exception("{$params["title"]}请选择报名开始和结束时间".$time);
+ $split_line = " - ";
+ $time_arr = explode($split_line,$time);
+ $params["sign_start_time"] = $time_arr[0] ;
+ $params["sign_end_time"] = $time_arr[1];
+ unset($params["sign_time"]);
+
+ $sign_start_time = $params["sign_start_time"];
+ $sign_end_time = $params["sign_end_time"];
+
+ if(empty($sign_start_time) || empty($sign_end_time)){
+ throw new \Exception("{$params["title"]}请选择报名开始和结束时间".$time);
+ }
+ //转化时间戳
+ $sign_start_time = $params["sign_start_time"] && !is_numeric($params["sign_start_time"]) ? strtotime($params["sign_start_time"]) : $params["sign_start_time"];
+ $sign_end_time = $params["sign_end_time"] && !is_numeric($params["sign_end_time"]) ? strtotime($params["sign_end_time"]) : $params["sign_end_time"];
+ //结束时间不能小于开始时间
+ if($sign_end_time<=$sign_start_time){
+ throw new \Exception("{$params["title"]}报名结束时间不能小于开始时间");
+ }
+
+
+ //两个时间区间段之间不能有任何交集 $start_time $end_time ,$sign_start_time $sign_end_time
+ //直接判断两个时间段之间是否有交集:分几种情况:1.两个时间段有交集 2.两个时间段没有交集 3.第一个时间段在第二个时间段内 4.第二个时间段在第一个时间段内 只有情况2合理
+ if(($start_time<=$sign_start_time && $sign_start_time<=$end_time) ||
+ ($start_time<=$sign_end_time && $sign_end_time<=$end_time) ||
+ ($sign_start_time<=$start_time && $end_time<=$sign_end_time) ||
+ ($sign_start_time>=$start_time && $sign_end_time<=$end_time)){
+ throw new \Exception("{$params["title"]}报名时间段和开始时间段有交叉请修改");
+ }
+
+ //报名时间必须早于开始时间
+ if($sign_start_time>$start_time){
+ throw new \Exception("{$params["title"]}报名时间必须早于开始时间");
+ }
+ //新增时,报名时间需晚于当前时间
+ $now_time = time();
+ if(!$row && $now_time>$sign_start_time){
+ throw new \Exception("{$params["title"]}报名时间必须是未来时间!");
+ }
+
+
+
+ $rule = [
+ 'user_id'=>'require',
+ 'title'=>'require',
+ 'images'=>'require',
+// 'headimage' => 'require',
+ 'address' => 'require',
+ 'address_detail' => 'require',
+ 'longitude' => 'require',
+ 'latitude' => 'require',
+// 'province' => 'require',
+// 'city' => 'require',
+// 'district' => 'require',
+// 'address_city' => 'require',
+// 'type' => 'require',
+ 'stock' => 'require',
+// 'address_type' => 'require',
+ 'content' => 'require',
+ 'cate_ids' => 'require',
+ 'price' => 'require',
+
+
+ 'start_time' => 'require',
+ 'end_time' => 'require',
+ 'sign_start_time' => 'require',
+ 'sign_end_time' => 'require',
+
+ ];
+
+
+ $rule_msg = [
+ "user_id.require"=>'发布用户必填',
+ "title.require"=>'标题必填',
+ "images.require"=>'轮播图必填',
+// "headimage.require"=>'课程头图必填',
+
+ 'address.require' => '地址必填',
+ 'address_detail.require' => '详细地址必填',
+ 'longitude.require' => '经度必填',
+ 'latitude.require' => '纬度必填',
+// 'province.require' => '省编号必填',
+// 'city.require' => '市编号必填',
+// 'district.require' => '县区编号必填',
+//
+// 'address_city.require' => '城市选择必填',
+// 'type.require' => '地点类型必填',
+ 'stock.require'=> '活动限制人数必填',
+// 'address_type.require'=> '地址类型必填',
+ 'content.require'=> '课程详情必填',
+ 'cate_ids.require'=> '平台分类必填',
+ 'price.require'=> '售价必填',
+
+
+
+ 'start_time.require' => '活动开始时间必填',
+ 'end_time.require' => '活动结束时间必填',
+ 'sign_start_time.require' => '报名开始时间必填',
+ 'sign_end_time.require' => '报名结束时间必填',
+
+
+ ];
+
+ self::check($params,$rule,$rule_msg);
+
+
+
+
+
+
+ //如果价格为零,记录免费状态
+ if($params["price"]==0){
+ $params["feel"] = '1';
+ }else{
+ $params["feel"] = '0';
+ }
+
+ $now_time = time();
+ //根据时间区间,设定录入的活动初始状态:1=未开始,2=报名中,3=待开始,4=进行中,5=已结束
+ //时间在报名开始时间之前为1=未开始
+ //时间在报名区间之内为2=报名中
+ //时间在开始时间之前,在报名结束时间之后为3=待开始
+ //时间在开始时间之后,在结束时间之前为4=进行中
+ //时间在结束时间之后为5=已结束
+ //已取消则不更新状态
+
+ if(!$row || $row["status"]!='-1'){
+ if($now_time<$sign_start_time){
+ $params["status"] = '1';
+ } else if($now_time>=$sign_start_time && $now_time<=$sign_end_time){
+ $params["status"] = '2';
+ } else if($now_time>$sign_end_time && $now_time<$start_time){
+ $params["status"] = '3';
+ } else if($now_time>=$start_time && $now_time<=$end_time){
+ $params["status"] = '4';
+ } else if($now_time>$end_time){
+ $params["status"] = '5';
+ }
+ }
+
+ if(isset($params["auth_status"])){
+ if(!in_array($params["auth_status"],[1,2])) throw new \Exception("{$params["title"]}请填写审核结果");
+ $params["auth_time"] = time();
+ if($params["auth_status"] == 2 && empty($params["reason"])) throw new \Exception("{$params["title"]}请填写审核失败原因");
+
+ //后台新增: 新增审核失败,状态则为已取消
+ if($params["auth_status"] == 2){
+
+ $params["status"] = '-1';
+ $params["cancel_type"] = '1';
+ if(!$row){
+ //新增审核
+ }else{
+ //编辑审核
+ if($row["auth_status"] != 0 && $row["auth_status"] != $params["auth_status"]){
+ throw new \Exception("{$params["title"]}您已审核不允许修改审核结果");
+ }
+ }
+
+ }
+ $auth = \app\admin\library\Auth::instance();
+ //审核id为后台登录id
+ $params["admin_id"] = $auth->id;
+ }else{
+ //前台提交
+ $params["auth_status"] = 0;
+
+
+ }
+
+
+ //判断新增身份
+ if(!$row){
+ if(isset($params["auth_status"])){
+ //总后台
+ $params["add_type"] = '2';
+ $params["add_id"] = $params["admin_id"];
+ }else{
+ //用户
+ $params["add_type"] = '1';
+ $params["add_id"] = $params["user_id"];
+
+ }
+ }
+
+
+
+ if(!isset($params["auth_status"]) &&$row){
+ //用户端不允许修改
+ throw new \Exception("{$params["title"]}审核通过的活动只允许手动关闭,不允许修改!");
+ }
+
+
+
+
+ }
+
+ /** 删除前判断
+ * @param $id
+ * @param $params
+ * @param $row
+ * @return void
+ */
+ public function updateCheck($id,$params=[],$row=null){
+
+ }
+
+
+
+ /**
+ * 获取所有活动列表
+ */
+ public static function getVaildList($params) {
+ extract($params);
+ $a = (new self)->getWithAlisaName().'.';
+ $with = ['user'];
+// if (isset($has_shop) && $has_shop) {
+// $with[] = 'shop';
+// }
+
+
+
+
+
+ $cate_list = Cate::where("status",'1')->column("name","id");
+// $label_list = Label::where("status",'1')->column("name","id");
+// $type_list = Type::where("status",'1')->column("name","id");
+ $selfetch = self::with($with);
+
+
+
+ $order = $order?? 'normal';
+ $per_page = $limit ?? 10;
+
+
+ $field = "{$a}start_time,{$a}end_time,{$a}sign_start_time,{$a}sign_end_time,{$a}id,{$a}user_id,{$a}title,{$a}images,{$a}province,{$a}city,{$a}district,{$a}address,{$a}address_detail,{$a}longitude,{$a}latitude,{$a}sale,{$a}stock,{$a}price,{$a}status,{$a}weigh,{$a}recommend,{$a}hot,{$a}new,{$a}cancel_type,{$a}createtime,{$a}feel,{$a}sign_num,{$a}verification_num,{$a}views,{$a}auth_status,{$a}reason,{$a}auth_time";
+
+ //得到距离
+ if (isset($latitude) && isset($longitude) && $latitude && $longitude) {
+ $field .= ', '.getDistanceBuilder($latitude, $longitude,$a);
+ }else{
+ $field .= ', 0 as distance';
+ }
+
+ //得到每个
+
+
+ $selfetch = $selfetch->field($field);
+ if (isset($keywords) && $keywords) {
+ $selfetch = $selfetch->where("{$a}title|{$a}address|{$a}address_detail|{$a}address_city", 'like', '%' . $keywords . '%');
+ }
+
+
+ if(isset($start_time) && isset($end_time) && ($end_time || $start_time)) {
+ if($start_time){
+ $selfetch = $selfetch->where("{$a}start_time", '>=', $start_time);
+ }
+ if($end_time){
+ $selfetch = $selfetch->where("{$a}end_time", '<=', $end_time);
+ }
+ }
+
+
+ if(isset($sign_start_time) && isset($sign_end_time) && ($sign_end_time || $sign_start_time)) {
+ if($sign_start_time){
+ $selfetch = $selfetch->where("{$a}sign_start_time", '>=', $sign_start_time);
+ }
+ if($sign_end_time){
+ $selfetch = $selfetch->where("{$a}sign_end_time", '<=', $sign_end_time);
+ }
+ }
+
+
+
+ // is_expire 是否查过期:1只查过期,2只查不过期,0全查
+ if(isset($is_expire) && $is_expire) {
+ if($is_expire == 1){
+ $selfetch = $selfetch->where("{$a}end_time", '<', time());
+ }else{
+ $selfetch = $selfetch->where("{$a}end_time", '>=', time());
+ }
+
+ }
+
+
+
+// if (isset($manystore_id) && $manystore_id) {
+// $selfetch = $selfetch->where("{$a}manystore_id", 'in', ''.$manystore_id);
+// }
+//
+// if (isset($shop_id) && $shop_id) {
+// $selfetch = $selfetch->where("{$a}shop_id", 'in', ''.$shop_id);
+// }
+
+ if (isset($user_id) && $user_id) {
+ $selfetch = $selfetch->where("{$a}user_id", 'in', ''.$user_id);
+ }
+
+ if (isset($my) && $my && isset($my_user_id) && $my_user_id) {
+ $selfetch = $selfetch->where("{$a}user_id", 'in', ''.$my_user_id);
+ }
+
+
+
+// if (isset($teacher_id) && $teacher_id) {
+// $selfetch = $selfetch->where("{$a}teacher_id", 'in', ''.$teacher_id);
+// }
+
+// if (isset($type) && $type) {
+// $selfetch = $selfetch->where("{$a}type", 'in', ''.$type);
+// }
+
+// if (isset($address_type) && $address_type) {
+// $selfetch = $selfetch->where("{$a}address_type", 'in', ''.$address_type);
+// }
+
+
+ if (isset($recommend) && $recommend) {
+ $selfetch = $selfetch->where("{$a}recommend", 'in', ''.$recommend);
+ }
+
+
+ if (isset($hot) && $hot) {
+ $selfetch = $selfetch->where("{$a}hot", 'in', ''.$hot);
+ }
+
+
+ if (isset($new) && $new) {
+ $selfetch = $selfetch->where("{$a}new", 'in', ''.$new);
+ }
+
+ if (isset($feel) && $feel) {
+ $selfetch = $selfetch->where("{$a}feel", 'in', ''.$feel);
+ }
+
+// //设置订单信息
+ if(isset($auth_status) && $auth_status !=='' && $auth_status !==null){
+ $selfetch = $selfetch->where("{$a}auth_status", 'in', ''.$auth_status);
+ }
+
+ //设置订单信息
+ if(isset($status) && $status !=='' && $status !==null){
+ $selfetch = $selfetch->where("{$a}status", 'in', ''.$status);
+ }
+
+
+
+ //区域搜索
+ if (isset($province) && $province) {
+ $selfetch = $selfetch->where("{$a}province", 'in', ''.$province);
+ }
+
+
+ if (isset($city) && $city) {
+ $selfetch = $selfetch->where("{$a}city", 'in', ''.$city);
+ }
+
+ if (isset($district) && $district) {
+ $selfetch = $selfetch->where("{$a}district", 'in', ''.$district);
+ }
+
+
+
+
+
+
+
+
+
+
+// if (isset($self_label_tag) && $self_label_tag) {
+// $self_label_tag = implode("|",explode(',',$self_label_tag));
+// $selfetch = $selfetch->whereRaw(" {$a}self_label_tag REGEXP '({$self_label_tag})'");
+// }
+//
+// if (isset($classes_type) && $classes_type) {
+// $classes_type = implode("|",explode(',',$classes_type));
+// $selfetch = $selfetch->whereRaw(" {$a}classes_type REGEXP '({$classes_type})'");
+// }
+
+
+
+
+ if (isset($cate_ids) && $cate_ids) {
+ $cate_ids = implode("|",explode(',',$cate_ids));
+ $selfetch = $selfetch->whereRaw(" {$a}cate_ids REGEXP '({$cate_ids})'");
+ }
+//
+// if (isset($classes_label_ids) && $classes_label_ids) {
+// $classes_label_ids = implode("|",explode(',',$classes_label_ids));
+// $selfetch = $selfetch->whereRaw(" {$a}classes_label_ids REGEXP '({$classes_label_ids})'");
+// }
+ $collect_classes_lib_ids = [-1];
+ //需登录查询条件:
+ if(isset($my_user_id) && $my_user_id){
+ //得到我收藏的课程ids
+ $collect_classes_lib_ids = Collect::where("user_id",$my_user_id)->column("classes_activity_id");
+ //专查我的收藏
+ if(isset($collect) && $collect){
+ $selfetch = $selfetch->where("{$a}id","in",$collect_classes_lib_ids);
+ }
+
+ }
+
+ if(isset($order) && $order == "distance"){
+ $selfetch = $selfetch->where("{$a}longitude","not null")
+ ->where("{$a}latitude","not null")
+ ->where("{$a}longitude","<>","")
+ ->where("{$a}latitude","<>","")
+ ->where("{$a}longitude","<>","null")
+ ->where("{$a}latitude","<>","null");
+ }
+
+
+
+
+
+ //排序
+ switch ($order) {
+ case "normal": //综合排序(推薦優先)
+ $selfetch = $selfetch->order("{$a}recommend desc,{$a}hot desc,{$a}new desc,{$a}weigh desc,{$a}start_time desc,{$a}id desc");
+ break;
+ case "distance": //距离优先 权重
+ $selfetch = $selfetch->order("distance asc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc,{$a}sign_num desc");
+ break;
+ case "hot": //熱門优先
+ $selfetch = $selfetch->order("{$a}hot desc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc,{$a}sign_num desc");
+ break;
+
+ case "new": //平台最新优先
+ $selfetch = $selfetch->order("{$a}new desc,{$a}id desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc,{$a}sign_num desc");
+ break;
+
+ case "recommend": //推薦优先
+ $selfetch = $selfetch->order("{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc,{$a}sign_num desc");
+ break;
+
+ case "sale": //銷量优先
+ $selfetch = $selfetch->order("{$a}sale desc,{$a}verification_num desc,{$a}sign_num desc,{$a}recommend desc,{$a}weigh desc");
+ break;
+
+ case "views": //浏览量优先
+ $selfetch = $selfetch->order("{$a}views desc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc");
+ break;
+ case "collect": //收藏量优先
+ $selfetch = $selfetch->order("{$a}collect desc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc");
+ break;
+ default:
+ throw new \Exception("不支持的排序类型");
+ }
+
+ if(isset($nearby) && $nearby) {
+// throw new \Exception("现版本不支持");
+ $selfetch = $selfetch->having("distance <= {$nearby}");
+ }
+
+
+
+
+ $selfetch = $selfetch->page($page,$limit)->select();
+
+
+ foreach ($selfetch as $row) {
+
+// $row->getRelation('manystore')->visible(['nickname']);
+ $row->getRelation('user')->visible(['nickname','avatar']);
+ }
+ $rows = $selfetch;
+// $total = $selfetch->total();
+
+
+
+ //额外附加数据
+ foreach ($rows as &$row) { //迭代器魔术方法遍历,填值自动引用传值
+ //设置是否已收藏
+ $row->is_collect = in_array($row->id,$collect_classes_lib_ids) ? 1 : 0;
+
+ if($row->is_collect){
+ $row["collect"] = Collect::where("user_id",$my_user_id)->where("classes_activity_id",$row->id)->find();
+ }
+
+ $classes_cate_ids = $row['cate_ids'];
+ $classes_cate = [];
+ foreach (explode(",", $classes_cate_ids) as $classes_cate_id){
+ if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id];
+ }
+ $row['classes_cate'] = $classes_cate;
+
+
+ }
+ $result = array("data" => $rows);
+ return $result;
+ }
+
+
+
+
+ /** 课程详情
+ * @param $id
+ * @throws \think\exception\DbException
+ */
+ public function detail($id,$user_id=0,$oper_type='user',$trans=false){
+ $self = $this->get($id,['user']);
+ //只查user的名字
+// $self->getRelation('user')->visible(['nickname']);
+
+ //是否收藏
+ $self['is_collect'] = 0;
+ //是否购买
+ $self['have_buy'] = 0;
+ if($user_id){
+ //判断是否收藏
+ $self['is_collect'] = Collect::where("user_id",$user_id)->where("classes_activity_id",$id)->count() ? 1:0 ;
+
+ //判断用户是否已报名
+ $self['have_buy'] = Order::where("activity_id",$id)
+ ->where("user_id",$user_id)
+ ->where("status","not in",["-3","6","9"])
+ ->count() ? 1 : 0 ;
+ }
+
+ //
+ $this->setViews($id,$user_id,$oper_type,$user_id,$trans);
+ $self->getRelation('user')->visible(['nickname','realname','mobile','avatar']);
+ //参与人数 = 虚拟人数 + 平台人数
+
+
+
+ $cate_list = Cate::where("status",'1')->column("name","id");
+ $classes_cate_ids = $self['cate_ids'];
+ $classes_cate = [];
+ foreach (explode(",", $classes_cate_ids) as $classes_cate_id){
+ if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id];
+ }
+ $self['classes_cate'] = $classes_cate;
+
+
+ $self['sign_time'] = "{$self["sign_start_time_text"]} - {$self["sign_end_time_text"]}";
+ $self['time'] = "{$self["start_time_text"]} - {$self["end_time_text"]}";
+
+
+ return $self;
+ }
+
+ /**设置浏览量
+ * @param $id
+ * @param int $user_id
+ * @param bool $check
+ * @param bool $trans
+ * @throws \Exception
+ */
+ public function setViews($id,$user_id,$oper_type='user',$oper_id=0,$trans=false){
+ $classes_lib = self::where("id",$id)->find();
+ if(!$classes_lib)throw new \Exception("找不到活动!");
+ //判断逻辑
+ if($trans){
+ self::beginTrans();
+ }
+
+ try{
+ //事务逻辑
+ $classes_lib->views = $classes_lib->views + 1;
+ //查询是否已收藏
+ $classes_lib->save();
+
+
+ //调用事件
+ $data = ['activity' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ \think\Hook::listen('new_activity_view_after', $data);
+
+
+ if($trans){
+ self::commitTrans();
+ }
+ }catch (\Exception $e){
+ if($trans){
+ self::rollbackTrans();
+ }
+ throw new \Exception($e->getMessage());
+ }
+ return $classes_lib;
+ }
+
+
+
+
+
+ /**设置收藏
+ * @param $id
+ * @param int $user_id
+ * @param int $collect 0取消收藏 1收藏
+ * @param bool $check
+ * @param bool $trans
+ * @throws \Exception
+ */
+ public function collect($id,$user_id,$collect,$oper_type='user',$oper_id=0,$trans=false){
+ $classes_lib = self::where("id",$id)->find();
+ if(!$classes_lib)throw new \Exception("找不到活动!");
+ //判断逻辑
+ if($trans){
+ self::beginTrans();
+ }
+
+ try{
+ //事务逻辑
+ $where = [
+ "user_id"=>$user_id,
+ "classes_activity_id"=>$id,
+// "weigh"=>$classes_lib["weigh"],
+ ];
+ //查询是否已收藏
+ $res1 = Collect::where($where)->find();
+ if($collect){
+ if(!$res1){
+ $where["weigh"] = $classes_lib["weigh"];
+
+ //未收藏,添加收藏
+ $res1 = new Collect();
+ $res1->allowField(true)->save($where);
+ }
+
+ self::update_classes($classes_lib["id"]);
+ //调用事件
+ $data = ['activity' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ \think\Hook::listen('new_activity_collect_success_after', $data);
+
+ }else{
+
+ unset($where["weigh"]);
+ //取消收藏
+ $res1 = Collect::where($where)->delete();
+ self::update_classes($classes_lib["id"]);
+ //调用事件
+ $data = ['activity' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ \think\Hook::listen('new_activity_collect_cancel_after', $data);
+
+
+ }
+
+
+ if($trans){
+ self::commitTrans();
+ }
+ }catch (\Exception $e){
+ if($trans){
+ self::rollbackTrans();
+ }
+ throw new \Exception($e->getMessage());
+ }
+ $where["is_collect"] = $collect;
+ return $where;
+ }
+
+
+ //更新活动状态
+ public function updateStatus($id,$trans=false){
+//判断逻辑
+ if($trans){
+ self::beginTrans();
+ }
+ $res = true;
+ try{
+ $row = self::get($id);
+ if(!$row)throw new \Exception("找不到活动!");
+
+ $now_time = time();
+ $sign_start_time = strtotime($row["sign_start_time"]);
+ $sign_end_time = strtotime($row["sign_end_time"]);
+ $start_time = strtotime($row["start_time"]);
+ $end_time = strtotime($row["end_time"]);
+ //根据时间区间,设定录入的活动初始状态:1=未开始,2=报名中,3=待开始,4=进行中,5=已结束
+ //时间在报名开始时间之前为1=未开始
+ //时间在报名区间之内为2=报名中
+ //时间在开始时间之前,在报名结束时间之后为3=待开始
+ //时间在开始时间之后,在结束时间之前为4=进行中
+ //时间在结束时间之后为5=已结束
+ //已取消则不更新状态
+ $params = [];
+ if(!$row || $row["status"]!='-1'){
+ if($now_time<$sign_start_time){
+ $params["status"] = '1';
+ } else if($now_time>=$sign_start_time && $now_time<=$sign_end_time){
+ $params["status"] = '2';
+ } else if($now_time>$sign_end_time && $now_time<$start_time){
+ $params["status"] = '3';
+ } else if($now_time>=$start_time && $now_time<=$end_time){
+ $params["status"] = '4';
+ } else if($now_time>$end_time){
+ $params["status"] = '5';
+ }
+ }
+ if($params){
+ $res = $row->allowField(true)->save($params);
+ }
+
+
+
+ if($trans){
+ self::commitTrans();
+ }
+ }catch (\Exception $e){
+ if($trans){
+ self::rollbackTrans();
+ }
+ throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
+ }
+ return $res;
+ }
+
+
+
+
+
+ /** 新增活动
+ * @param $params
+ * @param $trans
+ * @return $this
+ * @throws \Exception
+ */
+ public function add($params,$user_id,$oper_type='user',$oper_id=0,$trans=false){
+
+ if (empty($params)) {
+ throw new \Exception(__('Parameter %s can not be empty', ''));
+ }
+ if($user_id)$params["user_id"] = $user_id;
+
+
+//判断逻辑
+ if($trans){
+ self::beginTrans();
+ }
+ $res = true;
+ try{
+
+// //是否采用模型验证
+// if ($this->modelValidate) {
+// $name = str_replace("\\model\\", "\\validate\\", get_class($this));
+// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+// $this->validateFailException()->validate($validate);
+// }
+ $row = new self;
+ $this->update_check($params,null);
+ $result = $row->allowField(true)->save($params);
+ $this->update_classes($row["id"]);
+
+ //调用审核事件触发
+ $data = ['activity' => $row,"user_id"=>$params["user_id"],"oper_type"=>$oper_type,"oper_id"=>$oper_id];
+ \think\Hook::listen('new_activity_auth_need_after', $data);
+ if($trans){
+ self::commitTrans();
+ }
+ }catch (\Exception $e){
+ if($trans){
+ self::rollbackTrans();
+ }
+ throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
+ }
+ return $row;
+ }
+
+
+}
diff --git a/application/common/model/school/activity/Cate.php b/application/common/model/school/activity/Cate.php
new file mode 100644
index 0000000..141588d
--- /dev/null
+++ b/application/common/model/school/activity/Cate.php
@@ -0,0 +1,134 @@
+getPk();
+ $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+ }
+ });
+ }
+
+
+ public function getStatusList()
+ {
+ return ['1' => __('Status 1'), '2' => __('Status 2')];
+ }
+
+ public function getHotList()
+ {
+ return ['0' => __('Hot 0'), '1' => __('Hot 1')];
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getHotTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : '');
+ $list = $this->getHotList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
+
+
+ /**得到基础条件
+ * @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',"hot"]))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'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
+ if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}id|{$alisa}name", 'Like', "%{$whereData['keywords']}%");
+ if (isset($whereData['time'])&&$whereData['time']){
+ $model = $model->time($whereData['time']);
+ }
+
+ if (isset($whereData['hot'])) $model = $model->where("{$alisa}hot", 'in', $whereData['hot']);
+
+ return $model;
+ }
+
+
+ public static function showList($page, $limit,$keywords,$hot=null){
+ $field = ['*'];
+
+
+ $sort = "field(hot,'1','0') asc,weigh desc,id desc";
+ $serch_where = ['keywords'=>$keywords,"status"=>"1"];
+ if($hot==="0" || $hot==="1"){
+ $serch_where['hot'] = $hot;
+ }
+
+ return (new self)->getBaseList($serch_where, $page, $limit,$sort,$field);
+ }
+
+
+
+
+
+}
diff --git a/application/common/model/school/activity/Order.php b/application/common/model/school/activity/Order.php
new file mode 100644
index 0000000..1c4cd57
--- /dev/null
+++ b/application/common/model/school/activity/Order.php
@@ -0,0 +1,12 @@
+ __('Pay_type yue'), 'wechat' => __('Pay_type wechat')];
+ }
+
+ public function getStatusList()
+ {
+ return ['-3' => __('Status -3'), '0' => __('Status 0'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5'), '6' => __('Status 6'), '9' => __('Status 9')];
+ }
+
+ public function getBeforeStatusList()
+ {
+ return ['-3' => __('Before_status -3'), '0' => __('Before_status 0'), '2' => __('Before_status 2'), '3' => __('Before_status 3'), '4' => __('Before_status 4'), '6' => __('Before_status 6'), '9' => __('Before_status 9')];
+ }
+
+ public function getServerStatusList()
+ {
+ return ['0' => __('Server_status 0'), '3' => __('Server_status 3'), '6' => __('Server_status 6')];
+ }
+
+ public function getAuthStatusList()
+ {
+ return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
+ }
+
+
+ public function getPayTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
+ $list = $this->getPayTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getBeforeStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['before_status']) ? $data['before_status'] : '');
+ $list = $this->getBeforeStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getServerStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['server_status']) ? $data['server_status'] : '');
+ $list = $this->getServerStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getCanceltimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getPaytimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['paytime']) ? $data['paytime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getAuthTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_time']) ? $data['auth_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getReservationTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['reservation_time']) ? $data['reservation_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getFinishtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['finishtime']) ? $data['finishtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getRefundtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getAuthStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : '');
+ $list = $this->getAuthStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getRefundsendtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['refundsendtime']) ? $data['refundsendtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setCanceltimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setPaytimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setAuthTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setReservationTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setFinishtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setRefundtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setRefundsendtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function activity()
+ {
+ return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function detail()
+ {
+ return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/school/activity/order/OrderCode.php b/application/common/model/school/activity/order/OrderCode.php
new file mode 100644
index 0000000..b697068
--- /dev/null
+++ b/application/common/model/school/activity/order/OrderCode.php
@@ -0,0 +1,70 @@
+ __('Status 3'), '6' => __('Status 6')];
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getVerificationtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['verificationtime']) ? $data['verificationtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setVerificationtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function order()
+ {
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'verification_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/school/activity/order/OrderDetail.php b/application/common/model/school/activity/order/OrderDetail.php
new file mode 100644
index 0000000..5e6047d
--- /dev/null
+++ b/application/common/model/school/activity/order/OrderDetail.php
@@ -0,0 +1,182 @@
+getPk();
+ $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+ }
+ });
+ }
+
+
+ public function getRecommendList()
+ {
+ return ['0' => __('Recommend 0'), '1' => __('Recommend 1')];
+ }
+
+ public function getHotList()
+ {
+ return ['0' => __('Hot 0'), '1' => __('Hot 1')];
+ }
+
+ public function getNewList()
+ {
+ return ['0' => __('New 0'), '1' => __('New 1')];
+ }
+
+ public function getAddTypeList()
+ {
+ return ['1' => __('Add_type 1'), '2' => __('Add_type 2')];
+ }
+
+ public function getFeelList()
+ {
+ return ['0' => __('Feel 0'), '1' => __('Feel 1')];
+ }
+
+
+ public function getStartTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['start_time']) ? $data['start_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getEndTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['end_time']) ? $data['end_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getSignStartTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['sign_start_time']) ? $data['sign_start_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getSignEndTimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['sign_end_time']) ? $data['sign_end_time'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getRecommendTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['recommend']) ? $data['recommend'] : '');
+ $list = $this->getRecommendList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getHotTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : '');
+ $list = $this->getHotList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getNewTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['new']) ? $data['new'] : '');
+ $list = $this->getNewList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getAddTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['add_type']) ? $data['add_type'] : '');
+ $list = $this->getAddTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getFeelTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['feel']) ? $data['feel'] : '');
+ $list = $this->getFeelList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+ protected function setStartTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setEndTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setSignStartTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setSignEndTimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function order()
+ {
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function activity()
+ {
+ return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/school/activity/order/SettleLog.php b/application/common/model/school/activity/order/SettleLog.php
new file mode 100644
index 0000000..780827d
--- /dev/null
+++ b/application/common/model/school/activity/order/SettleLog.php
@@ -0,0 +1,109 @@
+ __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '-1' => __('Status -1')];
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getSettletimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['settletime']) ? $data['settletime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getCanceltimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getUnfreezetimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['unfreezetime']) ? $data['unfreezetime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setSettletimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setCanceltimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setUnfreezetimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function order()
+ {
+ return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function log()
+ {
+ return $this->belongsTo(UserwithdrawalLog::class, 'withdrawal_log_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function touser()
+ {
+ return $this->belongsTo('app\common\model\User', 'to_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+
+ public function payuser()
+ {
+ return $this->belongsTo('app\common\model\User', 'pay_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/user/withdrawal/Log.php b/application/common/model/user/withdrawal/Log.php
new file mode 100644
index 0000000..bd136e4
--- /dev/null
+++ b/application/common/model/user/withdrawal/Log.php
@@ -0,0 +1,12 @@
+belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/user/withdrawal/UserwithdrawalLog.php b/application/common/model/user/withdrawal/UserwithdrawalLog.php
new file mode 100644
index 0000000..56e42a4
--- /dev/null
+++ b/application/common/model/user/withdrawal/UserwithdrawalLog.php
@@ -0,0 +1,105 @@
+ __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
+ }
+
+ public function getWithdrawalStatusList()
+ {
+ return ['1' => __('Withdrawal_status 1'), '2' => __('Withdrawal_status 2'), '3' => __('Withdrawal_status 3')];
+ }
+
+ public function getTypeList()
+ {
+ return ['bank' => __('Type bank'), 'wechat' => __('Type wechat'), 'alipay' => __('Type alipay')];
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getWithdrawalStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['withdrawal_status']) ? $data['withdrawal_status'] : '');
+ $list = $this->getWithdrawalStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $list = $this->getTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getPaytimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['paytime']) ? $data['paytime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+
+ public function getExaminetimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['examinetime']) ? $data['examinetime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setPaytimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+ protected function setExaminetimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/public/assets/js/backend/school/activity/activity.js b/public/assets/js/backend/school/activity/activity.js
index 91136e5..6629e1c 100644
--- a/public/assets/js/backend/school/activity/activity.js
+++ b/public/assets/js/backend/school/activity/activity.js
@@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Table.api.init({
extend: {
index_url: 'school/activity/activity/index' + location.search,
- add_url: 'school/activity/activity/add',
- edit_url: 'school/activity/activity/edit',
+ add_url: 'school/activity/activity/add'+ location.search,
+ edit_url: 'school/activity/activity/edit'+ location.search,
del_url: 'school/activity/activity/del',
multi_url: 'school/activity/activity/multi',
import_url: 'school/activity/activity/import',
@@ -31,11 +31,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'user_id', title: __('User_id')},
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
- {field: 'address_city', title: __('Address_city'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
- {field: 'cate_ids', title: __('Cate_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
- {field: 'province', title: __('Province')},
- {field: 'city', title: __('City')},
- {field: 'district', title: __('District')},
+ // {field: 'address_city', title: __('Address_city'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+ // {field: 'cate_ids', title: __('Cate_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+
+ {field: 'cate_ids', title: __('Cate_ids'), searchList: cateListJson, formatter: Table.api.formatter.flag},
+ // {field: 'province', title: __('Province')},
+ // {field: 'city', title: __('City')},
+ // {field: 'district', title: __('District')},
{field: 'address', title: __('Address'), operate: 'LIKE'},
{field: 'address_detail', title: __('Address_detail'), operate: 'LIKE'},
{field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
@@ -150,6 +152,44 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
api: {
bindevent: function () {
+
+
+ $(document).on("dp.change", "#add-form .datetimerange", function () {
+ $(this).parent().prev().find("input").trigger("change");
+ });
+
+ $(document).on("dp.change", "#add-form .datetimepicker", function () {
+ $(this).parent().prev().find("input").trigger("change");
+ });
+ $(document).on("dp.change", "#edit-form .datetimerange", function () {
+ $(this).parent().prev().find("input").trigger("change");
+ });
+
+ $(document).on("dp.change", "#edit-form .datetimepicker", function () {
+ $(this).parent().prev().find("input").trigger("change");
+ });
+
+
+ $(document).on('click', '.btn-changeuser', function (event) {
+ var url = $(this).attr('data-url');
+ if(!url) return false;
+ var title = $(this).attr('title');
+ var width = $(this).attr('data-width');
+ var height = $(this).attr('data-height');
+ // var ids = $(this).attr('data-id');
+ var area = [$(window).width() > 800 ? (width?width:'800px') : '95%', $(window).height() > 600 ? (height?height:'600px') : '95%'];
+ var options = {
+ shadeClose: false,
+ shade: [0.3, '#393D49'],
+ area: area,
+ callback:function(ret){//回调方法,需要在本页面Controller中增加方法监听且调用Fast.api.close(ret)传递结果;
+ Fast.api.close(ret);
+ }
+ };
+ Fast.api.open(url,title,options);
+ });
+
+
Form.api.bindevent($("form[role=form]"));
}
}
diff --git a/public/assets/js/backend/school/activity/order/settle_log.js b/public/assets/js/backend/school/activity/order/settle_log.js
index 3844ddf..cfca19f 100644
--- a/public/assets/js/backend/school/activity/order/settle_log.js
+++ b/public/assets/js/backend/school/activity/order/settle_log.js
@@ -44,11 +44,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'order.order_no', title: __('Order.order_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'log.id', title: __('Log.id')},
{field: 'log.price', title: __('Log.price'), operate:'BETWEEN'},
- {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
- {field: 'user.realname', title: __('User.realname'), operate: 'LIKE'},
- {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
- {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
- {field: 'third.openname', title: __('Third.openname'), operate: 'LIKE'},
+ {field: 'touser.nickname', title: __('User.nickname'), operate: 'LIKE'},
+ {field: 'touser.realname', title: __('User.realname'), operate: 'LIKE'},
+ {field: 'touser.mobile', title: __('User.mobile'), operate: 'LIKE'},
+ {field: 'touser.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
+ {field: 'payuser.nickname', title: __('User.nickname'), operate: 'LIKE'},
+ {field: 'payuser.realname', title: __('User.realname'), operate: 'LIKE'},
+ {field: 'payuser.mobile', title: __('User.mobile'), operate: 'LIKE'},
+ {field: 'payuser.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
diff --git a/public/assets/js/backend/style/home_images.js b/public/assets/js/backend/style/home_images.js
index 38284ae..edc79d4 100644
--- a/public/assets/js/backend/style/home_images.js
+++ b/public/assets/js/backend/style/home_images.js
@@ -64,6 +64,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}},
{field: 'type', title: __('Type'), searchList: {"in":__('Type in'),"out":__('Type out')}, formatter: Table.api.formatter.normal},
+ {field: 'title', title: __('轮播图标题'), operate: 'LIKE'},
{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},