/**
  * Handles the after unlocking export event. This writes into the cache the
  * new value
  *
  * @param AfterUnlockFileEvent $event
  */
 public function onAfterUnlockFile(AfterUnlockFileEvent $event)
 {
     if ($event->isSuccess()) {
         if ($this->cache === null || !$this->cache instanceof ICache) {
             return;
         }
         $policy = $event->getPolicy();
         if ($this->_count === null) {
             $count = $policy->getCount($event->getCriteriaBuilder());
         } else {
             $count = $this->_count;
         }
         $key = $this->buildKey($policy, $event->getCriteriaBuilder());
         if (!$this->cache->set($key, $count)) {
             $message = Yii::t('export.cache_exported_file_behavior', 'Impossible to save value "{value}" in cache for key "{key}".', array('{value}' => $count, '{key}' => $key));
             Yii::log($message, CLogger::LEVEL_WARNING, 'export.cache_exported_file_behavior');
         }
     }
 }
Пример #2
0
 static function goods_category()
 {
     //获取商品分类缓存
     $cacheObj = new ICache('file');
     $catResult = $cacheObj->get('goodsCategory');
     if ($catResult) {
         return $catResult;
     }
     $catResult = array();
     $catObj = new IModel('category');
     $catFirst = $catObj->query('parent_id = 0', 'id,name,parent_id,visibility', 'sort', 'asc');
     $catOther = $catObj->query('parent_id != 0', 'id,name,parent_id,visibility', 'sort', 'asc');
     foreach ($catFirst as $first_key => $first) {
         foreach ($catOther as $other_key => $other_val) {
             if ($first['id'] == $other_val['parent_id']) {
                 //拼接二级分类
                 $first['second'][$other_key] = $other_val;
                 //拼接二级以下所有分类
                 $catMore = array();
                 self::recursion_goods_category($other_val, $catOther, $catObj, $catMore);
                 $first['second'][$other_key]['more'] = $catMore;
             }
         }
         $catResult[] = $first;
     }
     //写入缓存
     $cacheObj->set('goodsCategory', $catResult);
     return $catResult;
 }
Пример #3
0
 /**
  * @brief 商品分类列表
  */
 function category_list()
 {
     $isCache = false;
     $tb_category = new IModel('category');
     $cacheObj = new ICache('file');
     $data = $cacheObj->get('sortdata');
     if (!$data) {
         $goods = new goods_class();
         $data = $goods->sortdata($tb_category->query(false, '*', 'sort', 'asc'));
         $isCache ? $cacheObj->set('sortdata', $data) : "";
     }
     $this->data['category'] = $data;
     $this->setRenderData($this->data);
     $this->redirect('category_list', false);
 }
Пример #4
0
 /**
  * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户;
  * @param $payment_id int    支付方式ID
  * @param $type       string 信息获取方式 order:订单支付;recharge:在线充值;
  * @param $argument   mix    参数
  * @return array 支付提交信息
  */
 public static function getPaymentInfo($payment_id, $type, $argument)
 {
     //最终返回值
     $payment = array();
     //初始化配置参数
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     $configParam = $paymentInstance->configParam();
     foreach ($configParam as $key => $val) {
         $payment[$key] = '';
     }
     //获取公共信息
     $paymentRow = self::getPaymentById($payment_id, 'config_param');
     if ($paymentRow) {
         $paymentRow = JSON::decode($paymentRow);
         foreach ($paymentRow as $key => $item) {
             $payment[$key] = $item;
         }
     }
     if ($type == 'order') {
         $orderIdArray = $argument;
         $M_Amount = 0;
         $M_OrderNO = array();
         foreach ($orderIdArray as $key => $order_id) {
             //获取订单信息
             $orderObj = new IModel('order');
             $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
             if (empty($orderRow)) {
                 IError::show(403, '订单信息不正确,不能进行支付');
             }
             //判断商品库存
             $orderGoodsDB = new IModel('order_goods');
             $orderGoodsList = $orderGoodsDB->query('order_id = ' . $order_id);
             foreach ($orderGoodsList as $key => $val) {
                 if (!goods_class::checkStore($val['goods_nums'], $val['goods_id'], $val['product_id'])) {
                     IError::show(403, '商品库存不足无法支付,请重新下单');
                 }
             }
             $M_Amount += $orderRow['order_amount'];
             $M_OrderNO[] = $orderRow['order_no'];
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $M_Amount;
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
         //订单批量结算缓存机制
         $cacheObj = new ICache('file');
         $cacheObj->set($payment['M_OrderNO'], join(",", $M_OrderNO));
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Time'] = time();
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     return $payment;
 }
Пример #5
0
 public static function set($name, $value)
 {
     $key = self::key($name);
     self::$c_instance->set($key, $value);
     self::$c_cache[$key] = $value;
 }