FinancialRecord.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\store\order\StoreOrderRepository;
  14. use app\common\repositories\system\merchant\FinancialRecordRepository;
  15. use app\common\repositories\system\merchant\MerchantRepository;
  16. use crmeb\basic\BaseController;
  17. use crmeb\services\ExcelService;
  18. use think\App;
  19. /**
  20. * 资金流水
  21. */
  22. class FinancialRecord extends BaseController
  23. {
  24. protected $repository;
  25. public function __construct(App $app, FinancialRecordRepository $repository)
  26. {
  27. parent::__construct($app);
  28. $this->repository = $repository;
  29. }
  30. /**
  31. * 列表
  32. * @return \think\response\Json
  33. * @author Qinii
  34. */
  35. public function lst()
  36. {
  37. [$page, $limit] = $this->getPage();
  38. $where = $this->request->params(['keyword', 'date', 'mer_id','uid','real_name','nickname','order_sn']);
  39. $pay_type = $this->request->param('pay_type', '');
  40. if ($pay_type != '') $where['pay_type'] = StoreOrderRepository::PAY_TYPE_FILTEER[$pay_type];
  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', 'svip'];
  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', 'svip'];
  47. }
  48. return app('json')->success($this->repository->getList($where, $page, $limit));
  49. }
  50. /**
  51. * 导出
  52. * @return \think\response\Json
  53. * @author Qinii
  54. * @day 3/23/21
  55. */
  56. public function export()
  57. {
  58. $where = $this->request->params(['keyword', 'date', 'mer_id']);
  59. $merId = $this->request->merId();
  60. if ($merId) {
  61. $where['mer_id'] = $merId;
  62. $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order', 'order_platform_coupon', 'order_svip_coupon', 'svip'];
  63. } else {
  64. $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order', 'order_platform_coupon', 'order_svip_coupon', 'svip'];
  65. }
  66. [$page, $limit] = $this->getPage();
  67. $data = app()->make(ExcelService::class)->financial($where, $page, $limit);
  68. return app('json')->success($data);
  69. }
  70. /**
  71. * 账单头部统计
  72. * @return \think\response\Json
  73. * @author Qinii
  74. * @day 3/23/21
  75. */
  76. public function getTitle()
  77. {
  78. $where = $this->request->params(['date']);
  79. $where['is_mer'] = $this->request->merId() ?? 0;
  80. if ($where['is_mer'] == 0) {
  81. $data = $this->repository->getAdminTitle($where);
  82. } else {
  83. $data = $this->repository->getMerchantTitle($where);
  84. }
  85. return app('json')->success($data);
  86. }
  87. /**
  88. * 账单管理列表
  89. * @return \think\response\Json
  90. * @author Qinii
  91. * @day 3/23/21
  92. */
  93. public function getList()
  94. {
  95. [$page, $limit] = $this->getPage();
  96. $where = $this->request->params([['type', 1], 'date']);
  97. $where['is_mer'] = $this->request->merId() ?? 0;
  98. $data = $this->repository->getAdminList($where, $page, $limit);
  99. return app('json')->success($data);
  100. }
  101. /**
  102. * 详情
  103. * @param $type
  104. * @return \think\response\Json
  105. * @author Qinii
  106. * @day 3/23/21
  107. */
  108. public function detail($type)
  109. {
  110. $date = $this->request->param('date');
  111. $where['date'] = empty($date) ? date('Y-m-d', time()) : $date;
  112. $where['is_mer'] = $this->request->merId() ?? 0;
  113. if ($this->request->merId()) {
  114. $data = $this->repository->merDetail($type, $where);
  115. } else {
  116. $data = $this->repository->adminDetail($type, $where);
  117. }
  118. return app('json')->success($data);
  119. }
  120. /**
  121. * 导出账单详情 - 下载账单
  122. * @param $type
  123. * @author Qinii
  124. * @day 3/25/21
  125. */
  126. public function exportDetail($type)
  127. {
  128. [$page, $limit] = $this->getPage();
  129. $date = $this->request->param('date');
  130. $where['date'] = empty($date) ? date('Y-m-d', time()) : $date;
  131. $where['type'] = $type;
  132. $where['is_mer'] = $this->request->merId() ?? 0;
  133. $data = app()->make(ExcelService::class)->exportFinancial($where, $page, $limit);
  134. // app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'exportFinancial',$where['is_mer']);
  135. return app('json')->success($data);
  136. }
  137. /**
  138. * 流水统计
  139. * @return \think\response\Json
  140. * @author Qinii
  141. * @day 5/7/21
  142. */
  143. public function title()
  144. {
  145. $where = $this->request->params(['date']);
  146. // $data = $this->repository->getFiniancialTitle($this->request->merId(),$where);
  147. $data = [];
  148. return app('json')->success($data);
  149. }
  150. /**
  151. * 平台财务查看每个商户的财务信息列表
  152. * @return \think\response\Json
  153. * @author Qinii
  154. * @day 2023/10/18
  155. *
  156. */
  157. public function merchantFinancial()
  158. {
  159. [$page, $limit] = $this->getPage();
  160. $where = $this->request->params(['mer_id']);
  161. $where['is_del'] = 0;
  162. $data = $this->repository->merchantFinancial($where, $page, $limit);
  163. return app('json')->success($data);
  164. }
  165. /**
  166. * 财务记录
  167. * @param $id
  168. * @return \think\response\Json
  169. * @author Qinii
  170. * @day 2023/10/18
  171. */
  172. public function merAcountsList($id)
  173. {
  174. [$page, $limit] = $this->getPage();
  175. $where = $this->request->params([['type', 1], 'date']);
  176. $where['is_mer'] = $id;
  177. $data = $this->repository->getAdminList($where, $page, $limit);
  178. return app('json')->success($data);
  179. }
  180. /**
  181. * 头部统计
  182. * @param $id
  183. * @return \think\response\Json
  184. * @author Qinii
  185. * @day 2023/10/18
  186. */
  187. public function merAcountsTitle($id)
  188. {
  189. $where = $this->request->params(['date']);
  190. $where['is_mer'] = $id;
  191. $data = $this->repository->getMerchantTitle($where);
  192. return app('json')->success($data);
  193. }
  194. /**
  195. * 详情
  196. * @param $type
  197. * @return \think\response\Json
  198. * @author Qinii
  199. * @day 2023/10/18
  200. */
  201. public function merDetail($type)
  202. {
  203. $date = $this->request->param('date');
  204. $where['date'] = empty($date) ? date('Y-m-d', time()) : $date;
  205. $where['is_mer'] = $this->request->param('mer_id');
  206. if (!$where['is_mer']) return app('json')->fail('请选择商户');
  207. $data = $this->repository->merDetail($type, $where);
  208. return app('json')->success($data);
  209. }
  210. /**
  211. * 导出
  212. * @param $type
  213. * @return \think\response\Json
  214. * @author Qinii
  215. * @day 2023/10/18
  216. */
  217. public function merExportDetail($type)
  218. {
  219. [$page, $limit] = $this->getPage();
  220. $date = $this->request->param('date');
  221. $where['date'] = empty($date) ? date('Y-m-d', time()) : $date;
  222. $where['type'] = $type;
  223. $where['is_mer'] = $this->request->param('mer_id');
  224. if (!$where['is_mer']) return app('json')->fail('请选择商户');
  225. $data = app()->make(ExcelService::class)->exportFinancial($where, $page, $limit);
  226. return app('json')->success($data);
  227. }
  228. }