Ejemplo n.º 1
0
 public function getTakeorder(Request $request, $staffer_id, $tote_id, $product_amount)
 {
     $user = $request->user();
     $abd_id = $request->input('abd_id');
     $days = $request->input('days');
     $moment = $request->input('moment');
     $time = $request->input('time');
     $coupon_id = $request->input('coupon_id');
     $staffer = Staffer::apiFind($staffer_id);
     $address = Address::apiFind($abd_id);
     $item = Order::item($tote_id, $product_amount);
     $check = Tote::apiCheck($item, $staffer_id, $abd_id, $days, $moment, $coupon_id);
     $tote = Tote::apiFind($tote_id);
     $url = URL::full();
     session(['url' => $url]);
     return view('auth.staffer.takeorder', ['TITLE' => '下单', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => 'auth.staffer.takeorder', 'user' => $user, 'staffer' => $staffer, 'address' => $address, 'check' => $check, 'tote' => $tote, 'staffer_id' => $staffer_id, 'tote_id' => $tote_id, 'product_amount' => $product_amount, 'abd_id' => $abd_id, 'days' => $days, 'moment' => $moment, 'time' => $time, 'coupon_id' => $coupon_id, 'url' => $url]);
 }
Ejemplo n.º 2
0
 public function postAddtote(request $request)
 {
     $user = $request->user();
     $tote_id = $request->input('tote_id');
     $product_amount = $request->input('product_amount');
     $item = Order::item($tote_id, $product_amount);
     $staffer_id = $request->input('staffer_id');
     $abd_id = $request->input('abd_id');
     $days = $request->input('days');
     $time = $request->input('time');
     $moment = $request->input('moment');
     $coupon_id = $request->input('coupon_id');
     $url = $request->input('url');
     $response = Tote::apiCheck($item, $staffer_id, $abd_id, $days, $moment, $coupon_id);
     if ($response) {
         $params = ['item_id' => $staffer_id, 'item' => $item, 'abd_id' => $abd_id, 'days' => $days, 'moment' => $moment];
         if ($coupon_id) {
             $params['coupon_id'] = $coupon_id;
         }
         $order = Order::apiCreateSm($params);
         if (is_object($order)) {
             $business = new Business(env('WECHAT_APPID'), env('WECHAT_APPSECRET'), env('WECHAT_MCHID'), env('WECHAT_KEY'));
             $wxorder = new WxOrder();
             $wxorder->body = $order->odrno;
             $wxorder->out_trade_no = $order->odrno;
             $wxorder->total_fee = $order->final * 100;
             // 单位为 “分”, 字符串类型
             $wxorder->openid = $user->user_open_id;
             $wxorder->notify_url = API_PAY_CALLBACK_URL;
             $unifiedOrder = new UnifiedOrder($business, $wxorder);
             $payment = new Payment($unifiedOrder);
             $res = redirect('/pay')->with(['payment' => $payment, 'order' => $order, 'wxorder' => $wxorder, 'url' => $url, 'type' => 'SM']);
         } else {
             $res = redirect()->back()->with('msgError', $order);
         }
     } else {
         $res = redirect()->back()->with('msgError', '订单信息错误');
     }
     return $res;
 }