DownloadtaskController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * 产品下载任务控制器
  4. */
  5. class DownloadtaskController extends Controller
  6. {
  7. /**
  8. * 下载任务列表
  9. */
  10. public function actionIndex()
  11. {
  12. $page = Req::get('page') ? Req::get('page') : 1;
  13. $pageLimit = 5;
  14. $model=new BusinessPackProductTask();
  15. $result = $model->getList($this->schoolId,$page,$pageLimit);
  16. if(!empty($result['dataList'])) {
  17. $packStatus = ProductDownload::$pack_status;
  18. foreach ($result['dataList'] as &$item){
  19. $item['status'] = isset($packStatus[$item['pack_status']]) ? $packStatus[$item['pack_status']] : '状态异常';
  20. }
  21. }
  22. return $this->render('index', array(
  23. 'dataList' => $result['dataList'],
  24. 'pages' => $result['pages'],
  25. 'page'=>$page,
  26. ));
  27. }
  28. /**
  29. * 清除已复制下载任务
  30. */
  31. public function actionClear()
  32. {
  33. $schoolId = $this->schoolId;
  34. $rs = $this->conn->createCommand("delete from pack_product_task where school_id={$schoolId} and pack_status in (2,3)")->execute();
  35. if($rs){
  36. echo json_encode(array('success' => 0, 'message' => '清除失败'));
  37. exit;
  38. }else{
  39. echo json_encode(array('success'=>1,'message'=>'清除成功'));
  40. exit;
  41. }
  42. }
  43. /**
  44. * 复制链接
  45. */
  46. public function actionAjaxCopy()
  47. {
  48. $id = Req::get('id') ? Req::get('id') : 0;
  49. if(!$id) {
  50. echo json_encode(array('success' => 0, 'message' => '参数错误'));
  51. exit;
  52. }
  53. $model = BusinessPackProductTask::model()->findByPk($id);
  54. if($model) {
  55. $model-> pack_status = 3; //已复制
  56. $model->save();
  57. }else{
  58. echo json_encode(array('success' => 0, 'message' => '数据异常'));
  59. exit;
  60. }
  61. echo json_encode(array('success'=>1,'message'=>'复制成功'));
  62. }
  63. }