コード例 #1
0
ファイル: OrdersController.php プロジェクト: kukujiabo/linpai
  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);
  
  }
コード例 #2
0
ファイル: OrderController.php プロジェクト: kukujiabo/linpai
  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);
  
  }
コード例 #3
0
 public function good_list($category_id)
 {
     $category = Category::find($category_id);
     $goods = Good::where('onsale', true)->where('category_id', $category_id)->orderBy('created_at', 'desc')->get();
     return view('wechat.good_list', ['category' => $category, 'goods' => $goods]);
 }
コード例 #4
0
 private function new_goods()
 {
     $news = Message::make('news')->items(function () {
         $goods = Good::where('new', true)->get();
         $info = array();
         foreach ($goods as $good) {
             $info[] = Message::make('news_item')->title($good->name)->url(url('good', [$good->id]))->picUrl('http://wfhshop.whphp.com/' . $good->thumb);
         }
         return $info;
     });
     return $news;
 }