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(); } } }
public function getOrderComplete() { try { $status = Veritrans_Transaction::status(Request::get('order_id')); $order = Order::where('order_id', $status->order_id)->first(); $order->payment_id = \App\Models\Options\Payments::where('payment_type', $status->payment_type)->first()->id; $order->order_status = $status->transaction_status; $order->save(); } catch (Exception $exc) { Session::flash('error', $exc->getMessage()); } if (!Session::has('error')) { Session::forget('order'); } return view('front.eshopper.pages.checkout-success', $this->data); }