SupplierExtract.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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\admin\v1\supplier;
  12. use think\facade\App;
  13. use app\controller\admin\AuthController;
  14. use app\services\supplier\finance\SupplierExtractServices;
  15. /**
  16. * 供应商提现
  17. * Class SupplierExtract
  18. * @package app\controller\admin\v1\supplier
  19. */
  20. class SupplierExtract extends AuthController
  21. {
  22. /**
  23. * StoreExtract constructor.
  24. * @param App $app
  25. * @param SupplierExtractServices $services
  26. */
  27. public function __construct(App $app, SupplierExtractServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 显示资源列表
  34. * @return mixed
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. */
  39. public function index()
  40. {
  41. $where = $this->request->getMore([
  42. ['status', ''],
  43. ['pay_status', ''],
  44. ['extract_type', ''],
  45. ['nireid', '', '', 'like'],
  46. ['data', '', '', 'time'],
  47. ['supplier_id', '']
  48. ]);
  49. if (isset($where['extract_type']) && $where['extract_type'] == 'wx') {
  50. $where['extract_type'] = 'weixin';
  51. }
  52. $whereData = [
  53. 'supplier_id' => $where['supplier_id'],
  54. 'is_del' => 0,
  55. ];
  56. return app('json')->success($this->services->index($where, $whereData));
  57. }
  58. /**
  59. * 增加备注
  60. * @param $id
  61. * @return mixed
  62. */
  63. public function mark($id)
  64. {
  65. [$mark] = $this->request->getMore([
  66. ['mark', '']
  67. ], true);
  68. if (!$id) {
  69. return app('json')->fail('缺少参数');
  70. }
  71. if (!$mark) {
  72. return app('json')->fail('请填写备注信息');
  73. }
  74. $extract = $this->services->get((int)$id);
  75. if (!$extract) {
  76. return app('json')->fail('转账记录不存在');
  77. }
  78. if (!$this->services->update($id, ['supplier_mark' => $mark])) {
  79. return app('json')->fail('备注失败');
  80. }
  81. return app('json')->success('备注成功');
  82. }
  83. /**
  84. * 审核
  85. * @param $id
  86. * @return mixed
  87. */
  88. public function verify($id)
  89. {
  90. if (!$id) $this->fail('缺少参数');
  91. [$type, $message] = $this->request->postMore([
  92. ['type', 1],
  93. ['message', '']
  94. ], true);
  95. $adminId = $this->adminId;
  96. if ($type == 1) {
  97. $res = $this->services->adopt($id, $adminId);
  98. } else {
  99. $res = $this->services->refuse((int)$id, $message, $adminId);
  100. }
  101. return $this->success($res ? '操作成功' : '操作失败');
  102. }
  103. /**
  104. * 转账表单
  105. * @param $id
  106. * @return mixed
  107. */
  108. public function transfer($id)
  109. {
  110. if (!$id) $this->fail('缺少参数');
  111. return $this->success($this->services->add_transfer((int)$id));
  112. }
  113. /**
  114. * 转账提交
  115. * @param $id
  116. * @return mixed
  117. */
  118. public function save_transfer($id)
  119. {
  120. $data = $this->request->postMore([
  121. ['voucher_image', ''],
  122. ['voucher_title', '']
  123. ]);
  124. $info = $this->services->getExtract($id);
  125. if (!$info) $this->fail('提现记录不存在');
  126. if ($info['status'] != 1) $this->fail('请先审核提现记录');
  127. if ($info['pay_status'] == 1) $this->fail('请勿重复提现');
  128. $data['pay_status'] = 1;
  129. if (!$this->services->update($id, $data)) {
  130. return app('json')->fail('转账失败');
  131. }
  132. return app('json')->success('转账成功');
  133. }
  134. }