member.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. <?php
  2. /**
  3. * @brief 会员模块
  4. * @class Member
  5. * @note 后台
  6. */
  7. class Member extends IController implements adminAuthorization
  8. {
  9. public $checkRight = 'all';
  10. public $layout='admin';
  11. private $data = array();
  12. function init()
  13. {
  14. }
  15. /**
  16. * @brief 添加会员
  17. */
  18. function member_edit()
  19. {
  20. $uid = IFilter::act(IReq::get('uid'),'int');
  21. //编辑会员信息读取会员信息
  22. if($uid)
  23. {
  24. $userDB = new IQuery('user as u');
  25. $userDB->join = 'left join member as m on u.id = m.user_id';
  26. $userDB->where= 'u.id = '.$uid;
  27. $userInfo = $userDB->find();
  28. if($userInfo)
  29. {
  30. $this->userInfo = current($userInfo);
  31. }
  32. else
  33. {
  34. $this->member_list();
  35. Util::showMessage("没有找到相关记录!");
  36. exit;
  37. }
  38. }
  39. $this->redirect('member_edit');
  40. }
  41. //保存会员信息
  42. function member_save()
  43. {
  44. $user_id = IFilter::act(IReq::get('user_id'),'int');
  45. $user_name = IFilter::act(IReq::get('username'));
  46. $email = IFilter::act(IReq::get('email'));
  47. $password = IFilter::act(IReq::get('password'));
  48. $repassword = IFilter::act(IReq::get('repassword'));
  49. $group_id = IFilter::act(IReq::get('group_id'),'int');
  50. $truename = IFilter::act(IReq::get('true_name'));
  51. //add by Scott Chen on 2017-11-03
  52. $id_type = IFilter::act(IReq::get('id_type'));
  53. $id_code = IFilter::act(IReq::get('id_code'));
  54. $sex = IFilter::act(IReq::get('sex'),'int');
  55. $telephone = IFilter::act(IReq::get('telephone'));
  56. $mobile = IFilter::act(IReq::get('mobile'));
  57. $province = IFilter::act(IReq::get('province'),'int');
  58. $city = IFilter::act(IReq::get('city'),'int');
  59. $area = IFilter::act(IReq::get('area'),'int');
  60. $contact_addr = IFilter::act(IReq::get('contact_addr'));
  61. $zip = IFilter::act(IReq::get('zip'));
  62. $qq = IFilter::act(IReq::get('qq'));
  63. $exp = IFilter::act(IReq::get('exp'),'int');
  64. $point = IFilter::act(IReq::get('point'),'int');
  65. $status = IFilter::act(IReq::get('status'),'int');
  66. $_POST['area'] = "";
  67. if($province && $city && $area)
  68. {
  69. $_POST['area'] = ",{$province},{$city},{$area},";
  70. }
  71. if(!$user_id && $password == '')
  72. {
  73. $this->setError('请输入密码!');
  74. }
  75. if($password != $repassword)
  76. {
  77. $this->setError('两次输入的密码不一致!');
  78. }
  79. //创建会员操作类
  80. $userDB = new IModel("user");
  81. $memberDB = new IModel("member");
  82. if($userDB->getObj("username='".$user_name."' and id != ".$user_id))
  83. {
  84. $this->setError('用户名重复');
  85. }
  86. if($email && $memberDB->getObj("email='".$email."' and user_id != ".$user_id))
  87. {
  88. $this->setError('邮箱重复');
  89. }
  90. if($mobile && $memberDB->getObj("mobile='".$mobile."' and user_id != ".$user_id))
  91. {
  92. $this->setError('手机号码重复');
  93. }
  94. //add by Scott Chen on 2017-11-03
  95. //id_type
  96. if ($id_type != "1") {
  97. return "证件类型目前只支持身份证";
  98. }
  99. if (IValidate::id_ex_18($id_code) == false) {
  100. return "非法身份证号码";
  101. }else{
  102. $memberRow = $memberDB->getObj(" id_type='" . $id_type . "' and id_code='" . $id_code ."' and user_id != ".$user_id);
  103. if($memberRow)
  104. {
  105. $this->setError('证件类型,证件号码重复');
  106. }
  107. }
  108. //操作失败表单回填
  109. if($errorMsg = $this->getError())
  110. {
  111. $this->userInfo = $_POST;
  112. $this->redirect('member_edit',false);
  113. Util::showMessage($errorMsg);
  114. }
  115. $member = array(
  116. 'email' => $email,
  117. 'true_name' => $truename,
  118. //add by Scott Chen on 2017-11-03
  119. 'id_type' => $id_type,
  120. 'id_code' => $id_code,
  121. 'telephone' => $telephone,
  122. 'mobile' => $mobile,
  123. 'area' => $_POST['area'],
  124. 'contact_addr' => $contact_addr,
  125. 'qq' => $qq,
  126. 'sex' => $sex,
  127. 'zip' => $zip,
  128. 'exp' => $exp,
  129. 'point' => $point,
  130. 'group_id' => $group_id,
  131. 'status' => $status,
  132. );
  133. //添加新会员
  134. if(!$user_id)
  135. {
  136. $user = array(
  137. 'username' => $user_name,
  138. 'password' => md5($password),
  139. );
  140. $userDB->setData($user);
  141. $user_id = $userDB->add();
  142. $member['user_id'] = $user_id;
  143. $member['time'] = ITime::getDateTime();
  144. $memberDB->setData($member);
  145. $memberDB->add();
  146. }
  147. //编辑会员
  148. else
  149. {
  150. $user = array(
  151. 'username' => $user_name,
  152. );
  153. //修改密码
  154. if($password)
  155. {
  156. $user['password'] = md5($password);
  157. }
  158. $userDB->setData($user);
  159. $userDB->update('id = '.$user_id);
  160. $member_info = $memberDB->getObj('user_id='.$user_id);
  161. //修改积分记录日志
  162. if($point != $member_info['point'])
  163. {
  164. $ctrlType = $point > $member_info['point'] ? '增加' : '减少';
  165. $diffPoint= $point-$member_info['point'];
  166. $pointObj = new Point();
  167. $pointConfig = array(
  168. 'user_id' => $user_id,
  169. 'point' => $diffPoint,
  170. 'log' => '管理员'.$this->admin['admin_name'].'将积分'.$ctrlType.$diffPoint.'积分',
  171. );
  172. $pointObj->update($pointConfig);
  173. }
  174. $memberDB->setData($member);
  175. $memberDB->update("user_id = ".$user_id);
  176. }
  177. $this->redirect('member_list');
  178. }
  179. /**
  180. * @brief 会员列表
  181. */
  182. function member_list()
  183. {
  184. $search = IFilter::act(IReq::get('search'),'strict');
  185. $keywords = IFilter::act(IReq::get('keywords'));
  186. $where = ' 1 ';
  187. if($search && $keywords)
  188. {
  189. $where .= " and $search like '%{$keywords}%' ";
  190. }
  191. $this->data['search'] = $search;
  192. $this->data['keywords'] = $keywords;
  193. $this->data['where'] = $where;
  194. $tb_user_group = new IModel('user_group');
  195. $data_group = $tb_user_group->query();
  196. $group = array();
  197. foreach($data_group as $value)
  198. {
  199. $group[$value['id']] = $value['group_name'];
  200. }
  201. $this->data['group'] = $group;
  202. $this->setRenderData($this->data);
  203. $this->redirect('member_list');
  204. }
  205. /**
  206. * 用户余额管理页面
  207. */
  208. function member_balance()
  209. {
  210. $this->layout = '';
  211. $this->redirect('member_balance');
  212. }
  213. /**
  214. * @brief 删除至回收站
  215. */
  216. function member_reclaim()
  217. {
  218. $user_ids = IReq::get('check');
  219. $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
  220. $user_ids = IFilter::act($user_ids,'int');
  221. if($user_ids)
  222. {
  223. $ids = implode(',',$user_ids);
  224. if($ids)
  225. {
  226. $tb_member = new IModel('member');
  227. $tb_member->setData(array('status'=>'2'));
  228. $where = "user_id in (".$ids.")";
  229. $tb_member->update($where);
  230. }
  231. }
  232. $this->member_list();
  233. }
  234. //批量用户余额操作
  235. function member_recharge()
  236. {
  237. $id = IFilter::act(IReq::get('check'),'int');
  238. $balance = IFilter::act(IReq::get('balance'),'float');
  239. $type = IFIlter::act(IReq::get('type')); //操作类型 recharge充值,withdraw提现金
  240. $even = '';
  241. if(!$id)
  242. {
  243. die(JSON::encode(array('flag' => 'fail','message' => '请选择要操作的用户')));
  244. return;
  245. }
  246. //执行写入操作
  247. $id = is_array($id) ? join(',',$id) : $id;
  248. $memberDB = new IModel('member');
  249. $memberData = $memberDB->query('user_id in ('.$id.')');
  250. foreach($memberData as $value)
  251. {
  252. //用户余额进行的操作记入account_log表
  253. $log = new AccountLog();
  254. $config=array
  255. (
  256. 'user_id' => $value['user_id'],
  257. 'admin_id' => $this->admin['admin_id'],
  258. 'event' => $type,
  259. 'num' => $balance,
  260. );
  261. $re = $log->write($config);
  262. if($re == false)
  263. {
  264. die(JSON::encode(array('flag' => 'fail','message' => $log->error)));
  265. }
  266. }
  267. die(JSON::encode(array('flag' => 'success')));
  268. }
  269. /**
  270. * @brief 用户组添加
  271. */
  272. function group_edit()
  273. {
  274. $gid = (int)IReq::get('gid');
  275. //编辑会员等级信息 读取会员等级信息
  276. if($gid)
  277. {
  278. $tb_user_group = new IModel('user_group');
  279. $group_info = $tb_user_group->query("id=".$gid);
  280. if(is_array($group_info) && ($info=$group_info[0]))
  281. {
  282. $this->data['group'] = array(
  283. 'group_id' => $info['id'],
  284. 'group_name'=> $info['group_name'],
  285. 'discount' => $info['discount'],
  286. 'minexp' => $info['minexp'],
  287. 'maxexp' => $info['maxexp']
  288. );
  289. }
  290. else
  291. {
  292. $this->redirect('group_list',false);
  293. Util::showMessage("没有找到相关记录!");
  294. return;
  295. }
  296. }
  297. $this->setRenderData($this->data);
  298. $this->redirect('group_edit');
  299. }
  300. /**
  301. * @brief 保存用户组修改
  302. */
  303. function group_save()
  304. {
  305. $group_id = IFilter::act(IReq::get('group_id'),'int');
  306. $maxexp = IFilter::act(IReq::get('maxexp'),'int');
  307. $minexp = IFilter::act(IReq::get('minexp'),'int');
  308. $discount = IFilter::act(IReq::get('discount'),'float');
  309. $group_name = IFilter::act(IReq::get('group_name'));
  310. $group = array(
  311. 'maxexp' => $maxexp,
  312. 'minexp' => $minexp,
  313. 'discount' => $discount,
  314. 'group_name' => $group_name
  315. );
  316. if($discount > 100)
  317. {
  318. $errorMsg = '折扣率不能大于100';
  319. }
  320. if($maxexp <= $minexp)
  321. {
  322. $errorMsg = '最大经验值必须大于最小经验值';
  323. }
  324. if(isset($errorMsg) && $errorMsg)
  325. {
  326. $group['group_id'] = $group_id;
  327. $data = array($group);
  328. $this->setRenderData($data);
  329. $this->redirect('group_edit',false);
  330. Util::showMessage($errorMsg);
  331. exit;
  332. }
  333. $tb_user_group = new IModel("user_group");
  334. $tb_user_group->setData($group);
  335. if($group_id)
  336. {
  337. $affected_rows = $tb_user_group->update("id=".$group_id);
  338. $this->redirect('group_list');
  339. }
  340. else
  341. {
  342. $tb_user_group->add();
  343. $this->redirect('group_list');
  344. }
  345. }
  346. /**
  347. * @brief 删除会员组
  348. */
  349. function group_del()
  350. {
  351. $group_ids = IReq::get('check');
  352. $group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
  353. $group_ids = IFilter::act($group_ids,'int');
  354. if($group_ids)
  355. {
  356. $ids = implode(',',$group_ids);
  357. if($ids)
  358. {
  359. $tb_user_group = new IModel('user_group');
  360. $where = "id in (".$ids.")";
  361. $tb_user_group->del($where);
  362. }
  363. }
  364. $this->redirect('group_list');
  365. }
  366. /**
  367. * @brief 回收站
  368. */
  369. function recycling()
  370. {
  371. $search = IReq::get('search');
  372. $keywords = IReq::get('keywords');
  373. $search_sql = IFilter::act($search,'strict');
  374. $keywords = IFilter::act($keywords,'strict');
  375. $where = ' 1 ';
  376. if($search && $keywords)
  377. {
  378. $where .= " and $search_sql like '%{$keywords}%' ";
  379. }
  380. $this->data['search'] = $search;
  381. $this->data['keywords'] = $keywords;
  382. $this->data['where'] = $where;
  383. $tb_user_group = new IModel('user_group');
  384. $data_group = $tb_user_group->query();
  385. $data_group = is_array($data_group) ? $data_group : array();
  386. $group = array();
  387. foreach($data_group as $value)
  388. {
  389. $group[$value['id']] = $value['group_name'];
  390. }
  391. $this->data['group'] = $group;
  392. $this->setRenderData($this->data);
  393. $this->redirect('recycling');
  394. }
  395. /**
  396. * @brief 彻底删除会员
  397. */
  398. function member_del()
  399. {
  400. $user_ids = IReq::get('check');
  401. $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
  402. $user_ids = IFilter::act($user_ids,'int');
  403. if($user_ids)
  404. {
  405. $ids = implode(',',$user_ids);
  406. if($ids)
  407. {
  408. $tb_member = new IModel('member');
  409. $where = "user_id in (".$ids.")";
  410. $tb_member->del($where);
  411. $tb_user = new IModel('user');
  412. $where = "id in (".$ids.")";
  413. $tb_user->del($where);
  414. $logObj = new log('db');
  415. $logObj->write('operation',array("管理员:".$this->admin['admin_name'],"删除了用户","被删除的用户ID为:".$ids));
  416. }
  417. }
  418. $this->redirect('member_list');
  419. }
  420. /**
  421. * @brief 从回收站还原会员
  422. */
  423. function member_restore()
  424. {
  425. $user_ids = IReq::get('check');
  426. $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
  427. if($user_ids)
  428. {
  429. $user_ids = IFilter::act($user_ids,'int');
  430. $ids = implode(',',$user_ids);
  431. if($ids)
  432. {
  433. $tb_member = new IModel('member');
  434. $tb_member->setData(array('status'=>'1'));
  435. $where = "user_id in (".$ids.")";
  436. $tb_member->update($where);
  437. }
  438. }
  439. $this->redirect('recycling');
  440. }
  441. //[提现管理] 删除
  442. function withdraw_del()
  443. {
  444. $id = IFilter::act(IReq::get('id'));
  445. if($id)
  446. {
  447. $id = IFilter::act($id,'int');
  448. $withdrawObj = new IModel('withdraw');
  449. if(is_array($id))
  450. {
  451. $idStr = join(',',$id);
  452. $where = ' id in ('.$idStr.')';
  453. }
  454. else
  455. {
  456. $where = 'id = '.$id;
  457. }
  458. $withdrawObj->del($where);
  459. $this->redirect('withdraw_recycle');
  460. }
  461. else
  462. {
  463. $this->redirect('withdraw_recycle',false);
  464. Util::showMessage('请选择要删除的数据');
  465. }
  466. }
  467. //[提现管理] 回收站 删除,恢复
  468. function withdraw_update()
  469. {
  470. $id = IFilter::act( IReq::get('id') , 'int' );
  471. $type = IReq::get('type') ;
  472. if(!empty($id))
  473. {
  474. $withdrawObj = new IModel('withdraw');
  475. $is_del = ($type == 'res') ? '0' : '1';
  476. $dataArray = array(
  477. 'is_del' => $is_del
  478. );
  479. if(is_array($id))
  480. {
  481. $idStr = join(',',$id);
  482. $where = ' id in ('.$idStr.')';
  483. }
  484. else
  485. {
  486. $where = 'id = '.$id;
  487. }
  488. $dataArray = array(
  489. 'is_del' => $is_del,
  490. );
  491. $withdrawObj->setData($dataArray);
  492. $withdrawObj->update($where);
  493. $this->redirect('withdraw_list');
  494. }
  495. else
  496. {
  497. if($type == 'del')
  498. {
  499. $this->redirect('withdraw_list',false);
  500. }
  501. else
  502. {
  503. $this->redirect('withdraw_recycle',false);
  504. }
  505. Util::showMessage('请选择要删除的数据');
  506. }
  507. }
  508. //[提现管理] 详情展示
  509. function withdraw_detail()
  510. {
  511. $id = IFilter::act( IReq::get('id'),'int' );
  512. if($id)
  513. {
  514. $withdrawObj = new IModel('withdraw');
  515. $where = 'id = '.$id;
  516. $this->withdrawRow = $withdrawObj->getObj($where);
  517. $userDB = new IModel('user as u,member as m');
  518. $this->userRow = $userDB->getObj('u.id = m.user_id and u.id = '.$this->withdrawRow['user_id']);
  519. $this->redirect('withdraw_detail',false);
  520. }
  521. else
  522. {
  523. $this->redirect('withdraw_list');
  524. }
  525. }
  526. //[提现管理] 修改提现申请的状态
  527. function withdraw_status()
  528. {
  529. $id = IFilter::act( IReq::get('id'),'int');
  530. $re_note = IFilter::act( IReq::get('re_note'),'string');
  531. $status = IFilter::act(IReq::get('status'),'int');
  532. if($id && $status)
  533. {
  534. $withdrawObj = new IModel('withdraw');
  535. //提现成功
  536. if($status == 2)
  537. {
  538. $withdrawRow = $withdrawObj->getObj('id = '.$id);
  539. //用户余额进行的操作记入account_log表
  540. $log = new AccountLog();
  541. $config = array
  542. (
  543. 'user_id' => $withdrawRow['user_id'],
  544. 'admin_id' => $this->admin['admin_id'],
  545. 'event' => "withdraw",
  546. 'num' => $withdrawRow['amount'],
  547. );
  548. $result = $log->write($config);
  549. if($result == false)
  550. {
  551. $this->withdraw_detail();
  552. Util::showMessage($log->error);
  553. }
  554. }
  555. $dataArray = array(
  556. 're_note'=> $re_note,
  557. 'status' => $status,
  558. );
  559. $withdrawObj->setData($dataArray);
  560. $where = "`id`= {$id} AND `status` = 0";
  561. $withdrawObj->update($where);
  562. //管理员操作日志
  563. $logObj = new log('db');
  564. $logObj->write('operation',array("管理员:".$this->admin['admin_name'],"修改了提现申请","ID值为:".$id));
  565. $this->withdraw_detail();
  566. Util::showMessage("更新成功");
  567. }
  568. else
  569. {
  570. $this->redirect('withdraw_list');
  571. }
  572. }
  573. /**
  574. * @brief 商家修改页面
  575. */
  576. public function seller_edit()
  577. {
  578. $seller_id = IFilter::act(IReq::get('id'),'int');
  579. //修改页面
  580. if($seller_id)
  581. {
  582. $sellerDB = new IModel('seller');
  583. $this->sellerRow = $sellerDB->getObj('id = '.$seller_id);
  584. }
  585. $this->redirect('seller_edit');
  586. }
  587. /**
  588. * @brief 商户的增加动作
  589. */
  590. public function seller_add()
  591. {
  592. $seller_id = IFilter::act(IReq::get('id'),'int');
  593. $seller_name = IFilter::act(IReq::get('seller_name'));
  594. $email = IFilter::act(IReq::get('email'));
  595. $password = IFilter::act(IReq::get('password'));
  596. $repassword = IFilter::act(IReq::get('repassword'));
  597. $truename = IFilter::act(IReq::get('true_name'));
  598. $phone = IFilter::act(IReq::get('phone'));
  599. $mobile = IFilter::act(IReq::get('mobile'));
  600. $province = IFilter::act(IReq::get('province'),'int');
  601. $city = IFilter::act(IReq::get('city'),'int');
  602. $area = IFilter::act(IReq::get('area'),'int');
  603. $cash = IFilter::act(IReq::get('cash'),'float');
  604. $is_vip = IFilter::act(IReq::get('is_vip'),'int');
  605. $is_lock = IFilter::act(IReq::get('is_lock'),'int');
  606. $address = IFilter::act(IReq::get('address'));
  607. $account = IFilter::act(IReq::get('account'));
  608. $server_num = IFilter::act(IReq::get('server_num'));
  609. $home_url = IFilter::act(IReq::get('home_url'));
  610. $sort = IFilter::act(IReq::get('sort'),'int');
  611. if(!$seller_id && $password == '')
  612. {
  613. $errorMsg = '请输入密码!';
  614. }
  615. if($password != $repassword)
  616. {
  617. $errorMsg = '两次输入的密码不一致!';
  618. }
  619. //创建商家操作类
  620. $sellerDB = new IModel("seller");
  621. if($sellerDB->getObj("seller_name = '{$seller_name}' and id != {$seller_id}"))
  622. {
  623. $errorMsg = "登录用户名重复";
  624. }
  625. else if($sellerDB->getObj("true_name = '{$truename}' and id != {$seller_id}"))
  626. {
  627. $errorMsg = "商户真实全程重复";
  628. }
  629. //操作失败表单回填
  630. if(isset($errorMsg))
  631. {
  632. $this->sellerRow = $_POST;
  633. $this->redirect('seller_edit',false);
  634. Util::showMessage($errorMsg);
  635. }
  636. //待更新的数据
  637. $sellerRow = array(
  638. 'true_name' => $truename,
  639. 'account' => $account,
  640. 'phone' => $phone,
  641. 'mobile' => $mobile,
  642. 'email' => $email,
  643. 'address' => $address,
  644. 'is_vip' => $is_vip,
  645. 'is_lock' => $is_lock,
  646. 'cash' => $cash,
  647. 'province' => $province,
  648. 'city' => $city,
  649. 'area' => $area,
  650. 'server_num'=> $server_num,
  651. 'home_url' => $home_url,
  652. 'sort' => $sort,
  653. );
  654. //附件上传$_FILE
  655. if($_FILES)
  656. {
  657. $uploadObj = new PhotoUpload();
  658. $uploadObj->setIterance(false);
  659. $photoInfo = $uploadObj->run();
  660. //商户资质上传
  661. if(isset($photoInfo['paper_img']['img']) && file_exists($photoInfo['paper_img']['img']))
  662. {
  663. $sellerRow['paper_img'] = $photoInfo['paper_img']['img'];
  664. }
  665. //logo图片处理
  666. if(isset($photoInfo['logo']['img']) && file_exists($photoInfo['logo']['img']))
  667. {
  668. $sellerRow['logo'] = $photoInfo['logo']['img'];
  669. }
  670. }
  671. //添加新会员
  672. if(!$seller_id)
  673. {
  674. $sellerRow['seller_name'] = $seller_name;
  675. $sellerRow['password'] = md5($password);
  676. $sellerRow['create_time'] = ITime::getDateTime();
  677. $sellerDB->setData($sellerRow);
  678. $sellerDB->add();
  679. }
  680. //编辑会员
  681. else
  682. {
  683. //修改密码
  684. if($password)
  685. {
  686. $sellerRow['password'] = md5($password);
  687. }
  688. $sellerDB->setData($sellerRow);
  689. $sellerDB->update("id = ".$seller_id);
  690. }
  691. $this->redirect('seller_list');
  692. }
  693. /**
  694. * @brief 商户的删除动作
  695. */
  696. public function seller_del()
  697. {
  698. $id = IFilter::act(IReq::get('id'),'int');
  699. $sellerDB = new IModel('seller');
  700. $data = array('is_del' => 1);
  701. $sellerDB->setData($data);
  702. if(is_array($id))
  703. {
  704. $sellerDB->update('id in ('.join(",",$id).')');
  705. }
  706. else
  707. {
  708. $sellerDB->update('id = '.$id);
  709. }
  710. $this->redirect('seller_list');
  711. }
  712. /**
  713. * @brief 商户的回收站删除动作
  714. */
  715. public function seller_recycle_del()
  716. {
  717. $id = IFilter::act(IReq::get('id'),'int');
  718. $sellerDB = new IModel('seller');
  719. $goodsDB = new IModel('goods');
  720. $merch_ship_infoDB = new IModel('merch_ship_info');
  721. $specDB = new IModel('spec');
  722. if(is_array($id))
  723. {
  724. $id = join(",",$id);
  725. }
  726. $sellerDB->del('id in ('.$id.')');
  727. $goodsDB->del('seller_id in ('.$id.')');
  728. $merch_ship_infoDB->del('seller_id in ('.$id.')');
  729. $specDB->del('seller_id in ('.$id.')');
  730. $this->redirect('seller_recycle_list');
  731. }
  732. /**
  733. * @brief 商户的回收站恢复动作
  734. */
  735. public function seller_recycle_restore()
  736. {
  737. $id = IFilter::act(IReq::get('id'),'int');
  738. $sellerDB = new IModel('seller');
  739. $data = array('is_del' => 0);
  740. $sellerDB->setData($data);
  741. if(is_array($id))
  742. {
  743. $sellerDB->update('id in ('.join(",",$id).')');
  744. }
  745. else
  746. {
  747. $sellerDB->update('id = '.$id);
  748. }
  749. $this->redirect('seller_recycle_list');
  750. }
  751. //商户状态ajax
  752. public function ajax_seller_lock()
  753. {
  754. $id = IFilter::act(IReq::get('id'));
  755. $lock = IFilter::act(IReq::get('lock'));
  756. $sellerObj = new IModel('seller');
  757. $sellerObj->setData(array('is_lock' => $lock));
  758. $sellerObj->update("id = ".$id);
  759. //短信通知状态修改
  760. $sellerRow = $sellerObj->getObj('id = '.$id);
  761. if(isset($sellerRow['mobile']) && $sellerRow['mobile'])
  762. {
  763. $result = $lock == 0 ? "正常" : "锁定";
  764. $content = smsTemplate::sellerCheck(array('{result}' => $result));
  765. $result = Hsms::send($sellerRow['mobile'],$content,0);
  766. }
  767. }
  768. /**
  769. * 筛选用户
  770. */
  771. public function filter_user()
  772. {
  773. $where = array();
  774. $userIds = '';
  775. $search = IFilter::act(IReq::get('search'),'strict');
  776. $search = $search ? $search : array();
  777. foreach($search as $key => $val)
  778. {
  779. if($val)
  780. {
  781. $where[] = $key.'"'.$val.'"';
  782. }
  783. }
  784. //有筛选条件
  785. if($where)
  786. {
  787. $userDB = new IQuery('user as u');
  788. $userDB->join = 'left join member as m on u.id = m.user_id';
  789. $userDB->fields= 'u.id';
  790. $userDB->where = join(" and ",$where);
  791. $userData = $userDB->find();
  792. $tempArray = array();
  793. foreach($userData as $key => $item)
  794. {
  795. $tempArray[] = $item['id'];
  796. }
  797. $userIds = join(',',$tempArray);
  798. if(!$userIds)
  799. {
  800. die('<script type="text/javascript">alert("没有找到用户信息,请重新输入条件");window.history.go(-1);</script>');
  801. }
  802. }
  803. die('<script type="text/javascript">parent.searchUserCallback("'.$userIds.'");</script>');
  804. }
  805. /**
  806. * 筛选商户
  807. */
  808. public function filter_seller()
  809. {
  810. $where = array();
  811. $sellerIds = '';
  812. $search = IFilter::act(IReq::get('search'),'strict');
  813. $search = $search ? $search : array();
  814. foreach($search as $key => $val)
  815. {
  816. if($val)
  817. {
  818. $where[] = $key.'"'.$val.'"';
  819. }
  820. }
  821. //有筛选条件
  822. if($where)
  823. {
  824. $sellerDB = new IQuery('seller');
  825. $sellerDB->fields= 'id';
  826. $sellerDB->where = join(" and ",$where);
  827. $sellerData = $sellerDB->find();
  828. $tempArray = array();
  829. foreach($sellerData as $key => $item)
  830. {
  831. $tempArray[] = $item['id'];
  832. }
  833. $sellerIds = join(',',$tempArray);
  834. if(!$sellerIds)
  835. {
  836. die('<script type="text/javascript">alert("没有找到商户信息,请重新输入条件");window.history.go(-1);</script>');
  837. }
  838. }
  839. die('<script type="text/javascript">parent.searchSellerCallback("'.$sellerIds.'");</script>');
  840. }
  841. }