/**
  * Creates a new Notice model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Notice();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function save()
 {
     $notice = new Notice();
     $noticeContent = Request::input("noticeContent");
     // $noticeContent = $_POST["noticeContent"];
     $notice->noticeContent = $noticeContent;
     $notice->save();
     print_r($notice);
     return redirect("/home");
 }
Example #3
0
 public function actionCreate()
 {
     $model = new Notice();
     if ($model->load(Yii::$app->request->post())) {
         // 获取用户输入的数据,验证并保存
         $rids = $model->rids;
         $model->rids = ',' . implode(',', $model->rids) . ',';
         $model->uid = $this->user->id;
         $model->create_time = date('Y-m-d H:i:s');
         if ($model->save()) {
             $this->redirect('/notice/index');
         }
     }
     $roles = Role::findBySql('SELECT * FROM ' . Role::tableName() . ' where id > 1')->all();
     return $this->render('create', array('model' => $model, 'roles' => $roles));
 }
Example #4
0
 public static function afterFollow($favorite)
 {
     $types = [Favorite::TYPE_TOPIC => self::TYPE_FOLLOW_TOPIC, Favorite::TYPE_USER => self::TYPE_FOLLOW_USER];
     $notice = new Notice(['type' => $types[$favorite->type], 'source_id' => $favorite->source_id]);
     if ($favorite->type == Favorite::TYPE_TOPIC) {
         $notice->topic_id = $favorite->target_id;
         $notice->target_id = $favorite->topic->user_id;
         if ($notice->source_id == $notice->target_id) {
             return true;
         }
     } else {
         $notice->target_id = $favorite->target_id;
     }
     return $notice->save(false);
 }
Example #5
0
 /**
  *新增和修改提交
  * @return array
  */
 public function actionSubmit()
 {
     $params = Yii::$app->request->post();
     if (isset($params["notice_id"])) {
         $model = $this->findModel($params["notice_id"]);
     } else {
         $model = new Notice();
         $params["create_at"] = date("Y-m-d");
         $params["user_id"] = Yii::$app->user->getId();
     }
     $data = array();
     //yii自动生成的form参数是Enterprise["name"]这种形式,获取后就会是在一个Enterprise中
     $data["Notice"] = $params;
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if ($model->load($data) && $model->save()) {
         return ["success" => true];
     } else {
         return ["success" => false, "error_code" => 1];
     }
 }
 /**
  * @param Request $request
  * @return Response
  *
  * @api {get} /yzh/notice/investment 投资结果通知
  * @apiName GetNoticeInvestment
  * @apiGroup Notice
  *
  * @apiParam {String} UserId 用户ID
  * @apiParam {String} ProductName 理财产品名称
  * @apiParam {String} Amount 投资金额
  * @apiParam {String} DateTime 投资时间
  * @apiParam {String} Ref 消息流水号
  *
  * @apiSuccessExample Success-Response:
  * success
  */
 public function noticeInvestment(Request $request)
 {
     $input = $request->all();
     Logger::AuthorizationInfo('@YzhController noticeInvestment, start', $input);
     if (empty($input['sign'])) {
         Logger::AuthorizationError('@YzhController noticeInvestment, no sign');
         return response('no sign');
     }
     // sign
     if (!HMAC::compare($input, $this->getKey(), $input['sign'])) {
         Logger::AuthorizationError('@YzhController noticeInvestment, sign error');
         return response('sign error');
     }
     // duplicate
     $row = Notice::where('ref', $input['Ref'])->first();
     if ($row) {
         Logger::AuthorizationInfo('@YzhController noticeInvestment, duplicate, return success');
         return response('success');
     }
     // data 记录通知数据,跟据业务再做处理
     $notice = new Notice();
     $notice->ref = $input['Ref'];
     $notice->type = Notice::T_INVEST;
     $notice->uid = $input['UserId'];
     $notice->result = json_encode($input);
     $notice->save();
     // response
     Logger::AuthorizationInfo('@YzhController noticeInvestment, received, return success');
     return response('success');
 }