Esempio n. 1
0
 public function actionProfile()
 {
     $mInvest = new InvestTendency();
     $params = Yii::$app->request->post();
     if (isset($params['currency'])) {
         $params['currency'] = intval($params['currency']);
     }
     if (isset($params['min_invest_quota']) || isset($params['max_invest_quota'])) {
         $params['min_invest_quota'] = intval($params['min_invest_quota']);
         $params['max_invest_quota'] = intval($params['max_invest_quota']);
         if ($params['min_invest_quota'] > $params['max_invest_quota']) {
             $tmp = $params['max_invest_quota'];
             $params['max_invest_quota'] = $params['min_invest_quota'];
             $params['min_invest_quota'] = $tmp;
         }
     }
     if (isset($params['invest_stage']) && is_array($params['invest_stage'])) {
         $params['invest_stage'] = array_sum($params['invest_stage']);
     }
     if (isset($params['uid']) && $params['uid']) {
         $invests = $mInvest->getByUid($params['uid']);
         //如果用户投资信息存在
         if ($invests) {
             $result = $mInvest->renew($params);
         } else {
             //如果投资信息不存在
             $result = $mInvest->add($params);
         }
     }
     if ($result) {
         return Util::setAlert('更新成功', 'user/profile');
     } else {
         return Util::setAlert('更新失败', 'user/profile');
     }
 }
Esempio n. 2
0
 public function actionDelete()
 {
     $mUser = new UserBaseInfo();
     $params = Yii::$app->request->get();
     $params = array_map('trim', $params);
     if (isset($params['city'])) {
         $params['city'] = 0;
         $params['city_addr'] = null;
     } else {
         if (isset($params['hometown'])) {
             $params['hometown'] = 0;
             $params['hometown_addr'] = null;
         }
     }
     //修改用户基本资料
     $result = $mUser->updateUserById($params);
     if ($result) {
         return Util::setAlert('删除成功', 'user/profile');
     } else {
         return Util::setAlert('删除失败', 'user/profile');
     }
 }
 /**
  * 删除用户地址信息
  */
 public function actionDelete($id)
 {
     //判断用户是否登录
     if (!UserBaseInfo::isLogin()) {
         return $this->redirect(Url::toRoute('user/login'));
     }
     $id = intval($id);
     if (!$id) {
         return Util::setAlert('地址id不存在', 'address/index');
     }
     //从session或cookie中获取用户id
     $userId = UserBaseInfo::getUserId();
     $address = new Address();
     $data = $address->getById($id);
     if (!$data) {
         return Util::setAlert('地址信息不存在', 'address/index');
     }
     if ($data['user_id'] != $userId) {
         return Util::setAlert('不能操作其他用户的地址信息', 'address/index');
     }
     $result = $address->del($id);
     $addressLog = new UserOperateLog();
     if ($result) {
         $data = $addressLog->store('用户地址删除', '', '{"id" : ' . $id . '}', $result);
         if (!$data) {
             FileLogger::getInstance(date('Ymd') . '_address_operate_fail.log')->writeOne($id, Logger::LEVEL_ERROR, 'add_log_fail');
         }
         return $this->redirect(Url::toRoute('address/index'));
     } else {
         $data = $addressLog->store('用户地址删除', '', '{"id" : ' . $id . '}', $result);
         if (!$data) {
             FileLogger::getInstance(date('Ymd') . '_address_operate_fail.log')->writeOne($id, Logger::LEVEL_ERROR, 'add_log_fail');
         }
         return Util::setAlert('删除失败', 'address/index');
     }
 }