public function postReply($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $to = Input::get('to', 0);
     $to_u_id = Input::get('to_u_id', 0);
     $content = Input::get('content', '');
     try {
         $user = User::chkUserByToken($token, $u_id);
         $to_user = User::find($to_u_id);
         if (empty($to_user)) {
             $to_u_id = 0;
             $to_u_name = '';
         } else {
             $to_u_name = $to_user->u_nickname;
             $msg = new MessageDispatcher($to_u_id);
             $msg->fireCateToUser('您有新的用户回复', Notification::$CATE_CROWD_FUNDING, $id);
         }
         $cf = CrowdFunding::find($id);
         $reply = ['to_id' => $to, 'created_at' => Tools::getNow(), 'content' => $content, 'u_id' => $u_id, 'u_name' => $user->u_nickname, 'status' => 1, 'to_u_id' => $to_u_id, 'to_u_name' => $to_u_name];
         $replyObj = new Reply($reply);
         $cf->replies()->save($replyObj);
         $re = Tools::reTrue('回复成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '回复失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
示例#2
0
 public function checkoutCrowdFunding()
 {
     if ($this->c_type != 2) {
         return true;
     }
     // push msg to seller
     $booth = Booth::find($this->b_id);
     $product = CrowdFundingProduct::find($this->p_id);
     $product->confirmProduct($this->c_quantity);
     $funding = CrowdFunding::find($product->cf_id);
     $funding->c_amount += $this->c_amount;
     $funding->save();
     $msg = new MessageDispatcher($booth->u_id);
     $msg->fireCateToUser('您的众筹' . $funding->c_title . '已有人认购', 1, $funding->cf_id);
     return true;
 }
 public function postReply($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $content = Input::get('content', '');
     $to_u_id = Input::get('to', 0);
     $to = Input::get('parent', 0);
     try {
         $product = Product::find($id);
         $product->p_reply_count += 1;
         $user = User::chkUserByToken($token, $u_id);
         $to_user = User::find($to_u_id);
         if (empty($to_user)) {
             $to_u_id = 0;
             $to_u_name = '';
         } else {
             $to_u_name = $to_user->u_nickname;
             if ($product->p_type == 2) {
                 $cate = Notification::$CATE_FLEA;
             } else {
                 $cate = Notification::$CATE_PRODUCT_PROMO;
             }
             $msg = new MessageDispatcher();
             $msg->fireCateToUser('您有新的用户回复', $cate, $id);
         }
         $data = ['to_id' => $to, 'created_at' => Tools::getNow(), 'content' => $content, 'u_id' => $u_id, 'u_name' => $user->u_nickname, 'status' => 1, 'to_u_id' => $to_u_id, 'to_u_name' => $to_u_name];
         $reply = new Reply($data);
         $product->replies()->save($reply);
         $product->save();
         $re = Tools::reTrue('回复成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '回复失败:' . $e->getMessage());
     }
     return Response::json($re);
 }