当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::addOrder方法代码示例

本文整理汇总了PHP中Order::addOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::addOrder方法的具体用法?PHP Order::addOrder怎么用?PHP Order::addOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order::addOrder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addOrder

 /**
  * Create a new forex order
  */
 public function addOrder()
 {
     $data = $this->request->getJsonRawBody();
     if (!is_object($data) || !isset($data->currency_code) || !isset($data->currency_amount)) {
         $this->sendError('INVALID_PARAMS', 400);
     }
     $order = Order::addOrder($data->currency_code, $data->currency_amount);
     if ($order) {
         $this->sendSuccess($order);
     } else {
         $this->sendError('UNABLE_TO_SAVE_ORDER', 500);
     }
 }
开发者ID:ashleykleynhans,项目名称:forex,代码行数:16,代码来源:OrderController.php

示例2: signUpAction

 /**
  * 活动报名
  */
 public function signUpAction()
 {
     $json_data = $this->request->getJsonRawBody(true);
     //保存用户信息
     $user_id = $json_data['user_id'];
     $aid = $json_data['aid'];
     //判断是否登录账号,不是则在账号前加时间戳区别不同的未登录账号
     if (strpos($json_data['user_id'], '@') === false) {
         $json_data['user_id'] = $json_data['user_id'] . time();
     }
     //$is_joined = Activity::isUserJoin($user_id, $aid);
     $return_data = null;
     /*if($is_joined)
             {
     
                 $return_data = array(
                     'success' => false,
                     'err_msg' => '该用户已报过名'
                 );
             }
             else
             {*/
     $new_au_id = Activity::signUp($json_data, $aid);
     //活动参加用户记录新id
     if ($new_au_id === false) {
         $return_data = array('success' => false, 'err_msg' => '报名失败,请稍后重试');
     } else {
         $return_data = array('success' => true, 'err_msg' => '报名成功');
         //如果存在付款项目,即活动市收费的,则生成订单
         if (!empty($json_data['pay_items'])) {
             $json_data['au_id'] = $new_au_id;
             $order_result = Order::addOrder('activity', $json_data);
             if (!$order_result) {
                 $return_data['success'] = false;
                 $return_data['err_msg'] = '报名订单生成失败';
             } else {
                 $return_data['order_info'] = array('order_id' => $order_result[0], 'order_no' => $order_result[1], 'order_fee' => $order_result[2]);
             }
         }
     }
     //}
     $this->view->setVars($return_data);
 }
开发者ID:jkzleond,项目名称:car_mate_local_favour,代码行数:46,代码来源:ActivityController.php

