예제 #1
0
 public function get($f3)
 {
     // 设置 order_refer 记录,记录在客户端
     $orderRefer = array();
     // 检查彩贝的记录
     $caibeiRefer = $f3->get('SESSION[yiqifa_caibei_order_refer]');
     if (!empty($caibeiRefer)) {
         $orderRefer = $caibeiRefer;
         unset($orderRefer['refer_host']);
         // 去掉彩贝的 refer_host
     }
     // 清除彩贝记录
     $f3->set('SESSION[yiqifa_caibei_order_refer]', null);
     $orderRefer['utm_source'] = 'YIQIFACPS';
     // 保存额外的 亿起发 参数
     $validator = new Validator($_REQUEST);
     $referParamArray = array();
     $referParamArray['src'] = $validator->validate('src');
     $referParamArray['cid'] = $validator->validate('cid');
     $referParamArray['wi'] = $validator->validate('wi');
     $referParamArray['channel'] = $validator->validate('channel');
     $orderRefer['refer_param'] = json_encode($referParamArray);
     //设置 cookie
     ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
     // 页面跳转到商品
     $url = $validator->validate('url');
     $redirectUrl = empty($url) ? '/' : $url;
     RouteHelper::reRoute($this, $redirectUrl);
     return;
 }
예제 #2
0
파일: Pay.php 프로젝트: jackycgq/bzfshop
 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $order_id = $validator->required('订单ID非法')->digits('订单ID非法')->min(1, true, '订单ID非法')->validate('order_id');
     if (!$this->validate($validator)) {
         goto out_fail;
     }
     $userInfo = AuthHelper::getAuthUser();
     $userBasicService = new UserBasicService();
     $userInfo = $userBasicService->loadUserById($userInfo['user_id']);
     // 支付某一个特定的订单需要把订单加载到临时购物车里面
     $orderBasicService = new OrderBasicService();
     // 检查权限
     $orderInfo = $orderBasicService->loadOrderInfoById($order_id);
     if ($orderInfo->isEmpty() || $userInfo['user_id'] != $orderInfo['user_id'] || OrderBasicService::OS_UNCONFIRMED != $orderInfo['order_status']) {
         $this->addFlashMessage('订单ID非法');
         goto out_fail;
     }
     $cartBasicService = new CartBasicService();
     // 加载订单到购物车里
     if (!$cartBasicService->loadFromOrderInfo($order_id)) {
         $this->addFlashMessage('订单加载失败');
         goto out_fail;
     }
     $cartContext =& $cartBasicService->getCartContextRef();
     if ($cartContext->isEmpty()) {
         $this->addFlashMessage('订单为空,不能支付');
         goto out_fail;
     }
     // 做一次购物车计算
     $cartBasicService->calcOrderPrice();
     // 如果购物车里面有错误消息,我们需要显示它
     if ($cartContext->hasError()) {
         $this->addFlashMessageArray($cartContext->getAndClearErrorMessageArray());
         goto out_my_order_cart;
     }
     // 给模板赋值
     $smarty->assign('userInfo', $userInfo);
     $smarty->assign('orderInfo', $orderInfo);
     $smarty->assign('cartContext', $cartContext);
     $smarty->assign('orderGoodsArray', $cartContext->orderGoodsArray);
     $smarty->assign($cartContext->getAddressInfo());
     $smarty->assign('postscript', $cartContext->getValue('postscript'));
     //订单推送url
     $smarty->assign('orderNotifyUrlArray', ReferHelper::getOrderReferNotifyUrlArray($f3, $order_id));
     $smarty->display('cart_pay.tpl');
     return;
     out_my_order_cart:
     //失败从这里退出
     RouteHelper::reRoute($this, RouteHelper::makeUrl('/My/Order/Cart', array('order_id' => $order_id), true));
     return;
     out_fail:
     //失败从这里退出
     RouteHelper::reRoute($this, '/My/Order');
 }
