Financial.php 3.9 KB

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