StoreExtract.php 4.3 KB

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