예제 #3
0
 /**
  *
  * @param object  $f3         F3框架对象
  * @param boolean $result     执行 doNotifyUrl() 的返回结果,是否执行成功
  * @param object  $payGateway 支付网关对象
  */
 protected function postCallback($f3, $result, $payGateway)
 {
     if (!$result) {
         // 支付失败不用做什么操作
         return;
     }
     // order_refer 可能需要做一些额外的操作,比如推送订单给 CPS 方
     $orderId = $payGateway->getOrderId();
     ReferHelper::notifyOrderRefer($f3, $orderId);
 }
예제 #4
0
 public function afterRoute($f3)
 {
     // 记录用户从什么来源到达网站的
     ReferHelper::syncOrderReferStorage($f3);
     //同步信息
     // flash message 没有被消耗,保存到 session 中等下次使用
     if (!$this->isFlashMessageConsumed) {
         $f3->set($this->flashMessageStoragekey, $this->flashMessageArray);
     }
     parent::afterRoute($f3);
 }
예제 #5
0
 public function afterRoute($f3)
 {
     // 使用 Cookie 输出 flash message,目的是方便页面做缓存,别把这些数据写在页面上
     if (count($this->flashMessageArray) > 0) {
         setcookie('flash_message', json_encode($this->flashMessageArray), 0, $f3->get('BASE') . '/');
     } else {
         //setcookie('flash_message', null, 0, $f3->get('BASE')); // 清除上次的旧数据
     }
     // 记录用户从什么来源到达网站的
     ReferHelper::syncOrderReferStorage($f3);
     //同步信息
     // 通知客户端数据发生了变化,让客户端主动来取数据
     ClientData::notifyClientDataChange();
     parent::afterRoute($f3);
 }
예제 #6
0
 /**
  *
  * 为 mobile 系统设置运行环境
  *
  * @return bool
  */
 private function doMobileAction()
 {
     global $f3;
     // 获取当前插件的根地址
     $currentThemeBasePath = dirname(__FILE__);
     // 通用的加载
     $this->doOtherAction();
     // mobile 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载
     SystemHelper::addAutoloadPath($currentThemeBasePath . '/mobile/Code', true);
     // 设置路由,这样用户就能访问到我们的程序了
     $f3->config($currentThemeBasePath . '/mobile/route.cfg');
     $f3->config($currentThemeBasePath . '/mobile/route-rewrite.cfg');
     // 记录用户从什么来源到达网站的
     ReferHelper::addReferItem('HostRefer', new HostRefer());
     // 记录来源的 refer_host 和 refer_url
     // 注册 Asset 模块
     \Core\Asset\ManagerHelper::registerModule(MobileThemePlugin::pluginGetUniqueId(), $this->pluginGetVersion(), $currentThemeBasePath . '/mobile/Asset');
     // 发布必要的资源文件
     \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'jquery-mobile');
     \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'css');
     \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'js');
     \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'img');
     // 增加 smarty 模板搜索路径
     global $smarty;
     $smarty->addTemplateDir($currentThemeBasePath . '/mobile/Tpl/');
     // 加载 smarty 的扩展,里面有一些我们需要用到的函数
     require_once $currentThemeBasePath . '/mobile/Code/smarty_helper.php';
     // 注册 smarty 函数
     smarty_helper_register($smarty);
     global $f3;
     // 设置网站的 Base 路径,给 JavaScript 使用
     $smarty->assign("WEB_ROOT_HOST", $f3->get('sysConfig[webroot_schema_host]'));
     $smarty->assign("WEB_ROOT_BASE", $f3->get('BASE'));
     $smarty->assign("WEB_ROOT_BASE_RES", smarty_helper_function_get_asset_url(array('asset' => ''), null));
     $smarty->assign("IS_USER_AUTH", \Core\Helper\Utility\Auth::isAuthUser());
     // jQuery Mobile 根据当前页面的 URL 来决定是否缓存,我们对某些不希望缓存的页面在这里需要特殊处理,
     // 确保它的 url 是一直变化的
     $currentPageUrl = \Core\Helper\Utility\Route::getRequestURL();
     //  下面的操作页面不要缓存,因为每次可能都不一样,比如有验证码,或者有新订单
     if (false !== strpos($currentPageUrl, '/User/') || false !== strpos($currentPageUrl, '/My/') || false !== strpos($currentPageUrl, '/Cart/')) {
         $currentPageUrl = \Core\Helper\Utility\Route::addParam($currentPageUrl, array('_no_cache_page' => time()));
     }
     $smarty->assign("CURRENT_PAGE_URL", $currentPageUrl);
     return true;
 }
