public function actionUpdatePwd() { $response = array(); $user_phone = $this->request->getParam('user_phone'); $new_pwd = trim($this->request->getParam('new_pwd')); $phone_code = trim($this->request->getParam('phone_code')); $verifyCode = FCookie::get(FConfig::item('config.cookie.phone_key')); $verifyCode = Fn::crypt($verifyCode, FConfig::item('config.cookie.phone_code'), 'decode'); if ($phone_code != $verifyCode) { $response['status'] = 100001; $response['content'] = '短信验证失败!'; } else { $res = $this->user_model->updateAll(array('password' => md5($new_pwd)), 'phone_num=:phone', array(':phone' => $user_phone)); if ($res) { $response['status'] = 100000; $response['content'] = '修改密码成功!'; } else { $response['status'] = 100002; $response['content'] = '修改密码失败!'; } } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }
public function actionCheckBuyEndDate() { //所要执行的任务,如数据符合某条件更新,删除,修改 // echo "查询产品用户购买产品结束日期\n"; // 持有中2的到期后改为已结束3 $condition_syz = array('condition' => "buy_status = :buy_status", 'params' => array(":buy_status" => FConfig::item("config.buy_status.syz"))); $res_cyz = $this->userProductBuy_model->findAll($condition_syz); foreach ($res_cyz as $val_cyz) { $publish = $val_cyz->publish; $product = $publish->product; //创建时间y-m-d + N $buy_time = strtotime($val_cyz->create_time); if ($product->invest_start_type == 1) { if ($product->invest_date_type == 1) { $start_timestamp = strtotime("+{$product->invest_days} day", $buy_time); $end_time = date('Y-m-d', strtotime("+{$product->earn_days} days", $start_timestamp)); $start_time = date('Y-m-d', $start_timestamp); } elseif ($product->invest_date_type == 2) { $invest_days = $product->invest_days; $i = 0; $start_timestamp = strtotime("+1 day", $buy_time); for ($j = 0; $j < 15; $j++) { $is = FHelper::isHoliday($start_timestamp); if ($is) { $start_timestamp = strtotime("+1 day", $start_timestamp); } else { $i++; $start_timestamp = strtotime("+1 day", $start_timestamp); } if ($i == $invest_days) { $start_timestamp = strtotime("-1 day", $start_timestamp); break; } } $end_time = date('Y-m-d', strtotime("+{$product->earn_days} days", $start_timestamp)); $start_time = date('Y-m-d', $start_timestamp); } } else { $start_time = $product->invest_start_date; $end_time = $product->invest_end_date; } if ($end_time <= date('Y-m-d')) { $transaction = Yii::app()->db->beginTransaction(); $earn_val = sprintf("%.2f", floatval($val_cyz->buy_val) * floatval($product->yield_rate_year) * $product->earn_days / (360 * 100)); $result_cyz = $this->userProductBuy_model->updateByPk($val_cyz->id, array('buy_status' => 3, 'earn_val' => $earn_val)); Yii::log("已结束:用户ID:{$val_cyz->user_id}:产品ID:{$product->id}:发布ID:{$publish->id}:购买时间:{$val_cyz->create_time}:结束日:{$end_time}", CLogger::LEVEL_INFO, 'buy.actionCheckBuyStatus'); if ($result_cyz) { $userInfoRes = $this->userInfo_model->find('user_id=:user_id', array(':user_id' => $val_cyz->user_id)); if ($userInfoRes) { $sumVal = floatval($userInfoRes->account_val) + floatval($val_cyz->buy_val) + floatval($earn_val); $updateAttr = array("account_val" => $sumVal); $result = $this->userInfo_model->updateByPk($userInfoRes->id, $updateAttr); if (!$result) { Yii::log("充值失败", CLogger::LEVEL_ERROR, 'buy.actionCheckBuyStatus'); $transaction->rollback(); } else { $transaction->commit(); } } } else { $transaction->rollback(); Yii::log("修改交易记录失败", CLogger::LEVEL_ERROR, 'order.frontReceive'); } } else { $result_cyz = 3; Yii::log("起息结束未到期:用户ID:{$val_cyz->user_id}:产品ID:{$product->id}:发布ID:{$publish->id}:购买时间:{$val_cyz->create_time}:结束日:{$end_time}", CLogger::LEVEL_INFO, 'buy.actionCheckBuyStatus'); } $now_time = date('Y-m-d H:i:s'); $condition_arr = array('user_id' => $val_cyz->user_id, 'product_id' => $product->id, 'p_id' => $publish->id, 'user_buy_time' => $val_cyz->create_time, 'invest_start_time' => $start_time, 'invest_end_time' => $end_time, 'op_time' => $now_time, 'buy_log_status' => $result_cyz); $buyLogs = new BuyLogs(); $buyLogs->attributes = $condition_arr; $buyLogs->save(); } }
public function actionToCash() { $user_id = $this->request->getParam('user_id'); $cash_money = $this->request->getParam('cash_money'); $avail_cash = $this->request->getParam('avail_cash'); $create_time = FF_DATE_TIME; $attr_cash = array('user_id' => $user_id, 'cash_money' => $cash_money, 'avail_cash' => $avail_cash, 'create_time' => $create_time); $this->withdrawCash_model->attributes = $attr_cash; $account_val = $this->userInfo['account_val'] - $cash_money; $condition_account_val = array('account_val' => $account_val); $res_userInfo = $this->userInfo_model->updateByPk($this->userInfo['id'], $condition_account_val); $res = $this->withdrawCash_model->save(); if ($res && $res_userInfo) { $response['status'] = 100000; $response['content'] = success; } else { $response['status'] = 100001; $response['content'] = error; } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }
protected function beforeAction($action) { $this->_controller = $action->getController()->getId(); $this->_action = $action->getId(); $this->returnurl = Fn::url_login_current(); $token = FCookie::get("auth"); $now = time(); list($uid, $email, $timeout) = explode("\t", FHelper::auth_code($token, 'DECODE', FF_SALT)); if ($uid) { $userInfo = $this->getUserinfo($uid); if ($userInfo['user']['id']) { if ($token == $userInfo['user']['token']) { if ($now < $timeout) { $this->userInfo = $userInfo['info']; $this->user = $userInfo['user']; if ($timeout - $now < 60 * 2) { $timeout = time() + 60 * 15; $token = FHelper::auth_code("{$uid}\t{$email}\t{$timeout}", 'ENCODE', FF_SALT); FCookie::set('auth', $token, 60 * 15); $attr = array('token' => $token); $user_model = new User(); $user_model->updateByPk($uid, $attr); } // $timeout = time()+60 *15; // $token = FHelper::auth_code("$uid\t$email\t$timeout", 'ENCODE', FF_SALT); // FCookie::set('auth', $token); } } } } return true; }