...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace app\admin\controller\mobile\secret;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
|
* 通关密卷管理
|
...
|
...
|
@@ -73,4 +74,57 @@ class Secret extends Backend |
|
|
}
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
public function del($ids = "")
|
|
|
{
|
|
|
if ($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();
|
|
|
|
|
|
$count = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
foreach ($list as $k => $v) {
|
|
|
// 删除题目
|
|
|
$question_list = Db::name('mobile_question')->where('target_id',$v['id'])->where('target_type','5')->field('id')->select();
|
|
|
foreach ($question_list as $val){
|
|
|
// 删除回答
|
|
|
Db::name('mobile_question_answer')->where('question_id',$val['id'])->delete();
|
|
|
// 删除收藏
|
|
|
Db::name('mobile_question_collect')->where('question_id',$val['id'])->delete();
|
|
|
// 删除笔记
|
|
|
Db::name('mobile_question_note')->where('question_id',$val['id'])->delete();
|
|
|
// 删除纠错
|
|
|
Db::name('mobile_question_wrong')->where('question_id',$val['id'])->delete();
|
|
|
Db::name('mobile_question')->where('id',$val['id'])->delete();
|
|
|
}
|
|
|
// 删除订单
|
|
|
Db::name('mobile_secret_order')->where('secret_id',$v['id'])->delete();
|
|
|
// 删除规格
|
|
|
Db::name('mobile_secret_spec')->where('secret_id',$v['id'])->delete();
|
|
|
$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'));
|
|
|
}
|
|
|
} |
...
|
...
|
|