public function getReceiverinfo (Request $request) { $user = Auth::user(); $receiverInfoSet = ReceiverInfo::where('uid', '=', $user->id) ->where('active', '=', '1') ->orderBy('last_used', 'desc') ->orderBy('created_at', 'desc') ->get(); $provinceSet = Province::all(); $provinces = array(); foreach ($provinceSet as $province) { array_push($provinces, $province); } $cities = City::all(); $districts = array(); foreach ($cities as $city) { $district = District::where('city_code', '=', $city->code) ->where('active', '=', '1') ->first(); if ($district) { array_push($districts, $district); } } $receiverInfos = array(); foreach ($receiverInfoSet as $receiverInfo) { array_push($receiverInfos, $receiverInfo); } $data = [ 'receiverInfos' => $receiverInfos, 'provinces' => $provinces, 'cities' => $cities, 'districts' => $districts, 'receiverActive' => true, 'wTitle' => '个人中心 - 收货人信息' ]; return view('profile/receiver_info', $data); }
public function getReceiverinfo (Request $request) { $rid = $request->input('oid'); $receiver = ReceiverInfo::where('id', '=', $rid) ->where('active', '=', 1) ->first(); if (empty($receiver->id)) { return $this->failResponse(); } else { return $this->successResponse('receiver', $receiver); } }
private function wxJsPay($request) { $state = $request->input('state'); $decodeObject = json_decode($state); $user = Auth::user(); $order_code = $decodeObject->order_code; $order = Order::where('code', '=', $order_code)->first(); if (empty($order->id)) { //todo } else if ($order->status > 0) { return view('mobile/payed'); } $good = Good::where('id', '=', $order->gid)->first(); $orderPrice = OrderPrice::where('oid', '=', $order->id)->first(); $receiver = ReceiverInfo::find($order->rid); require_once "lib/WxPay.Api.php"; require_once "lib/WxPay.JsApiPay.php"; $notify_url = $this->debug ? "http://www.51linpai.com:8000/order/wxpay/" : "http://www.51linpai.com/order/wxpay/"; $tools = new \JsApiPay(); $openId = $tools->GetOpenid("", null); $input = new \WxPayUnifiedOrder(); $input->SetBody($good->name); $input->SetAttach($good->code); $input->SetOut_trade_no($order->code); $input->SetTotal_fee($orderPrice->final_price * 100); $input->SetTime_start(date("YmdHis")); $input->SetTime_expire(date("YmdHis", time() + 600)); $input->SetGoods_tag($good->code); $input->SetNotify_url($notify_url); $input->SetTrade_type("JSAPI"); $input->SetOpenid($openId); $jsWxOrder = \WxPayApi::unifiedOrder($input); $jsApiParameters = $tools->GetJsApiParameters($jsWxOrder); //获取共享收货地址js函数参数 $editAddress = $tools->GetEditAddressParameters(); $data = [ 'editAddress' => $editAddress, 'jsApiParameters' => $jsApiParameters, 'order_code' => $order->code, 'price' => $orderPrice->final_price, 'address' => $receiver->city . ' ' . $receiver->district . ' ' . $receiver->address, 'step' => 4, 'header' => '支付订单' ]; return view('mobile/wechat_js_pay', $data); }
public function getBuy(Request $request) { $gcode = $request->input('gcode'); $ch = $request->input('car_hand'); if (empty($ch) || strlen($ch) == 0) { return redirect('/miniorder/cartype'); } $user = Auth::user(); $gcode = (empty($gcode) || strlen($gcode) == 0) ? 'beyond-three' : $gcode; $good = Good::where('code', '=', $gcode)->first(); if (empty($good)) { //todo } $carhand = $ch == 1 ? 'one' : 'second'; $cars = Car::where('uid', '=', $user->id)->where('car_hand', '=', $carhand)->orderBy('last_used', 'desc')->get(); $defaultCar = Car::where('uid', '=', $user->id)->where('car_hand', '=', $carhand)->where('last_used', '=', 1)->first(); $receivers = Receiver::where('uid', '=', $user->id)->orderBy('last_used', 'desc')->get(); $defaultReceiver = Receiver::where('uid', '=', $user->id)->where('last_used', '=', 1)->first(); $bouns = Boun::where('uid', '=', $user->id) ->where('type', '=', 1) ->where('active', '=', 1) ->get(); $goodInfo = GoodAttribsInfo::where('gid', '=', $good->id)->where('acode', '=', 'price')->first(); $data = [ 'good' => $good, 'receivers' => $receivers, 'defaultReceiver' => $defaultReceiver, 'cars' => $cars, 'defaultCar' => $defaultCar, 'bouns' => $bouns, 'goodInfo' => $goodInfo, 'formCode' => md5(time()), 'car_hand' => $carhand, 'step' => 2, 'header' => '确认订单' ]; return view('mobile/pay', $data); }