123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * 产品下载任务控制器
- */
- class DownloadtaskController extends Controller
- {
- /**
- * 下载任务列表
- */
- public function actionIndex()
- {
- $page = Req::get('page') ? Req::get('page') : 1;
- $pageLimit = 5;
- $model=new BusinessPackProductTask();
- $result = $model->getList($this->schoolId,$page,$pageLimit);
- if(!empty($result['dataList'])) {
- $packStatus = ProductDownload::$pack_status;
- foreach ($result['dataList'] as &$item){
- $item['status'] = isset($packStatus[$item['pack_status']]) ? $packStatus[$item['pack_status']] : '状态异常';
- }
- }
- return $this->render('index', array(
- 'dataList' => $result['dataList'],
- 'pages' => $result['pages'],
- 'page'=>$page,
- ));
- }
- /**
- * 清除已复制下载任务
- */
- public function actionClear()
- {
- $schoolId = $this->schoolId;
- $rs = $this->conn->createCommand("delete from pack_product_task where school_id={$schoolId} and pack_status in (2,3)")->execute();
- if($rs){
- echo json_encode(array('success' => 0, 'message' => '清除失败'));
- exit;
- }else{
- echo json_encode(array('success'=>1,'message'=>'清除成功'));
- exit;
- }
- }
- /**
- * 复制链接
- */
- public function actionAjaxCopy()
- {
- $id = Req::get('id') ? Req::get('id') : 0;
- if(!$id) {
- echo json_encode(array('success' => 0, 'message' => '参数错误'));
- exit;
- }
- $model = BusinessPackProductTask::model()->findByPk($id);
- if($model) {
- $model-> pack_status = 3; //已复制
- $model->save();
- }else{
- echo json_encode(array('success' => 0, 'message' => '数据异常'));
- exit;
- }
- echo json_encode(array('success'=>1,'message'=>'复制成功'));
- }
- }
|