/** * Функция сохраняет текущее состояние записи, * восстанавливает состояние записи из резервной копии * и удаляет все резервные копии, превысившие лимит * * @param $dic_id * @param $id * @return string * @throws Exception */ public function restore($dic_id, $id) { $dic = Dictionary::where(is_numeric($dic_id) ? 'id' : 'slug', $dic_id)->first(); $versions = Config::get('dic/' . $dic->slug . '.versions'); if (!$this->checkDicPermission($dic) || !@$versions) { App::abort(404); } $this->dicval_permission($dic, 'dicval_restore'); /** * Находим запись резервной копии для восстановления */ $version = DicVal::where('id', $id)->with('allfields', 'metas', 'seo')->first(); if (!isset($version) || !is_object($version) || $version->version_of == NULL) { return Redirect::to(URL::previous()); } /** * Находим запись оригинала */ $element = DicVal::where('id', $version->version_of)->with('allfields', 'metas', 'seo', 'versions')->first(); if (!isset($element) || !is_object($element) || $element->version_of != NULL) { return Redirect::to(URL::previous()); } #Helper::ta($version); #Helper::ta($element); #dd(); #Helper::ta($element->versions); /** * Создаем резервную копию оригинальной записи */ $create_backup_result = $this->create_backup($version->version_of, false); if (!$create_backup_result) { throw new Exception("Can't create backup of original record"); } #Helper::tad($element->versions); /** * Восстанавливаем содержимое записи из резервной копии */ $restore_backup_result = $this->restore_backup($version->id); if (!$restore_backup_result) { throw new Exception("Can't restore backup of original record"); } /** * Удаляем старые резервные копии (если их больше лимита) */ $delete_backup_result = $this->delete_backups($element->id); if (!$delete_backup_result) { throw new Exception("Can't delete over backups of original record"); } #Helper::dd((int)$create_backup_result . ' / ' . (int)$restore_backup_result . ' / ' . (int)$delete_backup_result); $url = action(is_numeric($dic_id) ? 'dicval.edit' : 'entity.edit', array('dic_id' => $dic_id, 'id' => $element->id)) . (Request::getQueryString() ? '?' . Request::getQueryString() : ''); #Helper::d($element); #Helper::dd($url); #return Redirect::to($url); Redirect($url); return ''; }
/** * 获取店铺类型 * * @return Response */ public function getType() { $types = Dictionary::where('wy_dic_id', DIC_SHOP_TYPE)->get(array('wy_dic_item_id', 'wy_dic_value')); if (empty($types->toArray())) { return View::make('admin.template.dic.type')->withError(Lang::get('errormessages.-10040')); } else { return View::make('admin.template.dic.type', compact('types')); } }
public function getListInfo() { $shopID = base64_decode(Input::get('shopID')); $mainOrderID = base64_decode(Input::get('mainOrderID')); $disableChange = DEFAULT_0; $headerShop = AuthController::checkShop($shopID); if (!empty($headerShop)) { $mainOrder = MainOrder::where('wy_main_order_id', $mainOrderID)->where('wy_shop_id', $shopID)->first(array('wy_main_order_id', 'wy_shop_id', 'wy_order_number', 'wy_recv_name', 'wy_recv_addr', 'wy_recv_phone', 'wy_consumption_money', 'wy_actual_money', 'wy_order_state', 'wy_order_state_flow', 'wy_generate_time', 'wy_confirm_time', 'wy_send_time', 'wy_arrive_time', 'wy_reminder_flag', 'wy_reminder_count', 'wy_reminder_time', 'wy_refuse_time', 'wy_cancel_time', 'wy_user_note')); if (!empty($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; $reminderFlag = Dictionary::where('wy_dic_id', DIC_REMINDER_FLAG)->where('wy_dic_item_id', $mainOrder->wy_reminder_flag)->first(array('wy_dic_value')); $mainOrder->wy_reminder_flag_name = $reminderFlag->wy_dic_value; $subOrders = MainOrder::find($mainOrder->wy_main_order_id)->subOrders()->get(array('wy_goods_id', 'wy_goods_name', 'wy_goods_unit_price', 'wy_goods_amount', 'wy_goods_total_price')); $mainOrder->subOrders = $subOrders; $mainOrder->wy_shop_name = $headerShop->wy_shop_name; $mainOrder->wy_shop_id = base64_encode($mainOrder->wy_shop_id); $mainOrder->wy_main_order_id = base64_encode($mainOrder->wy_main_order_id); //订单流的处理 $orderStatFlows = str_split($mainOrder->wy_order_state_flow); return View::make('admin.template.order.orderdetail', compact('headerShop', 'disableChange', 'mainOrder', 'orderStatFlows')); } else { return View::make('admin.template.order.orderdetail', compact('headerShop', 'disableChange'))->withError(Lang::get('errormessages.-10068')); } } else { return View::make('admin.template.order.orderdetail', compact('disableChange'))->withError(Lang::get('errormessages.-10068')); } }
/** * 查询已下架菜品信息 * * @param [int] $[shopID] [店铺ID] * @param [int] $[goodsID] [商品ID] * * @return Response */ public function getUnsellInfo() { $shopID = base64_decode(Input::get('shopID')); $headerShop = AuthController::checkShop($shopID, true); $goodsID = base64_decode(Input::get('goodsID')); $good = Goods::where('wy_goods_id', $goodsID)->where('wy_shop_id', $shopID)->where('wy_goods_state', GOODS_STATUS_2)->first(array('wy_goods_id', 'wy_shop_id', 'wy_goods_name', 'wy_goods_type', 'wy_goods_icon', 'wy_goods_sale_price', 'wy_stock', 'wy_brief')); if (empty($good)) { return Redirect::back()->with('error', Lang::get('errormessages.-10048')); } else { $types = Dictionary::where('wy_dic_id', DIC_GOODS_TYPE)->get(); $typeValue = $good->wy_goods_type; $good->wy_goods_id = base64_encode($good->wy_goods_id); $good->wy_shop_id = base64_encode($good->wy_shop_id); return View::make('admin.freshbiz.goods.goodsinfo', compact('headerShop', 'good'))->nest('goodsType', 'admin.template.dic.type', compact('types', 'typeValue')); } }
public function getSphinx($dic_id) { if (!Allow::superuser()) { App::abort(404); } $dic = Dictionary::where(is_numeric($dic_id) ? 'id' : 'slug', $dic_id)->first(); if (!is_object($dic)) { App::abort(404); } #Helper::d('Данные словаря:') . Helper::ta($dic); $fields = Config::get('dic/' . $dic->slug . '.fields'); if (isset($fields) && is_callable($fields)) { $fields = $fields(); } #Helper::d('Доп. поля словаря (fields):') . Helper::d($fields); $fields_i18n = Config::get('dic/' . $dic->slug . '.fields_i18n'); if (isset($fields_i18n) && is_callable($fields_i18n)) { $fields_i18n = $fields_i18n(); } #Helper::d('Мультиязычные доп. поля словаря (fields_i18n):') . Helper::d($fields_i18n); $tbl_dic_field_val = (new DicFieldVal())->getTable(); $tbl_dic_textfield_val = (new DicTextFieldVal())->getTable(); /** * Будут индексироваться только поля следующих типов */ $indexed_types = array('textarea', 'textarea_redactor', 'text'); $fulltext_types = array('textarea', 'textarea_redactor'); $selects = array("dicval.id AS id", $dic->id . " AS dic_id", $dic->id . " AS source_id", "'" . $dic->name . "' AS dic_name", "'" . $dic->slug . "' AS dic_slug", "dicval.name AS name"); $sql = array(); $j = 0; /** * Поиск по обычным полям */ if (isset($fields) && is_array($fields) && count($fields)) { foreach ($fields as $field_key => $field) { if (!isset($field['type']) || !in_array($field['type'], $indexed_types)) { continue; } $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val; ++$j; $tbl = "tbl" . $j; ##$selects[] = $tbl . '.language AS language'; $selects[] = $tbl . '.value AS ' . $field_key; $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NULL"; } } /** * Поиск по мультиязычным полям */ if (isset($fields_i18n) && is_array($fields_i18n) && count($fields_i18n)) { foreach ($fields_i18n as $field_key => $field) { if (!in_array($field['type'], $indexed_types)) { continue; } $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val; ++$j; $tbl = "tbl" . $j; ##$selects[] = $tbl . '.language AS language'; $selects[] = $tbl . '.value AS `' . $field_key . '`'; $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NOT NULL"; } } $sql[] = "WHERE dicval.version_of IS NULL AND dicval.dic_id = '" . $dic->id . "'"; $selects_compile = implode(', ', $selects); array_unshift($sql, "SELECT " . $selects_compile . " FROM " . (new DicVal())->getTable() . " AS dicval"); return "<h1>Поиск по словарю «" . $dic->name . "» (" . $dic->slug . ")</h1>" . "<h3>SQL-запрос для тестирования (phpMyAdmin):</h3>" . nl2br(implode("\n", $sql)) . "<h3>SQL-запрос для вставки в конфиг Sphinx:</h3>" . "<pre>\n sql_query = \\\n " . implode(' \\' . "\n ", $sql) . "\n\n sql_attr_uint = source_id\n</pre>"; }
public function getBizReportList() { $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->getStatisticsConditions($conditions, $params, $dates, false); if (!empty($conditions) && !empty($params)) { $mainOrders = MainOrder::whereIn('wy_shop_id', $shopIDs)->whereRaw($conditions, $params)->orderBy('wy_generate_time')->paginate(PERPAGE_COUNT_10, array('wy_main_order_id', 'wy_shop_id', 'wy_order_number', 'wy_recv_name', 'wy_generate_time', 'wy_actual_money', 'wy_order_state', 'wy_reminder_flag')); 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; $reminderFlag = Dictionary::where('wy_dic_id', DIC_REMINDER_FLAG)->where('wy_dic_item_id', $mainOrder->wy_reminder_flag)->first(array('wy_dic_value')); $mainOrder->wy_reminder_flag_name = $reminderFlag->wy_dic_value; $shop = Shop::where('wy_shop_id', $mainOrder->wy_shop_id)->first(array('wy_shop_name')); if (!empty($shop)) { $mainOrder->wy_shop_name = $shop->wy_shop_name; } else { $mainOrder->wy_shop_name = $headerShop->wy_shop_name; } $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->getStatisticsConditions($conditions, $params, $dates, false); if (!empty($conditions) && !empty($params)) { $mainOrders = MainOrder::where('wy_shop_id', $shopID)->whereRaw($conditions, $params)->orderBy('wy_generate_time')->paginate(PERPAGE_COUNT_10, array('wy_main_order_id', 'wy_shop_id', 'wy_order_number', 'wy_recv_name', 'wy_generate_time', 'wy_actual_money', 'wy_order_state', 'wy_reminder_flag')); 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; $reminderFlag = Dictionary::where('wy_dic_id', DIC_REMINDER_FLAG)->where('wy_dic_item_id', $mainOrder->wy_reminder_flag)->first(array('wy_dic_value')); $mainOrder->wy_reminder_flag_name = $reminderFlag->wy_dic_value; $mainOrder->wy_shop_name = $headerShop->wy_shop_name; $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.trade.bizreportlist', compact('mainOrders')); }