FissionsharingController.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Seller\Model\FissionsharingModel;
  16. use Admin\Model\GoodsModel;
  17. use Admin\Model\MemberModel;
  18. class FissionsharingController extends CommonController{
  19. protected function _initialize(){
  20. parent::_initialize();
  21. $this->breadcrumb1='营销活动';
  22. $this->breadcrumb2='裂变分享';
  23. }
  24. public function index(){
  25. $model=new FissionsharingModel();
  26. $filter=I('get.');
  27. $search=array( );
  28. if(isset($filter['name'])){
  29. $search['name']=$filter['name'];
  30. }
  31. $data=$model->show_fission_page($search);
  32. $this->assign('empty',$data['empty']);// 赋值数据集
  33. $this->assign('list',$data['list']);// 赋值数据集
  34. $this->assign('page',$data['page']);// 赋值分页输出
  35. $this->display();
  36. }
  37. public function config()
  38. {
  39. if(IS_POST){
  40. $config=I('post.');
  41. if($config && is_array($config)){
  42. $c=M('Config');
  43. foreach ($config as $name => $value) {
  44. $map = array('name' => $name);
  45. $c->where($map)->setField('value', $value);
  46. }
  47. }
  48. $return = array(
  49. 'status'=>'success',
  50. 'message'=>'操作成功',
  51. 'jump'=>U('Fissionsharing/config')
  52. );
  53. $this->osc_alert($return);
  54. }
  55. $this->site=$this->get_config_by_group('site');
  56. $this->display();
  57. }
  58. function get_config_by_group($group){
  59. $list=M('config')->where(array('config_group'=>$group))->select();
  60. if(isset($list)){
  61. foreach ($list as $k => $v) {
  62. $config[$v['name']]=$v;
  63. }
  64. }
  65. return $config;
  66. }
  67. /**
  68. 分销提现申请
  69. **/
  70. public function commissapply()
  71. {
  72. $model=new MemberModel();
  73. $filter=I('get.');
  74. $search=array();
  75. if(isset($filter['name'])){
  76. $search['name']=$filter['name'];
  77. }
  78. $data=$model->show_fen_applymembercomiss_page($search);
  79. foreach($data['list'] as $key => $val)
  80. {
  81. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  82. if(!empty($address_info)) {
  83. $val['telephone'] = $address_info['telephone'];
  84. }
  85. $data['list'][$key] = $val;
  86. }
  87. $this->assign('empty',$data['empty']);// 赋值数据集
  88. $this->assign('list',$data['list']);// 赋值数据集
  89. $this->assign('page',$data['page']);// 赋值分页输出
  90. $this->display();
  91. }
  92. /**
  93. 分佣提现申请
  94. **/
  95. function commissmoneyapply()
  96. {
  97. $aid = I('get.aid',0);
  98. $id = I('get.id',0);
  99. $state = I('get.state',0,'intval');
  100. $member_commiss = M('member_sharing')->where( array('member_id' => $id) )->find();
  101. $tixian_order = M('fen_tixian_order')->where( array('id' => $aid) )->find();
  102. if($state == 1)
  103. {
  104. //money dongmoney getmoney
  105. $data = array();
  106. $data['getmoney'] = $member_commiss['getmoney'] + $tixian_order['money'];
  107. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  108. M('member_sharing')->where( array('member_id' => $id) )->save($data);
  109. M('fen_tixian_order')->where( array('id' => $aid) )->save( array('state' => 1,'shentime' => time()) );
  110. } else if($state == 2){
  111. $data = array();
  112. $data['money'] = $member_commiss['money'] + $tixian_order['money'];
  113. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  114. M('member_sharing')->where( array('member_id' => $id) )->save($data);
  115. M('fen_tixian_order')->where( array('id' => $aid) )->save( array('state' => 2,'shentime' => time()) );
  116. }
  117. $return = array();
  118. $return['status'] = 'success';
  119. $return['message'] = '操作成功';
  120. $return['jump'] = U('Fissionsharing/commissapply');
  121. $this->osc_alert($return);
  122. }
  123. }
  124. ?>