FinancialRecord.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace app\controller\admin\system\merchant;
  3. use app\common\repositories\store\ExcelRepository;
  4. use app\common\repositories\system\merchant\FinancialRecordRepository;
  5. use ln\basic\BaseController;
  6. use think\App;
  7. class FinancialRecord extends BaseController
  8. {
  9. protected $repository;
  10. public function __construct(App $app, FinancialRecordRepository $repository)
  11. {
  12. parent::__construct($app);
  13. $this->repository = $repository;
  14. }
  15. public function lst()
  16. {
  17. [$page, $limit] = $this->getPage();
  18. $where = $this->request->params(['keyword', 'date', 'mer_id']);
  19. $merId = $this->request->merId();
  20. if ($merId) {
  21. $where['mer_id'] = $merId;
  22. $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order'];
  23. } else {
  24. $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order'];
  25. }
  26. return app('json')->success($this->repository->getList($where, $page, $limit));
  27. }
  28. public function export()
  29. {
  30. $where = $this->request->params(['keyword', 'date', 'mer_id']);
  31. $merId = $this->request->merId();
  32. if ($merId) {
  33. $where['mer_id'] = $merId;
  34. $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order'];
  35. } else {
  36. $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order'];
  37. }
  38. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'financial',$merId);
  39. return app('json')->success('开始导出数据');
  40. }
  41. /**
  42. * TODO 头部统计
  43. * @return \think\response\Json
  44. * @author Qinii
  45. * @day 3/23/21
  46. */
  47. public function getTitle()
  48. {
  49. $where = $this->request->params(['date']);
  50. $where['is_mer'] = $this->request->merId() ?? 0 ;
  51. if($where['is_mer'] == 0){
  52. $data = $this->repository->getAdminTitle($where);
  53. }else{
  54. $data = $this->repository->getMerchantTitle($where);
  55. }
  56. return app('json')->success($data);
  57. }
  58. /**
  59. * TODO 列表
  60. * @return \think\response\Json
  61. * @author Qinii
  62. * @day 3/23/21
  63. */
  64. public function getList()
  65. {
  66. [$page, $limit] = $this->getPage();
  67. $where = $this->request->params(['type','date']);
  68. $where['is_mer'] = $this->request->merId() ?? 0 ;
  69. $data = $this->repository->getAdminList($where,$page, $limit);
  70. return app('json')->success($data);
  71. }
  72. /**
  73. * TODO 详情
  74. * @param $type
  75. * @return \think\response\Json
  76. * @author Qinii
  77. * @day 3/23/21
  78. */
  79. public function detail($type)
  80. {
  81. $date = $this->request->param('date');
  82. $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
  83. $where['is_mer'] = $this->request->merId() ?? 0 ;
  84. if($this->request->merId()){
  85. $data = $this->repository->merDetail($type,$where);
  86. }else{
  87. $data = $this->repository->adminDetail($type,$where);
  88. }
  89. return app('json')->success($data);
  90. }
  91. /**
  92. * TODO 导出文件
  93. * @param $type
  94. * @author Qinii
  95. * @day 3/25/21
  96. */
  97. public function exportDetail($type)
  98. {
  99. $date = $this->request->param('date');
  100. $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
  101. $where['type'] = $type;
  102. $where['is_mer'] = $this->request->merId() ?? 0 ;
  103. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'exportFinancial',$where['is_mer']);
  104. return app('json')->success('开始生成文件');
  105. }
  106. /**
  107. * TODO 流水统计
  108. * @return \think\response\Json
  109. * @author Qinii
  110. * @day 5/7/21
  111. */
  112. public function title()
  113. {
  114. $where = $this->request->params(['date']);
  115. $data = $this->repository->getFiniancialTitle($this->request->merId(),$where);
  116. return app('json')->success($data);
  117. }
  118. }