示例3: fakeCrowdFundingPurches

 public function fakeCrowdFundingPurches($id)
 {
     set_time_limit(0);
     $this->login();
     $bottom = Input::get('bottom', '');
     $top = Input::get('top', '');
     $p_id = Input::get('p_id', '');
     try {
         if (!$p_id || !$top || !$bottom) {
             throw new Exception("需要关键数据", 1);
         }
         $funding = CrowdFunding::find($id);
         $funding->load(['eventItem']);
         $product = CrowdFundingProduct::find($p_id);
         $quantity = 1;
         $users = User::where('u_mobile', '>=', $bottom)->where('u_mobile', '<=', $top)->get();
         foreach ($users as $key => $user) {
             $u_id = $user->u_id;
             // sku need to be calulated before cart generated
             $product->loadProduct($quantity);
             // add cart
             $cart = new Cart();
             $cart->p_id = $p_id;
             $cart->p_name = $product->p_title;
             $cart->u_id = $u_id;
             $cart->b_id = $product->b_id;
             $cart->created_at = Tools::getNow();
             $cart->c_quantity = $quantity;
             $cart->c_price = $product->p_price;
             $cart->c_amount = $product->p_price * $quantity;
             $cart->c_discount = 100;
             $cart->c_price_origin = $product->p_price;
             $cart->c_amount_origin = $product->p_price * $quantity;
             $cart->c_status = 2;
             $cart->c_type = 2;
             $re = $cart->save();
             if (!$re) {
                 throw new Exception("提交库存失败", 7006);
             }
             $shipping_address = 'Fake Purches';
             $shipping_name = $user->u_name;
             $shipping_phone = $user->u_mobile;
             $date_obj = new DateTime($funding->eventItem->e_start_at);
             $delivery_time_obj = $date_obj->modify('+' . ($funding->c_time + $funding->c_yield_time) . 'days');
             // add order
             $order_group_no = Order::generateOrderGroupNo($u_id);
             $rnd_str = rand(10, 99);
             $order_no = $order_group_no . $cart->b_id . $rnd_str;
             $order = new Order();
             $order->u_id = $u_id;
             $order->b_id = $cart->b_id;
             $order->o_amount_origin = $cart->c_amount_origin;
             $order->o_amount = $cart->c_amount;
             $order->o_shipping_fee = $funding->c_shipping_fee;
             $order->o_shipping_name = $shipping_name;
             $order->o_shipping_phone = $shipping_phone;
             $order->o_shipping_address = $shipping_address;
             $order->o_delivery_time = $delivery_time_obj->format('Y-m-d H:i:s');
             $order->o_shipping = $funding->c_shipping;
             $order->o_comment = 'Fake Order';
             $order->o_number = $order_no;
             $order->o_group_number = $order_group_no;
             $o_id = $order->addOrder();
             Cart::bindOrder([$order->o_id => [$cart->c_id]]);
             $cart->checkout();
             $order->o_status = 2;
             $order->o_shipping_status = 10;
             $order->paied_at = Tools::getNow();
             $order->save();
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     echo "done";
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:75,代码来源:EmergencyController.php

示例4: postOrder


//.........这里部分代码省略.........
         if ($now < $date_start) {
             throw new Exception("抱歉, 众筹还未开始, 请耐心等待", 2001);
         }
         if ($funding->c_status != 4) {
             throw new Exception("抱歉, 无效的众筹状态", 2001);
         }
         if ($funding->u_id == $u_id) {
             throw new Exception("您不能认筹自己发起的众筹", 2001);
         }
         $validator = Validator::make(['收货人电话' => (string) $shipping_phone, '收货人姓名' => $shipping_name, '收获地址' => $shipping_address, '产品' => $p_id, '数量' => $quantity], ['收货人电话' => 'required|numeric|digits:11', '收货人姓名' => 'required', '收获地址' => 'required', '产品' => 'required|numeric', '数量' => 'required|numeric']);
         if ($validator->fails()) {
             $msg = $validator->messages();
             throw new Exception($msg->first(), 7001);
         }
         $user = User::chkUserByToken($token, $u_id);
         if (!$user->u_mobile && ($id = 30)) {
             throw new Exception("此众筹需要绑定联系电话,请到[我的-编辑资料]里绑定后进行支持", 2001);
         }
         if ($funding->c_local_only) {
             $funding_owner = User::find($funding->u_id);
             if ($funding_owner->u_school_id != $user->u_school_id) {
                 throw new Exception("该众筹仅限于同校参与", 2001);
             }
         }
         $product = CrowdFundingProduct::find($p_id);
         if ($product->p_price == 0) {
             if ($quantity != 1) {
                 throw new Exception("此类众筹只能认筹一份", 1);
             }
             // check if user has bought
             $chk = Cart::where('u_id', '=', $u_id)->where('c_type', '=', 2)->where('p_id', '=', $p_id)->where('c_status', '>', 0)->first();
             if (!empty($chk)) {
                 throw new Exception("此类众筹每人限认筹一次", 7001);
             }
         }
         // sku need to be calulated before cart generated
         $product->loadProduct($quantity);
         // add cart
         $cart = new Cart();
         $cart->p_id = $p_id;
         $cart->p_name = $product->p_title;
         $cart->u_id = $u_id;
         $cart->b_id = $product->b_id;
         $cart->created_at = Tools::getNow();
         $cart->c_quantity = $quantity;
         $cart->c_price = $product->p_price;
         $cart->c_amount = $product->p_price * $quantity;
         $cart->c_discount = 100;
         $cart->c_price_origin = $product->p_price;
         $cart->c_amount_origin = $product->p_price * $quantity;
         $cart->c_status = 2;
         $cart->c_type = 2;
         $re = $cart->save();
         if (!$re) {
             throw new Exception("提交库存失败", 7006);
         }
         if (!$funding->c_shipping) {
             $shipping_address = '';
         }
         $shipping_name = $shipping_name ? $shipping_name : $user->u_name;
         $shipping_phone = $shipping_phone ? $shipping_phone : $user->u_mobile;
         $date_obj = new DateTime($funding->eventItem->e_start_at);
         $delivery_time_obj = $date_obj->modify('+' . ($funding->c_time + $funding->c_yield_time) . 'days');
         // add order
         $order_group_no = Order::generateOrderGroupNo($u_id);
         $rnd_str = rand(10, 99);
         $order_no = $order_group_no . $cart->b_id . $rnd_str;
         $order = new Order();
         $order->u_id = $u_id;
         $order->b_id = $cart->b_id;
         $order->o_amount_origin = $cart->c_amount_origin;
         $order->o_amount = $cart->c_amount;
         $order->o_shipping_fee = $funding->c_shipping_fee;
         $order->o_shipping_name = $shipping_name;
         $order->o_shipping_phone = $shipping_phone;
         $order->o_shipping_address = $shipping_address;
         $order->o_delivery_time = $delivery_time_obj->format('Y-m-d H:i:s');
         $order->o_shipping = $funding->c_shipping;
         $order->o_comment = $comment;
         $order->o_number = $order_no;
         $order->o_group_number = $order_group_no;
         $o_id = $order->addOrder();
         Cart::bindOrder([$order->o_id => [$cart->c_id]]);
         // change order to finish if price = 0
         if ($order->o_amount == 0) {
             $cart->checkout();
             $order->o_status = Order::$STATUS_FINISHED;
             $order->o_shipping_status = Order::$SHIPPING_STATUS_FINISHED;
             $order->paied_at = Tools::getNow();
             $order->save();
         }
         $data = ['order_no' => $order_group_no];
         $re = Tools::reTrue('提交订单成功', $data);
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提交订单失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:101,代码来源:CrowdFundingController.php

示例5: applyPolicyAction

 /**
  * 保险下单
  * @param $info_id
  */
 public function applyPolicyAction($info_id)
 {
     $data = $this->request->getJsonRawBody(true);
     $company_id = $data['company_id'];
     $final_result_id = $data['result_id'];
     $user = User::getCurrentUser();
     $info = Insurance::getInsuranceInfoById($info_id);
     $final_param_id = $info['final_param_id'];
     Insurance::updateFinalParam($final_param_id, array('company_id' => $company_id));
     $return_data = array();
     if ($info['state_id'] >= 4) {
         $return_data['success'] = false;
         $return_data['err_msg'] = '此订单已下单';
     } else {
         $success = Insurance::updateInsuranceInfo($info_id, array('company_id' => $company_id, 'final_result_id' => $final_result_id));
         if ($success) {
             $final_result = Insurance::getInsuranceFinalResultById($final_result_id);
             $total_fee = $final_result['totalAfterDiscount'];
             $order_result = Order::addOrder('insurance', array('info_id' => $info_id, 'user_id' => $user['user_id'], 'total_fee' => $total_fee));
             if (!$order_result) {
                 $return_data['success'] = false;
                 $return_data['err_msg'] = '保险支付订单生成失败';
             } else {
                 $return_data['success'] = true;
                 $return_data['order_info'] = array('order_id' => $order_result[0], 'order_no' => $order_result[1], 'order_fee' => $order_result[2]);
             }
         } else {
             $return_data['success'] = false;
             $return_data['err_msg'] = '订单生成失败';
         }
     }
     $this->view->setVars($return_data);
 }
开发者ID:jkzleond,项目名称:car_mate_local_favour,代码行数:37,代码来源:InsuranceController.php

示例6: addOrder

/**
* Insert an order into the database with the info from the JSON stored in $_POST.
*/
function addOrder()
{
    $user_id = $_SESSION['user_id'];
    if (!empty($user_id)) {
        $order = new Order();
        $order_data = json_decode($_POST['order']);
        $quantities;
        $iter_quant = 0;
        $toppings;
        $iter_top = 0;
        foreach ($order_data->order as $taco) {
            $quantities[$iter_quant] = $taco->quantity;
            $iter_top = 0;
            foreach ($taco->toppings as $topping_id) {
                $toppings[$iter_quant][$iter_top] = $topping_id->topping_id;
                $iter_top++;
            }
            $iter_quant++;
        }
        $order->addOrder($user_id, $quantities, $toppings);
    }
}
开发者ID:BreshardB,项目名称:TacoTruck,代码行数:25,代码来源:index.php

示例7: addOrder

 public function addOrder()
 {
     $input = Input::all();
     $id = Order::addOrder($input);
     return Response::json(['message' => '', 'id' => $id, 'result' => 'success'], 400);
 }
开发者ID:saurabhhack123,项目名称:fab_shivani,代码行数:6,代码来源:OrderController.php

示例8: showCart

 public function showCart()
 {
     $msg = "";
     $order = new Order();
     //        var_dump($_SESSION);
     if ($order->access_ModelMember_sessionExists() || $order->access_ModelMember_userAdmin()) {
         // RECUPERATION DU FORMULAIRE ET PAIEMENT *****************************************************************
         if (filter_has_var(INPUT_POST, 'payer')) {
             $codePromo = filter_input(INPUT_POST, 'codePromo', FILTER_SANITIZE_STRING);
             $memberID = $_SESSION['user']['id_membre'];
             $totalTTC = $_SESSION['montantFinal'];
             // SI PROMOTION ON FAIT LA SOUSTRACTION DU TOTAL ******************************************************
             if (!empty($codePromo)) {
                 $listPromos = $order->access_ModelPromo_listPromo();
                 foreach ($listPromos as $promos) {
                     if ($codePromo == $promos['code_promo']) {
                         $totalTTC = $totalTTC - $promos['reduction'];
                         $_SESSION['cart']['reduction'] = $promos['reduction'];
                     }
                 }
             }
             $order->setMontant($totalTTC);
             $order->setIdMembre($memberID);
             // VERIFICATIONS CGV : 1) cgv doit être coché 2) Si code promo, il est soustrait du montant final
             if (isset($_POST['cgv'])) {
                 $cgv = 1;
             } else {
                 $cgv = 0;
             }
             $resultArray = $order->checkCartConstraints($cgv);
             $msgError = "";
             for ($i = 0; $i < count($resultArray); $i++) {
                 if (!$resultArray[$i]->getPassed()) {
                     $msgError .= $resultArray[$i]->getErrorMessage();
                     $msgError .= "<br/>";
                 }
             }
             // SI PAS D'ERREURS CGV
             if ($msgError == "") {
                 // ENTREE EN BASE DE LA COMMANDE
                 $order->addOrder();
                 $newOrder = $order->selectOrder($_SESSION['user']['id_membre']);
                 $id_commande = $newOrder['id_commande'];
                 $order->setIdCommande($id_commande);
                 // Entrée des détails de commande en base, à savoir tous les produits du panier
                 for ($i = 0; $i < count($_SESSION['cart']['id_produit']); $i++) {
                     $order->setIdProduit($_SESSION['cart']['id_produit'][$i]);
                     $order->addOrderDetails();
                     // Retrait des produits du catalogue -> passage en statut "0"
                     $order->access_ModelProduct_changeStatusToUnavailableProduct($_SESSION['cart']['id_produit'][$i]);
                 }
                 //                    var_dump($_SESSION);
                 // Envoi de l'email récapitulatif au client ***********************************************************
                 $to = $_SESSION['user']['email'];
                 $subject = 'Confirmation de commande';
                 $message = '';
                 $message .= '<p>Merci, votre numéro de commande est le :' . $id_commande . '</p>';
                 $message .= '<p>Récapitulatif de votre commande: </p>';
                 $message .= $this->orderSummary();
                 $type = 'HTML';
                 // or Plain
                 $charset = 'utf-8';
                 $mail = 'no-reply@' . str_replace('www.', '', $_SERVER['SERVER_NAME']);
                 $uniqid = md5(uniqid(time()));
                 // Génère un identifiant unique basé sur l'heure courante
                 $headers = 'From: ' . $mail . "\n";
                 $headers .= 'Reply-to: ' . $mail . "\n";
                 $headers .= 'Return-Path: ' . $mail . "\n";
                 $headers .= 'Message-ID: <' . $uniqid . '@' . $_SERVER['SERVER_NAME'] . ">\n";
                 $headers .= 'MIME-Version: 1.0' . "\n";
                 $headers .= 'Date: ' . gmdate('D, d M Y H:i:s', time()) . "\n";
                 $headers .= 'X-Priority: 3' . "\n";
                 $headers .= 'X-MSMail-Priority: Normal' . "\n";
                 $headers .= 'Content-Type: multipart/mixed;boundary="----------' . $uniqid . '"' . "\n\n";
                 $headers .= '------------' . $uniqid . "\n";
                 $headers .= 'Content-type: text/' . $type . ';charset=' . $charset . '' . "\n";
                 $headers .= 'Content-transfer-encoding: 7bit';
                 mail($to, $subject, $message, $headers);
                 // Vidage du panier et de la session après transaction
                 if (isset($_SESSION['cart'])) {
                     unset($_SESSION['cart']);
                 }
                 //                    $msg .= 'Votre panier est vide.<br/>';
                 $msg .= "Transaction effectuée avec succès, merci pour votre achat !";
             } else {
                 $msg .= $msgError;
             }
         }
         // AFFICHAGE DU PANIER ********************************************************************************
         if (isset($_SESSION['cart']) && !empty($_SESSION['cart']['id_produit'])) {
             $msg .= '<table id="cartTable" class="table table-hover">';
             $msg .= '<tr>';
             $msg .= '<th>Produit</th>';
             $msg .= '<th>Salle</th>';
             $msg .= '<th>Photo</th>';
             $msg .= '<th>Date d\'arrivee</th>';
             $msg .= '<th>date de départ</th>';
             $msg .= '<th>Prix HT</th>';
             $msg .= '<th>TVA/20%</th>';
             $msg .= '<th>Prix TTC (€)</th>';
//.........这里部分代码省略.........
开发者ID:GiGis971,项目名称:evoyage,代码行数:101,代码来源:orders.php

示例9: postOrder

 public function postOrder($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', '');
     $shipping_name = Input::get('shipping_name', '');
     $shipping_phone = Input::get('shipping_phone', '');
     $shipping_address = Input::get('shipping_address', '');
     $comment = Input::get('comment', '');
     DB::beginTransaction();
     try {
         $user = User::chkUserByToken($token, $u_id);
         $now = Tools::getNow();
         $auction = Auction::find($id);
         if (empty($auction) || $auction->a_status != 2) {
             throw new Exception("请求的竞拍不存在", 2001);
         }
         $auction->load(['eventItem']);
         $bid = AuctionBid::find($auction->a_win_id);
         if (empty($bid) || $bid->is_pay) {
             throw new Exception("出价信息有误", 2001);
         }
         $limit = new DateTime($auction->eventItem->e_end_at);
         $limit->modify('+3 days');
         $now = Tools::getNow(false);
         if ($limit < $now) {
             $blacklist = new AuctionBlacklist();
             $blacklist->u_id = $u_id;
             $blacklist->a_id = $auction->a_id;
             $blacklist->start_at = $now;
             $now->modify('+7 days');
             $blacklist->end_at = $now->format('Y-m-d H:i:s');
             $blacklist->remark = '超时未购买';
             $blacklist->save();
             $auction->a_status = 4;
             $auction->save();
             throw new Exception("竞拍已超时, 无法购买", 2);
             //when exception code is 2, commit anyway after catch
         }
         // add cart
         $cart = new Cart();
         $cart->p_id = $auction->a_id;
         $cart->p_name = $auction->eventItem->e_title;
         $cart->u_id = $u_id;
         $cart->b_id = Tools::getMakerBooth();
         $cart->created_at = Tools::getNow();
         $cart->c_quantity = 1;
         $cart->c_price = $auction->a_win_price;
         $cart->c_amount = $auction->a_win_price;
         $cart->c_discount = 100;
         $cart->c_price_origin = $auction->a_cost;
         $cart->c_amount_origin = $auction->a_cost;
         $cart->c_status = 2;
         $cart->c_type = 4;
         $re = $cart->save();
         if (!$re) {
             throw new Exception("提交库存失败", 7006);
         }
         $shipping_name = $shipping_name ? $shipping_name : $user->u_name;
         $shipping_phone = $shipping_phone ? $shipping_phone : $user->u_mobile;
         // add order
         $order_group_no = Order::generateOrderGroupNo($u_id);
         $rnd_str = rand(10, 99);
         $order_no = $order_group_no . $cart->b_id . $rnd_str;
         $order = new Order();
         $order->u_id = $u_id;
         $order->b_id = $cart->b_id;
         $order->o_amount_origin = $cart->c_amount_origin;
         $order->o_amount = $cart->c_amount;
         $order->o_shipping_fee = 0.0;
         $order->o_shipping_name = $shipping_name;
         $order->o_shipping_phone = $shipping_phone;
         $order->o_shipping_address = $shipping_address;
         $order->o_delivery_time = Tools::getNow();
         $order->o_shipping = 1;
         $order->o_comment = $comment;
         $order->o_number = $order_no;
         $order->o_group_number = $order_group_no;
         $o_id = $order->addOrder();
         Cart::bindOrder([$order->o_id => [$cart->c_id]]);
         $data = ['order_no' => $order_group_no];
         $re = Tools::reTrue('提交订单成功', $data);
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提交订单失败:' . $e->getMessage());
         if ($e->getCode() == 2) {
             DB::commit();
         } else {
             DB::rollback();
         }
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:92,代码来源:MeAuctionController.php

示例10: postOrder

 public function postOrder()
 {
     $now = new DateTime();
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $amount_origin = Input::get('amount_origin', 0);
     $amount = Input::get('amount', 0);
     $shipping_fee = Input::get('shipping_fee', 0);
     $shipping_name = Input::get('shipping_name', '');
     $shipping_phone = Input::get('shipping_phone', '');
     $shipping_address = Input::get('shipping_address', '');
     $shipping = Input::get('shipping', 1);
     $delivery_time = Input::get('delivery_time', $now->format('Y-m-d H:i:s'));
     $comment = Input::get('comment', '');
     $carts = Input::get('carts', null);
     DB::beginTransaction();
     try {
         if (empty($carts)) {
             throw new Exception("请传入有效的购物车", 1);
         }
         $carts = explode(',', $carts);
         $user = User::chkUserByToken($token, $u_id);
         $list = Cart::whereIn('c_id', $carts)->get();
         $total_amount = 0;
         $total_amount_origin = 0;
         $b_ids = [];
         $amount_origin_sum = 0;
         $amount_sum = 0;
         $groups = [];
         foreach ($list as $key => $cart) {
             if ($cart->u_id != $u_id) {
                 throw new Exception("没有权限操作该购物车", 7001);
             }
             if ($cart->c_status > 1) {
                 throw new Exception("购物车无效", 7005);
             }
             $cart->updateCart($cart->c_quantity);
             if (empty($groups[$cart->b_id]['amount_origin'])) {
                 $groups[$cart->b_id]['amount_origin'] = 0;
                 $groups[$cart->b_id]['amount'] = 0;
                 $groups[$cart->b_id]['carts_ids'] = [];
             }
             $groups[$cart->b_id]['amount_origin'] += $cart->c_amount_origin;
             $groups[$cart->b_id]['amount'] += $cart->c_amount;
             $groups[$cart->b_id]['carts_ids'][] = $cart->c_id;
             $b_ids[] = $cart->b_id;
             $amount_sum += $groups[$cart->b_id]['amount'];
             $amount_origin_sum += $groups[$cart->b_id]['amount_origin'];
         }
         if ($amount_origin_sum != $amount_origin || $amount_sum != $amount) {
             throw new Exception("支付金额已刷新, 请重新提交订单", 9003);
         }
         $order_group_no = Order::generateOrderGroupNo($u_id);
         foreach ($groups as $b_id => $group) {
             $rnd_str = rand(10, 99);
             $order_no = $order_group_no . $b_id . $rnd_str;
             $order = new Order();
             $order->u_id = $u_id;
             $order->b_id = $b_id;
             $order->o_amount_origin = $group['amount_origin'];
             $order->o_amount = $group['amount'];
             $order->o_shipping_fee = $shipping_fee;
             $order->o_shipping_name = $shipping_name;
             $order->o_shipping_phone = $shipping_phone;
             $order->o_shipping_address = $shipping_address;
             $order->o_delivery_time = $delivery_time;
             $order->o_shipping = $shipping;
             $order->o_comment = $comment;
             $order->o_number = $order_no;
             $order->o_group_number = $order_group_no;
             $o_id = $order->addOrder();
             Cart::bindOrder([$order->o_id => $group['carts_ids']]);
         }
         // push msg to seller
         $list = Booth::whereIn('b_id', $b_ids)->get();
         foreach ($list as $key => $booth) {
             $obj = new MessageDispatcher($booth->u_id);
             $obj->fireTextToUser('您有新的订单, 请及时发货');
         }
         $re = Tools::reTrue('提交订单成功', ['order_no' => $order_group_no]);
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:87,代码来源:MarketController.php


注:本文中的Order::addOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。