예제 #7
0
파일: Cart.php 프로젝트: swcug/bzfshop
 /**
  * 把购物车中的信息保存到数据库订单中,如果订单已经存在,则更新订单数据,
  * 注意:这个方法必须在购物车计算完成之后调用,否则无法正确保存计算之后的数据
  *
  * @return mixed 失败返回 false,成功返回订单记录
  *
  * @param int    $userId   用户的数字 ID
  * @param string $username 用户名
  */
 public function saveOrder($userId, $username)
 {
     // 参数验证
     $validator = new Validator(array('userId' => $userId));
     $userId = $validator->required()->digits()->min(1)->validate('userId');
     $this->validate($validator);
     $orderBasicService = new OrderBasicService();
     $orderId = isset($this->cartContext->orderInfo) ? $this->cartContext->orderInfo['order_id'] : null;
     // 不允许创建空订单
     if (!$orderId && $this->cartContext->isEmpty()) {
         return false;
     }
     // 是否需要新建订单
     $isNewOrder = false;
     //检查这个 order_info 是否合法
     if ($orderId) {
         $orderInfo = $orderBasicService->loadOrderInfoById($orderId);
         // 不存在的 order_info 或者 已经付款了的订单不能再用了
         if ($orderInfo->isEmpty() || OrderBasicService::PS_UNPAYED != $orderInfo->pay_status) {
             $orderId = null;
             $isNewOrder = true;
         }
     } else {
         $isNewOrder = true;
     }
     // 创建 order_info 记录
     $orderInfoArray = $this->cartContext->orderInfoValue;
     $orderInfoArray['user_id'] = $userId;
     $orderInfoArray['order_status'] = OrderBasicService::OS_UNCONFIRMED;
     $orderInfoArray['pay_status'] = OrderBasicService::PS_UNPAYED;
     if (!$orderId) {
         // 新订单,生成 add_time 和 order_sn
         $orderInfoArray['add_time'] = Time::gmTime();
         $orderInfoArray['order_sn'] = OrderBasicService::generateOrderSn();
         $orderInfoArray['system_id'] = Cart::$cartSystemId;
         // 记录订单来自于哪个系统
     } elseif ($this->cartContext->isOrderAmountChange()) {
         // 去支付网关支付,如果订单金额发生变化都需要重新生成一次 order_sn ,因为订单金额如果发生变化,支付网关会拒绝支付
         $orderInfoArray['order_sn'] = OrderBasicService::generateOrderSn();
     } else {
         // do nothing
     }
     // 我们需要数据库事务的保障
     $dbEngine = DataMapper::getDbEngine();
     $dbEngine->begin();
     // 记录余额支付
     $oldSurplus = $this->cartContext->orderInfo ? $this->cartContext->orderInfo['surplus'] : 0;
     $newSurplus = $this->cartContext->getValue('surplus') > 0 ? $this->cartContext->getValue('surplus') : 0;
     // 记录使用红包
     $oldBonusId = $this->cartContext->orderInfo ? $this->cartContext->orderInfo['bonus_id'] : 0;
     $newBonusId = $this->cartContext->getValue('bonus_id') > 0 ? $this->cartContext->getValue('bonus_id') : 0;
     // 创建订单或者更新 order_info
     $orderInfo = $orderBasicService->saveOrderInfo($orderId, $orderInfoArray);
     // 创建订单失败,返回 false
     if ($orderInfo->isEmpty()) {
         goto out_fail;
     }
     // 处理余额支付
     if ($oldSurplus != $newSurplus) {
         // 前后发生了支付余额的改变
         $accountLog = new AccountLog();
         if ($oldSurplus > 0) {
             // 把之前的余额退还
             $accountLog->logChange($userId, $oldSurplus, 0, 0, 0, '退还余额,订单:' . $orderInfo['order_id'], AccountLog::ACT_OTHER);
         }
         if ($newSurplus > 0) {
             // 使用余额
             $accountLog->logChange($userId, -1 * $newSurplus, 0, 0, 0, '使用余额,订单:' . $orderInfo['order_id'], AccountLog::ACT_OTHER);
         }
         // 由于修改了用户信息,需要 reload 用户数据
         AuthHelper::reloadAuthUser();
     }
     // 处理红包支付
     if ($oldBonusId != $newBonusId) {
         // 红包支付前后发生了变化
         $bonusService = new Bonus();
         if ($oldBonusId > 0) {
             //退还之前使用的红包
             $bonusService->unUseBonus($oldBonusId);
         }
         if ($newBonusId > 0) {
             // 使用新的红包
             $bonusService->useBonus($newBonusId, $orderInfo['order_id']);
         }
     }
     // 创建 orderRefer 对象,记录订单的来源
     $orderReferService = new OrderReferService();
     $orderRefer = $orderReferService->loadOrderReferByOrderId($orderInfo['order_id']);
     // order_refer 记录创建一次之后就不会再修改了
     if ($orderRefer->isEmpty()) {
         // 新的 order_refer 记录,设置 order_id 值
         $orderRefer->order_id = $orderInfo['order_id'];
         $orderRefer->create_time = Time::gmTime();
         $orderRefer->login_type = AuthHelper::getLoginType();
         global $f3;
         $orderReferArray = ReferHelper::parseOrderRefer($f3);
         if (!empty($orderReferArray)) {
             unset($orderReferArray['refer_id']);
             //清除掉危险字段
             unset($orderReferArray['order_id']);
             //清除掉危险字段
             $orderRefer->copyFrom($orderReferArray);
         }
         $orderRefer->save();
         // 保存 order_refer 记录
     }
     // 取得数据库中已经存在的 order_goods 列表
     $dbOrderGoodsArray = array();
     if ($orderId > 0) {
         $dbOrderGoodsArray = $orderBasicService->fetchOrderGoodsArray($orderId);
     }
     $stillExistOrderGoodsIdArray = array();
     // 在购物车中仍然存在的 orderGoods 对象
     // 创建 orderInfo 对应的 order_goods 对象
     foreach ($this->cartContext->orderGoodsArray as $orderGoodsItem) {
         $orderGoodsValueArray = array();
         $orderGoodsValueArray['order_id'] = $orderInfo['order_id'];
         //从 goods 中复制属性
         $orderGoodsValueArray['goods_id'] = $orderGoodsItem->goods['goods_id'];
         $orderGoodsValueArray['goods_admin_user_id'] = $orderGoodsItem->goods['admin_user_id'];
         $orderGoodsValueArray['goods_admin_user_name'] = $orderGoodsItem->goods['admin_user_name'];
         $orderGoodsValueArray['goods_name'] = $orderGoodsItem->goods['goods_name_short'];
         $orderGoodsValueArray['goods_sn'] = $orderGoodsItem->goods['goods_sn'];
         $orderGoodsValueArray['warehouse'] = $orderGoodsItem->goods['warehouse'];
         $orderGoodsValueArray['shelf'] = $orderGoodsItem->goods['shelf'];
         $orderGoodsValueArray['market_price'] = $orderGoodsItem->goods['market_price'];
         $orderGoodsValueArray['shop_price'] = $orderGoodsItem->goods['shop_price'];
         $orderGoodsValueArray['shipping_fee'] = $orderGoodsItem->goods['shipping_fee'];
         $orderGoodsValueArray['is_real'] = $orderGoodsItem->goods['is_real'];
         $orderGoodsValueArray['extension_code'] = $orderGoodsItem->goods['extension_code'];
         $orderGoodsValueArray['suppliers_id'] = $orderGoodsItem->goods['suppliers_id'];
         $orderGoodsValueArray['suppliers_price'] = $orderGoodsItem->goods['suppliers_price'];
         $orderGoodsValueArray['suppliers_shipping_fee'] = $orderGoodsItem->goods['suppliers_shipping_fee'];
         // 合并一些因为计算而覆盖的值
         $orderGoodsValueArray = array_merge($orderGoodsValueArray, $orderGoodsItem->orderGoodsValue);
         $orderGoodsId = null;
         if (!$isNewOrder && $orderGoodsItem->orderGoods) {
             // 如果不是新订单,并且已经存在的 order_goods,做更新
             $orderGoodsId = $orderGoodsItem->orderGoods['rec_id'];
             $stillExistOrderGoodsIdArray[] = $orderGoodsId;
         } else {
             // 新建的 order_goods,我们需要取得它的 CPS 信息,CPS 信息只在一开始加入,后面不会再被修改了
             $cpsArray = ReferHelper::getCpsParam($orderRefer, $orderInfo, $orderGoodsValueArray);
             if (!empty($cpsArray)) {
                 $orderGoodsValueArray['cps_rate'] = isset($cpsArray['cps_rate']) ? $cpsArray['cps_rate'] : 0;
                 $orderGoodsValueArray['cps_fix_fee'] = isset($cpsArray['cps_fix_fee']) ? $cpsArray['cps_fix_fee'] : 0;
             }
         }
         $orderGoods = $orderBasicService->saveOrderGoods($orderGoodsId, $orderInfo['order_id'], $orderGoodsValueArray);
         if ($orderGoods->isEmpty()) {
             //创建失败
             goto out_fail;
         }
     }
     // 删除已经被用户删除的 order_goods
     foreach ($dbOrderGoodsArray as $dbOrderGoodsItem) {
         // 这个 order_goods 已经不存在了,删除它
         if (!in_array($dbOrderGoodsItem['rec_id'], $stillExistOrderGoodsIdArray)) {
             $orderBasicService->removeOrderGoods($dbOrderGoodsItem['rec_id']);
         }
     }
     // 记录订单操作日志
     $orderActionService = new OrderActionService();
     $orderActionService->logOrderAction($orderInfo['order_id'], 0, OrderBasicService::OS_UNCONFIRMED, OrderBasicService::PS_UNPAYED, OrderGoodsService::OGS_UNPAY, '订单创建或更新', $username, 0, 0);
     $dbEngine->commit();
     return $orderInfo;
     // 返回创建的订单
     out_fail:
     $dbEngine->rollback();
     return false;
 }
