public function remainAction()
 {
     $user_project_info = $this->getUserProject();
     if ($user_project_info) {
         $raise_id = $user_project_info->getRaiseId();
         $status = $user_project_info->getStatus();
         $wheel_id = $user_project_info->getNowWheelId();
         $dtb_wheel = DtbRaiseProjectWheel::findFirstBywheel_id($wheel_id);
         $this->view->setVar('dtb_wheel_info', $dtb_wheel);
         $this->view->setVar('valuation', $user_project_info->getValuation());
         $complete_percent = intval($dtb_wheel->getAlreadyMoney() / $dtb_wheel->getAimMoney() * 100);
         if ($complete_percent > 100) {
             $complete_percent = "100%";
         }
         $this->view->setVar('complete_percent', $complete_percent);
         $this->view->is_user_nav = 2;
     }
 }
 public function payCallbackAction($order_id)
 {
     $is_pay = true;
     if ($is_pay) {
         //TODO PAY CALLBACK
         //modify order_id
         $invest_order = DtbProjectInvestOrder::findFirstByorder_id($order_id);
         $raise_id = $invest_order->getRaiseId();
         $wheel_id = $invest_order->getWheelId();
         $project_wheel_info = DtbRaiseProjectWheel::findFirstBywheel_id($wheel_id);
         if ($project_wheel_info->getRaiseId() != $raise_id) {
             die('project error');
         }
         $invest_money = $invest_order->getInvestMoney();
         $aim_money = $project_wheel_info->getAimMoney();
         $already_money = $project_wheel_info->getAlreadyMoney();
         $result = $project_wheel_info->getResult();
         $is_update_status = false;
         if ($invest_money + $already_money >= $aim_money * self::project_success_value && intval($result) == 0) {
             $is_update_status = true;
         }
         $wheel_invested_num = $project_wheel_info->getWheelInvestedNum();
         try {
             $this->di['db']->begin();
             $invest_order_new = new DtbProjectInvestOrder();
             $params = array('result' => result_success, 'status' => 0, 'update_ts' => time());
             $res1 = $invest_order_new->updateOrderId($order_id, $params);
             $project_wheel_info->setAlreadyMoney($invest_money + $already_money);
             $project_wheel_info->setAlreadyMoney(intval($invest_money + $already_money));
             $project_wheel_info->setWheelInvestedNum($wheel_invested_num + 1);
             if ($is_update_status) {
                 $project_wheel_info->setResult(result_success);
             }
             $res2 = $project_wheel_info->save();
             if ($res1 && $res2) {
                 $this->di['db']->commit();
                 $this->flash->success('成功');
                 return $this->response->redirect('/invest/payFinish/' . $order_id);
             } else {
                 $this->di['db']->rollback();
             }
         } catch (Exception $ex) {
             $this->di['db']->rollback();
         }
     }
 }