SetController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace backend\controllers;
  3. use common\services\xhAdminService;
  4. use common\services\xhTMessageService;
  5. use Yii;
  6. use yii\web\Controller;
  7. use yii\filters\AccessControl;
  8. use common\services\xhMerchantExtendService;
  9. use common\components\util;
  10. class SetController extends BackendController
  11. {
  12. public function actionIndex()
  13. {
  14. return $this->render('index',['merchant' => $this->merchant]);
  15. }
  16. public function actionInit()
  17. {
  18. $extend = xhMerchantExtendService::getByMerchantId($this->merchantId);
  19. $gradeList = xhMerchantExtendService::getGradeList($extend);
  20. return $this->render('init',['extend' => $extend,'gradeList' => $gradeList]);
  21. }
  22. public function actionModify()
  23. {
  24. $post = Yii::$app->request->post();
  25. $extend = $this->merchantExtend;
  26. unset($post['_csrf']);
  27. if($extend['integral'] == 1){//积分已经修改过,不能第二次修改
  28. unset($post['gradeList']);
  29. }else{
  30. $post['integral'] = 1;
  31. }
  32. xhMerchantExtendService::updateByMerchantId($this->merchantId, $post);//上面要先初始化,再执行这边的更新
  33. util::successInfo();
  34. }
  35. public function actionConfirmPassword()
  36. {
  37. return $this->render('confirmPassword',['admin' => $this->admin]);
  38. }
  39. public function actionModifyPassword()
  40. {
  41. $post = Yii::$app->request->post();
  42. $prePassword = isset($post['prePassword']) ? $post['prePassword'] : '';
  43. $password = isset($post['password']) ? $post['password'] : '';
  44. $admin = $this->admin;
  45. $dbPwd = $admin['confirmPassword'];
  46. if(!empty($dbPwd) && md5($prePassword) != $dbPwd){
  47. util::failInfo('原密码不正确');
  48. }
  49. xhAdminService::updateById($this->adminId, ['confirmPassword'=>md5($password)]);
  50. util::successInfo();
  51. }
  52. }