Esempio n. 1
0
 public function actionDeleteMember($id, $userId)
 {
     $member = CourseMember::model()->findByAttributes(array('courseId' => $id, 'userId' => $userId));
     if ($member && $member->delete()) {
         Yii::app()->user->setFlash('success', Yii::t('app', '删除成功!'));
     } else {
         Yii::app()->user->setFlash('error', Yii::t('app', '删除失败!'));
     }
     $this->redirect(array('members', 'id' => $id));
 }
Esempio n. 2
0
 public function actionAlipayNotify()
 {
     //		error_log("ok");
     //		error_log(print_r($_POST,true));
     //ali验证不允许有多余参数
     if (isset($_GET['r'])) {
         unset($_GET['r']);
     }
     global $sysSettings;
     $alipay = new Alipay($sysSettings['payment']['aliPartner'], $sysSettings['payment']['aliKey']);
     if ($alipay->verifyNotify()) {
         //验证成功
         //商户订单号
         $out_trade_no = $_POST['out_trade_no'];
         //支付宝交易号
         $trade_no = $_POST['trade_no'];
         //交易状态
         $trade_status = $_POST['trade_status'];
         $order = Order::model()->findByPk($out_trade_no);
         $course = Course::model()->findByAttributes(array('entityId' => $order->produceEntityId));
         $user = UserInfo::model()->findByPk($order->userId);
         if ($trade_status == 'WAIT_BUYER_PAY') {
             //该判断表示买家已在支付宝交易管理中产生了交易记录,但没有付款
             echo "success";
             //请不要修改或删除
         } else {
             if ($trade_status == 'WAIT_BUYER_CONFIRM_GOODS' || $trade_status == 'WAIT_BUYER_CONFIRM_GOODS' || $trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') {
                 $order->status = Order::ORDER_PAID;
                 $order->tradeNo = $trade_no;
                 $order->save();
                 $member = CourseMember::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'courseId' => $course->id));
                 if (!$member) {
                     $member = new CourseMember();
                     $member->userId = $user->id;
                     $member->courseId = $course->id;
                     $member->arrRoles = array('student');
                     $member->startTime = time();
                     $member->save();
                 } else {
                     $member->startTime = time();
                     $member->save();
                 }
                 echo "success";
                 //请不要修改或删除
             } else {
                 //其他状态判断
                 echo "success";
             }
         }
     } else {
         //验证失败
         echo "fail";
     }
 }
Esempio n. 3
0
 public function actionAddComment($id)
 {
     $model = $this->loadModel($id);
     $comment = new Comment();
     if (isset($_POST['Comment'])) {
         $comment->attributes = $_POST['Comment'];
         if ($model->addComment($comment)) {
             $model->upTime = time();
             $model->save();
             //发送消息
             if ($model->asa('followable')) {
                 $follows = $model->getAllFollows();
                 foreach ($follows as $follow) {
                     if ($follow->userId != $comment->userId && $follow->userId != $comment->referId) {
                         Notice::send($follow->userId, $model->entity->type . "_comment_added", array('commentId' => $comment->id));
                     }
                 }
             }
             //更新回复统计
             $member = CourseMember::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'courseId' => $model->courseId));
             if ($member) {
                 $criteria = new CDbCriteria();
                 $criteria->join = "inner join {{course_post}} p on p.entityId=t.commentableEntityId";
                 $criteria->condition = "p.courseId=" . intval($model->courseId) . " and t.userId=" . Yii::app()->user->id;
                 //	Comment::model()->count($criteria);
                 $member->commentNum = Comment::model()->count($criteria);
                 $member->save();
             }
             Yii::app()->user->setFlash('success', '回复成功!');
         } else {
             Yii::app()->user->setFlash('error', '抱歉,回复失败!');
         }
     }
     $this->redirect(array('view', 'id' => $model->id));
 }
 public function findMember($c = array())
 {
     $c = array_merge_recursive($c, array('courseId' => $this->owner->id));
     return CourseMember::model()->findByAttributes($c);
     //'userId'=>Yii::app()->user->id
 }