| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace addons\AvoidTax\backend\controllers;
- use addons\AvoidTax\common\models\TaxOrder;
- use addons\AvoidTax\common\service\AccountService;
- use addons\AvoidTax\common\service\OrderService;
- use common\enums\DownloadEnum;
- use common\helpers\csv\CsvExportHelper;
- use Yii;
- /**
- * 交易相关
- *
- * Class OrderController
- * @package addons\AvoidTax\backend\controllers
- */
- class OrderController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 交易列表
- *
- * @return
- */
- public function actionIndex()
- {
- if ($this->request->isAjax && $this->request->isGet) {
- $params = $this->request->getQueryParams();
- $service = new OrderService(['mall_id' => $this->mall_id]);
- $list = $service->getOrderList($params);
- return $this->success('ok', $list);
- }
- if(Yii::$app->request->post('flag') == 'EXPORT'){
- $post = Yii::$app->request->post();
- $post['mall_id'] = $this->mall_id;
- $filename = '交易列表-' . date('YmdHis').'_'.rand(10000,99999);
- $post['sub_type'] = TaxOrder::SUB_TYPE_USER;
- $res = CsvExportHelper::exportDownLoadCenter($this->mall_id,$filename,DownloadEnum::TYPE_STATISTICS,TaxOrder::class,'exportHandle', $post);
- if ($res === false) return $this->error('加入导出任务失败'.CsvExportHelper::getStaticError());
- return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!');
- }
- return $this->render('index');
- }
- /**
- * 添加交易
- *
- * @return void
- */
- public function actionAdd()
- {
- if ($this->request->isAjax) {
- $data = $this->request->post('data');
- $service = new OrderService(['mall_id' => $this->mall_id]);
- return $service->addOrder($data) ? $this->success('ok') : $this->error($service->error);
- }
- return $this->render($this->action->id);
- }
- /**
- * 获取记帐本列表
- *
- * @return void
- */
- public function actionBookList()
- {
- if ($this->request->isAjax) {
- $service = new AccountService(['mall_id'=>$this->mall_id]);
- return $this->success('ok', $service->getBookList());
- }
- }
- /**
- * 支付打款
- *
- * @return void
- */
- public function actionTrans()
- {
- if ($this->request->isAjax) {
- $service = new OrderService(['mall_id'=>$this->mall_id]);
- $id = $this->request->getQueryParam('id');
-
- return $service->trans($id) ? $this->success('ok') : $this->error($service->error);
- }
- }
- /**
- * 批量汇款
- *
- * @return void
- */
- public function actionBatchTrans()
- {
- if ($this->request->isAjax) {
- $service = new OrderService(['mall_id'=>$this->mall_id]);
- $ids = $this->request->getBodyParam('ids');
- return $service->batchTrans($ids) ? $this->success('添加成功') : $this->error($service->error);
- }
- }
- /**
- * 获取一个批次号
- *
- * @return void
- */
- public function actionBatchNum()
- {
- if ($this->request->isAjax) {
- return $this->success('ok', TaxOrder::getBatchNum());
- }
- }
- /**
- * 手续费
- *
- * @return void
- */
- public function actionFee()
- {
- if ($this->request->isAjax) {
- $num = $this->request->get('num');
- $service = new OrderService(['mall_id' => $this->mall_id]);
- return $this->success('ok', $service->getFeeDeatil($num));
- }
- }
- }
|