Withdraw.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\fenxiao\shop\controller;
  11. use addon\fenxiao\model\FenxiaoStat;
  12. use addon\fenxiao\model\FenxiaoWithdraw as FenxiaoWithdrawModel;
  13. use app\shop\controller\BaseShop;
  14. /**
  15. * 分销等级管理
  16. */
  17. class Withdraw extends BaseShop
  18. {
  19. /**
  20. * 会员提现列表
  21. * @return mixed
  22. */
  23. public function lists()
  24. {
  25. $model = new FenxiaoWithdrawModel();
  26. $transfer_type_list = $model->getTransferType($this->site_id);
  27. if (request()->isAjax()) {
  28. $page = input('page', 1);
  29. $page_size = input('page_size', PAGE_LIST_ROWS);
  30. $withdraw_no = input('withdraw_no', '');
  31. $start_date = input('start_date', '');
  32. $end_date = input('end_date', '');
  33. $status = input('status', 'all');//提现状态
  34. $transfer_type = input('transfer_type', '');//提现转账方式
  35. $fenxiao_name = input('fenxiao_name', '');//提现转账方式
  36. $payment_start_date = input('payment_start_date', '');
  37. $payment_end_date = input('payment_end_date', '');
  38. $condition = [ [ 'fw.site_id', '=', $this->site_id ] ];
  39. if (!empty($withdraw_no)) {
  40. $condition[] = [ 'fw.withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  41. }
  42. if (!empty($transfer_type)) {
  43. $condition[] = [ 'fw.transfer_type', '=', $transfer_type ];
  44. }
  45. if ($status != "all") {
  46. $condition[] = [ 'fw.status', '=', $status ];
  47. }
  48. if (!empty($fenxiao_name)) {
  49. $condition[] = [ 'm.nickname|fw.fenxiao_name', '=', $fenxiao_name ];
  50. }
  51. if ($start_date != '' && $end_date != '') {
  52. $condition[] = [ 'fw.create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  53. } else if ($start_date != '' && $end_date == '') {
  54. $condition[] = [ 'fw.create_time', '>=', strtotime($start_date) ];
  55. } else if ($start_date == '' && $end_date != '') {
  56. $condition[] = [ 'fw.create_time', '<=', strtotime($end_date) ];
  57. }
  58. if ($payment_start_date != '' && $payment_end_date != '') {
  59. $condition[] = [ 'fw.payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_date) ] ];
  60. } else if ($payment_start_date != '' && $payment_end_date == '') {
  61. $condition[] = [ 'fw.payment_time', '>=', strtotime($payment_start_date) ];
  62. } else if ($payment_start_date == '' && $payment_end_date != '') {
  63. $condition[] = [ 'fw.payment_time', '<=', strtotime($payment_end_date) ];
  64. }
  65. $order = 'fw.create_time desc';
  66. $field = 'fw.*, m.headimg,m.nickname,m.mobile as member_mobile,m.headimg';
  67. $join = [
  68. [ 'member m', 'fw.member_id = m.member_id', 'left' ]
  69. ];
  70. $list = $model->getFenxiaoWithdrawPageList($condition, $page, $page_size, $order, $field, 'fw', $join);
  71. foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
  72. $list[ 'data' ][ 'list' ][ $k ][ 'transfer_type_name' ] = $transfer_type_list[ $v[ 'transfer_type' ] ];
  73. }
  74. return $list;
  75. } else {
  76. $this->assign('transfer_type_list', $transfer_type_list);
  77. $fenxiao_stat_model = new FenxiaoStat();
  78. $fenxiao_balance_sum = $fenxiao_stat_model->getFenxiaoAccountSum($this->site_id)[ 'data' ] ?? [];
  79. $this->assign('fenxiao_balance_sum', $fenxiao_balance_sum);
  80. return $this->fetch("withdraw/lists");
  81. }
  82. }
  83. /**
  84. * 提现记录详情
  85. * @return mixed
  86. */
  87. public function detail()
  88. {
  89. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  90. $params = array (
  91. 'id' => input('id', 0),
  92. 'site_id' => $this->site_id
  93. );
  94. $detail = $fenxiao_withdraw_model->getFenxiaoWithdrawDetail($params)[ 'data' ] ?? [];
  95. if (empty($detail))
  96. $this->error('找不到提现账户记录');
  97. $this->assign('info', $detail);
  98. return $this->fetch('withdraw/detail');
  99. }
  100. /**
  101. * 同意
  102. * @return array
  103. */
  104. public function agree()
  105. {
  106. if (request()->isAjax()) {
  107. $id = input('id', 0);
  108. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  109. $params = array (
  110. 'site_id' => $this->site_id,
  111. "id" => $id,
  112. );
  113. $result = $fenxiao_withdraw_model->agree($params);
  114. return $result;
  115. }
  116. }
  117. /**
  118. * 拒绝
  119. * @return array
  120. */
  121. public function refuse()
  122. {
  123. if (request()->isAjax()) {
  124. $id = input('id', 0);
  125. $refuse_reason = input('refuse_reason', '');
  126. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  127. $data = array (
  128. "refuse_reason" => $refuse_reason,
  129. 'site_id' => $this->site_id,
  130. 'id' => $id
  131. );
  132. $result = $fenxiao_withdraw_model->refuse($data);
  133. return $result;
  134. }
  135. }
  136. /**
  137. * 转账
  138. */
  139. public function transferFinish()
  140. {
  141. if (request()->isAjax()) {
  142. $id = input('id', 0);
  143. $certificate = input('certificate', '');
  144. $certificate_remark = input('certificate_remark', '');
  145. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  146. $data = array (
  147. "id" => $id,
  148. "site_id" => $this->site_id,
  149. "certificate" => $certificate,
  150. "certificate_remark" => $certificate_remark,
  151. );
  152. $result = $fenxiao_withdraw_model->transferFinish($data);
  153. return $result;
  154. }
  155. }
  156. /**
  157. * 转账
  158. */
  159. public function transfer()
  160. {
  161. if (request()->isAjax()) {
  162. $id = input('id', 0);
  163. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  164. $result = $fenxiao_withdraw_model->transfer([ 'id' => $id, 'site_id' => $this->site_id ]);
  165. return $result;
  166. }
  167. }
  168. public function export()
  169. {
  170. $fenxiao_withdraw_model = new FenxiaoWithdrawModel();
  171. $withdraw_no = input('withdraw_no', '');
  172. $start_date = input('start_date', '');
  173. $end_date = input('end_date', '');
  174. $status = input('status', 'all');//提现状态
  175. $transfer_type = input('transfer_type', '');//提现转账方式
  176. $fenxiao_name = input('fenxiao_name', '');//提现转账方式
  177. $payment_start_date = input('payment_start_date', '');
  178. $payment_end_date = input('payment_end_date', '');
  179. $condition = [ [ 'site_id', '=', $this->site_id ] ];
  180. if (!empty($withdraw_no)) {
  181. $condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  182. }
  183. if (!empty($transfer_type)) {
  184. $condition[] = [ 'transfer_type', '=', $transfer_type ];
  185. }
  186. if ($status != "all") {
  187. $condition[] = [ 'status', '=', $status ];
  188. }
  189. if (!empty($fenxiao_name)) {
  190. $condition[] = [ 'fenxiao_name', '=', $fenxiao_name ];
  191. }
  192. if ($start_date != '' && $end_date != '') {
  193. $condition[] = [ 'create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  194. } else if ($start_date != '' && $end_date == '') {
  195. $condition[] = [ 'create_time', '>=', strtotime($start_date) ];
  196. } else if ($start_date == '' && $end_date != '') {
  197. $condition[] = [ 'create_time', '<=', strtotime($end_date) ];
  198. }
  199. if ($payment_start_date != '' && $payment_end_date != '') {
  200. $condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_date) ] ];
  201. } else if ($payment_start_date != '' && $payment_end_date == '') {
  202. $condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
  203. } else if ($payment_start_date == '' && $payment_end_date != '') {
  204. $condition[] = [ 'payment_time', '<=', strtotime($payment_end_date) ];
  205. }
  206. $order = 'create_time desc';
  207. $fenxiao_withdraw_model->exportFenxiaoWithdraw($condition, $order, $this->site_id);
  208. }
  209. //
  210. // public function test(){
  211. // $model = new FenxiaoWithdrawModel();
  212. // $data = array (
  213. // 'member_id' => 417,
  214. // 'transfer_type' => 'alipay',
  215. // 'realname' => $realname ?? 'zxczx',
  216. // 'bank_name' => $bank_name ?? '45yuik',
  217. // 'account_number' => $account_number ?? '43453',
  218. // 'apply_money' => $apply_money ?? '1',
  219. // 'mobile' => $mobile ?? '18541256985',
  220. // 'app_type' => $app_type ?? ''
  221. // );
  222. // $result = $model->apply($data, $this->site_id, 'shop');
  223. // dd($result);
  224. // }
  225. }