public function yinlian() { include_once '../vendor/yinlian_sdk/acp_service.php'; if (isset($_POST['signature'])) { if (\AcpService::validate($_POST) && ($_POST['respCode'] == '00' || $_POST['respCode'] == 'A6')) { $order = Order::where('out_trade_no', $_POST['orderId'])->first(); if ($order != null) { $orderId = $order->id; $order->status = 1; $time = date("Y-m-d H:i:s", time()); $order->payment_time = $time; $order->payment_way = 3; $order->save(); $useCouponRecords = UseCouponRecords::where('order_id', $orderId)->first(); if ($useCouponRecords != null) { $useCouponRecords->status = 2; //礼券金额 $apiParam = ['accessToken' => $useCouponRecords->access_token, 'coupon' => $useCouponRecords->coupon, 'orderId' => $_POST['orderId']]; $res = $this->post('/zhmf/member/consumerCoupon/useCoupon', $apiParam); $res = json_decode($res); if ($res->Code == 0) { $useCouponRecords->status = 1; } $useCouponRecords->save(); } echo 'success'; } } else { @header('HTTP/1.1 500 Internal Server Error'); } } else { @header('HTTP/1.1 500 Internal Server Error'); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $bill = Bill::findOrNew($request->get('id')); $bill->is_paid = 1; $bill->save(); $order = Order::where('server_order_id', '=', $request->get('order_id'))->first(); $order->is_paid = 1; $order->save(); $passingData = array('order_id' => $request->get('order_id')); $data_string = json_encode($passingData); $url = curl_init('http://localhost:8000/api/order/updatepaid'); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_POSTFIELDS, $data_string); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); $result = curl_exec($url); return redirect('/bill'); }
public function update(Request $requests, $id) { $params = $requests->all(); $order = Order::where('out_trade_no', $id)->first(); if ($order == null) { $ret['meta']['code'] = 0; $ret['meta']['error'] = '目标不存在'; } else { $order->status = $params['status']; if ($order->status == 3) { $order->express_company_name = $params['express_company_name']; $order->express_number = $params['express_number']; $order->shipments_time = date("Y-m-d H:i:s", time()); } $order->save(); $ret['meta']['code'] = 1; } echo json_encode($ret); }
public function getOrderByCustomerId($customerId) { $order = Order::where('customer_id', '=', $customerId); return response()->json(['order' => $order]); }
public function push_order_process($param = false) { //echo $param;exit; $usps_obj = new Usps(); $obj = new helpers(); $all_process_orders = DB::table('add_process_order_labels')->get(); $all_filename = array(); $flag = 0; if (!empty($all_process_orders)) { foreach ($all_process_orders as $key => $value) { // Get details for each order $ord_dtls = Order::find($value->order_id); $serialize_add = unserialize($ord_dtls['shiping_address_serialize']); $user_email = $serialize_add['email']; $user_name = $serialize_add['first_name'] . " " . $serialize_add['last_name']; $phone = $serialize_add['phone']; $address = $serialize_add['address']; $address2 = $serialize_add['address2']; $city = $serialize_add['city']; $zone_id = $serialize_add['zone_id']; $country_id = $serialize_add['country_id']; $postcode = $serialize_add['postcode']; $ToState = ''; if (is_numeric($zone_id)) { $ToState = $obj->get_statecode($zone_id); } else { $ToState = $obj->get_statecode_by_name($zone_id); } // Call USPS API $parameters_array = array('ToName' => $user_name, 'ToFirm' => '', 'ToAddress1' => $address2, 'ToAddress2' => $address, 'ToCity' => $city, 'ToState' => $ToState, 'ToZip5' => $postcode, 'order_id' => $value->order_id); $ret_array = $usps_obj->USPSLabel($parameters_array); //echo "<pre>";print_r($ret_array);exit; if ($ret_array['filename'] != "") { $flag = 1; } $all_filename[] = $filename = $ret_array['filename']; $tracking_number = $ret_array['tracking_no']; // Update label name in DB Order::where('id', $value->order_id)->update(['tracking_number' => $tracking_number, 'shipping_carrier' => 'USPS', 'usps_label' => $filename, 'order_status' => 'shipped']); // change order status and send mail $order = Order::find($value->order_id); $subject = 'Order status change of : #' . $order->order_number; $cmessage = 'Your order status is changed to ' . $order->order_status . '. Please visit your account for details.'; $tracking = ''; $shipping = ''; if ($order->order_status == 'shipped') { $tracking = 'Tracking Number is : ' . $tracking_number; $shipping = 'Shipping Method is : USPS<br />Please visit your account for details'; } $setting = DB::table('sitesettings')->where('name', 'email')->first(); $admin_users_email = $setting->value; /*$sent = Mail::send('admin.order.statusemail', array('name'=>$user_name,'email'=>$user_email,'messages'=>$cmessage,'admin_users_email'=>$admin_users_email,'tracking'=>$tracking,'shipping'=>$shipping), function($message) use ($admin_users_email, $user_email,$user_name,$subject) { $message->from($admin_users_email); $message->to($user_email, $user_name)->cc($admin_users_email)->subject($subject); //$message->to('*****@*****.**', $user_name)->cc($admin_users_email)->subject($subject); });*/ } } // Delete from add_process_order_labels DB::table('add_process_order_labels')->delete(); if ($param == 1) { $full_path = array(); if (!empty($all_filename)) { foreach ($all_filename as $file) { if ($file != "") { $full_path[] = './uploads/pdf/' . $file; } } } if (!empty($full_path)) { $usps_obj->new_printPdf($full_path); } } //echo $flag;print_r($all_filename);exit; if ($flag == 1) { Session::flash('success', 'Message is sent to user and order status is updated successfully.'); } else { Session::flash('error', 'No label is created.'); } return redirect('admin/orders'); }
/** * Editable ajax change status. * * @param Request $request * @return mixed */ public function postChangeStatus(Request $request) { $data = $request->all(); if (Order::where('id', '=', $data['pk'])->update(['delivery_status' => $data['value']])) { return Response::json(['status' => 200]); } else { return Response::json(['status' => 502]); } }
/** * * @SWG\Api( * path="/orders/{out_trade_no}", * @SWG\Operation( * method="DELETE", summary="删除订单", notes="删除订单", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="out_trade_no", * description="订单号", * paramType="path", * required=true, * type="string" * ), * ) * ) */ public function destroy($out_trade_no) { $response = new BaseResponse(); $order = Order::where('out_trade_no', $out_trade_no)->first(); if ($order != null) { $order->delete_at = date("Y-m-d H:i:s", time()); $order->save(); } return $response->toJson(); }
public function getOrders(Request $request) { $customer_id = $request->input('customer_id'); $orders = Order::where('customer_id', $customer_id)->with('orderItems.product.productUnit', 'orderState', 'orderItems.orderItemState')->get(); return response()->json(['success' => true, 'data' => ['orders' => $orders]]); }
public function cancelOrderAPI(Request $request) { $order = Order::where('server_order_id', '=', $request->get('order_id'))->first(); $order->status = 2; $order->save(); $notificationController = new NotificationController(); $notificationController->store($request); return $order->id; }