Withdraw.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\store\storeapi\controller;
  11. use addon\store\model\StoreWithdraw;
  12. use app\storeapi\controller\BaseStoreApi;
  13. /**
  14. * 门店结算控制器
  15. */
  16. class Withdraw extends BaseStoreApi
  17. {
  18. /**
  19. * 门店申请结算
  20. */
  21. public function apply()
  22. {
  23. $store_withdraw_model = new StoreWithdraw();
  24. $money = $this->params[ 'money' ] ?? 0;
  25. $apply_params = array (
  26. 'site_id' => $this->site_id,
  27. 'store_id' => $this->store_id,
  28. 'money' => $money,
  29. 'settlement_type' => 'apply'
  30. );
  31. $withdraw_result = $store_withdraw_model->apply($apply_params);
  32. return $this->response($withdraw_result);
  33. }
  34. /**
  35. * 结算记录
  36. * @return false|string
  37. */
  38. public function page()
  39. {
  40. $page = $this->params[ 'page' ] ?? 1;
  41. $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
  42. $withdraw_no = $this->params[ 'withdraw_no' ] ?? '';
  43. $start_date = $this->params[ 'start_date' ] ?? '';
  44. $end_date = $this->params[ 'end_date' ] ?? '';
  45. $status = $this->params[ 'status' ] ?? 'all';//提现状态
  46. $transfer_type = $this->params[ 'transfer_type' ] ?? '';//提现转账方式
  47. $payment_start_date = $this->params[ 'payment_start_date' ] ?? '';
  48. $payment_end_time = $this->params[ 'payment_end_time' ] ?? '';
  49. $settlement_type = $this->params[ 'settlement_type' ] ?? '';
  50. $condition = [
  51. [ 'site_id', '=', $this->site_id ],
  52. [ 'store_id', '=', $this->store_id ]
  53. ];
  54. if (!empty($withdraw_no)) {
  55. $condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
  56. }
  57. if (!empty($transfer_type)) {
  58. $condition[] = [ 'transfer_type', '=', $transfer_type ];
  59. }
  60. if (!empty($settlement_type)) {
  61. $condition[] = [ 'settlement_type', '=', $settlement_type ];
  62. }
  63. if ($status != 'all') {
  64. $condition[] = [ 'status', '=', $status ];
  65. }
  66. if ($start_date != '' && $end_date != '') {
  67. $condition[] = [ 'apply_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
  68. } else if ($start_date != '' && $end_date == '') {
  69. $condition[] = [ 'apply_time', '>=', strtotime($start_date) ];
  70. } else if ($start_date == '' && $end_date != '') {
  71. $condition[] = [ 'apply_time', '<=', strtotime($end_date) ];
  72. }
  73. if ($payment_start_date != '' && $payment_end_time != '') {
  74. $condition[] = [ 'transfer_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_time) ] ];
  75. } else if ($payment_start_date != '' && $payment_end_time == '') {
  76. $condition[] = [ 'transfer_time', '>=', strtotime($payment_start_date) ];
  77. } else if ($payment_start_date == '' && $payment_end_time != '') {
  78. $condition[] = [ 'transfer_time', '<=', strtotime($payment_end_time) ];
  79. }
  80. $order = 'apply_time desc';
  81. $withdraw_model = new StoreWithdraw();
  82. $data = $withdraw_model->getStoreWithdrawPageList($condition, $page, $page_size, $order);
  83. return $this->response($data);
  84. }
  85. /**
  86. * 筛选内容
  87. * @return false|string
  88. */
  89. public function screen()
  90. {
  91. $withdraw_model = new StoreWithdraw();
  92. $data = [
  93. 'status' => $withdraw_model->status,
  94. 'settlement_type' => $withdraw_model->settlement_type,
  95. 'transfer_type_list' => $withdraw_model->getTransferType($this->site_id)
  96. ];
  97. return $this->response($this->success($data));
  98. }
  99. /**
  100. * 获取结算详情
  101. * @return false|string
  102. */
  103. public function detail()
  104. {
  105. $withdraw_id = $this->params[ 'withdraw_id' ] ?? 0;
  106. $withdraw_model = new StoreWithdraw();
  107. $withdraw_info = $withdraw_model->detail([ 'site_id' => $this->site_id, 'store_id' => $this->store_id, 'withdraw_id' => $withdraw_id ]);
  108. return $this->response($withdraw_info);
  109. }
  110. }