Financial.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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\merchant\system\financial;
  12. use app\common\repositories\system\financial\FinancialRepository;
  13. use app\common\repositories\system\merchant\MerchantRepository;
  14. use app\validate\merchant\MerchantFinancialAccountValidate;
  15. use crmeb\basic\BaseController;
  16. use think\App;
  17. class Financial extends BaseController
  18. {
  19. /**
  20. * @var FinancialRepository
  21. */
  22. protected $repository;
  23. /**
  24. * Merchant constructor.
  25. * @param App $app
  26. * @param FinancialRepository $repository
  27. */
  28. public function __construct(App $app, FinancialRepository $repository)
  29. {
  30. parent::__construct($app);
  31. $this->repository = $repository;
  32. }
  33. /**
  34. * TODO 转账信息Form
  35. * @param $id
  36. * @return \think\response\Json
  37. * @author Qinii
  38. * @day 3/18/21
  39. */
  40. public function accountForm()
  41. {
  42. return app('json')->success(formToData($this->repository->financialAccountForm($this->request->merId())));
  43. }
  44. /**
  45. * TODO 转账信息保存
  46. * @param MerchantFinancialAccountValidate $accountValidate
  47. * @return \think\response\Json
  48. * @author Qinii
  49. * @day 3/18/21
  50. */
  51. public function accountSave(MerchantFinancialAccountValidate $accountValidate)
  52. {
  53. $data = $this->request->params(['account','financial_type','name','bank','bank_code','wechat','wechat_code','alipay','alipay_code']); //idcard
  54. $accountValidate->check($data);
  55. $this->repository->saveAccount($this->request->merId(),$data);
  56. return app('json')->success('保存成功');
  57. }
  58. /**
  59. * TODO 申请转账form
  60. * @return \think\response\Json
  61. * @author Qinii
  62. * @day 3/19/21
  63. */
  64. public function createForm()
  65. {
  66. return app('json')->success(formToData($this->repository->applyForm($this->request->merId())));
  67. }
  68. /**
  69. * TODO 申请转账保存
  70. * @return \think\response\Json
  71. * @author Qinii
  72. * @day 3/19/21
  73. */
  74. public function createSave()
  75. {
  76. $data = $this->request->param(['extract_money','financial_type','mark']);
  77. $data['mer_admin_id'] = $this->request->adminId();
  78. $this->repository->saveApply($this->request->merId(),$data);
  79. return app('json')->success('保存成功');
  80. }
  81. /**
  82. * TODO 列表
  83. * @author Qinii
  84. * @day 3/19/21
  85. */
  86. public function lst()
  87. {
  88. [$page, $limit] = $this->getPage();
  89. $where = $this->request->params(['date','status','financial_type','financial_status','keyword']);
  90. $where['keywords_'] = $where['keyword'];
  91. unset($where['keyword']);
  92. $where['mer_id'] = $this->request->merId();
  93. $data = $this->repository->getAdminList($where,$page,$limit);
  94. return app('json')->success($data);
  95. }
  96. /**
  97. * TODO 取消申请
  98. * @param $id
  99. * @return \think\response\Json
  100. * @author Qinii
  101. * @day 3/19/21
  102. */
  103. public function delete($id)
  104. {
  105. $this->repository->cancel($this->request->merId(),$id,['is_del' => 1]);
  106. return app('json')->success('取消申请');
  107. }
  108. /**
  109. * TODO
  110. * @param $id
  111. * @return \think\response\Json
  112. * @author Qinii
  113. * @day 3/19/21
  114. */
  115. public function detail($id)
  116. {
  117. $data = $this->repository->detail($id,$this->request->merId());
  118. if(!$data) return app('json')->fail('数据不存在');
  119. return app('json')->success($data);
  120. }
  121. public function markForm($id)
  122. {
  123. return app('json')->success(formToData($this->repository->markForm($id)));
  124. }
  125. public function mark($id)
  126. {
  127. $ret = $this->repository->getWhere([$this->repository->getPk() => $id,'mer_id' => $this->request->merId()]);
  128. if(!$ret) return app('json')->fail('数据不存在');
  129. $data = $this->request->params(['mark']);
  130. $this->repository->update($id,$data);
  131. return app('json')->success('备注成功');
  132. }
  133. }