public function store() { //上传文件 //$file = $this->request->file('orderExcel'); $orderExcel = Excel::selectSheets('Sheet1')->load(public_path('uploads/excel/70.xls'), function ($reader) { $reader->take(10); }); $results = $orderExcel->toArray(); // dd($results); foreach ($results as $result) { //TODO //查询是否已经存在 //TODO 判断序号是否为null 不为null存入数据库 如果为null 查找子序号所指向序号是否存在 if ($result['序号'] != null) { $order = new Order(); $order->excel_id = (int) $result['序号']; $order->fw_number = $result['国外运单号']; $order->name = $result['姓名']; $order->mobile = $result['电话']; $order->address = $result['地址']; $order->zip_code = $result['邮编']; $order->weight = $result['重量']; $order->id_number = $result['身份证号']; // if(!$order->save()){ // return 'false'; // } //存入订单产品 $product = new OrderProduct(); $product->order_id = $order->id; $product->name = $result['品名']; $product->count = $result['数量']; //$product->save(); } else { var_dump((int) $result['子序号']); //存入子订单 $order = Order::where('excel_id', (int) $result['子序号'])->first(); //存入订单产品 $product = new OrderProduct(); $product->order_id = $order->id; $product->name = $result['品名']; $product->count = $result['数量']; //$product->save(); } } }
private function renderPaymentLink($array = []) { $order = $array; $transaction_details = array('order_id' => Order::max('order_id') + 1, 'gross_amount' => $order['total']); $i = 0; foreach ($order['product'] as $product) { $items_details = [$i => ['id' => $product['id'], 'price' => $product['product_price'], 'quantity' => $product['product_qty'], 'name' => $product['product_name']]]; $i++; } $shipping_fee = ['id' => 'shipping', 'price' => $order['shipping']['fee'], 'quantity' => '1', 'name' => $order['shipping']['service']]; array_push($items_details, $shipping_fee); // Optional $billing_address = array('first_name' => $order['user']['first_name'], 'last_name' => $order['user']['last_name'], 'address' => $order['user']['address'], 'city' => getCity($order['user']['city']), 'postal_code' => "55281", 'phone' => $order['user']['mob_phone'], 'country_code' => 'IDN'); // Optional $customer_details = array('first_name' => $order['user']['first_name'], 'last_name' => $order['user']['last_name'], 'email' => $order['user']['email'], 'phone' => $order['user']['mob_phone'], 'billing_address' => $billing_address, 'shipping_address' => $billing_address); // Fill transaction details $transaction = array('payment_type' => 'vtweb', "vtweb" => array("enabled_payments" => getPayment(), "credit_card_3d_secure" => true, "finish_redirect_url" => url('checkout/complete'), "unfinish_redirect_url" => url('checkout/uncomplete'), "error_redirect_url" => url('checkout/error')), 'transaction_details' => $transaction_details, 'customer_details' => $customer_details, 'item_details' => $items_details); $vtweb_url = Veritrans_VtWeb::getRedirectionUrl($transaction); return $vtweb_url; }
public function destroy($id) { $order = Order::findOrFail($id); $order->delete($id); return redirect()->back()->withFlashSuccess('订单删除成功'); }
public function getAll($order_by = 'id', $sort = 'asc') { return Order::orderByDate()->paginate(15); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('orders')->truncate(); \App\Models\Order\Order::create(['userId' => 1, 'status' => 'noua', 'refNo' => uniqid(), 'firstName' => 'Gigi', 'lastName' => 'Becali', 'email' => '*****@*****.**', 'phone' => '0723111222', 'total' => 800]); }