FinancialRecord.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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 crmeb\services\ExcelService;
  16. use think\App;
  17. class FinancialRecord extends BaseController
  18. {
  19. protected $repository;
  20. public function __construct(App $app, FinancialRecordRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. }
  25. public function lst()
  26. {
  27. [$page, $limit] = $this->getPage();
  28. $where = $this->request->params(['keyword', 'date', 'mer_id']);
  29. $merId = $this->request->merId();
  30. if ($merId) {
  31. $where['mer_id'] = $merId;
  32. $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon'];
  33. } else {
  34. $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon'];
  35. }
  36. return app('json')->success($this->repository->getList($where, $page, $limit));
  37. }
  38. public function export()
  39. {
  40. $where = $this->request->params(['keyword', 'date', 'mer_id']);
  41. $merId = $this->request->merId();
  42. if ($merId) {
  43. $where['mer_id'] = $merId;
  44. $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon'];
  45. } else {
  46. $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon'];
  47. }
  48. [$page, $limit] = $this->getPage();
  49. $data = app()->make(ExcelService::class)->financial($where,$page,$limit);
  50. return app('json')->success($data);
  51. }
  52. /**
  53. * TODO 头部统计
  54. * @return \think\response\Json
  55. * @author Qinii
  56. * @day 3/23/21
  57. */
  58. public function getTitle()
  59. {
  60. $where = $this->request->params(['date']);
  61. $where['is_mer'] = $this->request->merId() ?? 0 ;
  62. if($where['is_mer'] == 0){
  63. $data = $this->repository->getAdminTitle($where);
  64. }else{
  65. $data = $this->repository->getMerchantTitle($where);
  66. }
  67. return app('json')->success($data);
  68. }
  69. /**
  70. * TODO 列表
  71. * @return \think\response\Json
  72. * @author Qinii
  73. * @day 3/23/21
  74. */
  75. public function getList()
  76. {
  77. [$page, $limit] = $this->getPage();
  78. $where = $this->request->params([['type',1],'date']);
  79. $where['is_mer'] = $this->request->merId() ?? 0 ;
  80. $data = $this->repository->getAdminList($where,$page, $limit);
  81. return app('json')->success($data);
  82. }
  83. /**
  84. * TODO 详情
  85. * @param $type
  86. * @return \think\response\Json
  87. * @author Qinii
  88. * @day 3/23/21
  89. */
  90. public function detail($type)
  91. {
  92. $date = $this->request->param('date');
  93. $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
  94. $where['is_mer'] = $this->request->merId() ?? 0 ;
  95. if($this->request->merId()){
  96. $data = $this->repository->merDetail($type,$where);
  97. }else{
  98. $data = $this->repository->adminDetail($type,$where);
  99. }
  100. return app('json')->success($data);
  101. }
  102. /**
  103. * TODO 导出文件
  104. * @param $type
  105. * @author Qinii
  106. * @day 3/25/21
  107. */
  108. public function exportDetail($type)
  109. {
  110. [$page, $limit] = $this->getPage();
  111. $date = $this->request->param('date');
  112. $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
  113. $where['type'] = $type;
  114. $where['is_mer'] = $this->request->merId() ?? 0 ;
  115. $data = app()->make(ExcelService::class)->exportFinancial($where,$page,$limit);
  116. // app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'exportFinancial',$where['is_mer']);
  117. return app('json')->success($data);
  118. }
  119. /**
  120. * TODO 流水统计
  121. * @return \think\response\Json
  122. * @author Qinii
  123. * @day 5/7/21
  124. */
  125. public function title()
  126. {
  127. $where = $this->request->params(['date']);
  128. // $data = $this->repository->getFiniancialTitle($this->request->merId(),$where);
  129. $data = [];
  130. return app('json')->success($data);
  131. }
  132. }