예제 #1
0
 public function addOrderDrinks($drink_data)
 {
     $order_drink = new OrderDrinks();
     $order_drink_id = UUID::v4();
     $data = array('id' => $order_drink_id, 'order_id' => $drink_data['order_id'], 'drink_id' => $drink_data['drink_id'], 'store_coldheat_id' => $drink_data['store_coldheat_id'], 'store_coldheat_level_id' => $drink_data['store_coldheat_level_id'], 'store_sugar_id' => $drink_data['store_sugar_id'], 'drink_size' => $drink_data['drink_size'], 'uid' => isset($drink_data['uid']) ? $drink_data['uid'] : 0, 'username' => isset($drink_data['username']) ? $drink_data['username'] : null, 'amount' => $drink_data['amount'], 'notes' => isset($drink_data['notes']) ? $drink_data['notes'] : null);
     $transaction = $this->transactionManager->get();
     if (isset($drink_data['drink_extras']) && is_array($drink_data['drink_extras']) && count($drink_data['drink_extras']) > 0) {
         foreach ($drink_data['drink_extras'] as $extra_id) {
             $orderDrinksExtras = new OrderDrinksExtras();
             $extra_data = array('order_drinks_id' => $order_drink_id, 'store_extra_id' => $extra_id);
             if (false === $orderDrinksExtras->saveOrderDrinkExtras($extra_data)) {
                 $transaction->rollback();
                 return false;
             }
         }
     }
     if (false === $order_drink->saveOrderDrink($data)) {
         $transaction->rollback();
         return false;
     }
     $transaction->commit();
     return true;
 }
예제 #2
0
 private function addDrinkSizes($drink_id, $drink_coldheats_id, $drink_sizes)
 {
     $drink_sizes_model = new DrinkSizes();
     $drink_sizes_array = explode(',', $drink_sizes);
     foreach ($drink_sizes_array as $_key => $_size) {
         $_size = str_replace(':', ':', $_size);
         $_size_explode = explode(':', $_size);
         $drink_size_id = UUID::v4();
         $data = array('id' => $drink_size_id, 'drink_id' => $drink_id, 'drink_coldheat_id' => $drink_coldheats_id, 'name' => $_size_explode[0], 'price' => (int) $_size_explode[1]);
         if (false === $drink_sizes_model->add($data)) {
             return false;
         }
     }
     return true;
 }