BalanceController.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 Seller\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 = 'seller_id='.SELLERUID;
  25. $post_data = I('get.');
  26. if( isset($post_data['begin_time']) && !empty($post_data['begin_time']))
  27. {
  28. $search .= ' and balance_time >= '.strtotime($post_data['begin_time']);
  29. }
  30. if( isset($post_data['end_time']) && !empty($post_data['end_time']))
  31. {
  32. $search .= ' and balance_time <= '.strtotime($post_data['end_time']);
  33. }
  34. $this->post_data = $post_data;
  35. $data=$model->show_balance_page($search);
  36. $this->assign('empty',$data['empty']);// 赋值数据集
  37. $this->assign('list',$data['list']);// 赋值数据集
  38. $this->assign('page',$data['page']);// 赋值分页输出
  39. $this->display();
  40. }
  41. /**
  42. * 个人资产
  43. */
  44. public function assets()
  45. {
  46. $this->breadcrumb2='资产';
  47. $model=new BalanceModel();
  48. $search = ' and st.seller_id='.SELLERUID;
  49. $data=$model->show_balance_assets_page($search);
  50. $this->assign('empty',$data['empty']);// 赋值数据集
  51. $this->assign('list',$data['list']);// 赋值数据集
  52. $this->assign('page',$data['page']);// 赋值分页输出
  53. $seller_balance = M('seller_balance')->where( array('seller_id' => SELLERUID) )->find();
  54. if( empty($seller_balance) ) {
  55. $seller_balance = array();
  56. $seller_balance['money'] = 0;
  57. $seller_balance['hasgetmoney'] = 0;
  58. $seller_balance['dongmoney'] = 0;
  59. }
  60. $wait_balance_money = $model->wait_balance_order(SELLERUID);
  61. $this->wait_balance_money = $wait_balance_money;
  62. $this->seller_balance = $seller_balance;
  63. $this->display();
  64. }
  65. /**
  66. * 申请提现
  67. */
  68. public function shenqing()
  69. {
  70. $shenmoney = I('post.shenmoney');
  71. $seller_balance = M('seller_balance')->where( array('seller_id' => SELLERUID) )->find();
  72. $result = array('code' => 0,'msg' => '可提现余额不足');
  73. if(empty($seller_balance) || $seller_balance['money'] < $shenmoney) {
  74. echo json_encode($result);
  75. die();
  76. }
  77. $data = array();
  78. $data['seller_id'] = SELLERUID;
  79. $data['money'] = $shenmoney;
  80. $data['state'] = 0;
  81. $data['addtime'] = time();
  82. $res = M('seller_tixian')->add($data);
  83. if($res) {
  84. $se_data = array();
  85. $se_data['money'] = $seller_balance['money'] - $shenmoney;
  86. $se_data['dongmoney'] = $seller_balance['dongmoney'] + $shenmoney;
  87. M('seller_balance')->where( array('id' => $seller_balance['id']) )->save($se_data);
  88. $result['code'] = 1;
  89. }
  90. echo json_encode($result);
  91. die();
  92. }
  93. public function orderlook()
  94. {
  95. $model=new BalanceModel();
  96. $bid = I('get.bid');
  97. $data=$model->show_balance_order_page($bid);
  98. $this->assign('empty',$data['empty']);// 赋值数据集
  99. $this->assign('list',$data['list']);// 赋值数据集
  100. $this->assign('page',$data['page']);// 赋值分页输出
  101. $this->display();
  102. }
  103. public function suremoney()
  104. {
  105. $bid = I('get.bid');
  106. M('balance')->where( array('bid' => $bid) )->save( array('state' => 1) );
  107. $return = array(
  108. 'status'=>'success',
  109. 'message'=>'确认成功',
  110. 'jump'=>U('Balance/index')
  111. );
  112. $this->osc_alert($return);
  113. }
  114. }
  115. ?>