Esempio n. 1
0
 public function getFinanceReportList()
 {
     $mainOrders = array();
     $conditions = "";
     $params = array();
     $dates = array();
     $shopID = base64_decode(Input::get('shop_id'));
     if (Request::ajax()) {
         if (0 == strcmp($shopID, ALL_SHOPS_FALG)) {
             $userID = Auth::id();
             $shops = Shop::where('wy_shopkeeper', $userID)->where('wy_audit_state', SHOP_AUDIT_STATUS_4)->get(array('wy_shop_id'));
             $shopIDs = array();
             foreach ($shops as $index => $shop) {
                 array_push($shopIDs, $shop->wy_shop_id);
             }
             if (!empty($shopIDs)) {
                 $this->getGenerateConditions($conditions, $params, $dates, false);
                 if (!empty($conditions) && !empty($params)) {
                     $mainOrders = MainOrder::whereIn('wy_shop_id', $shopIDs)->where('wy_order_state', ORDER_STATE_4)->whereRaw($conditions, $params)->orderBy('wy_generate_time')->paginate(PERPAGE_COUNT_10, array('wy_main_order_id', 'wy_shop_id', 'wy_order_number', 'wy_generate_time', 'wy_consumption_money', 'wy_actual_money', 'wy_order_state'));
                     foreach ($mainOrders as $index => $mainOrder) {
                         $orderStatus = Dictionary::where('wy_dic_id', DIC_ORDER_STATUS)->where('wy_dic_item_id', $mainOrder->wy_order_state)->first(array('wy_dic_value'));
                         $mainOrder->wy_order_state_name = $orderStatus->wy_dic_value;
                         $mainOrder->wy_shop_id = base64_encode($mainOrder->wy_shop_id);
                         $mainOrder->wy_main_order_id = base64_encode($mainOrder->wy_main_order_id);
                     }
                 }
             } else {
                 $mainOrders = Paginator::make(array(), DEFAULT_0, PERPAGE_COUNT_10);
             }
         } else {
             $headerShop = AuthController::checkShop($shopID);
             if (!empty($headerShop)) {
                 $this->getGenerateConditions($conditions, $params, $dates, false);
                 if (!empty($conditions) && !empty($params)) {
                     $mainOrders = MainOrder::where('wy_shop_id', $shopID)->where('wy_order_state', ORDER_STATE_4)->whereRaw($conditions, $params)->orderBy('wy_generate_time')->paginate(PERPAGE_COUNT_10, array('wy_main_order_id', 'wy_shop_id', 'wy_order_number', 'wy_generate_time', 'wy_consumption_money', 'wy_actual_money', 'wy_order_state'));
                     foreach ($mainOrders as $index => $mainOrder) {
                         $orderStatus = Dictionary::where('wy_dic_id', DIC_ORDER_STATUS)->where('wy_dic_item_id', $mainOrder->wy_order_state)->first(array('wy_dic_value'));
                         $mainOrder->wy_order_state_name = $orderStatus->wy_dic_value;
                         $mainOrder->wy_shop_id = base64_encode($mainOrder->wy_shop_id);
                         $mainOrder->wy_main_order_id = base64_encode($mainOrder->wy_main_order_id);
                     }
                 }
             } else {
                 $mainOrders = Paginator::make(array(), DEFAULT_0, PERPAGE_COUNT_10);
             }
         }
     }
     return View::make('admin.report.finance.financelist', compact('mainOrders'));
 }
Esempio n. 2
0
 protected function getAllTradeInfo(&$totalTurnover, &$totalOrderCount, &$newOrderCount)
 {
     $userID = Auth::id();
     $shops = Shop::where('wy_shopkeeper', $userID)->where('wy_audit_state', SHOP_AUDIT_STATUS_4)->get(array('wy_shop_id'));
     $shopIDs = array();
     foreach ($shops as $index => $shop) {
         array_push($shopIDs, $shop->wy_shop_id);
     }
     if (!empty($shopIDs)) {
         $date = Carbon::now()->toDateString();
         $totalTurnover = MainOrder::whereIn('wy_shop_id', $shopIDs)->where('wy_order_state', ORDER_STATE_4)->whereRaw('date(wy_generate_time) = ?', array($date))->sum('wy_actual_money');
         $totalTurnover = round($totalTurnover, 2);
         $totalOrderCount = MainOrder::whereIn('wy_shop_id', $shopIDs)->whereRaw('date(wy_generate_time) = ?', array($date))->count();
         $newOrderCount = MainOrder::whereIn('wy_shop_id', $shopIDs)->where('wy_order_state', ORDER_STATE_1)->whereRaw('date(wy_generate_time) = ?', array($date))->count();
     }
 }