예제 #8
0
 public function post($f3)
 {
     //首先验证参数签名
     $map = $_POST;
     unset($map['Vkey']);
     //读取除了vkey外的所有参数,并且放入数组map中
     ksort($map);
     //进行按参数的升序排序
     //进行签名,注意考虑到md5加密输出的大小写问题,所有约定md5的输出均为小写
     $vkey = implode('', array_values($map));
     $md5_1 = strtolower(md5($vkey . YiqifaCpsPlugin::getOptionValue('qqcaibei_key1')));
     $vkey = strtolower(md5($md5_1 . YiqifaCpsPlugin::getOptionValue('qqcaibei_key2')));
     if ($vkey != $_POST['Vkey']) {
         // 参数签名错误
         goto out;
     }
     // 保存额外的 亿起发 参数
     $orderRefer = array();
     $orderRefer['utm_medium'] = 'QQCAIBEI';
     //设置 cookie
     ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
     $f3->set('SESSION[yiqifa_caibei_order_refer]', ReferHelper::parseOrderRefer($f3));
     // 取得QQ彩贝传递过来的参数
     //$acct     = @$_POST['Acct'];
     $url = @$_POST['Url'];
     $openId = @$_POST['OpenId'];
     //$clubInfo = @intval($_POST['ClubInfo']); // 会员等级信息,目前没用
     $viewInfo = @$_POST['ViewInfo'];
     if (get_magic_quotes_gpc()) {
         $viewInfo = stripslashes($viewInfo);
     }
     $viewInfoArray = array();
     parse_str($viewInfo, $viewInfoArray);
     //解析 viewInfoArray 数组
     //$f3->set('SESSION[qqcaibei_viewinfoarray]', json_encode($viewInfoArray)); //放入到 session 里面
     // 设置 ClientData
     ClientData::saveClientData('qqcaibei_viewinfoarray', json_encode($viewInfoArray));
     if (empty($openId)) {
         // 没有  openId 没法登陆,直接退出
         goto out;
     }
     // 这里做 QQ彩贝 联合登陆
     $sns_login = "******";
     // 用户登陆操作
     $userBasicService = new UserBasicService();
     $authUser = $userBasicService->doAuthSnsUser($sns_login, null, null, false);
     if ($authUser) {
         goto out_login_user;
     }
     // 之前没有登陆过,自动注册用户
     $authUser = $userBasicService->doAuthSnsUser($sns_login, $openId . '@qq.com', $openId . '@qq.com', true);
     printLog('注册QQ用户:' . print_r($viewInfoArray, true), 'QQLOGIN', \Core\Log\Base::INFO);
     out_login_user:
     AuthHelper::saveAuthUser($authUser->toArray(), 'qqcaibei');
     // 设置用户名在网页显示
     ClientData::saveClientData(\Controller\User\Login::$clientDataIsUserLoginKey, true);
     ClientData::saveClientData(\Controller\User\Login::$clientDataUserNameDisplayKey, 'QQ彩贝用户:' . $viewInfoArray['NickName']);
     out:
     // 页面跳转到商品
     $redirectUrl = empty($url) ? '/' : $url;
     RouteHelper::reRoute($this, $redirectUrl);
     return;
 }
