Financial.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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\financial;
  12. use app\common\repositories\store\ExcelRepository;
  13. use app\common\repositories\system\financial\FinancialRepository;
  14. use crmeb\basic\BaseController;
  15. use crmeb\services\ExcelService;
  16. use think\App;
  17. /**
  18. * 商户财务申请提现
  19. */
  20. class Financial extends BaseController
  21. {
  22. public $repository;
  23. public function __construct(App $app, FinancialRepository $repository)
  24. {
  25. parent::__construct($app);
  26. $this->repository = $repository;
  27. }
  28. /**
  29. * 商户申请转账申请记录列表
  30. * @return \think\response\Json
  31. * @author Qinii
  32. */
  33. public function lst()
  34. {
  35. [$page, $limit] = $this->getPage();
  36. $where = $this->request->params(['date', 'status', 'financial_type', 'financial_status', 'keyword', 'is_trader', 'mer_id']);
  37. $where['type'] = 0;
  38. $data = $this->repository->getAdminList($where, $page, $limit);
  39. return app('json')->success($data);
  40. }
  41. /**
  42. * 商户保证金列表
  43. * @return \think\response\Json
  44. * @author Qinii
  45. * @day 2023/5/24
  46. */
  47. public function getMarginLst()
  48. {
  49. [$page, $limit] = $this->getPage();
  50. $where = $this->request->params(['date', 'status', 'keyword', 'is_trader', 'mer_id', 'type_id', 'category_id']);
  51. $where['type'] = 1;
  52. $data = $this->repository->getAdminList($where, $page, $limit);
  53. return app('json')->success($data);
  54. }
  55. /**
  56. * 详情
  57. * @param $id
  58. * @return \think\response\Json
  59. * @author Qinii
  60. * @day 3/19/21
  61. */
  62. public function detail($id)
  63. {
  64. $data = $this->repository->detail($id);
  65. return app('json')->success($data);
  66. }
  67. /**
  68. * 审核表单
  69. * @param $id
  70. * @return \think\response\Json
  71. * @author Qinii
  72. */
  73. public function statusForm($id)
  74. {
  75. return app('json')->success(formToData($this->repository->statusForm($id)));
  76. }
  77. /**
  78. * 审核
  79. * @param $id
  80. * @return \think\response\Json
  81. * @author Qinii
  82. * @day 3/19/21
  83. */
  84. public function switchStatus($id)
  85. {
  86. $data = $this->request->params([['status', 0], 'refusal']);
  87. $type = $this->request->param('type', 0);
  88. $data['status_time'] = date('Y-m-d H:i:s');
  89. if (!in_array($data['status'], [1, -1])) {
  90. return app('json')->fail('审核状态错误');
  91. }
  92. if (($data['status'] == -1) && empty($data['refusal'])) {
  93. return app('json')->fail('请输入拒绝理由');
  94. }
  95. if ($data['status'] == 1) $data['refusal'] = '';
  96. $data['admin_id'] = $this->request->adminId();
  97. $this->repository->switchStatus($id, $type, $data);
  98. return app('json')->success('审核完成');
  99. }
  100. /**
  101. * 退款详情
  102. * @param $id
  103. * @return \think\response\Json
  104. * @author Qinii
  105. */
  106. public function refundShow($id)
  107. {
  108. return app('json')->success($this->repository->refundShow($id));
  109. }
  110. /**
  111. * 修改凭证
  112. * @param $id
  113. * @return \think\response\Json
  114. * @author Qinii
  115. * @day 3/19/21
  116. */
  117. public function update($id)
  118. {
  119. $image = $this->request->param('image');
  120. if (empty($image)) return app('json')->fail('请上传凭证');
  121. $res = $this->repository->get($id);
  122. if ($res['status'] != 1) return app('json')->success('申请未通过审核');
  123. $data['image'] = implode(',', $image);
  124. $data['admin_id'] = $this->request->adminId();
  125. $data['update_time'] = date('Y-m-d H:i:s');
  126. $data['financial_status'] = 1;
  127. $this->repository->update($id, $data);
  128. return app('json')->success('修改完成');
  129. }
  130. /**
  131. * 备注表单
  132. * @param $id
  133. * @return \think\response\Json
  134. * @author Qinii
  135. */
  136. public function markForm($id)
  137. {
  138. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  139. }
  140. /**
  141. * 保证金备注表单
  142. * @param $id
  143. * @return \think\response\Json
  144. * @author Qinii
  145. */
  146. public function markMarginForm($id)
  147. {
  148. return app('json')->success(formToData($this->repository->adminMarginMarkForm($id)));
  149. }
  150. /**
  151. * 备注
  152. * @param $id
  153. * @return \think\response\Json
  154. * @author Qinii
  155. * @day 3/19/21
  156. */
  157. public function mark($id)
  158. {
  159. $ret = $this->repository->getWhere([$this->repository->getPk() => $id]);
  160. if (!$ret) return app('json')->fail('数据不存在');
  161. $data = $this->request->params(['admin_mark']);
  162. $this->repository->update($id, $data);
  163. return app('json')->success('备注成功');
  164. }
  165. /**
  166. * 头部统计
  167. * @return \think\response\Json
  168. * @author Qinii
  169. * @day 4/22/21
  170. */
  171. public function title()
  172. {
  173. $ret = $this->repository->getTitle(['type' => 0]);
  174. return app('json')->success($ret);
  175. }
  176. /**
  177. * 导出
  178. * @return \think\response\Json
  179. * @author Qinii
  180. * @day 4/22/21
  181. */
  182. public function export()
  183. {
  184. $where = $this->request->params(['date', 'status', 'financial_type', 'financial_status', 'keyword', 'is_trader', 'mer_id']);
  185. [$page, $limit] = $this->getPage();
  186. $where['type'] = 0;
  187. $data = app()->make(ExcelService::class)->financialLog($where, $page, $limit);
  188. return app('json')->success($data);
  189. }
  190. }