MemberController.class.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 Admin\Controller;
  15. use Admin\Model\MemberModel;
  16. class MemberController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='用户';
  20. $this->breadcrumb2='前台用户';
  21. }
  22. public function index(){
  23. $model=new MemberModel();
  24. $filter=I('get.');
  25. $search=array();
  26. if(isset($filter['name'])){
  27. $search['name']=$filter['name'];
  28. }
  29. $data=$model->show_member_page($search);
  30. foreach($data['list'] as $key => $val)
  31. {
  32. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  33. if(!empty($address_info)) {
  34. $val['telephone'] = $address_info['telephone'];
  35. }
  36. $data['list'][$key] = $val;
  37. }
  38. $this->assign('empty',$data['empty']);// 赋值数据集
  39. $this->assign('list',$data['list']);// 赋值数据集
  40. $this->assign('page',$data['page']);// 赋值分页输出
  41. $this->display();
  42. }
  43. /**
  44. 分销提现申请
  45. **/
  46. public function commissapply()
  47. {
  48. $this->breadcrumb2='分销提现申请';
  49. $model=new MemberModel();
  50. $filter=I('get.');
  51. $search=array();
  52. if(isset($filter['name'])){
  53. $search['name']=$filter['name'];
  54. }
  55. $data=$model->show_applymembercomiss_page($search);
  56. foreach($data['list'] as $key => $val)
  57. {
  58. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  59. if(!empty($address_info)) {
  60. $val['telephone'] = $address_info['telephone'];
  61. }
  62. $data['list'][$key] = $val;
  63. }
  64. $this->assign('empty',$data['empty']);// 赋值数据集
  65. $this->assign('list',$data['list']);// 赋值数据集
  66. $this->assign('page',$data['page']);// 赋值分页输出
  67. $this->display();
  68. }
  69. /**
  70. 分销申请
  71. **/
  72. public function apply()
  73. {
  74. $this->breadcrumb2='分销商申请';
  75. $model=new MemberModel();
  76. $filter=I('get.');
  77. $search=array();
  78. if(isset($filter['name'])){
  79. $search['name']=$filter['name'];
  80. }
  81. $data=$model->show_applymember_page($search);
  82. foreach($data['list'] as $key => $val)
  83. {
  84. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  85. if(!empty($address_info)) {
  86. $val['telephone'] = $address_info['telephone'];
  87. }
  88. $data['list'][$key] = $val;
  89. }
  90. $this->assign('empty',$data['empty']);// 赋值数据集
  91. $this->assign('list',$data['list']);// 赋值数据集
  92. $this->assign('page',$data['page']);// 赋值分页输出
  93. $this->display();
  94. }
  95. /**
  96. * 导出会员名单
  97. */
  98. function export()
  99. {
  100. $filter=I('get.');
  101. $search=array();
  102. if(isset($filter['name'])){
  103. $search['name']=$filter['name'];
  104. }
  105. if(isset($filter['tel'])){
  106. $search['tel']=$filter['tel'];
  107. }
  108. $sql="select * from ".C('DB_PREFIX')."member where 1 ";
  109. if(isset($search['name'])){
  110. $sql.=" and uname like '%".$search['name']."%'";
  111. }
  112. if(isset($search['tel'])){
  113. $sql.=" and telephone='".$search['tel']."'";
  114. }
  115. $sql.=' order by member_id desc LIMIT 100000 ';
  116. $list = M()->query($sql);
  117. $need_data = array();
  118. foreach($list as $val)
  119. {
  120. $tmp_data = array();
  121. $tmp_data['member_id'] = $val['member_id'];
  122. $tmp_data['openid'] = $val['openid'];
  123. $tmp_data['name'] = $val['name'];
  124. $tmp_data['telephone'] = ' ';
  125. $tmp_data['address_name'] = '未填写';
  126. $tmp_data['province'] = '未填写';
  127. $tmp_data['city'] = '未填写';
  128. $tmp_data['country'] = '未填写';
  129. $tmp_data['address'] = '未填写';
  130. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  131. if(!empty($address_info)) {
  132. $province_info = M('area')->where( array('area_id' => $address_info['province_id']) )->find();
  133. if(!empty($province_info)) {
  134. $tmp_data['province'] = $province_info['area_name'];
  135. }
  136. $city_info = M('area')->where( array('area_id' => $address_info['city_id']) )->find();
  137. if(!empty($city_info)) {
  138. $tmp_data['city'] = $city_info['area_name'];
  139. }
  140. $country_info = M('area')->where( array('area_id' => $address_info['country_id']) )->find();
  141. if(!empty($country_info)) {
  142. $tmp_data['country'] = $country_info['area_name'];
  143. }
  144. $tmp_data['telephone'] = ' '.$address_info['telephone'];
  145. $tmp_data['address_name'] = $address_info['name'];
  146. $tmp_data['address'] = $address_info['address'];
  147. }
  148. $need_data[] = $tmp_data;
  149. }
  150. $xlsCell = array(
  151. array('member_id','会员ID'),
  152. array('openid','OPENID'),
  153. array('name','昵称'),
  154. array('address_name','收件人姓名'),
  155. array('telephone','联系电话'),
  156. array('province','省份'),
  157. array('city','城市'),
  158. array('country','区 '),
  159. array('address','详细地址 ')
  160. );
  161. $expTitle = '会员信息_'.date('Y-m-d H:i:s');
  162. export_excel($expTitle,$xlsCell,$need_data);
  163. }
  164. /**
  165. 升级成为分销商
  166. **/
  167. function fencommiss()
  168. {
  169. $id = I('get.id');
  170. M('member')->where( array('member_id' => $id) )->save( array('comsiss_flag' => 1) );
  171. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  172. if(empty($member_commiss))
  173. {
  174. $data = array();
  175. $data['member_id'] = $id;
  176. $data['money'] = 0;
  177. $data['dongmoney'] = 0;
  178. $data['getmoney'] = 0;
  179. M('member_commiss')->add($data);
  180. }
  181. $return = array();
  182. $return['status'] = 'success';
  183. $return['message'] = '操作成功';
  184. $return['jump'] = U('Member/apply');
  185. $this->osc_alert($return);
  186. }
  187. //'{:U("Member/commissmoneyapply",array("id"=>$m["member_id"],"aid" => $m["id"], "state" => 1))}' >
  188. /**
  189. 分佣提现申请
  190. **/
  191. function commissmoneyapply()
  192. {
  193. $aid = I('get.aid',0);
  194. $id = I('get.id',0);
  195. $state = I('get.state',0,'intval');
  196. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  197. $tixian_order = M('tixian_order')->where( array('id' => $aid) )->find();
  198. if($state == 1)
  199. {
  200. //money dongmoney getmoney
  201. $data = array();
  202. $data['getmoney'] = $member_commiss['getmoney'] + $tixian_order['money'];
  203. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  204. M('member_commiss')->where( array('member_id' => $id) )->save($data);
  205. M('tixian_order')->where( array('id' => $aid) )->save( array('state' => 1,'shentime' => time()) );
  206. } else if($state == 2){
  207. $data = array();
  208. $data['money'] = $member_commiss['money'] + $tixian_order['money'];
  209. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  210. M('member_commiss')->where( array('member_id' => $id) )->save($data);
  211. M('tixian_order')->where( array('id' => $aid) )->save( array('state' => 2,'shentime' => time()) );
  212. }
  213. $return = array();
  214. $return['status'] = 'success';
  215. $return['message'] = '操作成功';
  216. $return['jump'] = U('Member/commissapply');
  217. $this->osc_alert($return);
  218. }
  219. function fencommissapply()
  220. {
  221. $aid = I('get.aid',0);
  222. $id = I('get.id',0);
  223. M('member_commiss_apply')->where( array('id' => $aid) )->save( array('state' => 1) );
  224. M('member')->where( array('member_id' => $id) )->save( array('comsiss_flag' => 1) );
  225. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  226. if(empty($member_commiss))
  227. {
  228. $data = array();
  229. $data['member_id'] = $id;
  230. $data['money'] = 0;
  231. $data['dongmoney'] = 0;
  232. $data['getmoney'] = 0;
  233. M('member_commiss')->add($data);
  234. }
  235. $return = array();
  236. $return['status'] = 'success';
  237. $return['message'] = '操作成功';
  238. $return['jump'] = U('Member/apply');
  239. $this->osc_alert($return);
  240. }
  241. function add(){
  242. $model=new MemberModel();
  243. if(IS_POST){
  244. $data=I('post.');
  245. $return=$model->add_member($data);
  246. $this->osc_alert($return);
  247. }
  248. $this->crumbs='新增';
  249. $this->display();
  250. }
  251. function info(){
  252. $model=new MemberModel();
  253. if(IS_POST){
  254. $data=I('post.');
  255. $return=$model->edit_info($data);
  256. $this->osc_alert($return);
  257. }
  258. $this->crumbs='编辑';
  259. $this->action=U('Member/info');
  260. $this->data=$model->info(I('id'));
  261. $this->display();
  262. }
  263. }
  264. ?>