예제 #9
0
 /**
  * 为系统设置运行环境
  *
  * @return bool
  */
 private function doYiqifaCpsAction()
 {
     // 获取当前插件的根地址
     $currentPluginBasePath = dirname(__FILE__);
     // yiqifacps code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载
     SystemHelper::addAutoloadPath($currentPluginBasePath . '/yiqifacps/Code');
     // 设置 CPS 日志,按照日期分目录存储
     $todayDateStr = \Core\Helper\Utility\Time::localTimeStr('Y-m-d');
     $todayDateArray = explode('-', $todayDateStr);
     $fileLogger = new \Core\Log\File('YIQIFACPS/' . $todayDateArray[0] . '/' . $todayDateArray[1] . '/' . implode('-', $todayDateArray) . '.yiqifacps.log');
     $fileLogger->sourceAllow[] = 'YIQIFACPS';
     // 只接收 YIQIFACPS 的日志
     global $logger;
     $logger->addLogger($fileLogger);
     // 把 $fileLogger 放到全局日志列表中
     // 设置路由,这样用户就能访问到我们的程序了
     SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/Redirect', 'Controller\\Thirdpart\\YiqifaCps\\Redirect');
     SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/QueryOrder', 'Controller\\Thirdpart\\YiqifaCps\\QueryOrder');
     SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/CaibeiLogin', 'Controller\\Thirdpart\\YiqifaCps\\CaibeiLogin');
     // 设置一个 OrderRefer 用于记录订单来自于 亿起发CPS
     require_once $currentPluginBasePath . '/yiqifacps/Code/YiqifaCpsRefer.php';
     // 设置订单 refer 用于记录订单来源于 亿起发CPS
     ReferHelper::addReferItem('YiqifaCpsRefer', new YiqifaCpsRefer());
     // 增加 smarty 模板搜索路径
     global $smarty;
     $smarty->addTemplateDir($currentPluginBasePath . '/yiqifacps/Tpl/');
     return true;
 }
