Inheritance: extends Core\Model
示例#1
0
 /**
  * 创建订单
  *
  */
 public function create()
 {
     $user = User::getCurrent();
     $data['custom_plan_name'] = json_decode(Option::get('custom_plan_name'), true);
     $data['custom_transfer_level'] = json_decode(Option::get('custom_transfer_level'), true);
     $plan = strtoupper($_GET['plan']);
     $money = 0;
     switch ($plan) {
         case 'B':
             $money = 12;
             break;
         case 'C':
             $money = 20;
             break;
         case 'D':
             $money = 35;
             break;
         case 'VIP':
             $money = 50;
             break;
         case 'Z':
             $money = 50;
             break;
     }
     /*
     if(count(MOrder::getByUserId($user->uid)) > 0) {
         header("Location: /order/lists");
         exit();
     }
     */
     $order = new MOrder();
     $order->uid = $user->uid;
     $order->createTime = time();
     $order->money = $money;
     $order->plan = $plan;
     $order->status = 0;
     $order->type = 0;
     // 类型: 0 - 购买套餐 1 - 账户金额充值 2 - 购买卡号
     $remark = $order->type == 0 ? "购买套餐 " : $order->type == 1 ? "金额充值 " : "购买卡号 ";
     $remark .= $plan . ', ' . $money . '元';
     $order->remark = $remark;
     $order->save(Model::SAVE_INSERT);
     Template::putContext("order_id", $order->id);
     Template::putContext('transfer', $data['custom_transfer_level'][$plan]);
     Template::putContext('plan', $plan);
     Template::putContext('plan_name', $data['custom_plan_name'][$plan]);
     Template::putContext('money', $money);
     Template::putContext('user', $user);
     Template::setView('panel/order_create');
 }
示例#2
0
 public function index()
 {
     // -- ** -- GET Twig & city list
     $twig = Config::getTwig();
     $loginResult = Order::getOrders();
     //die($_SERVER['REQUEST_URI']);
     // -- ** -- Check $cityList content is exist with isset method
     $result = array('orders' => $loginResult->content);
     // -- ** -- Render result with twig
     if ($loginResult->isSuccess()) {
         return $twig->render('admin/pages/tables/orders.html', $result);
     } else {
         return $twig->render('admin/pages/tables/orders.html', $result);
     }
 }
 /**
  * Filter the query by a related \Model\Order object
  *
  * @param \Model\Order|ObjectCollection $order the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildTruckQuery The current query, for fluid interface
  */
 public function filterByOrder($order, $comparison = null)
 {
     if ($order instanceof \Model\Order) {
         return $this->addUsingAlias(TruckTableMap::COL_ID, $order->getTruckId(), $comparison);
     } elseif ($order instanceof ObjectCollection) {
         return $this->useOrderQuery()->filterByPrimaryKeys($order->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByOrder() only accepts arguments of type \\Model\\Order or Collection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   ChildOrder $order Object to remove from the list of results
  *
  * @return $this|ChildOrderQuery The current query, for fluid interface
  */
 public function prune($order = null)
 {
     if ($order) {
         $this->addUsingAlias(OrderTableMap::COL_ID, $order->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 public function placeOrder()
 {
     // Make sure request is well formated
     if (!array_key_exists('order', $this->request_body)) {
         throw new Exception('Missing or malformed request.', 422);
     }
     $input = $this->request_body['order'];
     $requiredKeys = array('customerName', 'customerEmail', 'itemName', 'price', 'token');
     $this->app['utils']->verifyInputIsntNull($input, $requiredKeys);
     // Create new Order object
     $order = new Order();
     $order->setTruckId($truckId = 1);
     $order->setItemName($input['itemName']);
     $order->setPrice($input['price']);
     $order->setCustomerName($input['customerName']);
     $order->setCustomerEmail($input['customerEmail']);
     if (array_key_exists('customerPhoneNumber', $input)) {
         $order->setCustomerPhoneNumber($input['customerPhoneNumber']);
     }
     // Pay for order
     $payment = $this->stripeWrapper->payForOrder($input);
     // Add order info to order
     $order->setChargeId($payment['chargeId']);
     $order->setCustomerId($payment['customerId']);
     // Save the Order to the db
     $order->save();
     // Return Order objet
     return array('order' => $order->toArray());
 }
示例#6
0
 /**
  * @param ChildOrder $order The ChildOrder object to add.
  */
 protected function doAddOrder(ChildOrder $order)
 {
     $this->collOrders[] = $order;
     $order->setTruck($this);
 }