public function showShop() { $shop = Shop::where('user_id', Auth::user()->id)->first(); if (!$shop) { $shop = new Shop(); $shop->user_id = Auth::user()->id; $shop->save(); } $items = $shop->shopItems; $total = 0; foreach ($items as $item) { $total += $item->item->price; } return view('shop', ['items' => $items, 'total' => $total]); }
/** * 显示评价信息 * GET /rate * * @return Response */ public function getList() { // $rates = array(); if (Input::has('shopID')) { $shopID = base64_decode(Input::get('shopID')); if (0 == strcmp($shopID, ALL_SHOPS_FALG)) { $headerShop = (object) array("wy_shop_id" => base64_encode(ALL_SHOPS_FALG), "wy_shop_name" => ALL_SHOPS); return View::make('admin.manage.rate.rate', compact('headerShop', 'rates'))->withAll(Lang::get('messages.10015')); } else { $headerShop = AuthController::checkShop($shopID); if (empty($headerShop)) { return View::make('admin.manage.rate.rate', compact('headerShop', 'rates'))->withError(Lang::get('errormessages.-10045')); } else { $shop = Shop::where('wy_shop_id', $shopID)->first(array('wy_comprehensive_evaluation', 'wy_service_score', 'wy_goods_score')); $rates = Rate::where('wy_shop_id', $shopID)->orderBy('wy_time', 'desc')->paginate(PERPAGE_COUNT_10, array('wy_comment_id', 'wy_main_order_id', 'wy_user_phone', 'wy_time', 'wy_content')); foreach ($rates as $index => $rate) { $rate->wy_comment_id = base64_encode($rate->wy_comment_id); $mainOrder = MainOrder::where('wy_main_order_id', $rate->wy_main_order_id)->first(array('wy_order_number')); if (!empty($mainOrder)) { $rate->wy_order_number = $mainOrder->wy_order_number; } else { $rate->wy_order_number = Lang::get('errormessages.-10058'); } $rate->wy_main_order_id = base64_encode($rate->wy_main_order_id); } return View::make('admin.manage.rate.rate', compact('headerShop', 'shop', 'rates')); } } } else { return View::make('admin.manage.rate.rate', compact('rates'))->withError(Lang::get('errormessages.-10045')); } }
/** * Execute the console command. * * @return mixed */ public function fire() { // $shop_id = $this->argument('shop'); if (!$shop_id) { return $this->error('You must provide a shop ID.'); } $shop = Shop::where('id', $shop_id)->first(); if (!$shop) { return $this->error('The shop ID you provided is invalid.'); } $access_title = $this->argument('access_title'); if (!$access_title) { $access_title = 'Free'; } $accessLevel = AccessLevel::where('title', $access_title)->first(); if (!$accessLevel) { return $this->error('The access level you provided is invalid.'); } $apiKey = new ApiKey(); $apiKey->shop_id = $shop_id; $apiKey->public_key = Hash::make($shop_id . 'REMEDY'); $apiKey->access_level_id = $accessLevel->id; $apiKey->save(); $this->info('The generated API key is:'); return $this->info($apiKey->public_key); }
/** * Store a newly created shop in storage. * * @return Response */ public function store() { $shopValidator = Validator::make($data = Input::all(), Shop::$rules); if ($shopValidator->fails()) { return Redirect::back()->withErrors($shopValidator)->withInput(); } /* Shop */ if (Input::has('createShop')) { Shop::create($data); } $message = "登録しました。"; if (Input::has('deleteShop')) { $s = Shop::where('Tenpo', Input::get('Tenpo'))->first(); Shop::destroy($s->id); $message = "削除しました。"; if (Input::has('selectedShop')) { Input::replace(array('selectedShop', '')); } } if (Input::has('updateShop')) { $messages = array('required' => '新しい店舗名を入力してください。'); $shopValidator = Validator::make($data = Input::all(), Shop::$update_rules, $messages); if ($shopValidator->fails()) { return Redirect::back()->withErrors($shopValidator)->withInput(); } $s = Shop::where('Tenpo', Input::get('Tenpo'))->first(); Shop::destroy($s->id); $data['Tenpo'] = $data['new_shopName']; Shop::create($data); $message = "更新しました。"; } return Redirect::route('employees.index')->with('message', $message); }
public function mainSearch() { $string = Input::get('string'); $shopData = Shop::where('intro', 'like', '%' . $string . '%')->orWhere('name', 'like', '%' . $string . '%')->orWhere('address', 'like', '%' . $string . '%')->get(); $key = 0; foreach ($shopData as $value) { $shopData[$key] = array('shop_name' => $value->name, 'shop_id' => $value->id, 'shop_url' => url('shop' . '/' . $value->id), 'img_url' => $value->pic); $key++; } echo json_encode(array('success' => true, 'state' => 200, 'nextSrc' => '', 'errMsg' => '', 'no' => '', 'data' => $shopData)); }
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(); } }
/** * 修改店铺的相关信息 * @return array 执行状态 */ public function modifyInfo() { $shop_id = Input::get('shop_id'); $data = Input::get('data'); $shop = Shop::where('id', $menu_id)->update($data); }
public function getShop() { $shop = Shop::where('domain', '=', Session::get('shop'))->first(); $sh = App::make('ShopifyAPI', ['API_KEY' => Config::get('shopify.APP_API_KEY'), 'API_SECRET' => Config::get('shopify.APP_API_SECRET')]); $sh->setup(['SHOP_DOMAIN' => $shop->domain, 'ACCESS_TOKEN' => $shop->getAccessToken()]); $res = ''; return Response::json(['status' => 'success', 'themes' => $res, 'shop' => $shop]); }
/** * 修改店铺营业状态 * * @return Json */ public function postChangeStatus() { $userID = Auth::id(); $shopID = base64_decode(Input::get('shop_id')); $shopStatus = Input::get('shop_status'); $retCode = SUCCESS; $retMsg = ""; $shop = Shop::where('wy_shopkeeper', $userID)->where('wy_shop_id', $shopID)->where('wy_audit_state', SHOP_AUDIT_STATUS_4)->where('wy_state', '!=', $shopStatus)->first(); if (empty($shop)) { $retCode = -10043; $retMsg = Lang::get('errormessages.-14043'); $context = array("errorCode" => $retCode, "userID" => $userID, "shopID" => $shopID); Log::error($retMsg, $context); } else { $shop->wy_state = $shopStatus; $result = $shop->save(); if ($result) { $retMsg = Lang::get('messages.10008'); } else { $retCode = -10044; $retMsg = Lang::get('errormessages.-14044'); $context = array("errorCode" => $retCode, "userID" => $userID, "shopID" => $shopID, "shopStatus" => $shopStatus); Log::error($retMsg, $context); } } $sendMsgArray = array("ret_code" => $retCode, "msg" => $retMsg); return Response::json($sendMsgArray); }
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')); }
/** * 店铺logo上传 **/ public function logoUpload() { $file = Input::file('photo'); $shop_id = Input::get('shop_id'); if ($file && $file->isValid()) { $filename = $file->getClientOriginalName(); //获取初始文件名 //获取文件类型并进行验证 $filetype = $file->getMimeType(); $typeArray = explode('/', $filetype, 2); if ($typeArray['0'] != 'image') { echo json_encode(array('status' => '400', 'msg' => '文件格式或类型违法!')); exit; } $typeName = $file->getClientOriginalExtension(); //获取文件后缀名 $b_uid = Auth::user()->uid; $newFileName = $this->fileNameMake($filename, $typeName); $directoryName = $b_uid % 100; //根据用户id和100的模值,生成对应存储目录地址 $savePath = public_path() . '/uploads/businessUser/' . $directoryName . '/logo'; $fileSave = $file->move($savePath, $newFileName); if ($fileSave) { $pic = asset('uploads/businessUser/' . $directoryName . '/logo/' . $newFileName); if (Shop::where('id', $shop_id)->update(array('pic' => $pic))) { echo json_encode(array('status' => '200', 'msg' => 'upload finished')); } else { echo json_encode(array('status' => '400', 'msg' => 'save failed')); } } else { echo json_encode(array('status' => '400', 'msg' => 'move failed')); } } else { echo json_encode(array('status' => '400', 'msg' => 'invalid file')); } }
public static function getShop($shopID) { $userID = Auth::id(); $shop = Shop::where('wy_shop_id', $shopID)->where('wy_shopkeeper', $userID)->where('wy_audit_state', SHOP_AUDIT_STATUS_4)->first(array('wy_shop_id', 'wy_region_id', 'wy_shop_name')); if (empty($shop)) { $context = array("errorCode" => -10021, "userID" => $userID, "shopID" => $shopID); Log::error(Lang::get('errormessages.-10021'), $context); if (Request::ajax()) { $sendMsgArray = array("ret_code" => -10021, "msg" => Lang::get('errormessages.-10021')); return Response::json($sendMsgArray); } else { return Redirect::back()->with('error', Lang::get('errormessages.-10021')); } } else { $shop->wy_shop_id = base64_encode($shop->wy_shop_id); } return $shop; }
<?php use Coble\General\API\ResponseBuilder; /** * Landing page, after installation / authentication */ Route::get('/', function () { $shop = Shop::where('domain', Session::get('shop'))->first(); $apiKey = ApiKey::where('shop_id', $shop->id)->with('accessLevel', 'shop')->first(); return View::make('hello')->with('apiKey', $apiKey); })->before('shopify.auth'); /** * Shopify connector */ //installation Route::get('/install', function () { return View::make('install')->with('install_url', ''); }); Route::post('/install', function () { $domain = Input::get('domain'); $shopifyController = new ShopifyAuthController(); $installUrl = $shopifyController->installURL($domain); return View::make('install')->with('install_url', $installUrl); }); //get the install url for the app Route::get('/authURL/{url}', array('uses' => 'ShopifyAuthController@installURL')); //authorize the shopify shop / install the app to the shopify shop Route::get('/auth', array('uses' => 'ShopifyAuthController@installOrAuthenticate')); //uninstall webhook callback Route::post('/uninstall', array('uses' => 'ShopifyAuthController@uninstall')); /**
/** * 打印订单 * * @return Response */ public function getPrint($shop_id, $main_order_id) { $shopID = base64_decode($shop_id); $headerShop = AuthController::checkShop($shopID); $mainOrderID = base64_decode($main_order_id); if (empty($headerShop)) { App::abort(404); } else { $shop = Shop::where('wy_shop_id', $shopID)->first(); $shop->wy_shop_id = base64_encode($shop->wy_shop_id); $mainOrder = MainOrder::where('wy_shop_id', $shopID)->where('wy_main_order_id', $mainOrderID)->first(); $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')); $goodsTotalAmout = MainOrder::find($mainOrder->wy_main_order_id)->subOrders()->sum('wy_goods_amount'); $mainOrder->goodsTotalAmout = $goodsTotalAmout; $mainOrder->subOrders = $subOrders; $mainOrder->wy_shop_id = base64_encode($mainOrder->wy_shop_id); $mainOrder->wy_main_order_id = base64_encode($mainOrder->wy_main_order_id); return View::make('admin.print.print', compact('mainOrder', 'shop')); } }