ReconsumeController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/3/9
  6. * Time: 上午11:56
  7. */
  8. namespace console\controllers;
  9. use backendApi\modules\v1\models\lists\finance\RechargeList;
  10. use common\libs\export\module\ReconsumeExport;
  11. use Yii;
  12. class ReconsumeController extends BaseController {
  13. // /**
  14. // * 复销池余额列表导出
  15. // * @param $taskId
  16. // * @return bool
  17. // */
  18. // public function actionPoolListExport($taskId) {
  19. // return $this->_export($taskId, PoolList::class, '复销池余额列表');
  20. // }
  21. //
  22. // /**
  23. // * 复销余额调整审核列表导出
  24. // * @param $taskId
  25. // * @return bool
  26. // */
  27. // public function actionChangeAuditListExport($taskId) {
  28. // return $this->_export($taskId, ReconsumeAuditList::class, '复销余额调整审核列表');
  29. // }
  30. //
  31. // /**
  32. // * 复销流水导出
  33. // * @param $taskId
  34. // * @return bool
  35. // */
  36. // public function actionFlowListExport($taskId) {
  37. // return $this->_export($taskId, FlowList::class, '复销流水');
  38. // }
  39. /**
  40. * 导出方法
  41. * @param $taskId
  42. * @param $className
  43. * @param $listName
  44. * @return bool
  45. */
  46. private function _export($taskId, $className, $listName){
  47. $factory = ReconsumeExport::factory($taskId);
  48. $factory->listModelClass = $className;
  49. try {
  50. if ($factory->generate()) {
  51. \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), $listName.'导出成功');
  52. }
  53. unset($factory, $taskId, $className, $listName);
  54. return true;
  55. } catch (\Exception $e) {
  56. \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), $listName.'导出失败。详情:' . $e->getMessage(), false);
  57. }
  58. unset($factory, $taskId, $className, $listName);
  59. return false;
  60. }
  61. }