FinancialRecord.php 4.8 KB

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