BalanceController.class.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Controller;
  15. use Admin\Model\BalanceModel;
  16. class BalanceController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='结算中心';
  20. $this->breadcrumb2='结算管理';
  21. }
  22. public function index(){
  23. $model=new BalanceModel();
  24. $search = ' 1= 1 ';
  25. $post_data = I('get.');
  26. if( isset($post_data['seller_id']) && intval($post_data['seller_id']) > 0)
  27. {
  28. $search .= ' and seller_id = '.$post_data['seller_id'];
  29. }
  30. if( isset($post_data['begin_time']) && !empty($post_data['begin_time']))
  31. {
  32. $search .= ' and balance_time >= '.strtotime($post_data['begin_time']);
  33. }
  34. if( isset($post_data['end_time']) && !empty($post_data['end_time']))
  35. {
  36. $search .= ' and balance_time <= '.strtotime($post_data['end_time']);
  37. }
  38. $seller_list = M('seller')->where( array('s_status' => 1) )->select();
  39. //$seller_balance = M('seller_balance')->where( array('seller_id' => $seller_id) )->find();
  40. $seller_money_arr = array();
  41. foreach($seller_list as $key => $val)
  42. {
  43. //s_id
  44. $seller_balance = M('seller_balance')->where( array('seller_id' => $val['s_id']) )->find();
  45. if(empty($seller_balance))
  46. {
  47. $seller_money_arr[$val['s_id']] = 0;
  48. } else {
  49. $seller_money_arr[$val['s_id']] = $seller_balance['money'];
  50. }
  51. }
  52. $this->seller_money_arr = $seller_money_arr;
  53. $this->seller_list = $seller_list;
  54. $this->post_data = $post_data;
  55. $data=$model->show_balance_page($search);
  56. $this->assign('empty',$data['empty']);// 赋值数据集
  57. $this->assign('list',$data['list']);// 赋值数据集
  58. $this->assign('page',$data['page']);// 赋值分页输出
  59. $this->display();
  60. }
  61. public function suretixianmoney()
  62. {
  63. $id = I('get.id');
  64. $seller_tixian = M('seller_tixian')->where( array('id' => $id) )->find();
  65. if(!empty($seller_tixian)) {
  66. $seller_balance = M('seller_balance')->where( array('seller_id' => $seller_tixian['seller_id']) )->find();
  67. M('seller_tixian')->where( array('id' => $id) )->save( array('state' => 1) );
  68. $data = array();
  69. $data['dongmoney'] = $seller_balance['dongmoney']- $seller_tixian['money'];
  70. $data['hasgetmoney'] = $seller_balance['hasgetmoney'] + $seller_tixian['money'];
  71. M('seller_balance')->where( array('seller_id' => $seller_balance['seller_id']) )->save($data);
  72. $return = array(
  73. 'status'=>'success',
  74. 'message'=>'确认成功',
  75. 'jump'=>U('Balance/assets')
  76. );
  77. $this->osc_alert($return);
  78. }else {
  79. $return = array(
  80. 'status'=>'fail',
  81. 'message'=>'确认失败',
  82. 'jump'=>U('Balance/assets')
  83. );
  84. $this->osc_alert($return);
  85. }
  86. }
  87. public function suremoney()
  88. {
  89. $bid = I('get.bid');
  90. M('balance')->where( array('bid' => $bid) )->save( array('state' => 2) );
  91. $balance_info = M('balance')->where( array('bid' => $bid) )->find();//seller_id
  92. $seller_balance_info = M('seller_balance')->where( array('seller_id' => $balance_info['seller_id']) )->find();
  93. if(empty($seller_balance_info)) {
  94. $data = array();
  95. $data['money'] = $balance_info['money'];
  96. $data['seller_id'] = $balance_info['seller_id'];
  97. $data['hasgetmoney'] = 0;
  98. $data['dongmoney'] = 0;
  99. M('seller_balance')->add($data);
  100. } else {
  101. $data = array();
  102. $data['money'] = $balance_info['money']+ $seller_balance_info['money'];
  103. M('seller_balance')->where( array('seller_id' => $balance_info['seller_id']) )->save($data);
  104. }
  105. $return = array(
  106. 'status'=>'success',
  107. 'message'=>'确认成功',
  108. 'jump'=>U('Balance/index')
  109. );
  110. $this->osc_alert($return);
  111. }
  112. public function assets()
  113. {
  114. $this->breadcrumb2='申请提现';
  115. $model=new BalanceModel();
  116. $name = I('get.name','');
  117. $search = '';
  118. if(!empty($name))
  119. {
  120. $search = ' and s.s_true_name like "%'.$name.'%" ';
  121. }
  122. $data=$model->show_balance_assets_page($search);
  123. $this->assign('empty',$data['empty']);// 赋值数据集
  124. $this->assign('list',$data['list']);// 赋值数据集
  125. $this->assign('page',$data['page']);// 赋值分页输出
  126. $seller_balance = M('seller_balance')->where( array('seller_id' => SELLERUID) )->find();
  127. if( empty($seller_balance) ) {
  128. $seller_balance = array();
  129. $seller_balance['money'] = 0;
  130. $seller_balance['hasgetmoney'] = 0;
  131. $seller_balance['dongmoney'] = 0;
  132. }
  133. $this->seller_balance = $seller_balance;
  134. $this->display();
  135. }
  136. public function orderlook()
  137. {
  138. $model=new BalanceModel();
  139. $bid = I('get.bid');
  140. $data=$model->show_balance_order_page($bid);
  141. $balance = M('balance')->where( array('bid' => $bid) )->find();
  142. $seller_id = $balance['seller_id'];
  143. $seller_balance = M('seller_balance')->where( array('seller_id' => $seller_id) )->find();
  144. if( empty($seller_balance) ) {
  145. $seller_balance = array();
  146. $seller_balance['money'] = 0;
  147. $seller_balance['hasgetmoney'] = 0;
  148. $seller_balance['dongmoney'] = 0;
  149. }
  150. $wait_balance_money = $model->wait_balance_order($seller_id);
  151. $this->wait_balance_money = $wait_balance_money;
  152. $this->seller_balance = $seller_balance;
  153. $this->assign('empty',$data['empty']);// 赋值数据集
  154. $this->assign('list',$data['list']);// 赋值数据集
  155. $this->assign('page',$data['page']);// 赋值分页输出
  156. $this->display();
  157. }
  158. }
  159. ?>