Withdraw.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\store\shop\controller;
  11. use addon\store\model\StoreWithdraw;
  12. use app\shop\controller\BaseShop;
  13. /**
  14. * 门店提现控制器
  15. */
  16. class Withdraw extends BaseShop
  17. {
  18. /**
  19. * 转账
  20. */
  21. public function transferFinish()
  22. {
  23. if (request()->isAjax()) {
  24. $withdraw_id = input('withdraw_id', 0);
  25. $voucher_img = input('voucher_img', '');
  26. $voucher_desc = input('voucher_desc', '');
  27. $withdraw_model = new StoreWithdraw();
  28. $data = array (
  29. 'withdraw_id' => $withdraw_id,
  30. 'site_id' => $this->site_id,
  31. 'voucher_desc' => $voucher_desc,
  32. 'voucher_img' => $voucher_img,
  33. );
  34. $result = $withdraw_model->transferFinish($data);
  35. return $result;
  36. }
  37. }
  38. /**
  39. * 门店提现列表
  40. * @return mixed
  41. */
  42. public function lists()
  43. {
  44. $withdraw_model = new StoreWithdraw();
  45. if (request()->isAjax()) {
  46. $page = input('page', 1);
  47. $page_size = input('page_size', PAGE_LIST_ROWS);
  48. $withdraw_no = input('withdraw_no', '');
  49. $start_date = input('start_date', '');
  50. $end_date = input('end_date', '');
  51. $status = input('status', 'all');//提现状态
  52. $transfer_type = input('transfer_type', '');//提现转账方式
  53. $store_id = input('store_id', 0);//门店
  54. $transfer_start_date = input('transfer_start_date', '');
  55. $transfer_end_date = input('transfer_end_date', '');
  56. $settlement_type = input('settlement_type', '');
  57. $condition = [ [ 'sw.site_id', '=', $this->site_id ] ];
  58. if (!empty($withdraw_no)) {
  59. $condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  60. }
  61. if (!empty($transfer_type)) {
  62. $condition[] = [ 'transfer_type', '=', $transfer_type ];
  63. }
  64. if ($store_id > 0) {
  65. $condition[] = [ 'sw.store_id', '=', $store_id ];
  66. }
  67. if (!empty($settlement_type)) {
  68. $condition[] = [ 'settlement_type', '=', $settlement_type ];
  69. }
  70. if ($status != 'all') {
  71. $condition[] = [ 'sw.status', '=', $status ];
  72. }
  73. if ($start_date != '' && $end_date != '') {
  74. $condition[] = [ 'apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  75. } else if ($start_date != '' && $end_date == '') {
  76. $condition[] = [ 'apply_time', '>=', strtotime($start_date) ];
  77. } else if ($start_date == '' && $end_date != '') {
  78. $condition[] = [ 'apply_time', '<=', strtotime($end_date) ];
  79. }
  80. if ($transfer_start_date != '' && $transfer_end_date != '') {
  81. $condition[] = [ 'transfer_time', 'between', [ strtotime($transfer_start_date), strtotime($transfer_end_date) ] ];
  82. } else if ($transfer_start_date != '' && $transfer_end_date == '') {
  83. $condition[] = [ 'transfer_time', '>=', strtotime($transfer_start_date) ];
  84. } else if ($transfer_start_date == '' && $transfer_end_date != '') {
  85. $condition[] = [ 'transfer_time', '<=', strtotime($transfer_end_date) ];
  86. }
  87. $order = 'apply_time desc';
  88. $join = [
  89. [ 'store s', 's.store_id = sw.store_id', 'left' ]
  90. ];
  91. return $withdraw_model->getStoreWithdrawPageList($condition, $page, $page_size, $order, 'sw.*,s.telphone', 'sw', $join);
  92. } else {
  93. $this->assign('settlement_type_list', $withdraw_model->settlement_type);
  94. $transfer_type_list = $withdraw_model->getTransferType($this->site_id);
  95. $this->assign('transfer_type_list', $transfer_type_list);
  96. $store_model = new \app\model\store\Store();
  97. $store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
  98. $this->assign('store_list', $store_list);
  99. $stat_model = new \addon\store\model\Stat();
  100. $stat_condition = array (
  101. [ 'site_id', '=', $this->site_id ]
  102. );
  103. $total_account = $stat_model->getStoreAccountSum($stat_condition, 'account')[ 'data' ] ?? 0;
  104. $total_account_apply = $stat_model->getStoreAccountSum($stat_condition, 'account_apply')[ 'data' ] ?? 0;
  105. $total_account_withdraw = $stat_model->getStoreAccountSum($stat_condition, 'account_withdraw')[ 'data' ] ?? 0;
  106. $this->assign('stat', [
  107. 'total_account' => $total_account,
  108. 'total_account_apply' => $total_account_apply,
  109. 'total_account_withdraw' => $total_account_withdraw,
  110. ]);
  111. $this->assign('status_list', $withdraw_model->status);
  112. return $this->fetch('withdraw/lists');
  113. }
  114. }
  115. /**
  116. * 提现详情
  117. * @return mixed
  118. */
  119. public function detail()
  120. {
  121. $withdraw_id = input('withdraw_id', 0);
  122. $withdraw_model = new StoreWithdraw();
  123. $withdraw_info = $withdraw_model->detail([ 'site_id' => $this->site_id, 'withdraw_id' => $withdraw_id ])[ 'data' ] ?? [];
  124. if (empty($withdraw_info))
  125. $this->error('找不到此项提现记录!');
  126. $this->assign('withdraw_info', $withdraw_info);
  127. return $this->fetch('withdraw/detail');
  128. }
  129. /**
  130. * 同意
  131. * @return array
  132. */
  133. public function agree()
  134. {
  135. if (request()->isAjax()) {
  136. $withdraw_id = input('withdraw_id', 0);
  137. $withdraw_model = new StoreWithdraw();
  138. $params = array (
  139. 'site_id' => $this->site_id,
  140. 'withdraw_id' => $withdraw_id,
  141. 'status' => 0
  142. );
  143. $result = $withdraw_model->agree($params);
  144. return $result;
  145. }
  146. }
  147. /**
  148. * 拒绝
  149. * @return array
  150. */
  151. public function refuse()
  152. {
  153. if (request()->isAjax()) {
  154. $withdraw_id = input('withdraw_id', 0);
  155. $refuse_reason = input('refuse_reason', '');
  156. $withdraw_model = new StoreWithdraw();
  157. $params = array (
  158. 'site_id' => $this->site_id,
  159. 'withdraw_id' => $withdraw_id,
  160. 'refuse_reason' => $refuse_reason
  161. );
  162. $result = $withdraw_model->refuse($params);
  163. return $result;
  164. }
  165. }
  166. }