OrderController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace addons\AvoidTax\backend\controllers;
  3. use addons\AvoidTax\common\models\TaxOrder;
  4. use addons\AvoidTax\common\service\AccountService;
  5. use addons\AvoidTax\common\service\OrderService;
  6. use common\enums\DownloadEnum;
  7. use common\helpers\csv\CsvExportHelper;
  8. use Yii;
  9. /**
  10. * 交易相关
  11. *
  12. * Class OrderController
  13. * @package addons\AvoidTax\backend\controllers
  14. */
  15. class OrderController extends BaseController
  16. {
  17. public $enableCsrfValidation = false;
  18. /**
  19. * 交易列表
  20. *
  21. * @return
  22. */
  23. public function actionIndex()
  24. {
  25. if ($this->request->isAjax && $this->request->isGet) {
  26. $params = $this->request->getQueryParams();
  27. $service = new OrderService(['mall_id' => $this->mall_id]);
  28. $list = $service->getOrderList($params);
  29. return $this->success('ok', $list);
  30. }
  31. if(Yii::$app->request->post('flag') == 'EXPORT'){
  32. $post = Yii::$app->request->post();
  33. $post['mall_id'] = $this->mall_id;
  34. $filename = '交易列表-' . date('YmdHis').'_'.rand(10000,99999);
  35. $post['sub_type'] = TaxOrder::SUB_TYPE_USER;
  36. $res = CsvExportHelper::exportDownLoadCenter($this->mall_id,$filename,DownloadEnum::TYPE_STATISTICS,TaxOrder::class,'exportHandle', $post);
  37. if ($res === false) return $this->error('加入导出任务失败'.CsvExportHelper::getStaticError());
  38. return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!');
  39. }
  40. return $this->render('index');
  41. }
  42. /**
  43. * 添加交易
  44. *
  45. * @return void
  46. */
  47. public function actionAdd()
  48. {
  49. if ($this->request->isAjax) {
  50. $data = $this->request->post('data');
  51. $service = new OrderService(['mall_id' => $this->mall_id]);
  52. return $service->addOrder($data) ? $this->success('ok') : $this->error($service->error);
  53. }
  54. return $this->render($this->action->id);
  55. }
  56. /**
  57. * 获取记帐本列表
  58. *
  59. * @return void
  60. */
  61. public function actionBookList()
  62. {
  63. if ($this->request->isAjax) {
  64. $service = new AccountService(['mall_id'=>$this->mall_id]);
  65. return $this->success('ok', $service->getBookList());
  66. }
  67. }
  68. /**
  69. * 支付打款
  70. *
  71. * @return void
  72. */
  73. public function actionTrans()
  74. {
  75. if ($this->request->isAjax) {
  76. $service = new OrderService(['mall_id'=>$this->mall_id]);
  77. $id = $this->request->getQueryParam('id');
  78. return $service->trans($id) ? $this->success('ok') : $this->error($service->error);
  79. }
  80. }
  81. /**
  82. * 批量汇款
  83. *
  84. * @return void
  85. */
  86. public function actionBatchTrans()
  87. {
  88. if ($this->request->isAjax) {
  89. $service = new OrderService(['mall_id'=>$this->mall_id]);
  90. $ids = $this->request->getBodyParam('ids');
  91. return $service->batchTrans($ids) ? $this->success('添加成功') : $this->error($service->error);
  92. }
  93. }
  94. /**
  95. * 获取一个批次号
  96. *
  97. * @return void
  98. */
  99. public function actionBatchNum()
  100. {
  101. if ($this->request->isAjax) {
  102. return $this->success('ok', TaxOrder::getBatchNum());
  103. }
  104. }
  105. /**
  106. * 手续费
  107. *
  108. * @return void
  109. */
  110. public function actionFee()
  111. {
  112. if ($this->request->isAjax) {
  113. $num = $this->request->get('num');
  114. $service = new OrderService(['mall_id' => $this->mall_id]);
  115. return $this->success('ok', $service->getFeeDeatil($num));
  116. }
  117. }
  118. }