public function run() { $user = new User(); $user->email = '*****@*****.**'; $user->password = Hash::make('amirulbaharazis'); $user->status = 'active'; $user->save(); $user_id = User::max('id'); $role = User::find($user_id); $role->assignRole(2); $customer = new Customer(); $customer->user_id = $user_id; $customer->fullname = 'Azis Amirulbahar'; $customer->address = 'Jalan raya Yogya Purworejo km 9, Temon, Kulon Progo, Yogyakarta'; $customer->avatar = 'assets/sandbox/default_avatar.png'; $customer->sex = 'Laki-laki'; $customer->phone = '081802726781'; $customer->save(); $user = new User(); $user->email = '*****@*****.**'; $user->password = Hash::make('mrizqihanafi'); $user->status = 'active'; $user->save(); $user_id = User::max('id'); $role = User::find($user_id); $role->assignRole(2); $customer = new Customer(); $customer->user_id = $user_id; $customer->fullname = 'Miftah Rizqi Hanafi'; $customer->address = 'Jalan raya Yogya Magelang km 3, Muntilan, Magelang, Jawa Tengah'; $customer->avatar = 'assets/sandbox/default_avatar.png'; $customer->sex = 'Laki-laki'; $customer->phone = '081102726881'; $customer->save(); $user = new User(); $user->email = '*****@*****.**'; $user->password = Hash::make('rrardian'); $user->status = 'active'; $user->save(); $user_id = User::max('id'); $role = User::find($user_id); $role->assignRole(2); $customer = new Customer(); $customer->user_id = $user_id; $customer->fullname = 'Rais Rahman Ardian'; $customer->address = 'Jalan Samas km 15, Palbapang, Bantul, Yogyakarta'; $customer->avatar = 'assets/sandbox/default_avatar.png'; $customer->sex = 'Laki-laki'; $customer->phone = '085729086154'; $customer->save(); }
public function returnCredit($order_number, $customer_id, $coupon_id, $credit, $customer_new_credit) { $dynamoClass = new DynamoDb(); $dynamoClass->table(env('DYNAMO_TABLE_PREFIX') . '_customer'); if (isset($coupon_id) && $coupon_id > 0) { CouponCodesRedeemed::where('order_number', '=', $order_number)->where('customer_id', '=', $customer_id)->delete(); } if (isset($credit) && $credit > 0) { Customer::where('id', '=', $customer_id)->increment('credit', $credit); $cus_input['credit'] = (double) $customer_new_credit; $dynamoClass->update($customer_id, $cus_input); } }
public function createDummyOrders() { $this->syncDeliveryZones(3); exit; //static data $input = array("meal_plan_id" => 254, "zone_id" => 1, "state_code" => "CA"); echo "<pre>"; //input data randomized $recipient = array("lr3nRmFE50bWm0dGdPH8rfeZ", "64r7AdG6q7oLmhvsVXGBIhZN", "K4M1OGiMkopR~fBSdiDKjJ6*"); $rand = rand(0, 2); $input['recipient_id'] = $recipient[$rand]; $db_exists = $this::setCurrentDatabase($input['state_code']); $OrderHelper = new OrderHelper(); $market_office_id = $OrderHelper->getMarketOfficeCity($input['zone_id']); $mrkt_ofc_data = $OrderHelper->getMarketOfficeData($market_office_id); $customer = Customer::orderBy(DB::raw("RAND()"))->first(); $food = $OrderHelper->getMenuItems($input['meal_plan_id']); $gross_amount = 0; //to be added to database $order = array(); $order['state_code'] = $input['state_code']; $order['market_office_id'] = $market_office_id; $order['market_office_name'] = $mrkt_ofc_data['office_name']; $order['market_office_city_id'] = MarketOfficeCityDeliveryZones::where('id', '=', $input['zone_id'])->pluck('market_office_city_id'); $order['market_office_city_name'] = MarketOfficeCity::where('id', '=', $order['market_office_city_id'])->pluck('city_name'); $order['market_office_city_delivery_zone_id'] = $input['zone_id']; $order['market_office_city_delivery_zone_name'] = MarketOfficeCityDeliveryZones::where('id', '=', $input['zone_id'])->pluck('delivery_zone_name'); $order['customer_id'] = $customer->id; $order['customer_delivery_address'] = $customer->address; $order['meal_plan_id'] = $input['meal_plan_id']; $order['meal_plan_name'] = $OrderHelper->getCurrentMealCategory($input['meal_plan_id']); $order['tax_percentage'] = $mrkt_ofc_data['tax_percentage']; $order['tax_amount'] = 0; $order['gross_amount'] = 0; $order['coupon_id'] = 0; $order['coupon_code'] = NULL; $order['coupon_amount'] = "0.00"; $order['credit'] = "0.00"; $order['tips_percentage'] = "0"; $order['tips_amount'] = "0.00"; $order['total_amount'] = $gross_amount + $order['tax_amount']; $order['note'] = ""; $order['phone'] = $customer->phone; $order['order_status'] = "Processing"; $order['created_at'] = date('Y-m-d H:i:s'); $lastOrderId = Order::insertGetId($order); echo $lastOrderId . "\n"; $orderDetails = $OrderHelper->insertOrderDetails($food, $lastOrderId); print_r($orderDetails); $menu_food = array(); foreach ($orderDetails as $val) { $obj['food_id'] = $val['menu_item_id']; $obj['food_qty'] = $val['quantity']; $menu_food[] = (object) $obj; $gross_amount += $val['amount']; } $hash = sha1($lastOrderId . uniqid(mt_rand())); $order_number = sha1($lastOrderId . uniqid(mt_rand())); $transactionId = 0; $card_number = "NDI0Mg=="; $cardType = "Visa"; $order_number = $input['state_code'] . '00' . $lastOrderId; $tax_amount = round($gross_amount * ($order['tax_percentage'] / 100), 2); $total_amount = $gross_amount + $tax_amount; Order::where('id', '=', $lastOrderId)->update(array('transaction_id' => $transactionId, 'card_number' => $card_number, 'card_type' => $cardType, 'hash' => $hash, 'order_number' => $order_number, 'payment_status' => 'Charged', 'gross_amount' => $gross_amount, 'tax_amount' => $tax_amount, 'total_amount' => $total_amount)); $order['order_id'] = $lastOrderId; $order['food'] = $menu_food; $order['recipient_id'] = $input['recipient_id']; #$ApiRedis = new ApiRedis(); $b = $this->syncDeliveryZones(1); $c = $this->pushOrderIntoQueue($lastOrderId, 0); $d = $this->pushOrderIntoHash($lastOrderId, $order); var_dump($b); var_dump($c); var_dump($d); print_r($order); echo $order_number . "\n" . $transactionId . "\n" . $hash . "\n" . $card_number . "\n" . $cardType . "\n" . $gross_amount . "\n" . $tax_amount; // $ApiRedis->pushOrderIntoQueue($order); }
protected function sendCancelOrderMail($order_id = NULL) { if ($order_id) { $order_info = array(); $order_data = Order::select('order_number', 'customer_id')->where('id', '=', $order_id)->first(); if ($order_data->order_number) { $order_info['order_number'] = $order_data->order_number; $order_info['customer_record'] = Customer::select('full_name', 'email', DB::raw('CONCAT(country_code,phone) AS phone'))->where('id', '=', $order_data->customer_id)->first(); Mail::send('emails.cancel_order', array('name' => $order_info['customer_record']['full_name'], 'order_number' => $order_info['order_number']), function ($message) use($order_info) { $message->from('*****@*****.**', 'Foodjets'); $message->to($order_info['customer_record']['email'], $order_info['customer_record']['full_name'])->subject('Cancel Order'); }); } } }