Memberwithdraw.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\shop\controller;
  11. use app\model\member\Withdraw as MemberWithdrawModel;
  12. use app\model\system\Pay;
  13. use app\model\web\Account as AccountModel;
  14. /**
  15. * 会员管理 控制器
  16. */
  17. class Memberwithdraw extends BaseShop
  18. {
  19. /**
  20. * 会员提现配置
  21. */
  22. public function config()
  23. {
  24. $config_model = new MemberWithdrawModel();
  25. if (request()->isAjax()) {
  26. if (empty(input("transfer_type"))) {
  27. $transfer_type = "";
  28. } else {
  29. $transfer_type = implode(",", input("transfer_type"));
  30. }
  31. //订单提现
  32. $data = [
  33. 'is_auto_audit' => input('is_auto_audit', 0),//是否需要审核 1 手动审核 2 自动审核
  34. 'rate' => input('rate', 0),//提现手续费比率 (0-100)
  35. 'transfer_type' => $transfer_type,//转账方式,
  36. 'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账
  37. 'min' => input('min', 0),//提现最低额度
  38. 'max' => input('max', 0),//提现最高额度
  39. ];
  40. $this->addLog("设置会员提现配置");
  41. $is_use = input("is_use", 0);//是否启用
  42. $res = $config_model->setConfig($data, $is_use, $this->site_id, $this->app_module);
  43. return $res;
  44. } else {
  45. $this->forthMenu();
  46. $this->assign("is_exist", addon_is_exit("memberwithdraw", $this->site_id));
  47. //会员提现
  48. $config_result = $config_model->getConfig($this->site_id, $this->app_module);
  49. $this->assign('config', $config_result[ 'data' ]);
  50. $pay_model = new Pay();
  51. $transfer_type_list = $pay_model->getTransferType($this->site_id);
  52. $this->assign("transfer_type_list", $transfer_type_list);
  53. return $this->fetch('memberwithdraw/config');
  54. }
  55. }
  56. /**
  57. * 会员提现列表
  58. * @return mixed
  59. */
  60. public function lists()
  61. {
  62. $withdraw_model = new MemberWithdrawModel();
  63. if (request()->isAjax()) {
  64. $page = input('page', 1);
  65. $page_size = input('page_size', PAGE_LIST_ROWS);
  66. $withdraw_no = input('withdraw_no', '');
  67. $start_date = input('start_date', '');
  68. $end_date = input('end_date', '');
  69. $status = input('status', 'all');//提现状态
  70. $transfer_type = input('transfer_type', '');//提现转账方式
  71. $member_name = input('member_name', '');//提现转账方式
  72. $payment_start_date = input('payment_start_date', '');
  73. $payment_end_time = input('payment_end_time', '');
  74. $condition = [ [ 'site_id', '=', $this->site_id ] ];
  75. if (!empty($withdraw_no)) {
  76. $condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  77. }
  78. if (!empty($transfer_type)) {
  79. $condition[] = [ 'transfer_type', '=', $transfer_type ];
  80. }
  81. if ($status != "all") {
  82. $condition[] = [ 'status', '=', $status ];
  83. }
  84. if (!empty($member_name)) {
  85. $condition[] = [ 'member_name', '=', $member_name ];
  86. }
  87. if ($start_date != '' && $end_date != '') {
  88. $condition[] = [ 'apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  89. } else if ($start_date != '' && $end_date == '') {
  90. $condition[] = [ 'apply_time', '>=', strtotime($start_date) ];
  91. } else if ($start_date == '' && $end_date != '') {
  92. $condition[] = [ 'apply_time', '<=', strtotime($end_date) ];
  93. }
  94. if ($payment_start_date != '' && $payment_end_time != '') {
  95. $condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
  96. } else if ($payment_start_date != '' && $payment_end_time == '') {
  97. $condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
  98. } else if ($payment_start_date == '' && $payment_end_time != '') {
  99. $condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
  100. }
  101. $order = 'apply_time desc';
  102. return $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order);
  103. } else {
  104. $this->assign("is_exist", addon_is_exit("memberwithdraw", $this->site_id));
  105. $pay_model = new Pay();
  106. $transfer_type_list = $pay_model->getTransferType($this->site_id);
  107. $this->assign("transfer_type_list", $transfer_type_list);
  108. $account_model = new AccountModel();
  109. $member_balance_sum = $account_model->getMemberBalanceSum($this->site_id);
  110. $this->assign('member_balance_sum', $member_balance_sum[ 'data' ]);
  111. return $this->fetch("memberwithdraw/lists");
  112. }
  113. }
  114. /**
  115. * 详情
  116. */
  117. public function detail()
  118. {
  119. $id = input('id', 0);
  120. $withdraw_model = new MemberWithdrawModel();
  121. $withdraw_info_result = $withdraw_model->getMemberWithdrawInfo([ [ "id", "=", $id ], [ 'site_id', '=', $this->site_id ] ]);
  122. $withdraw_info = $withdraw_info_result[ "data" ];
  123. if (empty($withdraw_info)) $this->error('未获取到提现数据', addon_url('shop/memberwithdraw/lists'));
  124. $this->assign("withdraw_info", $withdraw_info);
  125. return $this->fetch("memberwithdraw/detail");
  126. }
  127. /**
  128. * 同意
  129. * @return array
  130. */
  131. public function agree()
  132. {
  133. if (request()->isAjax()) {
  134. $id = input('id', 0);
  135. $withdraw_model = new MemberWithdrawModel();
  136. $condition = array (
  137. [ 'site_id', '=', $this->site_id ],
  138. [ "id", "=", $id ],
  139. [ 'status', '=', 0 ]
  140. );
  141. $result = $withdraw_model->agree($condition);
  142. return $result;
  143. }
  144. }
  145. /**
  146. * 拒绝
  147. * @return array
  148. */
  149. public function refuse()
  150. {
  151. if (request()->isAjax()) {
  152. $id = input('id', 0);
  153. $refuse_reason = input('refuse_reason', '');
  154. $withdraw_model = new MemberWithdrawModel();
  155. $condition = array (
  156. [ 'site_id', '=', $this->site_id ],
  157. [ "id", "=", $id ],
  158. [ 'status', '=', 0 ]
  159. );
  160. $data = array (
  161. "refuse_reason" => $refuse_reason
  162. );
  163. $result = $withdraw_model->refuse($condition, $data);
  164. return $result;
  165. }
  166. }
  167. /**
  168. * 转账
  169. */
  170. public function transferFinish()
  171. {
  172. if (request()->isAjax()) {
  173. $id = input('id', 0);
  174. $certificate = input('certificate', '');
  175. $certificate_remark = input('certificate_remark', '');
  176. $withdraw_model = new MemberWithdrawModel();
  177. $data = array (
  178. "id" => $id,
  179. "site_id" => $this->site_id,
  180. "certificate" => $certificate,
  181. "certificate_remark" => $certificate_remark,
  182. );
  183. $result = $withdraw_model->transferFinish($data);
  184. return $result;
  185. }
  186. }
  187. public function export(){
  188. $withdraw_model = new MemberWithdrawModel();
  189. $withdraw_no = input('withdraw_no', '');
  190. $start_date = input('start_date', '');
  191. $end_date = input('end_date', '');
  192. $status = input('status', 'all');//提现状态
  193. $transfer_type = input('transfer_type', '');//提现转账方式
  194. $member_name = input('member_name', '');//提现转账方式
  195. $payment_start_date = input('payment_start_date', '');
  196. $payment_end_time = input('payment_end_time', '');
  197. $condition = [ [ 'site_id', '=', $this->site_id ] ];
  198. if (!empty($withdraw_no)) {
  199. $condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  200. }
  201. if (!empty($transfer_type)) {
  202. $condition[] = [ 'transfer_type', '=', $transfer_type ];
  203. }
  204. if ($status != "all") {
  205. $condition[] = [ 'status', '=', $status ];
  206. }
  207. if (!empty($member_name)) {
  208. $condition[] = [ 'member_name', '=', $member_name ];
  209. }
  210. if ($start_date != '' && $end_date != '') {
  211. $condition[] = [ 'apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  212. } else if ($start_date != '' && $end_date == '') {
  213. $condition[] = [ 'apply_time', '>=', strtotime($start_date) ];
  214. } else if ($start_date == '' && $end_date != '') {
  215. $condition[] = [ 'apply_time', '<=', strtotime($end_date) ];
  216. }
  217. if ($payment_start_date != '' && $payment_end_time != '') {
  218. $condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
  219. } else if ($payment_start_date != '' && $payment_end_time == '') {
  220. $condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
  221. } else if ($payment_start_date == '' && $payment_end_time != '') {
  222. $condition[] = [ 'payment_time', '<=', strtotime($payment_end_time) ];
  223. }
  224. $order = 'apply_time desc';
  225. $withdraw_model->exportWithdraw($condition, $order);
  226. }
  227. }