예제 #10
0
파일: index.php 프로젝트: jackycgq/bzfshop
// 加载全局变量设置
$f3->config(PROTECTED_PATH . '/Config/mobile.cfg');
// 根据环境变量的不同,加载对应的环境变量设置,开发环境和生产环境的配置显然是不一样的
$f3->config(PROTECTED_PATH . '/Config/mobile-' . $f3->get('sysConfig[env]') . '.cfg');
// 设置工作时区
if ($f3->get('sysConfig[time_zone]')) {
    date_default_timezone_set($f3->get('sysConfig[time_zone]'));
}
// 设置 session 在多个子域名之间共享
if ($f3->get('sysConfig[cookie_domain]')) {
    $f3->set('JAR.domain', $f3->get('sysConfig[cookie_domain]'));
}
// 设置网站唯一的 key,防止通用模块之间的冲突
RouteHelper::$uniqueKey = 'MOBILE';
OrderBasicService::$orderSnPrefix = 'MB';
ReferHelper::$orderReferStorageKey = 'BZFOrderRefer';
// 记录系统订单来源
CartBasicService::$cartSystemId = \Core\Plugin\PluginHelper::SYSTEM_MOBILE;
// 把几个网站的 key 设置成一样,配合 sysConfig[cookie_domain] 设置,就可以实现几个网站 统一登陆
AuthHelper::$uniqueKey = 'BZFAUTH';
// ------------ 2. 初始化 云服务引擎,云服务引擎会设置好我们的运行环境,包括 可写目录 等 ------------
CloudHelper::initCloudEnv(PluginHelper::SYSTEM_MOBILE);
// ---------------------------------------- 3. 开启系统日志 --------------------------------------
$todayDateStr = \Core\Helper\Utility\Time::localTimeStr('Y-m-d');
$todayDateArray = explode('-', $todayDateStr);
// 设置一个 fileLogger 方便查看所有的日志输出,按照 年/月/年-月-日.log 输出
$fileLogger = new \Core\Log\File($todayDateArray[0] . '/' . $todayDateArray[1] . '/' . implode('-', $todayDateArray) . '.mobile.log');
// 我们不打印 DEBUG 级别的日志,不然数据量太大了
$fileLogger->levelAllow = array(\Core\Log\Base::CRITICAL, \Core\Log\Base::ERROR, \Core\Log\Base::WARN, \Core\Log\Base::NOTICE, \Core\Log\Base::INFO);
$logger->addLogger($fileLogger);
unset($fileLogger);
예제 #11
0
 /**
  *
  * 为 shop 系统设置运行环境
  *
  * @return bool
  */
 private function doShopAction()
 {
     global $f3;
     global $smarty;
     // 获取当前插件的根地址
     $currentThemeBasePath = dirname(__FILE__);
     // 通用的加载
     $this->doOtherAction();
     // shop Code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载
     SystemHelper::addAutoloadPath($currentThemeBasePath . '/shop/Code', true);
     // 设置路由,这样用户就能访问到我们的程序了
     $f3->config($currentThemeBasePath . '/shop/route.cfg');
     $f3->config($currentThemeBasePath . '/shop/route-rewrite.cfg');
     ReferHelper::addReferItem('HostRefer', new HostRefer());
     // 记录来源的 refer_host 和 refer_url
     // 注册 Asset 模块
     \Core\Asset\ManagerHelper::registerModule(ShopThemePlugin::pluginGetUniqueId(), $this->pluginGetVersion(), $currentThemeBasePath . '/shop/Asset');
     // 发布必要的资源文件
     \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'bootstrap-custom');
     \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'css');
     \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'js');
     \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'img');
     // 增加 smarty 模板搜索路径
     $smarty->addTemplateDir($currentThemeBasePath . '/shop/Tpl/');
     // 加载 smarty 的扩展,里面有一些我们需要用到的函数
     require_once $currentThemeBasePath . '/shop/Code/smarty_helper.php';
     // 注册 smarty 函数
     smarty_helper_register($smarty);
     // 设置网站的 Base 路径,给 JavaScript 使用
     $smarty->assign("WEB_ROOT_HOST", $f3->get('sysConfig[webroot_schema_host]'));
     $smarty->assign("WEB_ROOT_BASE", $f3->get('BASE'));
     $smarty->assign("WEB_ROOT_BASE_RES", smarty_helper_function_get_asset_url(array('asset' => ''), null));
     return true;
 }