2024-12-23 18:21:02 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\manystore\controller\school\classes\activity;
|
|
|
|
|
|
|
|
|
|
use app\common\controller\ManystoreBase;
|
|
|
|
|
use app\common\model\manystore\UserAuth;
|
2024-12-24 18:27:48 +08:00
|
|
|
|
use app\common\model\school\classes\activity\order\Order;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
use app\common\model\User;
|
|
|
|
|
use app\manystore\model\Manystore;
|
|
|
|
|
use think\Db;
|
|
|
|
|
use think\Exception;
|
|
|
|
|
use think\exception\PDOException;
|
|
|
|
|
use think\exception\ValidateException;
|
2025-01-04 18:09:51 +08:00
|
|
|
|
use think\Url;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 课程活动
|
|
|
|
|
*
|
|
|
|
|
* @icon fa fa-circle-o
|
|
|
|
|
*/
|
|
|
|
|
class Activity extends ManystoreBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Activity模型对象
|
|
|
|
|
* @var \app\manystore\model\school\classes\activity\Activity
|
|
|
|
|
*/
|
|
|
|
|
protected $model = null;
|
|
|
|
|
protected $itemmodel = null;
|
|
|
|
|
|
|
|
|
|
protected $qSwitch = true;
|
|
|
|
|
protected $qFields = ["user_id","shop_id","manystore_id"];
|
2024-12-24 18:27:48 +08:00
|
|
|
|
//不用审核允许修改的字段
|
|
|
|
|
protected $no_auth_fields = ['headimage','images',"status"];
|
2025-01-04 18:09:51 +08:00
|
|
|
|
protected $noNeedLogin = ["miniqrcode"];
|
2024-12-24 18:27:48 +08:00
|
|
|
|
protected $need_auth = true;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
|
|
|
|
public function _initialize()
|
|
|
|
|
{
|
|
|
|
|
// parent::_initialize();
|
|
|
|
|
$this->model = new \app\manystore\model\school\classes\activity\Activity;
|
|
|
|
|
$this->itemmodel = new \app\manystore\model\school\classes\activity\ActivityItem();
|
|
|
|
|
parent::_initialize();
|
|
|
|
|
$this->view->assign("addressTypeList", $this->model->getAddressTypeList());
|
|
|
|
|
$this->view->assign("statusList", $this->model->getStatusList());
|
|
|
|
|
$this->view->assign("recommendList", $this->model->getRecommendList());
|
|
|
|
|
$this->view->assign("hotList", $this->model->getHotList());
|
|
|
|
|
$this->view->assign("newList", $this->model->getNewList());
|
|
|
|
|
$this->view->assign("selfhotList", $this->model->getSelfhotList());
|
|
|
|
|
$this->view->assign("expirestatusList", $this->model->getExpirestatusList());
|
|
|
|
|
$this->view->assign("addTypeList", $this->model->getAddTypeList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->getCity();
|
|
|
|
|
|
|
|
|
|
$this->view->assign("itemStatusList", $this->itemmodel->getStatusList());
|
|
|
|
|
$this->view->assign("sexList", $this->itemmodel->getSexList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function import()
|
|
|
|
|
{
|
|
|
|
|
parent::import();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
|
|
|
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
|
|
|
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
//当前是否为关联查询
|
|
|
|
|
$this->relationSearch = true;
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$this->searchFields = ["id","title","address","address_detail","address_city","manystoreshop.name"];
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
//设置过滤方法
|
|
|
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
|
|
|
|
if ($this->request->request('keyField')) {
|
|
|
|
|
return $this->selectpage();
|
|
|
|
|
}
|
2024-12-26 18:13:04 +08:00
|
|
|
|
list($where, $sort, $order, $offset, $limit, $page, $alias, $bind, $excludearray) = $this->buildparams(null, null, ["has_expire","has_sign_expire"]);
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
|
|
|
|
if (isset($excludearray['has_expire']['value']) && $excludearray['has_expire']['value']) {
|
|
|
|
|
$has_expire = $excludearray['has_expire']['value'];
|
|
|
|
|
$as = (new \app\common\model\school\classes\activity\Activity)->getWithAlisaName();
|
|
|
|
|
switch ($has_expire) {
|
|
|
|
|
case '1': //查过期
|
|
|
|
|
$expireWhere = [
|
|
|
|
|
$as . '.end_time', '<=', time(),
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case '2': //查未过期
|
|
|
|
|
$expireWhere = [
|
|
|
|
|
$as . '.end_time', '>', time(),
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$expireWhere = [[]];
|
|
|
|
|
}
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
2024-12-26 18:13:04 +08:00
|
|
|
|
if (isset($excludearray['has_sign_expire']['value']) && $excludearray['has_sign_expire']['value']) {
|
|
|
|
|
$has_expire = $excludearray['has_sign_expire']['value'];
|
|
|
|
|
$as = (new \app\common\model\school\classes\activity\Activity)->getWithAlisaName();
|
|
|
|
|
switch ($has_expire) {
|
|
|
|
|
case '1': //查过期
|
|
|
|
|
$expireSignWhere = [
|
|
|
|
|
$as . '.sign_end_time', '<=', time(),
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case '2': //查未过期
|
|
|
|
|
$expireSignWhere = [
|
|
|
|
|
$as . '.sign_end_time', '>', time(),
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$expireSignWhere = [[]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$list = $this->model
|
|
|
|
|
->with(['manystore','manystoreshop'])
|
|
|
|
|
->where($where)
|
2024-12-24 18:27:48 +08:00
|
|
|
|
->where(...$expireWhere)
|
2024-12-26 18:13:04 +08:00
|
|
|
|
->where(...$expireSignWhere)
|
2024-12-23 18:21:02 +08:00
|
|
|
|
->order($sort, $order)
|
|
|
|
|
->paginate($limit);
|
|
|
|
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
|
|
|
|
|
|
|
$row->getRelation('manystore')->visible(['nickname']);
|
|
|
|
|
$row->getRelation('manystoreshop')->visible(['name','logo']);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 18:09:51 +08:00
|
|
|
|
$rows = $list->items();
|
|
|
|
|
foreach ($rows as $k=>&$v){
|
|
|
|
|
$v["miniqrcode_link"] = Url::build("/manystore/school/classes/activity/activity/miniqrcode", ["ids" => $v["id"]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = array("total" => $list->total(), "rows" => $rows);
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
|
|
|
|
return json($result);
|
|
|
|
|
}
|
|
|
|
|
return $this->view->fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function update_classes($classes_activity_id){
|
2024-12-26 18:13:04 +08:00
|
|
|
|
if($classes_activity_id) \app\common\model\school\classes\activity\Activity::update_classes($classes_activity_id);
|
2024-12-23 18:21:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function updateCheck($id,$params=[],$row=null){
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
if($params && $row){
|
|
|
|
|
// var_dump($this->no_auth_fields_check($params,$row));
|
|
|
|
|
if(!$this->no_auth_fields_check($params,$row)){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
// 课程存在售后订单则不允许操作
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$order = Order::where("classes_activity_id",$id)->where("status","not in","-3,6,9")->find();
|
|
|
|
|
if($order)throw new \Exception("存在正在使用中的订单报名学员,规格无法继续操作,如规格有误请下架!");
|
2024-12-23 18:21:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function update_check(&$params,$row=null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
try {
|
|
|
|
|
if($row){
|
|
|
|
|
if(empty($params["shop_id"]))$params["shop_id"] = $row["shop_id"];
|
|
|
|
|
if($params["status"] != '3' && $row["status"] == '3'){
|
|
|
|
|
throw new \Exception("已被平台下架!无法操作上架状态!");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
$classesLib = new \app\common\model\school\classes\activity\Activity();
|
|
|
|
|
$classesLib->no_auth_fields = $this->no_auth_fields;
|
|
|
|
|
$classesLib->need_auth = $this->need_auth;
|
|
|
|
|
$classesLib->have_auth = $this->have_auth;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
$classesLib->activityCheck($params,null,$row);
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
$this->need_auth = $classesLib->need_auth;
|
|
|
|
|
$this->have_auth = $classesLib->have_auth;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
2024-12-30 18:09:23 +08:00
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
$this->error($e->getMessage());
|
2024-12-23 18:21:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
//修改
|
|
|
|
|
if($row){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
//新增
|
2024-12-24 18:27:48 +08:00
|
|
|
|
//新增
|
|
|
|
|
$params["add_type"] = '1';
|
|
|
|
|
$params["add_id"] = $this->auth->id;
|
2024-12-23 18:21:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
* @throws \think\Exception
|
|
|
|
|
*/
|
|
|
|
|
public function add()
|
|
|
|
|
{
|
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
$params = $this->request->post("row/a");
|
|
|
|
|
if ($params) {
|
|
|
|
|
$params = $this->preExcludeFields($params);
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$this->error(__('添加功能已被禁用!', ''));
|
2024-12-23 18:21:02 +08:00
|
|
|
|
if($this->storeIdFieldAutoFill && STORE_ID ){
|
|
|
|
|
$params['store_id'] = STORE_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($this->shopIdAutoCondition && SHOP_ID){
|
|
|
|
|
$params['shop_id'] = SHOP_ID;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$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(true)->validate($validate);
|
|
|
|
|
}
|
|
|
|
|
$this->update_check($params,$row=null);
|
2024-12-24 18:27:48 +08:00
|
|
|
|
$spec = $params["item_json"];
|
|
|
|
|
unset($params["item_json"]);
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$result = $this->model->allowField(true)->save($params);
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
|
|
|
|
//添加课程规格
|
|
|
|
|
foreach ($spec as $k=>$v){
|
|
|
|
|
$v["classes_activity_id"] = $this->model["id"];
|
|
|
|
|
$v["manystore_id"] = $this->model["manystore_id"];
|
|
|
|
|
$v["shop_id"] = $this->model["shop_id"];
|
|
|
|
|
|
|
|
|
|
unset($v["id"]);
|
|
|
|
|
(new \app\common\model\school\classes\activity\ActivityItem())->allowField(true)->save($v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//因为是批量添加,所有规格重新进行检测,防止出现时间重叠
|
|
|
|
|
$specss = \app\common\model\school\classes\activity\ActivityItem::where("classes_activity_id",$this->model["id"])->select();
|
|
|
|
|
foreach ($specss as $k=>$specs){
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$params =$specs->toArray();
|
2024-12-24 18:27:48 +08:00
|
|
|
|
(new \app\common\model\school\classes\activity\ActivityItem)->specCheck($params,null,$specs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$this->update_classes($this->model["id"]);
|
|
|
|
|
Db::commit();
|
|
|
|
|
} catch (ValidateException $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
if ($result !== false) {
|
|
|
|
|
$this->success();
|
|
|
|
|
} else {
|
|
|
|
|
$this->error(__('No rows were inserted'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->error(__('Parameter %s can not be empty', ''));
|
|
|
|
|
}
|
|
|
|
|
return $this->view->fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑
|
|
|
|
|
*/
|
|
|
|
|
public function edit($ids = null)
|
|
|
|
|
{
|
|
|
|
|
if($this->shopIdAutoCondition){
|
|
|
|
|
$this->model->where(array('shop_id'=>SHOP_ID));
|
|
|
|
|
}
|
|
|
|
|
$row = $this->model->where(array('id'=>$ids))->find();
|
|
|
|
|
if (!$row) {
|
|
|
|
|
$this->error(__('No Results were found'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
$params = $this->request->post("row/a");
|
|
|
|
|
if ($params) {
|
|
|
|
|
$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(true)->validate($validate);
|
|
|
|
|
}
|
|
|
|
|
$this->update_check($params,$row);
|
2024-12-30 18:09:23 +08:00
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
if($this->have_auth){
|
|
|
|
|
(new \app\common\model\school\classes\activity\Activity)->applyAuth($row["id"],$params);
|
|
|
|
|
$result = true;
|
|
|
|
|
}else{
|
2024-12-30 18:09:23 +08:00
|
|
|
|
// var_dump($this->have_auth);
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
|
|
|
|
$spec = $params["item_json"] ?? [];
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
// var_dump($spec);
|
|
|
|
|
|
|
|
|
|
$delete_spec_ids = $params["delete_spec_ids"] ?? [];
|
|
|
|
|
unset($params["item_json"]);
|
|
|
|
|
unset($params["delete_spec_ids"]);
|
2024-12-23 18:21:02 +08:00
|
|
|
|
|
|
|
|
|
$result = $row->allowField(true)->save($params);
|
2024-12-24 18:27:48 +08:00
|
|
|
|
|
|
|
|
|
//添加课程规格
|
|
|
|
|
foreach ($spec as $k=>$v){
|
|
|
|
|
$v["classes_activity_id"] = $row["id"];
|
|
|
|
|
$v["manystore_id"] = $row["manystore_id"];
|
|
|
|
|
$v["shop_id"] = $row["shop_id"];
|
|
|
|
|
//有id更新,否则新增
|
|
|
|
|
if(isset($v["id"]) && $v["id"]){
|
|
|
|
|
\app\common\model\school\classes\activity\ActivityItem::update((new \app\common\model\school\classes\activity\ActivityItem)->checkAssemblyParameters($v));
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
\app\common\model\school\classes\activity\ActivityItem::create((new \app\common\model\school\classes\activity\ActivityItem)->checkAssemblyParameters($v));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//删除规格
|
|
|
|
|
foreach ($delete_spec_ids as $k=>$delete_spec){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(new \app\common\model\school\classes\activity\ActivityItem)->updateCheck($delete_spec["id"]);
|
|
|
|
|
|
|
|
|
|
$delete_spec->delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//因为是批量添加,所有规格重新进行检测,防止出现时间重叠
|
|
|
|
|
$specss = \app\common\model\school\classes\activity\ActivityItem::where("classes_activity_id",$row["id"])->select();
|
|
|
|
|
foreach ($specss as $k=>$specs){
|
|
|
|
|
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$params =$specs->toArray();
|
2024-12-24 18:27:48 +08:00
|
|
|
|
(new \app\common\model\school\classes\activity\ActivityItem)->specCheck($params,null,$specs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$this->update_classes($row["id"]);
|
|
|
|
|
Db::commit();
|
|
|
|
|
} catch (ValidateException $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
if ($result !== false) {
|
|
|
|
|
$this->success();
|
|
|
|
|
} else {
|
|
|
|
|
$this->error(__('No rows were updated'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->error(__('Parameter %s can not be empty', ''));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-12-24 18:27:48 +08:00
|
|
|
|
// $user = User::where("id", $row["user_id"])->find();
|
|
|
|
|
//// if(!$user) $this->error("未找到用户请先让用户登录小程序再提交表单");
|
|
|
|
|
// $row["user_id"] = $user["mobile"]?? ""; //nickname|realname|mobile
|
|
|
|
|
|
|
|
|
|
$spec = \app\common\model\school\classes\activity\ActivityItem::where("classes_activity_id",$row["id"])->field("id,classes_activity_id,name,price,age,sex,limit_num,status,weigh")->order('weigh desc,id desc')->select();
|
|
|
|
|
|
|
|
|
|
$row["item_json"] = json_encode($spec);
|
|
|
|
|
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$this->view->assign("row", $row);
|
|
|
|
|
return $this->view->fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*/
|
|
|
|
|
public function del($ids = "")
|
|
|
|
|
{
|
|
|
|
|
if (!$this->request->isPost()) {
|
|
|
|
|
$this->error(__("Invalid parameters"));
|
|
|
|
|
}
|
|
|
|
|
$ids = $ids ? $ids : $this->request->post("ids");
|
|
|
|
|
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();
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
$this->updateCheck($item->id);
|
|
|
|
|
}
|
|
|
|
|
$count = 0;
|
|
|
|
|
Db::startTrans();
|
|
|
|
|
try {
|
|
|
|
|
foreach ($list as $k => $v) {
|
2024-12-24 18:27:48 +08:00
|
|
|
|
//删除课程规格
|
|
|
|
|
\app\common\model\school\classes\activity\ActivityItem::where("classes_activity_id",$item->id)->delete();
|
|
|
|
|
//删除课程规格
|
|
|
|
|
\app\common\model\school\classes\activity\ActivityItemAuth::where("classes_activity_id",$item->id)->delete();
|
|
|
|
|
\app\common\model\school\classes\activity\ActivityAuth::where("classes_activity_id",$item->id)->delete();
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
$count += $v->delete();
|
|
|
|
|
}
|
|
|
|
|
Db::commit();
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
if ($count) {
|
|
|
|
|
$this->success();
|
|
|
|
|
} else {
|
|
|
|
|
$this->error(__('No rows were deleted'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 18:09:51 +08:00
|
|
|
|
/**
|
|
|
|
|
* 微信小程序码
|
|
|
|
|
* @return string
|
|
|
|
|
* @throws \think\Exception
|
|
|
|
|
* @throws \think\db\exception\BindParamException
|
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
|
* @throws \think\exception\PDOException
|
|
|
|
|
*/
|
|
|
|
|
public function miniqrcode($ids = ''){
|
|
|
|
|
$param = $this->request->param();
|
|
|
|
|
try{
|
|
|
|
|
if(isset($param['ids']))$ids = $param['ids'];
|
|
|
|
|
//设置模拟资格
|
|
|
|
|
$url = \app\common\model\school\classes\activity\Activity::getMiniQrcodeLink($ids);
|
|
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $url["response"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看微信小程序码
|
|
|
|
|
* @return string
|
|
|
|
|
* @throws \think\Exception
|
|
|
|
|
* @throws \think\db\exception\BindParamException
|
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
|
* @throws \think\exception\PDOException
|
|
|
|
|
*/
|
|
|
|
|
public function lookminiqrcode($ids = ''){
|
|
|
|
|
$param = $this->request->param();
|
|
|
|
|
if($this->request->isPost()){
|
|
|
|
|
try{
|
|
|
|
|
if(isset($param['ids']))$ids = $param['ids'];
|
|
|
|
|
//设置模拟资格
|
|
|
|
|
$url = \app\common\model\school\classes\activity\Activity::getMiniQrcodeLink($ids);
|
|
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
$this->success("生成小程序码成功",null,$url);
|
|
|
|
|
}
|
|
|
|
|
$row = $this->model->get($ids);
|
|
|
|
|
$this->view->assign('vo', $row);
|
|
|
|
|
return $this->view->fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-23 18:21:02 +08:00
|
|
|
|
}
|