AgentController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace addons\CloudStock\backend\controllers;
  3. use addons\CloudStock\common\services\AgentService;
  4. use common\enums\DownloadEnum;
  5. use common\helpers\csv\CsvExportHelper;
  6. use Yii;
  7. /**
  8. * 默认控制器
  9. *
  10. * Class DefaultController
  11. * @package addons\CloudStock\backend\controllers
  12. */
  13. class AgentController extends BaseController
  14. {
  15. public $enableCsrfValidation = false;
  16. public function actionDispenseOrderManagement()
  17. {
  18. // 查询参数
  19. if (Yii::$app->request->isAjax) {
  20. if (Yii::$app->request->isGet) {
  21. $params = Yii::$app->request->get();
  22. $params['mall_id'] = $this->mall_id;
  23. $list = (new AgentService(['mall_id' => $this->mall_id]))->dispenseOrderManagement($params);
  24. return $this->success('操作成功', $list);
  25. }
  26. if (\Yii::$app->request->post('flag') == 'EXPORT') {
  27. $data = \Yii::$app->request->post();
  28. $data['mall_id'] = $this->mall_id;
  29. $filename = "云库存-配货管理-" . date('YmdHis') . '_' . rand(10000, 99999);
  30. $res = CsvExportHelper::exportDownLoadCenter($this->mall_id, $filename, DownloadEnum::TYPE_CLOUD_STOCK, AgentService::class, 'exportData', $data);
  31. if ($res === false) return $this->error('加入导出任务失败' . CsvExportHelper::getStaticError());
  32. return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!');
  33. }
  34. }
  35. return $this->render($this->action->id);
  36. }
  37. public function actionGetDetail()
  38. {
  39. // 查询参数
  40. if (Yii::$app->request->isAjax) {
  41. if (Yii::$app->request->isGet) {
  42. $params = Yii::$app->request->get();
  43. $params['mall_id'] = $this->mall_id;
  44. $list = (new AgentService(['mall_id' => $this->mall_id]))->getDetail($params);
  45. return $this->success('操作成功', $list);
  46. }
  47. }
  48. }
  49. public function actionGetExportList()
  50. {
  51. $data = (new AgentService(['mall_id' => $this->mall_id]))->getExportFieldList();
  52. return $this->success('操作成功', $data);
  53. }
  54. }